<?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>Jee Labs</title>
	<atom:link href="http://news.jeelabs.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://news.jeelabs.org</link>
	<description>Computing stuff tied to the physical world</description>
	<lastBuildDate>Thu, 02 Sep 2010 22:01:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JeeNode goes solar</title>
		<link>http://news.jeelabs.org/2010/09/03/jeenode-goes-solar/</link>
		<comments>http://news.jeelabs.org/2010/09/03/jeenode-goes-solar/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 22:01:05 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9228</guid>
		<description><![CDATA[Now that ultra low-power options are coming into reach for JeeNodes, lots of new scenarios can be explored. The most obvious one is probably a solar-powered JeeNode &#8230; so meet the latest new node #5 at Jee Labs: It also uses a 0.47 F supercap, same as yesterday, but now hooked up to a small [...]]]></description>
			<content:encoded><![CDATA[<p>Now that <a href="/2010/09/02/sending-packets-without-battery/">ultra low-power</a> options are coming into reach for JeeNodes, lots of new scenarios can be explored.</p>

<p>The most obvious one is probably a solar-powered JeeNode &#8230; so meet the latest new node #5 at Jee Labs:</p>

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

<p>It also uses a 0.47 F supercap, same as yesterday, but now hooked up to a small 4.5 V solar cell (which can only deliver a few mA in bright sunlight), and a Schottky diode between the solar cell and the capacitor.</p>

<p>Here&#8217;s the &#8220;power supply&#8221; in more detail:</p>

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

<p>As you can see, the solar cell is tiny. A few square cm&#8217;s only. In fact, it takes quite some time for it to charge the supercap to acceptable levels. I had to place the cell in moderately bright sunlight for about half an hour to get to a 4 Volt charge. It was inching along, taking several seconds per 0.01 V increase.</p>

<p>To avoid losing all that charge right away in the power-up cycle, I modified the ATmega&#8217;s fuses to start in 258 clock cycles after power down, and to start up within 4.1 msec after reset. That way it will start up as quickly as possible at all times. The 258 CK setting is particularly nice, because it means the ATmega can get out of total power down within about 16 µs, <em>fast enough to respond to a byte RX/TX interrupt from the RFM12B!</em></p>

<p>Does it work? Check it out: after connecting the JeeNode with the &#8220;radioBlip.pde&#8221; sketch pre-loaded&#8230; <em>away it went</em> &#8211; sending one packet every 60 seconds as node 5:</p>

<pre><code>    OK 5 1 0
    OK 5 2 0
    OK 5 3 0
    OK 5 4 0
</code></pre>

<p>While exposed to the current partly-sunny / partly-cloudy light levels, the voltage on the supercap is still increasing. This is good &#8211; it means there&#8217;s a surplus of solar energy, even with these transmissions going on. That extra energy will be crucial if this thing is to last through the night&#8230;</p>

<p>If everything works out, this little Arduino-compatible bugger could well be the first JeeNode to become completely autonomous and transmit wirelessly&#8230; <em>forever!</em></p>

<p>Time will tell :)</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/09/03/jeenode-goes-solar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending packets without battery</title>
		<link>http://news.jeelabs.org/2010/09/02/sending-packets-without-battery/</link>
		<comments>http://news.jeelabs.org/2010/09/02/sending-packets-without-battery/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 22:01:20 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9211</guid>
		<description><![CDATA[Here&#8217;s a fun experiment&#8230; After yesterday&#8217;s improved power-down current results, I wanted to find out how much power it really takes to send out a bunch of small packets. No acks, just periodically sending out a packet and sleeping. Trouble is, I didn&#8217;t want to wait for a battery to run down, since that would [...]]]></description>
			<content:encoded><![CDATA[<p><em>Here&#8217;s a fun experiment&#8230;</em></p>

<p>After <a href="/2010/09/01/sleep/">yesterday&#8217;s</a> improved power-down current results, I wanted to find out how much power it <em>really</em> takes to send out a bunch of small packets. No acks, just periodically sending out a packet and sleeping.</p>

<p>Trouble is, I didn&#8217;t want to wait for a battery to run down, since that would take months or even years. <em>Bit long to get results for this weblog, eh?</em></p>

<p>So instead, I used this little chap:</p>

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

<p>It&#8217;s a super-capacitor which can handle up to 5.5V and has a capacity of 0.47 <em>Farad!</em> That&#8217;s like putting a thousand 470 µF caps in parallel. Amazing stuff, in an even more amazingly small package.</p>

<p>Here&#8217;s a <a href="http://cafe.jeelabs.net/hw/jeenode/">JeeNode</a>, fitted with this new power source, to give you an idea of just how small this thing is:</p>

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

<p>The next step was to design a small sketch to test this. Here&#8217;s what I came up with:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_29_at_115738.png" alt="Screen Shot 2010 08 29 at 11.57.38" /></p>

<p>Some of the code left out for brevity. Full source code can be found <a href="http://code.jeelabs.org/libraries/RF12/examples/radioBlip/radioBlip.pde">here</a>.</p>

<p>What this demo does is send out a packet with a 2-byte payload, then sleep for approximately 1 second, then send again, etc. Until power runs out.</p>

<p>Sure enough, packets started coming in every second:</p>

<pre><code>    OK 4 0 0
    OK 4 1 0
    OK 4 2 0
    OK 4 3 0
    [...]
</code></pre>

<p>I expected it to send out say 100 packets or so, before the charge in the 0.47 F supercap would run out.</p>

<p><em>Guess how far it went&#8230;</em></p>

<pre><code>    [...]
    OK 4 178 28
    OK 4 179 28
    OK 4 180 28
    OK 4 181 28
</code></pre>

<p>That&#8217;s packet number &#8230; clickety, clickety &#8230; 28 * 256 + 181 = <strong>7349</strong> !!!</p>

<p>In other words, the JeeNode was able to send out well over 7000 packets, i.e. two hours of packets sent once a second.</p>

<p>This is fantastic. I think the secret &#8211; apart from the 3 µA powerdown mode &#8211; is that the RFM12B + RF12 driver require very little time to start up, send off a packet, and go back to sleep again. There is no ACK involved, the RFM12B is hardly ever in reception mode.</p>

<p>With real-world use, I expect power requirements to be considerably higher. First of all, a <a href="http://cafe.jeelabs.net/hw/room_board/">Room Board</a> will draw around 50 µA, due to the on-board PIR sensor. And second, I&#8217;m going to want to use ACKs for at least the motion detector reports, so that the system has a robust mechanism for reporting motion whenever it is detected. This means putting the RFM12B in receive mode for a few milliseconds, waiting for the ACK. And repeating this process a few times if that ACK isn&#8217;t immediately received.</p>

<p><em>But still &#8230; over 7000 packets without a battery!</em></p>

<p><strong>Update</strong> &#8211; with one packet per 5 seconds, the charge lasted 4523 packets, i.e. just over 6:15.</p>

<p><strong>Update #2</strong> &#8211; with one packet per 60 seconds, 771 packets got sent out, that&#8217;s 12:51 hours &#8230; <em>looks like the self-discharge of the supercap is eating up the remaining energy.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/09/02/sending-packets-without-battery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Sleep!</title>
		<link>http://news.jeelabs.org/2010/09/01/sleep/</link>
		<comments>http://news.jeelabs.org/2010/09/01/sleep/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 22:01:11 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[LowPower]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9192</guid>
		<description><![CDATA[The &#8220;powerdown_demo.pde&#8221; sketch in this recent post draws 20 µA, which surprised me a bit&#8230; A while back, I got it down to a fraction of that, by turning off the brown-out detector (BOD) through a fuse bit on the ATmega. That&#8217;s a little circuit which prevents the ATmega from coming out of reset and [...]]]></description>
			<content:encoded><![CDATA[<p>The &#8220;powerdown_demo.pde&#8221; sketch in this <a href="/2010/08/21/another-lipo-option/">recent post</a> draws 20 µA, which surprised me a bit&#8230;</p>

<p>A while back, I got it down to a <a href="/2009/05/16/power-consumption-more-savings/">fraction</a> of that, by turning off the <em>brown-out detector</em> (BOD) through a fuse bit on the ATmega. That&#8217;s a little circuit which prevents the ATmega from coming out of reset and doing anything if the voltage is too low.</p>

<p>As it turns out, you <em>can</em> turn off the BOD in software, but only for sleep mode. The reasoning being that there&#8217;s no point in protecting the processor from going berserk while it&#8217;s <em>not doing anything</em> in the first place&#8230;</p>

<p>Well, my code to turn off the BOD was wrong. You have to do this <em>right</em> before going to sleep. Here&#8217;s the updated <a href="http://code.jeelabs.org/libraries/Ports/examples/powerdown_demo/powerdown_demo.pde">powerdown_demo.pde</a> sketch:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_28_at_125018.png" alt="Screen Shot 2010 08 28 at 12.50.18" /></p>

<p><em>(correction &#8211; I mixed up my bits: change &#8220;PINB |= &#8230;&#8221; to &#8220;PINB = &#8230;&#8221; or &#8220;PORTD ^= &#8230;&#8221;)</em></p>

<p>The result?</p>

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

<p><em>Now we&#8217;re cookin&#8217; again!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/09/01/sleep/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making 6-wire cables</title>
		<link>http://news.jeelabs.org/2010/08/31/making-6-wire-cables/</link>
		<comments>http://news.jeelabs.org/2010/08/31/making-6-wire-cables/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 22:01:56 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[JeePlug]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9161</guid>
		<description><![CDATA[I&#8217;ve been making cables for the Utility Plug recently. They come with the kit, but the reason for choosing these &#8220;modular&#8221; jacks and connectors, is that they are very easy to make yourself. FYI, the 26 AWG wires in this type of cabling are rated for 360 mA current. Plenty for signaling and powering electronic [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been making cables for the <a href="http://cafe.jeelabs.net/hw/utility_plug/">Utility Plug</a> recently. They come with the kit, but the reason for choosing these &#8220;modular&#8221; jacks and connectors, is that they are very easy to make yourself.</p>

<p>FYI, the 26 AWG wires in this type of cabling are rated for 360 mA current. Plenty for signaling and powering electronic stuff, but not suited for high power or high voltages.</p>

<p>I use the following low-cost crimp tool for most of my 4-. 6-. and 8-core cables:</p>

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

<p>Actually, I have a second one for 8-core cables (i.e. RJ-45 network cables) &#8211; it&#8217;s sturdier but also more expensive:</p>

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

<p>Here&#8217;s how the cable is made, from start to finish. First, make a clean straight cut:</p>

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

<p>Then you have to strip the outer mantle, without damaging the inner wires:</p>

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

<p>This is what comes out:</p>

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

<p>It fits <em>perfectly</em> into a &#8220;6P6C&#8221; RJ-12 modular plug (6 positions, 6 connections):</p>

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

<p>Now the magic part:</p>

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

<p>Seen from the other side, with the plug ready to be crimped on:</p>

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

<p>Here&#8217;s a before-and-after picture, you can see the metal pushed into the cable (and the cable jacket clamped for strain relief):</p>

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

<p>Another view:</p>

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

<p>How does it work? Well, here&#8217;s the crimp tool, in released state:</p>

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

<p>And here it is again, squeezed tight (it has a stop, ya can&#8217;t squeeze too far):</p>

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

<p>If you keep goin&#8217; at it for a while, you get this:</p>

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

<p>And that&#8217;s where they end up at Jee Labs:</p>

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

<p>Easy. And if you don&#8217;t want to go through all this: <em>just cut up a telephone cable instead</em> (note that such cables will work fine, but most of them only connect the inner 4 wires, i.e. AIO, DIO, +3V, and GND, not PWR &amp; IRQ).</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/31/making-6-wire-cables/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New PIR motion sensor</title>
		<link>http://news.jeelabs.org/2010/08/30/new-pir-motion-sensor/</link>
		<comments>http://news.jeelabs.org/2010/08/30/new-pir-motion-sensor/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 22:01:17 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9183</guid>
		<description><![CDATA[From now on, the Room Board is going to be shipped with a new PIR (passive infrared) motion sensor: The reason I went looking for a replacement is that the ELV unit was out of stock for a long time, especially in quantity. It seems to be back now, but I had already found a [...]]]></description>
			<content:encoded><![CDATA[<p>From now on, the <a href="http://cafe.jeelabs.net/hw/room_board/">Room Board</a> is going to be shipped with a new PIR (passive infrared) motion sensor:</p>

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

<p>The reason I went looking for a replacement is that the ELV unit was out of stock for a long time, especially in quantity. It seems to be back now, but I had already found a good alternative.</p>

<p>The unit shown above is nice for a couple of reasons:</p>

<ul>
<li>it&#8217;s equally low-power, drawing 40..50 µA</li>
<li>this unit is specifically for 3 .. 3.3V, whereas the ELV unit was running slightly out of spec

<ul>
<li>(it officially requires 5..24V, but the regulator brings that to 3V)</li>
</ul></li>
<li>it&#8217;s slightly lower on the sensor side (and higher on the component side)</li>
<li>the sensor seems to be sensitive over a somewhat wider angle</li>
<li>it&#8217;s no longer a kit, no need to solder-in that sensitive PIR chip anymore</li>
</ul>

<p>I&#8217;ve yet to do some serious testing w.r.t. range, but it appears to be ok.</p>

<p>Here are the two sensors side-by-side:</p>

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

<p>One unfortunate detail is that the pinout is different. <em>Yes, even 3 pins can lead to incompatible variations!</em></p>

<p>The old sensor has: <strong>VCC GND OUT</strong> &#8211; the new one uses: <strong>VCC OUT GND</strong>. Besides, I want to connect it to +3V now, i.s.o. PWR.</p>

<p>I solved this by using the <em>other side</em> of the room board, and reconnecting GND slightly differently &#8211; i.e. cutting the pin off and rewiring it as follows:</p>

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

<p>It&#8217;s a hack, but it works. The two remaining pins are still enough to keep the sensor board firmly in place.</p>

<p><em>Onwards!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/30/new-pir-motion-sensor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>LED strip efficiency</title>
		<link>http://news.jeelabs.org/2010/08/29/led-strip-efficiency/</link>
		<comments>http://news.jeelabs.org/2010/08/29/led-strip-efficiency/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 22:01:16 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Home automation]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9167</guid>
		<description><![CDATA[LED lighting is efficient right? Oh, sure&#8230; the LEDs are, but the way they are connected isn&#8217;t necessarily! I&#8217;ve always been puzzled by those resistors you see on RGB LED strips: My impression is that these strips consists of segments which all have (essentially) the following schematic: Measuring the 60-LED/meter RGB strip I have here, [...]]]></description>
			<content:encoded><![CDATA[<p>LED lighting is efficient right? Oh, sure&#8230; the <em>LEDs</em> are, but the way they are <em>connected</em> isn&#8217;t necessarily!</p>

<p>I&#8217;ve always been puzzled by those resistors you see on RGB LED strips:</p>

<p><img src="http://files.jeelabs.org/2010/08/dsc_1664_2.jpg" alt="Dsc 1664 2" /></p>

<p>My impression is that these strips consists of segments which all have (essentially) the following schematic:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_27_at_215922.png" alt="Screen Shot 2010 08 27 at 21.59.22" /></p>

<p>Measuring the 60-LED/meter RGB strip I have here, I get the following readings for 0.5 m, i.e. 10 of the above segments:</p>

<ul>
<li>RED draws ≈ 180 mA, the voltage over its resistor is ≈ 5.5V</li>
<li>GREEN draws ≈ 170 mA, the voltage over its resistor is ≈ 2.2V</li>
<li>BLUE draws ≈ 190 mA, the voltage over its resistor is ≈ 2.4V</li>
</ul>

<p>Total current draw is roughly 540 mA, or 1.08 A/meter @ 12V. So the total power consumption is 13 watts for each meter of LED strip.</p>

<p>But&#8230;</p>

<ul>
<li>the <em>red</em> LED&#8217;s resistor consumes 0.18 x 5.5 = 0.99 W on each 0.5 m</li>
<li>the <em>green</em> LED&#8217;s resistor consumes 0.17 x 2.2 = 0.37 W on each 0.5 m</li>
<li>the <em>blue</em> LED&#8217;s resistor consumes 0.19 x 2.4 = 0.46 W on each 0.5 m</li>
</ul>

<p>That&#8217;s 3.64 W of the 13 W pumped in per meter &#8211; turned into &#8230; <em>heat!</em></p>

<p>Is LED lighting a good idea, in terms of efficiency? Yes, probably. A meter of RGB LEDs at full power draws 13 watts and looks a lot brighter to me than a classical lightbulb, halogen light, or even them new fluorescent &#8220;long-life&#8221; bulbs that are all the rage (but oh so ugly).</p>

<p>Note that I&#8217;m not talking of &#8220;power LEDs&#8221;, i.e. the 1W, 3W, or more LEDs that are used for very bright lights and which need te be mounted on a cooling fin (Infineon, etc). These are usually driven by a (more complex) <em>constant-current</em> source, and not a plain 12V supply. The reason for this is that at those power levels, you couldn&#8217;t possibly adjust the current draw via resistors &#8211; these would become scorching hot and cause lots of problems of their own!</p>

<p>The are a couple more figures to be gleaned from the above information, btw, but you can also measure these values directly on the RGB strip:</p>

<ul>
<li>the <em>red</em> LED resistors are 300 Ω each, each LED gets 2.2V</li>
<li>the <em>green</em> LED resistors are 120 Ω each, each LED gets 3.3V</li>
<li>the <em>blue</em> LED resistors are 120 Ω each, each LED gets 3.2V</li>
</ul>

<p>That voltage is the real reason for all these resistors. If you were to feed <em>exactly</em> 6.6V to the 3 red LEDs (9.8V for green, 9.6V for blue), then you wouldn&#8217;t need any resistors to pick up the slack. But that&#8217;s not feasible in a practical / cheap way, so instead we drive these strips with 12V and have the resistors eat away 28% of excess energy in the form of generated heat. Note: it would be more accurate to say: &#8220;if you were to feed exactly 180 mA, etc&#8221; &#8230; because the voltage is a &#8220;side effect&#8221; for each type of LED, the current is what determines their brightness.</p>

<p>Another source of inefficieny is the 12V power supply &#8211; let&#8217;s assume it&#8217;s about 90% efficient. Then 72 watts of power going into the LEDs will draw a total of 111 watts from the power line.</p>

<p>The good news is that these ratios won&#8217;t change when the LEDs are dimmed via PWM. A 50% pulse reduces the total amount of energy used by the same percentage (again: 28% of <em>that</em> is gobbled up by resistors).</p>

<p><em>Sooo&#8230; if you&#8217;ve got 8 meters of RGB strip going at full power, then that&#8217;s about 100 watts &#8211; 28 of which are turned into heat before they even reach the LEDs. And the power supply used another 11 to do its job.</em></p>

<p>I still think LED strips are a good idea &#8211; <em>if</em> I can get the white balance right and <em>if</em> their color is very even.</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/29/led-strip-efficiency/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fractional bits?</title>
		<link>http://news.jeelabs.org/2010/08/28/fractional-bits/</link>
		<comments>http://news.jeelabs.org/2010/08/28/fractional-bits/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 22:01:42 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9139</guid>
		<description><![CDATA[To continue this little weblog series on bits, I&#8217;m going to go into bit fractions. Yeah, right&#8230; there is no such thing, of course &#8211; unless you&#8217;re into probabilities or fuzzy logic, perhaps. What I actually want to do, is describe &#8220;analog output&#8221; on the ATmega, using the Arduino library&#8217;s analogWrite() function. And throw in [...]]]></description>
			<content:encoded><![CDATA[<p>To continue this little weblog series on <a href="/2010/08/27/flippin’-bits/">bits</a>, I&#8217;m going to go into bit fractions.</p>

<p><em>Yeah, right&#8230; there is no such thing, of course &#8211; unless you&#8217;re into probabilities or fuzzy logic, perhaps.</em></p>

<p>What I actually want to do, is describe &#8220;analog output&#8221; on the ATmega, using the Arduino library&#8217;s <a href="http://www.arduino.cc/en/Reference/AnalogWrite">analogWrite()</a> function. And throw in some bit manipulations along the way, to stay somewhat on topic.</p>

<p>The little secret with analogWrite() is that it doesn&#8217;t do what its name suggests. The ATmega has no way of generating an analog signal, i.e. a voltage level between 0 and VCC.</p>

<p>Instead, a pulse is generated, with a varying duty cycle. I.e. the &#8220;on&#8221; and the &#8220;off&#8221; times of the pulse will be different, the ratio of these times being proprtional to the 0..255 value passed as argument to analogWrite(). With &#8220;0&#8243;, the signal will be 100% off, with &#8220;255&#8243; the signal will be 100% on. With &#8220;128&#8243; the pulse will be on the same amount of time as off. With &#8220;1&#8243;, it will be on <em>very</em> briefly, and then off most of the time, and so on&#8230;</p>

<p>The neat thing is that you connect it to an incandescent lamp, or a motor, then the effect will be that these will light/turn at less than their full power, due to the time it takes for these devices to try and follow the pulse. So the <em>effect</em> is similar to a fractional adjustment: you can dim / slow down these devices by using analogWrite().</p>

<p>It even works with LEDs, although these turn on and off very fast. In this case, the reason is that our eyes can&#8217;t follow such fast changes, and so we perceive the result as dimmed as well. A whole industry was once created around this &#8220;persistence of vision&#8221; property of our eyes &#8211; <em>it&#8217;s called TV&#8230;</em></p>

<p>Here&#8217;s a sketch which uses this pulsed output to control the brightness of a LED connected to DIO3 (i.e. D6):</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_27_at_164438.png" alt="Screen Shot 2010 08 27 at 16.44.38" /></p>

<p>Note that I didn&#8217;t have to define pin 6 as an output, analogWrite() does that.</p>

<p>What the above does, is ramp up gradually from 0 to 255, and then repeat:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_27_at_164906.png" alt="Screen Shot 2010 08 27 at 16.49.06" /></p>

<p>Suppose we want it to fade in and out instead:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_27_at_164917.png" alt="Screen Shot 2010 08 27 at 16.49.17" /></p>

<p>Try implementing this yourself.</p>

<p>Note that you&#8217;re going to need at least 9 bits of information to do this: 8 for the brightness level and 1 to keep track of whether you&#8217;re currently in the up ramp or in the down ramp:</p>

<p>Here&#8217;s one way to do it, using some bit trickery:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_27_at_170515.png" alt="Screen Shot 2010 08 27 at 17.05.15" /></p>

<p>A few notes:</p>

<ul>
<li>I&#8217;ve changed the &#8220;level&#8221; variable from an 8-bit <em>byte</em> to a 16-bit <em>word</em></li>
<li>bit 8 toggles from 0 to 1 and back every 256 level counts</li>
<li>it&#8217;ll be 1 when level is 256..511, 768..1023, etc</li>
<li>when it&#8217;s 1, we flip the bits, i.e. 0 becomes 255, 1 becomes 254, etc</li>
<li>the analogWrite() function ignores all upper bits</li>
</ul>

<p>If you think <em>that</em> was an obscure call to analogWrite(), try this one:</p>

<pre><code>    analogWrite(6, level ^ -((level &gt;&gt; 8) &amp; 1));
</code></pre>

<p>Maybe you can decypher it when written slightly differently?</p>

<pre><code>    analogWrite(6, level ^ -bitRead(level, 8));
</code></pre>

<p>(hint: bitRead() always returns either 0 or 1)</p>

<p>It&#8217;s all pretty geeky stuff, and let&#8217;s hope you&#8217;ll never have to deal with code such as this again, but the point of this story is that there&#8217;s no magic. You just have to know what each operator does, and how to translate an integer from decimal to binary notation and back.</p>

<p>I&#8217;ll summarize my intuitive interpretation of bit operators below:</p>

<ul>
<li>&#8220;<strong>X | Y</strong>&#8221; = take X and copy all the 1&#8242;s of Y into it</li>
<li>&#8220;<strong>X &amp; Y</strong>&#8221; = take X and copy all the 0&#8242;s of Y into it</li>
<li>&#8220;<strong>X ^ Y</strong>&#8221; = take X and flip all the bits where Y has 1&#8242;s</li>
<li>&#8220;<strong>~ X</strong>&#8221; = flip all the bits of X</li>
<li>&#8220;<strong>- X</strong>&#8221; = arithmetic minus (same as &#8220;(~X) + 1&#8243; !)</li>
<li>&#8220;<strong>! X</strong>&#8221; = 1 if X is zero, 0 otherwise</li>
<li>&#8220;<strong>X &lt;&lt; N</strong>&#8221; = multiply X by 2, N times</li>
<li>&#8220;<strong>X >> N</strong>&#8221; = divide X by 2, N times</li>
</ul>

<p>Some tricks based on this:</p>

<ul>
<li>&#8220;<strong>~ 0</strong>&#8221; = all bits set to 1 (same as &#8220;-1&#8243; !)</li>
<li>&#8220;<strong>~ 0 &lt;&lt; N</strong>&#8221; = all bits 1, but N lowest bits set to 0</li>
<li>&#8220;<strong>bit(N) &#8211; 1</strong>&#8221; = a constant with N lowest bits set to 1</li>
<li>&#8220;<strong>X &amp; (bit(N) &#8211; 1)</strong>&#8221; = the N lowest bits of X, the rest is 0</li>
<li>&#8220;<strong>X &amp; ~ (bit(N) &#8211; 1)</strong>&#8221; = X, but with the N lowest bits set to 0</li>
<li>&#8220;<strong>!! X</strong>&#8221; = 0 if X is zero, 1 otherwise</li>
</ul>

<p>An useful rule when writing logical expressions is: <em>when in doubt, parenthesize!</em> &#8211; see <a href="http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B">C operator precedence</a>.</p>

<p>Sooo&#8230; use bit(), bitRead(), bitWrite(), bitSet(), and bitClear() wherever you can, since it usually makes the code easier to read. But there&#8217;s no need to get lost if you see ^&amp;|~!&#8217;s in your expression &#8211; just <em>slow down</em> and decode such expressions step by step!</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/28/fractional-bits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flippin’ bits</title>
		<link>http://news.jeelabs.org/2010/08/27/flippin%e2%80%99-bits/</link>
		<comments>http://news.jeelabs.org/2010/08/27/flippin%e2%80%99-bits/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 22:01:12 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9123</guid>
		<description><![CDATA[After yesterday&#8217;s post about setting and clearing bits, let&#8217;s explore reversing bits, i.e. changing them from 0 to 1 and back. And let&#8217;s do it by blinking an LED attached to DIO of port 1 &#8211; i.e. Arduino digital pin 4: The &#8220;if (onOff = 0)&#8221; etc is the logic that toggles onOff between 0 [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="/2010/08/26/bit-manipulation/">yesterday&#8217;s post</a> about setting and clearing bits, let&#8217;s explore <em>reversing</em> bits, i.e. changing them from 0 to 1 and back. <em>And let&#8217;s do it by blinking an LED attached to DIO of port 1</em> &#8211; i.e. Arduino digital pin 4:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_26_at_103126.png" alt="Screen Shot 2010 08 26 at 10.31.26" /></p>

<p>The &#8220;if (onOff = 0)&#8221; etc is the logic that toggles onOff between 0 and 1 on each pass through the loop:</p>

<pre><code>    if (onOff == 0) onOff = 1; else onOff = 0;
</code></pre>

<p>But there are <em>lots of</em> ways to do the same thing, coded differently:</p>

<pre><code>    if (onOff == 0) onOff = 1; else onOff = 0;
    if (onOff == 0) onOff = bit(0); else onOff = 0;
    if (onOff == 0) bitSet(onOff, 0); else bitClear(onOff, 0);
    onOff = onOff ? 0 : 1;
    onOff = (~ onOff) &amp; 1;
    onOff = (onOff + 1) &amp; 1;
    onOff = ! onOff;
    onOff = 1 - onOff;
    onOff = onOff ^ 1;
    onOff ^= 1;
</code></pre>

<p>See if you can figure out all of these.</p>

<p>Take your pick. Those last two use C&#8217;s <em>XOR</em> operator. I tend to prefer shorter source code, so I&#8217;d use that last notation (note that the resulting <em>compiled</em> code is not necessarily shorter than the other examples).</p>

<p>Now suppose you have a byte value &#8220;X&#8221; and you want to flip the 4th bit in it, while not changing anything else. That&#8217;s a bit more work. It could be done like this, for example:</p>

<pre><code>    if (bitRead(X, 4) == 0) bitSet(X, 4); else bitClear(X, 4);
</code></pre>

<p>Or like either of these:</p>

<pre><code>    X = X ^ bit(4);
    X ^= bit(4);
</code></pre>

<p>This shows clearly that the &#8220;^&#8221; XOR operator does exactly what we need: flip bits.</p>

<p>Back to blinking an actual LED, as done with the above sketch. Here&#8217;s a little mind bender &#8211; another sketch, <em>doing the same</em> using raw ports and the XOR operator:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_26_at_105810.png" alt="Screen Shot 2010 08 26 at 10.58.10" /></p>

<p>The first example was doing things &#8220;the Arduino way&#8221;, using pinMode() and digitalWrite(). It compiles to 890 bytes of code. This second example goes straight to the hardware and uses 554 bytes of code:</p>

<ul>
<li>Arduino digital pin 4 is bit 4 on the &#8220;D port&#8221; of an ATmega</li>
<li>&#8220;DDRD&#8221; is the &#8220;Data Direction Register&#8221;, where we set up pin 4 as an output</li>
<li>&#8220;PORTD&#8221; is the out &#8220;Port Register&#8221;, which controls the actual output signal</li>
</ul>

<p>You can see the XOR in action in that last example. It takes all the output bits of port D (Arduino pins 0 .. 7), and flips just a single bit, i.e. bit 4.</p>

<p>Just for kicks, I&#8217;ll show you one more way to blink the LED:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_26_at_110344.png" alt="Screen Shot 2010 08 26 at 11.03.44" /></p>

<p>This uses a relatively little-known feature of the hardware, which actually has &#8220;bit flipping&#8221; built-in. The &#8220;PIND&#8221; register is normally used for input, i.e. for reading the state of a pin as an input signal. But you can also write to that register. When you do, it will be used to <em>flip</em> output pins, <em>but only for the bits which were set to 1</em>. It&#8217;s essentially a built-in XOR.</p>

<p>That last example uses 550 bytes of code, most of which is overhead from the Arduino run-time library (setting up the milliseconds timer, etc). So what&#8217;s in a measly 4 bytes, right? Wrong. There is a minute, but sometimes important difference: the other approaches all had to read the register value first, flip the bit, and then write the value back. This last version only writes a (constant) value to a register. With interrupts, that can be <em>very</em> important: this last version can&#8217;t ever go wrong, it will always flip the requested bit. The other version <em>could</em> have an interrupt occur between the read and the write. It&#8217;s a <a href="http://code.google.com/p/arduino/issues/detail?id=146">known issue</a> for the Arduino Mega. It can lead to code which runs for a week, and then fails mysteriously. Bugs like these are fiendishly hard to properly diagnose.</p>

<p>Bit-flipping can be quite useful for physical computing. Not only does it let you easily toggle specific bits, and change the state of some output pins, it can also be a way to <em>clear</em> a bit. Let&#8217;s say you need to generate a (very) quick pulse. Here are four ways to accomplish the same thing:</p>

<pre><code>    bitSet(PORTD, 4); bitClear(PORTD, 4);
    PORTD |= bit(4); PORTD ^= bit(4);
    PORTD |= bit(4); PIND = bit(4);
    PIND = bit(4); PIND = bit(4);
</code></pre>

<p>That second one based on XOR works, because bit 4 is <em>known</em> to be one, so setting it to zero is always the same as flipping it. That&#8217;s also why the third PORTD/PIND example works, with PIND doing the XOR in hardware. Lastly, the fourth approach will only work if bit 4 was initially zero. It&#8217;s the fastest one, and does not suffer from the interrupt race condition mentioned above.</p>

<p><em>Ok, that&#8217;s enough flippin&#8217; for one day!</em></p>

<p>Tomorrow, I&#8217;m going to go into, ehm&#8230; &#8220;fractional bits&#8221; (haha!) ;)</p>

<p><strong>Update</strong> &#8211; see comment below on why &#8220;bitSet(PORTD, 4); bitClear(PORTD, 4);&#8221; are also interrupt-safe (mostly &#8211; but not on <em>every</em> pin of an Arduino Mega!).</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/27/flippin%e2%80%99-bits/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bit manipulation</title>
		<link>http://news.jeelabs.org/2010/08/26/bit-manipulation/</link>
		<comments>http://news.jeelabs.org/2010/08/26/bit-manipulation/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 22:01:13 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[AVR]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9096</guid>
		<description><![CDATA[Today I&#8217;d like to go into bit manipulation, ehm, a bit&#8230; You need bit manipulation when you&#8217;re dealing with the individual bits in a byte, such as on the I/O ports of an ATmega, for example. First the easy approach &#8211; use these predefined macros from the Arduino library: bit(N) returns an integer with the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;d like to go into bit manipulation, ehm, <em>a bit</em>&#8230;</p>

<p>You need bit manipulation when you&#8217;re dealing with the individual bits in a byte, such as on the I/O ports of an ATmega, for example.</p>

<p>First the <em>easy</em> approach &#8211; use these predefined macros from the <a href="http://arduino.cc/en/Reference/Bit">Arduino library</a>:</p>

<ul>
<li><strong>bit(N)</strong> returns an integer with the N&#8217;th bit set to 1</li>
<li><strong>bitRead(X,N)</strong> &#8211; returns the N-th bit of X as 0 or 1</li>
<li><strong>bitWrite(X,N,B)</strong> &#8211; sets Nth bit of X to B (0 or 1)</li>
<li><strong>bitSet(X,N)</strong> &#8211; sets the Nth bit of X to 1</li>
<li><strong>bitClear(X,N)</strong> &#8211; sets the Nth bit of X to 0</li>
</ul>

<p>This is why you might see code such as the following:</p>

<pre><code>    bitSet(WDTCSR, WDIE);
</code></pre>

<p>This means: &#8220;set the Watchdog Interrupt Enable to 1 in the Watchdog Timer Control Register&#8221;. The WDTCSR and WDIE terms are predefined constants. WDIE is 6, for example.</p>

<p>Note that some of these routines can be written in terms of the others, i.e.</p>

<ul>
<li>bitSet(X,N) <em>is the same as</em> bitWrite(X,N,1)</li>
<li>bitClear(X,N) <em>is the same as</em> bitWrite(X,N,0)</li>
</ul>

<p><em>But what does it all mean?</em></p>

<p>Well, let&#8217;s dive in. First make sure that you are comfortable with &#8220;bit shifting&#8221;. The expression &#8220;bit(3)&#8221; is the same as &#8220;1 &lt;&lt; 3&#8243;, which in turn is the same as doubling the value 1 three times, i.e. the value <em>eight</em>. So &#8220;bit(0)&#8221; is 1 doubled zero times (i.e. 1) and &#8220;bit(7)&#8221; is 1 doubled 7 times, i.e. 128. Bytes have 8 bits numbered 0 to 7, so all you need for (byte-sized) hardware registers is to remember that bits 0..7 map to (specific!) integers with values 1 to 128.</p>

<p>Setting a bit, is like <em>OR-ing</em> the bit with the rest of the value. The following statements are all identical:</p>

<pre><code>    WDTCSR = WDTCSR | bit(WDIE);
    WDTCSR = WDTCSR | (1 &lt;&lt; WDIE);
    WDTCSR = WDTCSR | (1 &lt;&lt; 6);
    WDTCSR = WDTCSR | 0b1000000;
    WDTCSR = WDTCSR | 0x40;
    WDTCSR = WDTCSR | 64;
</code></pre>

<p>This, in turn, can be abbreviated in C as:</p>

<pre><code>    WDTCSR |= bit(WDIE);
    WDTCSR |= (1 &lt;&lt; WDIE);
    WDTCSR |= (1 &lt;&lt; 6);
    etc...
</code></pre>

<p>Or you could write:</p>

<pre><code>    bitSet(WDTCSR, WDIE);
</code></pre>

<p>It&#8217;s all the same. So <em>OR-ing</em> is about <em>setting</em> bits (to 1).</p>

<p>Likewise, <em>AND-ing</em> is about <em>not clearing</em> bits (to 0). Whoa, that&#8217;s confusing. This expression returns a value which is what X was, but <em>only</em> for bit N:</p>

<pre><code>    X &amp; bit(N);
</code></pre>

<p>So this will change X to a value with all bits <em>except</em> bit N set to zero:</p>

<pre><code>    X = X &amp; bit(N);
</code></pre>

<p>To put it differently: X will lose its original bits, except bit N, which will be left alone. All the bits are set to zero, <em>except</em> bit N.</p>

<p>Usually, you want the opposite, setting <em>only</em> bit N to zero. That too is accomplished with <em>AND-ing</em>, but you have to flip all the 0&#8242;s to 1 and all the 1&#8242;s to 0 first. Hang in there, it&#8217;s a slightly longer story. This sets bit N to zero:</p>

<pre><code>    X = X &amp; ~ bit(N);
</code></pre>

<p>Let&#8217;s examine what&#8217;s going on here. First, &#8220;bit(N)&#8221; is a value with <em>only</em> the Nth bit set. Now, &#8220;~ bit(N)&#8221; is a value with all the bits flipped around (&#8220;~&#8221; is called the <em>complement</em> operator in C), so that&#8217;s a value with all <em>but</em> the Nth bit set. Everything is 1, but bit N is 0.</p>

<p>Now we can tackle the expression &#8220;X &amp; ~ bit(N)&#8221;. Since <em>AND-ing</em> is about &#8220;not clearing bits&#8221;, that means that the result of this expression is all the bits of X unchanged where &#8220;~ bit(N)&#8221; was one, which is almost everywhere. The only bit that differs is bit N &#8211; it is zero in &#8220;~ bit(N)&#8221;, therefore that particular bit will &#8220;not not clear &#8230;&#8221; (a double negation!): it <em>will</em> be cleared (to 0) in the result.</p>

<p>Finally, we replace X by that result. So X will change in precisely one bit: bit N. That bit will be cleared to zero, the rest is not affected. In short: we&#8217;ve cleared bit N.</p>

<p><em>Confused?</em></p>

<p>Well, that&#8217;s why the bit/bitSet/etc macro definitions were introduced. These expressions are all identical:</p>

<pre><code>    X = X &amp; ~ bit(N);
    X = X &amp; ~ (1 &lt;&lt; N);
    if (X &amp; bit(N)) X = X - bit(N);
    bitClear(X, N);
</code></pre>

<p>That last one is clearest by far, because it conveys the actual operation with a well-chosen name: clear bit N, leave the rest alone.</p>

<p><em>So why would anyone ever choose to use anything but the bit/bitRead/etc routines?</em></p>

<p>Many reasons. Habit, perhaps. Coming from another environment which doesn&#8217;t have these macros. Being so used to this bit-manipulation that the use of words doesn&#8217;t really look any clearer. Whatever&#8230;</p>

<p>But another more important reason is that you can&#8217;t do everything with these bit/bitSet/bitClear routines. Sometimes you just have to go to the raw code. Such as when you need to set multiple bits at once, or flip bits. That&#8217;s why the ATmega datasheet has examples like these:</p>

<pre><code>    WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);
</code></pre>

<p>By now, you should be able to decode such a statement. It&#8217;s the same as:</p>

<pre><code>    WDTCSR |= bit(WDCE) | bit(WDE);
</code></pre>

<p>In other words:</p>

<pre><code>    WDTCSR = WDTCSR | bit(WDCE) | bit(WDE);
</code></pre>

<p>Which in turn is <em>almost</em> the same as these two statements together:</p>

<pre><code>    WDTCSR |= bit(WDCE);
    WDTCSR |= bit(WDE);
</code></pre>

<p>That in turn, can be written as these two lines:</p>

<pre><code>    bitSet(WDTCSR, WDCE);
    bitSet(WDTCSR, WDE);
</code></pre>

<p>Much clearer, right? Except&#8230; <em>it&#8217;s not 100% identical!</em></p>

<p>The problem is a hardware issue: timing. The above two statements will set both bits, but <em>not at the same time!</em> For hardware register settings, that difference can be important. There is a fraction of a microsecond between the WDCE bit being set and the WDE bit being set. Unfortunately, in some cases that causes real problems &#8211; your code won&#8217;t work as expected.</p>

<p>Tomorrow, I&#8217;ll continue on this topic, but it&#8217;ll be a bit more fun, because there will be <em>LEDs</em> involved!</p>

<p><img src="http://files.jeelabs.org/2010/08/dsc_1385_2.jpg" alt="Dsc 1385 2" /></p>

<p><em>(Please ignore the cable on the left, I snatched the above picture from <a href="http://news.jeelabs.org/2010/05/06/low-level-development/">this post</a>)</em></p>

<p><strong>Update</strong> &#8211; see this excellent <a href="http://en.wikipedia.org/wiki/Bitwise_operation">Wikipedia article</a> for more details about bitwise operations.</p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/26/bit-manipulation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sideways?</title>
		<link>http://news.jeelabs.org/2010/08/25/sideways/</link>
		<comments>http://news.jeelabs.org/2010/08/25/sideways/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 22:01:22 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[JeeNode]]></category>
		<category><![CDATA[JeePlug]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9092</guid>
		<description><![CDATA[I&#8217;m always looking for new ways to fit stuff together. JeeStuff ain&#8217;t no Lego, but that sure won&#8217;t stop me from trying to make it as modular as possible&#8230; Here&#8217;s an idea: I just used a pair of Proto Boards and inserted a bunch of plugs into them. Just to see what it would lead [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always looking for new ways to fit stuff together. <em>JeeStuff ain&#8217;t no Lego, but that sure won&#8217;t stop me from trying to make it as modular as possible&#8230;</em></p>

<p>Here&#8217;s an idea:</p>

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

<p>I just used a pair of <a href="http://cafe.jeelabs.net/hw/proto_board/">Proto Boards</a> and inserted a bunch of plugs into them. Just to see what it would lead to, not as &#8220;the&#8221; actual design.</p>

<p>Would probably have to invent another type of &#8220;backplane&#8221; for this approach, but what surprised me was how sturdy the resulting object was.</p>

<p>Would probably need to have 15 to 25 possible slots to place headers in (perhaps even allow soldering the plugs in for good?). And some way to select which AIO and DIO pins go to which port. With I2C, they could be connected in parallel, with dedicated plugs you&#8217;d have to reserve a port for them of course.</p>

<p>The reason this could work is that everything in the JeeFamily has the same 21.1 mm width. That was quite deliberate, although I didn&#8217;t have this particular path in mind at the time.</p>

<p>Hmm&#8230; mounting? Power options? Ethernet? Breadboard area?</p>

<p><em>Just doodling&#8230; ideas are cheap &#8211; and plentiful, here at Jee Labs!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://news.jeelabs.org/2010/08/25/sideways/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.856 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-03 00:47:31 -->
