<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JeeLabs &#187; JeeNode</title>
	<atom:link href="http://jeelabs.org/tag/jeenode/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeelabs.org</link>
	<description>Computing stuff tied to the physical world</description>
	<lastBuildDate>Tue, 22 May 2012 22:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>The JeeNode, as seen from 15.24 km</title>
		<link>http://jeelabs.org/2011/12/19/the-jeenode-as-seen-from-15-24-km/</link>
		<comments>http://jeelabs.org/2011/12/19/the-jeenode-as-seen-from-15-24-km/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 23:01:34 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=16963</guid>
		<description><![CDATA[(that&#8217;s 50,000 feet, or 9.47 miles &#8211; if those units mean more to you) This post was prompted by a message on the forum, about what this whole &#8220;JeeNode&#8221; thing is, really. Here are a JeeNode v6 and an Arduino Duemilanove, side by side: Let me start by saying, tongue-in-cheek: it&#8217;s all Arduino&#8217;s fault! Because [...]]]></description>
			<content:encoded><![CDATA[<p><em>(that&#8217;s 50,000 feet, or 9.47 miles &#8211; if those units mean more to you)</em></p>

<p>This post was prompted by a message on the <a href="http://forum.jeelabs.net/node/742">forum</a>, about what this whole &#8220;<a href="http://jeelabs.net/projects/hardware/wiki/JeeNode">JeeNode</a>&#8221; thing is, really.</p>

<p>Here are a JeeNode v6 and an Arduino Duemilanove, side by side:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/12/DSC_2826.jpg" alt="DSC 2826" border="0" width="604" height="436" /></p>

<p>Let me start by saying, tongue-in-cheek: <em>it&#8217;s all Arduino&#8217;s fault!</em></p>

<p>Because &#8211; let&#8217;s face it &#8211; the core of each Arduino and each JeeNode is really 95% the same: an Atmel AVR ATmega328P chip, surrounded by a teeny little bit of support circuitry and placed on a printed circuit board. So part of the confusion comes from the fact that the Arduino introduced its own conventions, moving it further away from the underlying <em>common</em> ATmega technology.</p>

<p>The differences between an Arduino Duemilanove and a JeeNode v6 &#8211; which resemble each other most &#8211; are:</p>

<ul>
<li>the JeeNode has a &#8220;skinnier&#8221; shape, incompatible with Arduino &#8220;shields&#8221;</li>
<li>the Arduino runs at 5V, whereas the JeeNode runs at 3.3V (this carries through to all I/O pins)</li>
<li>the JeeNode includes a wireless radio module, called the RFM12B by HopeRF</li>
<li>the Arduino includes an FTDI &lt;-> USB interface, while the JeeNode relies on an external one</li>
</ul>

<p>There are many other differences, of course &#8211; so let&#8217;s continue this list a bit:</p>

<ul>
<li>the Arduino&#8217;s &#8220;eco-system&#8221; is far, <em>far</em> bigger than the JeeNode&#8217;s (translation: everyone who finds out about JeeNodes probably already knows about the Arduino platform, and usually already has one or more of &#8216;em)</li>
<li>this carries through to articles, websites, books, and discussion forums &#8211; Arduino is everywhere</li>
<li>you can do lots of stuff with an Arduino without ever touching a soldering iron, whereas the JeeNode is really not usable without <em>some</em> soldering (even if just to solder on a few pin headers)</li>
<li>different pinouts&#8230; it&#8217;s one big conspiracy to confuse everyone, of course! <em>(just kidding: see below)</em></li>
</ul>

<p>My reasons for coming up with the JeeNode have been documented in the past on this weblog, and can be summarized as: 1) running at 3.3V for lower power consumption and to better match modern sensors and chips, and 2) supporting a simpler form of expandability through the use of &#8220;plugs&#8221; &#8211; little boards which can be mixed and matched in many different combinations.</p>

<p>On the software side, JeeNodes remain fully compatible with the Arduino IDE, a convenient software environment for Windows, Mac, and Linux to develop &#8220;sketches&#8221; and upload them to the board(s).</p>

<p>The biggest stumbling block seems to be the way pins are identified. There are 4 conventions, all different:</p>

<ul>
<li>Atmel&#8217;s hardware documentation talks about pins on its internal hardware ports, in a logical manner: so for example, there is a port &#8220;D&#8221; with 8 I/O pins numbered 0..7 &#8211; the sixth one would be called <strong>PD5</strong>.</li>
<li>Then there is the pin on the chip, this depends on which chip and which package is being referred to. On the 28-pin DIP package used for an ATmega328P, that same PD5 pin would be identified as <strong>pin 11</strong>. That&#8217;s the 11th pin, counting from the left side of the chip with pin 1 at the top.</li>
<li>The Arduino run-time library has software to control these pins. For a digital output pin, you can set it to &#8220;1&#8243; for example, by writing <strong>digitalWrite(5,1)</strong>. This resembles PD5, but it fails for other pins (PB0 is &#8220;8&#8243; in Arduino-land, and PC1 is &#8220;1&#8243; if used as an analog input, or &#8220;15&#8243; if used otherwise &#8211; go figure&#8230;).</li>
<li>The JeeNode organizes several pins as part of 6-pin &#8220;Ports&#8221; (no relation to Atmels terminology!), each of them having 1 digital and 1 analog-or-digital pin.</li>
</ul>

<p>The thing about JeeNode Ports is that there are 4 of them, and they can all be used for plugs in the same way. To support this, there&#8217;s a <a href="http://jeelabs.net/projects/cafe/wiki/Ports">Ports library</a> which lets you define port objects. This is an abstraction layer <em>on top</em> of the Arduino runtime. The reason is that it lets you associate a port object with a header on the JeeNode:</p>

<pre><code>    Port myport (2);
</code></pre>

<p>Then you can connect your hardware / sensor / plug / whatever to the header marked &#8220;P2&#8243; on the JeeNode, and access it as follows:</p>

<pre><code>    myport.digiWrite(1);
</code></pre>

<p>This happens to be the same pin as in the examples above, i.e. PD5 of an ATmega, pin 11 of the 28-pin DIP chip, and digitalWrite(5,1) on an Arduino. This also means that there are <em>numerous</em> ways to perform the same action of setting pin 11 of the chip to a logical &#8220;1&#8243; (i.e. 3.3V or 5V):</p>

<ul>
<li><p>the &#8220;raw&#8221; C-level access, using Atmel&#8217;s register conventions and definitions (fastest, by far):</p>

<pre><code>    PORTD |= 1 &lt;&lt; 5;  // or ...
    PORTD |= _BV(5);  // same thing
    bitSet(PORTD, 5); // same thing, using an Arduino macro
</code></pre></li>
<li><p>the Arduino way of doing things:</p>

<pre><code>    digitalWrite(5, 1);
</code></pre></li>
<li><p>the JeeNode Ports library way of doing things, as shown above:</p>

<pre><code>    Port myport (2);
    myport.digiWrite(1);
</code></pre></li>
<li><p><em>&#8230; let&#8217;s throw in an extra bullet item, since every other list in this post appears to come in fours ;)</em></p></li>
</ul>

<p>The one (minor) benefit you get from using the Ports approach on a JeeNode, is that if you attach your hardware to a different port, say port 3, then you only need to change a single line of code (to &#8220;<code>Port myport (3);</code>&#8221; in this case). The rest of the code, i.e. everywhere where its pins are being read or written, can then remain the same.</p>

<p>For an overview of all pinout differences, see also <a href="http://jeelabs.org/2011/11/10/pins-damned-pins-and-jeenodes/">this weblog post</a>. For full details, see the <a href="http://jeelabs.net/attachments/388/JN5-pinout.pdf">JeeNode PDF docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/12/19/the-jeenode-as-seen-from-15-24-km/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>The beat goes on</title>
		<link>http://jeelabs.org/2011/09/04/the-beat-goes-on/</link>
		<comments>http://jeelabs.org/2011/09/04/the-beat-goes-on/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 22:01:42 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14292</guid>
		<description><![CDATA[Today, a milestone was reached: $ jeemon examples/driver-demo/ 15:45:01.975 RF12demo config usb-A700fdxv RF12-868.5 reading:RF12-868.5.3:radioBlip:ping = 493295 reading:RF12-868.5.3:radioBlip:age = 365 ^C That&#8217;s nearly half a million packets, one every 64 seconds, all on a single LiPo battery charge: The setup is very simple. A 1300 mAh LiPo battery (I just picked one up in a camera [...]]]></description>
			<content:encoded><![CDATA[<p>Today, a milestone was reached:</p>

<pre><code>    $ jeemon examples/driver-demo/
    15:45:01.975 RF12demo config usb-A700fdxv RF12-868.5
    reading:RF12-868.5.3:radioBlip:ping = 493295
    reading:RF12-868.5.3:radioBlip:age = 365
    ^C
</code></pre>

<p>That&#8217;s nearly half a million packets, one every 64 seconds, all on a single LiPo battery charge:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/09/Screen-Shot-2011-09-03-at-15.51.53.png" alt="Screen Shot 2011 09 03 at 15 51 53" title="Screen Shot 2011-09-03 at 15.51.53.png" border="0" width="546" height="123" /></p>

<p>The setup is very simple. A 1300 mAh LiPo battery (I just picked one up in a camera shop with a convenient size), attached to a <a href="/ju3">JeeNode USB</a>:</p>

<p><img src="http://files.jeelabs.org/2010/08/dsc_1822.jpg" alt="" /></p>

<p>At 3.94 V the battery is still far from dead, so it&#8217;ll probably stay alive for quite a bit longer&#8230;</p>

<p>The sketch running on this node is:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/09/Screen-Shot-2011-09-03-at-16.14.28.png" alt="Screen Shot 2011 09 03 at 16 14 28" title="Screen Shot 2011-09-03 at 16.14.28.png" border="0" width="461" height="467" /></p>

<p>(looks like I had lost the low-power stuff in the &#8220;radioBlip&#8221; code, now fixed on <a href="https://github.com/jcw/jeelib/blob/master/examples/RF12/radioBlip/radioBlip.ino">GitHub</a>)</p>

<p>Lots of low-power nodes are holding out nicely here at JeeLabs, by the way. There are about half a dozen permanent room nodes, and with the latest roomNode sketch they just keep going. Some are running on 3x AA rechargeable <a href="http://jeelabs.org/2010/08/19/new-aa-battery-option/">EneLoop</a> batteries, others use 3x AAA with even less juice, and all of them have been running with just a single charge since the beginning of this year.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/09/04/the-beat-goes-on/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JeeNode with a 32 KHz crystal</title>
		<link>http://jeelabs.org/2011/06/28/jeenode-with-a-32-khz-crystal/</link>
		<comments>http://jeelabs.org/2011/06/28/jeenode-with-a-32-khz-crystal/#comments</comments>
		<pubDate>Mon, 27 Jun 2011 22:01:05 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14138</guid>
		<description><![CDATA[Another experiment: running a JeeNode on its internal 8 MHz RC clock while using the crystal input to run timer 2 as an RTC. This would allow going into a very low-power mode while still maintaining a much more accurate sense of time. To this end, I modified a JeeNode SMD, by replacing the 16 [...]]]></description>
			<content:encoded><![CDATA[<p>Another experiment: running a <a href="/jn6">JeeNode</a> on its internal 8 MHz RC clock while using the crystal input to run timer 2 as an RTC. This would allow going into a very low-power mode while still maintaining a much more accurate sense of time.</p>

<p>To this end, I modified a JeeNode SMD, by replacing the 16 MHz resonator with a 32 KHz crystal:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/dsc_25991.jpg" alt="Dsc 2599" /></p>

<p>I didn&#8217;t even bother adding capacitors, these are probably not needed with this crystal (same as on the <a href="/rp1">RTC Plug</a>) since there is probably enough parasitic capacitance already.</p>

<p>The tricky part is the code, since the ATmega is now running in a not-so-Arduino-like mode. Could <em>almost</em> have used OptiBoot with this setup, but the only internal RC clock build for it is the LilyPad, which has an ATmega168.</p>

<p>I ended up using the ISP programmer. IOW, I now compile for &#8220;LilyPad w/ 328&#8243; and then bypass the bootstrap and serial-upload. Less convenient, but it works.</p>

<p>Here&#8217;s a quick test sketch which writes a dot on the serial line exactly once a second:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_155149.png" alt="Screen Shot 2011 06 24 at 15.51.49" /></p>

<p>So this setup is working. It draws 4.10 ma, consistent with the recent <a href="http://jeelabs.org/2011/06/26/current-measurements/">current measurements</a>: slightly less than with the 16 MHz resonator pre-scaled by two.</p>

<p>In idle mode, current use drops to 1.71 mA, not bad!</p>

<p>Now let&#8217;s power down with just the timer running as real time clock. There&#8217;s a special &#8220;power save&#8221; mode which does just that. The difference is that timer 0 will now be off, so there won&#8217;t be interrupts waking up the ATmega every 1024 µs (as side-effect, the <em>millis()</em> function will start to lose track of time):</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_161504.png" alt="Screen Shot 2011 06 24 at 16.15.04" /></p>

<p>A small adjustment is needed to make sure the serial port is finished before we go into low-power mode, hence the call to <em>delay(3)</em>.</p>

<p>Hm, power consumption is still 0.67 mA &#8211; quite a bit, given that we&#8217;re really powering down most of the time.</p>

<p><em>Ah, wait.</em> I forgot to turn off the radio. Doing that brings the reading down to 0.15 mA &#8211; and I forgot to turn off the ADC and other sub-systems. Now we&#8217;re down to &#8230; 0.05 mA, while still printing dots:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_163915.png" alt="Screen Shot 2011 06 24 at 16.39.15" /></p>

<p>Note that these 1 second interrupts are very accurately timed, more so even than with the standard 16 MHz resonator. This could be used to perform time-domain tricks on the wireless side, i.e. waking up <em>just in time</em> whenever a &#8220;scheduled&#8221; packet is expected to come in &#8211; as described in <a href="http://jeelabs.org/2011/06/27/time-controlled-transmissions/">yesterday&#8217;s post</a>.</p>

<p>There&#8217;s probably more left to try. The delay is running on full power, waiting for the serial output to clear the USART. It could be done while in idle mode, for example. Anyway&#8230; that entire delay becomes superfluous when we stop sending out debugging output over the serial port.</p>

<p>So there you have it &#8211; a JeeNode running at ≈ 8 MHz, with a precise 32,768 Hz pulse feeding timer 2, in a way which supports low-power sketches while maintaining an accurate sense of time.</p>

<p><em>Wanna make a clock?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/28/jeenode-with-a-32-khz-crystal/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Time-controlled transmissions</title>
		<link>http://jeelabs.org/2011/06/27/time-controlled-transmissions/</link>
		<comments>http://jeelabs.org/2011/06/27/time-controlled-transmissions/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 22:01:33 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeLink]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14161</guid>
		<description><![CDATA[Receiving data on remote battery-powered JeeNodes is a bit of a dilemma: you can&#8217;t just leave the receiver on, because it&#8217;ll quickly drain the battery. Compare this to sending, where nodes can easily run for months on end. The difference is that with a remote node initiating all transmissions, it really only has to enable [...]]]></description>
			<content:encoded><![CDATA[<p>Receiving data on remote battery-powered <a href="/jn6">JeeNodes</a> is a bit of a dilemma: you can&#8217;t just leave the receiver on, because it&#8217;ll quickly drain the battery. Compare this to sending, where nodes can easily run for months on end.</p>

<p>The difference is that with a remote node initiating all transmissions, it really only has to enable the RFM12B wireless module very briefly. With a <a href="http://jeelabs.org/2011/06/26/current-measurements/">12..23 mA current drain</a>, <em>brevity matters!</em></p>

<p>So how do you get data <em>from</em> a central node, <em>to</em> remote and <em>power-starved</em> nodes?</p>

<p>One way is to poll: let the remote node ask for data, and return that data in an ACK packet as soon as asked. This will indeed work, and is probably the easiest way to implement that return data path towards remote nodes. One drawback is that if all nodes start polling a lot, the band may become overloaded and there will be more collisions.</p>

<p>Another approach is to <em>agree</em> on when to communicate. So now, the receiver again &#8220;polls&#8221; the airwaves, but now it tracks real time and <em>knows</em> when transmissions for it might occur. This is more complex, because it requires the transmitter(s) and receiver(s) to be in sync, and to <em>stay</em> in sync over time.</p>

<p>Note that both approaches imply a difficult trade-off between power consumption and responsiveness. Maximum responsiveness requires leaving the receiver on at all times &#8211; which just isn&#8217;t an option. But suppose we were able to stay in sync within 1 ms on both sides. The receiver would then only have to start 1 ms early, and wait up to 2 ms for a packet to come in. If it does this once a second, then it would still be on just 0.2% of the time, i.e. a 500-fold power saving.</p>

<p>Let&#8217;s try this out. Here&#8217;s the <a href="http://jeelabs.net/projects/cafe/repository/entry/RF12/examples/timedRecv/timedRecv.pde">timedRecv.pde</a> sketch (now in the RF12 library):</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_205437.png" alt="Screen Shot 2011 06 24 at 20.54.37" /></p>

<p>It listens for incoming packets, then goes into low-power mode for 2 seconds, then it starts listening again. The essential trick is to report two values as ACK to the sender: the time the receiver started listening (relative to that receiver&#8217;s notion of time), and the number of milliseconds it had to wait for the packet to arrive.</p>

<p>There&#8217;s no actual data processing &#8211; I&#8217;m just interested in the syncing bit here.</p>

<p>The sender side is in the <a href="http://jeelabs.net/projects/cafe/repository/entry/RF12/examples/timedSend/timedSend.pde">timedSend.pde</a> sketch:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_205817.png" alt="Screen Shot 2011 06 24 at 20.58.17" /></p>

<p>This one tries to send a new packet each time the receiver is listening. If done right, the receiver will wake up at <em>just</em> the right time, and then go to sleep again.
The ACK we get back in the sender contains valuable information, because it lets us see how accurate our timing was.</p>

<p>Here&#8217;s what I get when sending a new packet exactly 2,096 milliseconds after an ACK comes in:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_203933.png" alt="Screen Shot 2011 06 24 at 20.39.33" /></p>

<p>Not bad, one ack for each packet sent out, and the receiver only has to wait about 6 milliseconds with its wireless receiver powered up. I&#8217;ve let it run for 15 minutes, and it didn&#8217;t miss a beat.</p>

<p>For some reason, send times need to be ≈ 2.1 s instead of the expected 2.0 s.</p>

<p>Now let&#8217;s try with 2,095 milliseconds:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_203717.png" alt="Screen Shot 2011 06 24 at 20.37.17" /></p>

<p>Something strange is happening: <em>there&#8217;s consistently 1 missed packet for each 5 successful ones!</em></p>

<p>My hunch is that there&#8217;s an interaction with the watchdog timer on the receiver end, which is used to power down for 2000 milliseconds. I suspect that when you ask it to run for 16 ms (the miminum), then it won&#8217;t actually synchronize its timer, but will fit the request into what is essentially a free-running counter.</p>

<p>There may also be some unforeseen interaction due to the ACKs which get sent back, i.e. there&#8217;s a complete round-trip involved in the above mechanism</p>

<p><em>Hmm&#8230; this will need further analysis.</em></p>

<p>I&#8217;m using a standard <a href="/jn6">JeeNode</a> on the receiving end, i.e. running at 16 MHz with a ceramic resonator (specs say it&#8217;s 0.5% accurate). On the sender side, where timing is much more important, I&#8217;m using a <a href="/jl2">JeeLink</a> which conveniently has an accurate 16 MHz crystal (specs say it&#8217;s 10 ppm, i.e. 0.001% accurate).</p>

<p>But still &#8211; even this simple example illustrates how a remote can receive data while keeping its wireless module off more than 99% of the time.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/27/time-controlled-transmissions/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Current measurements</title>
		<link>http://jeelabs.org/2011/06/26/current-measurements/</link>
		<comments>http://jeelabs.org/2011/06/26/current-measurements/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 22:01:31 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14125</guid>
		<description><![CDATA[Wanted to check a few things w.r.t. current consumption of a JeeNode. The old way of doing this was a bit inconvenient, so I made a new test setup: (old one on the left, new one on the right) Sturdier, no need to disconnect the multimeter to short it out, and most importantly: high-side current [...]]]></description>
			<content:encoded><![CDATA[<p>Wanted to check a few things w.r.t. current consumption of a JeeNode. The old way of doing this was a bit inconvenient, so I made a new test setup:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/dsc_2597.jpg" alt="Dsc 2597" /></p>

<p><em>(old one on the left, new one on the right)</em></p>

<p>Sturdier, no need to disconnect the multimeter to short it out, and most importantly: <em>high-side</em> current sensing! That&#8217;s quite important, because multimeters can add a small voltage drop when used in current measurement mode, and that voltage drop will affect the serial I/O on the FTDI pins when placed in the GND line. Silly me, should have been on the PWR line all along!</p>

<p>The back side of the new connector is trivial:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/dsc_2598.jpg" alt="Dsc 2598" /></p>

<p>The multimeter attaches to the top pins, bent apart for easy connection. The jumper shorts it out so this contraption can still be used when the multimeter is turned off.</p>

<p>Ok, time for some simple measurements:</p>

<ul>
<li>ATmega full speed, doing nothing: 6.84 mA</li>
<li>ATmega full speed, with the RFM12B receiver on: 18.42 mA</li>
<li>ATmega powered down, only the RFM12B receiver on: 11.53 mA</li>
<li>ATmega full speed, with the RFM12B tranmitter on: 29.92 mA</li>
</ul>

<p>Idle mode is a simple way to reduce power consumption without changing the logic of the code. It turns the MPU off until an interrupt occurs. Basically, you&#8217;re telling it &#8220;I&#8217;ve got nothing to do until something new happens&#8221;. It&#8217;s a pretty safe change, and well worth doing in any idle loop which isn&#8217;t directly polling I/O pins. The ATmega&#8217;s current consumption is slashed by more than half:</p>

<ul>
<li>ATmega in idle mode, doing nothing: 2.80 mA</li>
</ul>

<p>Another way to reduce power consumption, is to slow down the clock at which everything takes place, by setting the &#8220;clock pre-scaler&#8221;:</p>

<ul>
<li>ATmega @ 16 MHz, doing nothing: 6.84 mA (as before)</li>
<li>ATmega @ 8 MHz, doing nothing: 4.35 mA</li>
<li>ATmega @ 4 MHz, doing nothing: 2.96 mA</li>
<li>ATmega @ 2 MHz, doing nothing: 2.02 mA</li>
<li>ATmega @ 1 MHz, doing nothing: 1.55 mA</li>
<li>ATmega @ 500 KHz, doing nothing: 1.28 mA</li>
<li>ATmega @ 250 KHz, doing nothing: 1.16 mA</li>
<li>ATmega @ 125 KHz, doing nothing: 1.09 mA</li>
<li>ATmega @ 62.5 KHz, doing nothing: 1.06 mA</li>
</ul>

<p>Diminishing returns, clearly. Note that lowering the system clock in this way is not necessarily the best choice &#8211; getting something done N times faster and then powering down completely might be more efficient (see below).</p>

<p>One thing to watch out for: don&#8217;t go below 4 Mhz if you want to be able to use the RFM12B, or the processor will be too slow to process each byte.</p>

<p>When combining this, we get:</p>

<ul>
<li>ATmega @ 4 MHz in idle mode, doing nothing: 1.48 mA</li>
<li>ATmega @ 62.5 KHz in idle mode, doing nothing: 1.03 mA</li>
</ul>

<p>The advantage of this approach is that the clock is still running on the 16 MHz resonator (which probably draws most of that remaining current), so you&#8217;re still able to keep track of time &#8211; just more slowly.</p>

<p>A different approach is to go into real low power mode, and use the watchdog to get back out of this comatose state. The watch dog timer is less accurate, but depending on your application that may not be an issue.</p>

<p>Here&#8217;s the current consumption with the ATmega alternately in full speed and in power down mode:</p>

<ul>
<li>ATmega 16 ms @ 16 MHz / 16 ms powered down, doing nothing: 3.49 mA</li>
<li>ATmega 8 ms @ 16 MHz / 16 ms powered down, doing nothing: 2.31 mA</li>
<li>ATmega 4 ms @ 16 MHz / 16 ms powered down, doing nothing: 1.39 mA</li>
<li>ATmega 2 ms @ 16 MHz / 16 ms powered down, doing nothing: 0.80 mA</li>
<li>ATmega 1 ms @ 16 MHz / 16 ms powered down, doing nothing: 0.46 mA</li>
</ul>

<p>That last one does about the same amount of work as when running constantly @ 1 MHz, but with a third of the power consumption. Here is the corresponding sketch:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_24_at_134556.png" alt="Screen Shot 2011 06 24 at 13.45.56" /></p>

<p>And it will continues to scale downward:</p>

<ul>
<li>ATmega 100 µs @ 16 MHz / 16 ms powered down, doing nothing: 90.4 µA</li>
</ul>

<p><em>Which still represents 100,000 active processor cycles per second&#8230;</em></p>

<p>And lastly, let&#8217;s take it into power down and run for just 1 ms per <em>second</em>, i.e. 0.1% of the time. I can&#8217;t measure this with the multimeter, because the power use jumps up every second, but the comatose period draws a mere 6.8 µA, which is consistent with what has been reported several times before (the watchdog is still active, and so is the brown-out detector).</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/26/current-measurements/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>MCP1702 current draw</title>
		<link>http://jeelabs.org/2011/06/21/mcp1702-current-draw/</link>
		<comments>http://jeelabs.org/2011/06/21/mcp1702-current-draw/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 22:01:32 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Power]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14041</guid>
		<description><![CDATA[The MCP1702 used in JeeNodes and other circuits here at JeeLabs is a nifty little voltage regulator. It&#8217;s not particularly good for high voltages (limited to about 13V), but it has a very low idle current. That&#8217;s very useful for low-power circuits, especially when trying to get months or even years of service out of [...]]]></description>
			<content:encoded><![CDATA[<p>The MCP1702 used in <a href="/jn6">JeeNodes</a> and other circuits here at JeeLabs is a nifty little voltage regulator. It&#8217;s not particularly good for high voltages (limited to about 13V), but it has a very low idle current. That&#8217;s very useful for low-power circuits, especially when trying to get months or even years of service out of one set of batteries.</p>

<p>Let&#8217;s find out how it&#8217;s performing. I&#8217;ve set up this little test circuit:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_20_at_003911.png" alt="Screen Shot 2011 06 20 at 00.39.11" /></p>

<p>Well, it&#8217;s not really a test circuit at all &#8211; it&#8217;s in fact exactly what you need to use one of these things.</p>

<p>Putting 5V on the input (Vin), and leaving it a few minutes to settle, gives me a reading of 2.2 µA. Great, just what the specs say. It doesn&#8217;t really go up much with input voltage: 2.8 µA @ 12V. This is at no load.</p>

<p>With a 10 kΩ load, current draw rises to 338.1 µA, i.e. 330 µA for the resistor and about 8.1 µA for the regulator (assuming perfect calibration). That&#8217;s only 6 µA more, i.e. about 2% of the load.</p>

<p>Now let&#8217;s take the input voltage down, and see how this &#8220;low-drop&#8221; regulator behaves:</p>

<ul>
<li>5.0 V -> 2.2 µA</li>
<li>4.0 V -> 2.2 µA</li>
<li>3.5 V -> 2.1 µA</li>
<li>3.3 V -> 2.1 µA</li>
<li>3.2 V -> 90.4 µA</li>
<li>3.1 V -> 84.1 µA</li>
<li>3.0 V -> 78.2 µA</li>
</ul>

<p><em>Whoa</em>&#8230; it sure doesn&#8217;t like being fed less voltage than it needs to supply a regulated output of 3.3V! The change is quite pronounced between 3.30 and 3.28V (I couldn&#8217;t get my power supply knob to adjust any more accurately).</p>

<p>For yesterday&#8217;s <a href="http://jeelabs.org/2011/06/20/aa-boost-ripple/">AA power board discussion</a> that&#8217;s actually bad news, because it means that when the supply drops a mere 20 mV, it could cause the regulator to start wasting a fair amount of current (relatively speaking).</p>

<p>Let&#8217;s try something different: <em>no power on Vin, but power on Vout instead</em>.</p>

<p>This simulates connecting a battery to the +3V pin, and bypassing the MCP1702 voltage regulator altogether. Evidently, it&#8217;s not a good idea putting much more than 3.3V on there, since now we&#8217;re reverse feeding the regulator, something not all regulators are happy with:</p>

<ul>
<li>3.40 V -> 1000 µA</li>
<li>3.35 V -> 500 µA</li>
<li>3.30 V -> 90 µA</li>
<li>3.25 V -> 90 µA</li>
<li>3.20 V -> 90 µA</li>
<li>3.10 V -> 84 µA</li>
</ul>

<p>The conclusion seems to be: <em>when using the <a href="/aa1">AA Power Board</a> in combination with a <a href="/jn6">JeeNode</a>, it might be better in certain cases to omit the regulator altogether if you&#8217;re aiming for minimal power consumption!</em></p>

<p>It&#8217;s not enough to short the regulator&#8217;s Vin and Vout, it really has to be taken out of the circuit. Fortunately, you don&#8217;t have to disconnect <em>all three pins</em> &#8211; just disconnect the ground pin (on the JeeNode v4..v6, that&#8217;s the one closest to the FTDI connector).</p>

<p>But if all you want to do is power the whole thing from some power source over 3.3V, such as a 3x AA battery pack or a LiPo battery, then all is fine&#8230; you&#8217;ll see that ultra-low 2.2 µA figure &#8211; as intended in this design.</p>

<p>Just beware of low voltages: <em>weird things do happen!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/21/mcp1702-current-draw/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AA boost ripple</title>
		<link>http://jeelabs.org/2011/06/20/aa-boost-ripple/</link>
		<comments>http://jeelabs.org/2011/06/20/aa-boost-ripple/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 22:01:57 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Power]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=14006</guid>
		<description><![CDATA[The AA Power Board contains a switching boost converter to step the voltage from a single AA battery up to the 3.3V required by a JeeNode. Nifty stuff. Magic almost&#8230; if you take the water analogy, then it&#8217;s similar to pushing water up a mountain! Wikipedia has a schematic with the basic idea: Think of [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="/aa1">AA Power Board</a> contains a switching <a href="http://en.wikipedia.org/wiki/Boost_converter">boost converter</a> to step the voltage from a single AA battery up to the 3.3V required by a JeeNode.</p>

<p>Nifty stuff. Magic almost&#8230; if you take the water analogy, then it&#8217;s similar to <em>pushing water up a mountain!</em> Wikipedia has a schematic with the basic idea:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/boost_circuit.png" alt="Boost Circuit" /></p>

<p>Think of the coil as a rubber band (I&#8217;ll use a gravitational force analogy here), then closing the switch is like stretching it from the current voltage to ground. Opening the switch is equivalent to letting it go again &#8211; causing the rubber band to contract, pulling the end back up and then <em>exceding</em> the original height (voltage) as it overshoots. The diode then sneakily gets hold of the rubber band at its highest point. The analogy works even better if you imagine a cup of water attached to the end. <em>Well, you get the picture&#8230;</em></p>

<p>The trick is to repeat this over and over again, with a very efficient switch and a good rubber band, eh&#8230; I mean inductor. The way these boost regulators work, you&#8217;ll see that they constantly seek the proper voltage (feeding a storage pool at the end, in the form of a capacitor).</p>

<p>Enough talk. Let&#8217;s <em>look at it</em> with a scope:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/open.png" alt="Open" /></p>

<p>What you&#8217;re seeing is not the output voltage, which is of course 3.3V, but the <em>variation</em> in output voltage, which is measured in millivolts. IOW, 45 times a second, the regulator is overshooting the desired output by about 20 mV, and then it falls back almost 20 mV under 3.3V, at which point the booster kicks in again.</p>

<p>Let&#8217;s load the circuit lightly with a 10 kΩ resistance, i.e. 330 µA current draw:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/10k.png" alt="10k" /></p>

<p>No fundamental change, but the horizontal axis is now greatly enlarged, because the discharge is more substantial, causing the boost frequency to go to 2.2 KHz.</p>

<p>With a 1 kΩ load, i.e. 3.3 mA current draw, you can see the boost working a bit harder to charge up, i.e. the slope towards ≈ 20 mV above 3.3V is more gradual:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/1k.png" alt="1k" /></p>

<p>Keep in mind that the difference is also due to yet more magnification on the horizontal time axis. The boost converter is cycling at 21.1 KHz now.</p>

<p>With a 330 Ω load, i.e. 10 mA current draw, the wavevorm starts getting a few high-frequency spikes:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/330.png" alt="330" /></p>

<p>The total regulation is still good, though, with about 25 mV peak-to-peak ripple.</p>

<p>Now let&#8217;s simulate what happens with the RFM12B transmitter on, using a 100 Ω load, i.e. 33 mA current:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/100.png" alt="100" /></p>

<p>Looks like the regulator needs more time to charge than to discharge, at this power level. Still the characteristic &#8220;hunting&#8221; towards the proper voltage level.</p>

<p>With a 68 Ω / 50 mA load, the regulator decides to use more force, losing a bit of its fine touch:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/68.png" alt="68" /></p>

<p>The scope&#8217;s frequency measurement was off here, it probably got confused by the high frequency components in the signal. Repetion rate appears to be ≈ 65 KHz. But now the total ripple has increased to about 70 mV.</p>

<p>That&#8217;s probably about as high as we&#8217;re going to need for a JeeNode with some low-power sensors attached. <em>But hey, why stop here, right?</em></p>

<p>Here&#8217;s the output with a 47 Ω load, i.e. about 70 mA:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/47.png" alt="47" /></p>

<p>Whoa&#8230; that&#8217;s a ± 0.05 V swing, regulation is starting to suffer. I also just found out that the scope software has peak-to-peak measurement logic built in (and more). No need to estimate values from the divisions anymore.</p>

<p>Note that a 70 mA current at the end will translate to some 200 mA current draw on the battery &#8211; that&#8217;s the flip side of boost regulators: you only get higher voltage by drawing a hefty current from the input source as well.</p>

<p>Until this point, I used a standard 1.5V alkaline battery, but it&#8217;s not fresh and showing signs of exhaustion at these power levels (the output was a bit erratic).</p>

<p>To push even further, I switched to a fully charged <a href="http://jeelabs.org/2010/08/19/new-aa-battery-option/">Eneloop</a> battery, which supplies 1.2 .. 1.3V and has a much lower internal resistance. This translates to being able to supply much larger currents (over 1 A) without the output voltage dropping too much. In this case, the change didn&#8217;t have much effect on the measurements, but I was worried that continued testing would soon deplete the alkaline battery and skew the results.</p>

<p>To put it all in perspective, here is the output with the same 47 Ω load, but showing actual DC voltage levels:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/47dc.png" alt="47dc" /></p>

<p>So you see, its still a fairly well regulated power supply at 70 mA, though not quite up to 3.3V, as it should be.</p>

<p>One last test, using a 33 Ω resistor, which at 3.3V means we&#8217;ll be pulling a serious 100 mA from this circuit:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/33dc.png" alt="33dc" /></p>

<p>Measuring these values with a multimeter gives me 3.16 V @ 89 mA, while the resitance reads as 32.7 Ω &#8211; there&#8217;s some inconsistency here, which might be caused by the high-frequency fluctations in the output, I&#8217;m not sure.</p>

<p>But all in all, the AA Power Board seems to be doing what it&#8217;s supposed to do, with sufficient <em>oomph</em> to drive the ATmega, the RFM12B in transmit mode, and a bit of extra circuitry. <em>A bit jittery, but no sweat!</em></p>

<p><strong>Update</strong> &#8211; With a 10 µF capacitor plus 10 kΩ load the limits don&#8217;t change much, just the discharge shape:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/slow.png" alt="Slow" /></p>

<p>The same, at higher horizontal magnification:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/cap.png" alt="Cap" /></p>

<p>Note that AC coupling distorts the vertical position, it&#8217;s still ± 18 mV ripple, even if the <em>up</em> peak appears higher.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/20/aa-boost-ripple/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>EtherCard library API</title>
		<link>http://jeelabs.org/2011/06/19/ethercard-library-api/</link>
		<comments>http://jeelabs.org/2011/06/19/ethercard-library-api/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 22:01:42 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=13968</guid>
		<description><![CDATA[As you may have noticed in the last few weblog posts, the API of the EtherCard library has changed quite a bit lately. I&#8217;m not doing this to be different, but as part of my never-ending quest to try and simplify the calling interface and to reduce the code size of the library (these changes [...]]]></description>
			<content:encoded><![CDATA[<p>As you may have noticed in the last few weblog posts, the API of the <a href="http://jeelabs.net/projects/cafe/wiki/EtherCard">EtherCard</a> library has changed quite a bit lately. I&#8217;m not doing this to be different, but as part of my never-ending quest to try and simplify the calling interface and to reduce the code size of the library (these changes shaved several Kb off the compiled code).</p>

<p>The main change was to switch to a single global buffer for storing an outgoing Ethernet packet and for receiving the next packet from the controller. This removes the need to pass a buffer pointer to almost each of the many functions in the library.</p>

<p>Buffer space is scarce on an ATmega, so you have to be careful not to run out of memory, while still having a sufficiently large buffer to do meaningful things. The way it works now is that you have to allocate the global buffer in your main sketch:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_093245.png" alt="Screen Shot 2011 06 15 at 09.32.45" /></p>

<p>This particular style was chosen because it allows the library to access the buffer easily, and more importantly: without requiring an intermediate pointer.</p>

<p>To make this work, you have to initialize the EtherCard library in the proper way. This is now done by calling the <em>begin()</em> function as part of your <em>setup()</em> code:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_093446.png" alt="Screen Shot 2011 06 15 at 09.34.46" /></p>

<p>The <em>ether</em> variable is defined globally in the <a href="http://jeelabs.net/projects/cafe/repository/entry/EtherCard/EtherCard.h">EtherCard.h</a> header file. The <em>begin()</em> call also needs the MAC address to use for this unit. The simplest way to provide that is to define a static array at the top of the sketch with a suitable value (it has to be unique on your LAN):</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_093718.png" alt="Screen Shot 2011 06 15 at 09.37.18" /></p>

<p>Next, you can use DHCP to obtain an IP address and locate the gateway and DNS server:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_093927.png" alt="Screen Shot 2011 06 15 at 09.39.27" /></p>

<p>The <em>printIp()</em> utility function can optionally be used to print some info on the Serial port.</p>

<p>If you are going to set up a server, then a fixed IP address might be preferable. There&#8217;s a new <em>staticSetup()</em> function you can use when not doing DHCP:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_094255.png" alt="Screen Shot 2011 06 15 at 09.42.55" /></p>

<p>The gateway IP address is only needed if you&#8217;re going to access an IP address outside of your LAN, and the DNS IP addres is also optional (it&#8217;ll default to Google&#8217;s &#8220;8.8.8.8&#8243; DNS server if you do a DNS lookup). To omit values, pass a null pointer or leave the arguments off altogether:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_094555.png" alt="Screen Shot 2011 06 15 at 09.45.55" /></p>

<p>Just remember to call either <em>dhcpSetup()</em> or <em>staticSetup()</em> after the <em>begin()</em> call.</p>

<p>DNS lookups are also very simple:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_094732.png" alt="Screen Shot 2011 06 15 at 09.47.32" /></p>

<p>The one thing to keep in mind here, is that the <em>website</em> argument needs to be a  <em>flash-based</em> string, which must be defined as follows:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_095110.png" alt="Screen Shot 2011 06 15 at 09.51.10" /></p>

<p>Note the &#8220;PROGMEM&#8221; modifier. See the <a href="http://jeelabs.org/2011/05/23/saving-ram-space/">Saving RAM space</a> weblog post for more info about this technique.</p>

<p>This concludes the intialization part of the EtherCard library. Next, we need to keep things going by frequently polling for new incoming packets and responding to low-level ARP and ICMP requests. The easiest way to do so is to use the following template for <em>loop()</em>:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_095901.png" alt="Screen Shot 2011 06 15 at 09.59.01" /></p>

<p>The <em>packetReceive()</em> function polls for new incoming data and copies it into the global buffer. The return value is the size of this packet (or zero if there is none).</p>

<p>The <em>packetLoop()</em> function looks at the incoming data and takes care of low-level responses. The return value is the offset in the global packet buffer where incoming TCP data can be found (or zero if there is none).</p>

<p>As to what to do next: it really all depends on what you&#8217;re after. Check out the examples in the Ethercard library for how to build web servers and web clients on top of this functionality.</p>

<p>To get an idea of the code overhead of the EtherCard library: a simple web client using DHCP and DNS is around 10 Kb, while an even simpler one using static IP addresses (no DHCP and no DNS) is under 7 Kb. The fairly elaborate <a href="http://jeelabs.net/projects/cafe/repository/entry/EtherCard/examples/etherNode/etherNode.pde">EtherNode</a> sample sketch, which includes DHCP and the <a href="http://jeelabs.net/projects/cafe/wiki/RF12">RF12</a> library is now ≈ 13 Kb.</p>

<p><em>IOW, lots of room for adding your own app logic!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/19/ethercard-library-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Complete web client demo</title>
		<link>http://jeelabs.org/2011/06/17/complete-web-client-demo/</link>
		<comments>http://jeelabs.org/2011/06/17/complete-web-client-demo/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 22:01:42 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=13925</guid>
		<description><![CDATA[After yesterday&#8217;s addition of DHCP to the EtherCard library, it&#8217;s only a small step to create a sketch which does everything needed for convenient stand-alone use on a local LAN. Here&#8217;s a webClient.pde demo sketch which sets itself up via DHCP, then does a DNS lookup to find a server by name, then does a [...]]]></description>
			<content:encoded><![CDATA[<p>After yesterday&#8217;s <a href="/2011/06/16/dhcp-support/">addition of DHCP</a> to the EtherCard library, it&#8217;s only a small step to create a sketch which does everything needed for convenient stand-alone use on a local LAN.</p>

<p>Here&#8217;s a <a href="http://jeelabs.net/projects/cafe/repository/entry/EtherCard/examples/webClient/webClient.pde">webClient.pde</a> demo sketch which sets itself up via DHCP, then does a DNS lookup to find a server by name, then does a web request every 5 seconds and displays the first part of the result:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_090457.png" alt="Screen Shot 2011 06 15 at 09.04.57" /></p>

<p>Sample output:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/screen_shot_2011_06_15_at_090551.png" alt="Screen Shot 2011 06 15 at 09.05.51" /></p>

<p>The total sketch is under 10 Kb, so there&#8217;s still <em>lots</em> of room to add the RF12 wireless driver, as well as a fair amount of application logic.</p>

<p><em>Who says a little 8-bit processor can&#8217;t be part of today&#8217;s internet revolution, eh?</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/17/complete-web-client-demo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DC high-side control</title>
		<link>http://jeelabs.org/2011/06/12/dc-high-side-control/</link>
		<comments>http://jeelabs.org/2011/06/12/dc-high-side-control/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 22:01:23 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[Power]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=13822</guid>
		<description><![CDATA[Good news: the &#8220;high-side&#8221; DC power switch works! On the bottom, a DC jack getting 12V power, on the right a cable with a DC plug powering an external USB disk. The little board in the middle is sort of a breakout board for two SMD chips: a dual P-MOSFET and a low-drop -3.3V linear [...]]]></description>
			<content:encoded><![CDATA[<p><em>Good news: the &#8220;high-side&#8221; <a href="/2011/06/01/hard-disk-power-3/">DC power switch</a> works!</em></p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/06/dsc_2561.jpg" alt="Dsc 2561" /></p>

<p>On the bottom, a DC jack getting 12V power, on the right a cable with a DC plug powering an external USB disk.</p>

<p>The little board in the middle is sort of a breakout board for two SMD chips: a dual P-MOSFET and a low-drop -3.3V linear voltage regulator to power the JeeNode. The rest is boilerplate stuff, i.e. the <a href="/xp1">JeeNode Experimenter&#8217;s Pack</a>, a couple of resistors, and some electrolytic caps.</p>

<p>I&#8217;ve only tested it with a load of about 1A, but it should work up to 3A without any problem. What&#8217;s also nice is that as a high-side switch, it doesn&#8217;t really care what voltage is being used as power supply &#8211; anything between 3.5V and 16V should work just fine. That means this can also be used for 5V devices and even with devices powered off 1..4 LiPo-batteries. This simply fits between a DC power plug and its device &#8211; <em>convenient!</em></p>

<p>The current consumption is 21 mA with the ATmega and receiver permanently on. Could easily be lowered a few mA by putting the ATmega in &#8220;idle&#8221; mode.</p>

<p>The current sensing capabilities are definitely working, but the resistance of the P-MOSFET is not quite 0.1 Ω: with a 390 mA current, I see about 90 mV across the MOSFET, indicating that its internal resistance when driven from a 3.3V JeeNode is more like 0.23 Ω. That&#8217;s on the high side (pardon the pun), because this would mean a 1A load will get about 0.23V less out of the power supply than it would with a direct connection &#8211; and 0.7V less when drawing 3A. Oh well, it&#8217;ll be ok for most devices, cheap power bricks don&#8217;t always supply exactly 12V anyway.</p>

<p>The question of course is how consistent this MOSFET resistance is. I suspect that there will be quite a bit of variation across different units. But that&#8217;s not necessarily a problem: we don&#8217;t really care about <em>absolute</em> currents, we just need to see how the device&#8217;s current consumption is <em>relative</em> to full power and idle modes, basically. And we can always calibrate the value with a multimeter or power resistor.</p>

<p>The other weak spot in all this is that the voltage levels measured with this setup are very low, and only cover a few percent of the ADC range. It would be nice to have a bit more resolution there.</p>

<p><em>Ok, let&#8217;s throw an op-amp into the mix&#8230;</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/06/12/dc-high-side-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.791 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-23 09:55:54 -->

