<?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>bbum&#039;s weblog-o-mat &#187; Micro-controllers</title>
	<atom:link href="http://www.friday.com/bbum/category/micro-controllers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.friday.com/bbum</link>
	<description>...so google can index my head.</description>
	<lastBuildDate>Sat, 04 Feb 2012 06:32:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Great Internet Migratory Box of Electronic Junk [TGIMBOEJ]</title>
		<link>http://www.friday.com/bbum/2008/05/23/the-great-internet-migratory-box-of-electronic-junk-tgimboej/</link>
		<comments>http://www.friday.com/bbum/2008/05/23/the-great-internet-migratory-box-of-electronic-junk-tgimboej/#comments</comments>
		<pubDate>Fri, 23 May 2008 08:19:22 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/?p=1035</guid>
		<description><![CDATA[Over the weekend, I received one (1) box of electronic junk. Not just any box of electronic junk (as I have many of those, as it is), but one Great Internet Migratory Box of Electronic Junk. As per the TGIMBOEJ rules, I took some junk treasures and replaced it with a bunch of my own [...]]]></description>
			<content:encoded><![CDATA[<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2515919312" title="View 'Red 7 Segment Displays' on Flickr.com"><img src="http://farm4.static.flickr.com/3244/2515919312_d1014ab2d8.jpg" alt="Red 7 Segment Displays" border="0" width="500" height="333" /></a></div>
<p>Over the weekend, I received one (1) box of electronic junk.  Not just <em>any</em> box of electronic junk (as I have many of those, as it is), but one <a href="http://www.evilmadscientist.com/article.php/junkbox">Great Internet Migratory Box of Electronic Junk</a>.</p>
<p>As per the TGIMBOEJ rules, I took some <s>junk</s> treasures and replaced it with a bunch of my own <s>junk</s> stuff.</p>
<p>And, as per the rules, I took a handful of photos of <em>some</em> of the stuff I pulled out.   Not all.</p>
<p>I did <em>not</em> take photos of the stuff I put in.  That is for the next person on the list to discover fully.   Some vague clues, though:  I added some antique semiconductors, some power management related componentry, some completely random small bits of goodness, a working caseless gigabit switch, and a purely mechanical device that is gloriously elegant in its implementation.  And some other stuff, too.</p>
<p>More TGIMBOEJ pr0n on the click through&#8230;.<br />
<br clear="left"/></p>
<p><span id="more-1035"></span></p>
<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2515918810" title="View 'Golden Towers' on Flickr.com"><img src="http://farm4.static.flickr.com/3177/2515918810_be08126857.jpg" alt="Golden Towers" border="0" width="500" height="333" /></a></div>
<p> I have no need &#8212; have many already &#8212; of the parts pictured at right.  But I don&#8217;t have them in such an elegant construct.</p>
<p>Thus, I took this vague photo and put the assembly back.  It is quite solidly built and, better yet, the individual components are quite easily removed, should one desire.<br />
<br clear="right"/></p>
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2515094387" title="View 'Switching Jack' on Flickr.com"><img src="http://farm4.static.flickr.com/3145/2515094387_b6e1acdda6.jpg" alt="Switching Jack" border="0" width="500" height="333" /></a></div>
<p> This is a quarter-inch jack that was likely designed to be used on a mid-70s receiver.</p>
<p>Note the gracefully curved arms with the little plastic nubs at the end.</p>
<p>When you plug a 1/4&#8243; jack into said device, it not only connects the signal lines to the jack but it also actively <em>disconnects</em> the signals from other pins on the jack!</p>
<p>Simple and elegant design.  Beyond elegant, it is just terribly pleasant to  look at.  I don&#8217;t believe I could ever install such a thing behind a panel.</p>
<p>I should snap another picture with a jack inserted, to see the change.<br />
<br clear="left"/></p>
<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2515920150" title="View 'Hex Switch' on Flickr.com"><img src="http://farm4.static.flickr.com/3206/2515920150_4c678e720b.jpg" alt="Hex Switch" border="0" width="500" height="333" /></a><br /><a href="http://www.flickr.com/photos/49503114554@N01/2515095151" title="View 'Self Documenting Electronics' on Flickr.com"><img src="http://farm4.static.flickr.com/3010/2515095151_cd0e0c8dec.jpg" alt="Self Documenting Electronics" border="0" width="500" height="333" /></a></div>
<p> This is the real treasure that I claimed, though.</p>
<p>It is a 32 bit hexadecimal entry switch assembly.   Beyond that, it is obviously completely modular.  Take those screws out along the top and bottom and the whole thing could be reconfigured.</p>
<p>It has an extremely <em>solid</em> feel.  You <em>know</em> when you have changed a switch&#8217;s value by the solid <strong>thunk</strong> it makes as it lands in a new position.</p>
<p>This is one seriously well made bit of equipment.</p>
<p>Well made right down to the fact that it is self documenting!</p>
<p>Lifting one of the edge connectors slightly off the boards at the back of the assembly reveals numeric labels.</p>
<p>The <strong>C</strong> is the common connection.   The 1,2,4,8 are &#8212; obviously &#8212; individual bits that are turned on/off depending on the value of the rotary switch.</p>
<p>Now, seems a little odd that each switch would have <em>two</em> wires for <em>one</em> bit value.  Not so fast&#8211; the numbers on the right have little lines over them to indicate that the value on the right will be <em>the inverse</em> of the values on the left.</p>
<p>Awesome.<br />
<br clear="right"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/05/23/the-great-internet-migratory-box-of-electronic-junk-tgimboej/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using a Vertical Stack Counter to Debounce Switches</title>
		<link>http://www.friday.com/bbum/2008/04/05/using-a-vertical-stack-counter-to-debounce-switches/</link>
		<comments>http://www.friday.com/bbum/2008/04/05/using-a-vertical-stack-counter-to-debounce-switches/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 06:41:48 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/?p=1019</guid>
		<description><![CDATA[At left is a simple EMSL AtmegaXX8 Target Board (same board I have written about before) 3 bit up/down counter circuit. Push the left button? Counts down. Push the right button? Counts up. Simple. Sort of. The switches are fully debounced using an extremely elegant algorithm that I ran across while trying to figure out [...]]]></description>
			<content:encoded><![CDATA[<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2387144408" title="View '3 bit counter' on Flickr.com"><img src="http://farm4.static.flickr.com/3043/2387144408_5408552f1c.jpg" alt="3 bit counter" border="0" width="282" height="500" /></a></div>
<p>At left is a simple <a href="http://www.evilmadscientist.com/article.php/card">EMSL AtmegaXX8 Target Board</a> (same board I have <a href="http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/">written about before</a>) 3 bit up/down counter circuit.</p>
<p>Push the left button? Counts down.  Push the right button? Counts up.</p>
<p>Simple.</p>
<p>Sort of.</p>
<p>The switches are fully debounced using an extremely elegant algorithm that I ran across while trying to figure out how to efficiently debounce switches with an AVR controller.</p>
<p>Specifically, the software uses a <em><a href="http://everything2.com/e2node/vertical%2520counter">vertical stack count</a></em> to efficiently debounce up to 8 switches in very few instructions and only 3 bytes of memory.</p>
<p>Read on for schematic and a description of the software&#8230;<br />
<br clear="left"/></p>
<p><span id="more-1019"></span></p>
<div class="imgLeft"><img src="http://www.friday.com/bbum/wp-content/uploads/2008/04/3led2switch.png" alt="3LED2Switch.png" border="0" width="547" height="463" /></div>
<p>The software for this circuit can be found in <a href="http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/two-led-button-mode-switch/two-led-button-mode-switch.c">my SVN repository</a>.   I added a third LED, but didn&#8217;t change the name of the source file.  Oh well.</p>
<p>The circuit is terribly simple;   two switches connected to ground and three LEDs each connected through a 1K resistor to VCC.</p>
<p>That is it;  8 discrete components.</p>
<p>Aside:  I have never used EAGLE, a schematic and board layout package, before.   It is awesomely powerful but woefully sucky at the same time.   The user experience is just abysmal.  Not terribly surprising as it is X11.   There is both <a href="http://www.cadsoft.de/">a commercial and a freeware version available</a>.</p>
<p>But, at least, there is a downloadable binary.  The alternative standard appears to be <a href="http://www.geda.seul.org/">gEDA</a>, for which there are no prebuilt binaries available.  There is a <a href="http://www.finkproject.org/">Fink</a> package available, but it takes a good 5 hours to build or so on a MacBook Pro.</p>
<p>But I digress.<br />
<br clear="left"/></p>
<p>Diving into the <a href="http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/two-led-button-mode-switch/two-led-button-mode-switch.c">software that goes with this particular schematic</a>, I&#8217;m going to discuss it in order of initialization, main loop, and event handling.</p>
<hr />
<p><em><strong>The initialization</strong></em> &#8212; the prelude of main() &#8212; looks like this:</p>
<pre>
int main(void) {
    DDRB = 0xFF; // Make all PB* -- PORT B -- pins output.
    PORTB = 0xFF; // turn all PB* -- PORT B -- pins off.
</pre>
<p>This turns all 8 bits of PORTB, pins PB0 through PB7, into output pins.   Only PB0, PB1, and PB2 are used, but there is no harm in setting them all.</p>
<p>It also sets all pins to be outputting a logic 1;  to be pulled high.  Since the LEDs are connected to VCC through resistors, this effectively turns all of the LEDs off.   A bit misleading, but &#8212; <a href="http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/#comment-185864">as a comment on a previous article indicates</a> &#8212; the Atmel chips can handle more current through an output pin when acting as ground (sink) then when acting as VCC (source).</p>
<pre>
    bit_clear_8(DDRC, BIT(PC0) | BIT(PC1)); // PC0, PC1 is an input
    bit_set_8(PORTC, BIT(PC0) | BIT(PC1)); // Turn on pull-up resistor on PC0, PC1
</pre>
<p>This configures the pins <code>PC0</code> and <code>PC1</code> to be input pins.  It also turns on the internal pull-up resistor on said pins.  Without that second line of code, you would need to add pull-up resistors externally to the chip.</p>
<p>If you forget that line of code (I forget to turn on the pull-up for PC1 when I added a second switch) and don&#8217;t have an external pull-up resistor, it is very likely that the input pin will quite happily float between on and off quite rapidly as you wave your hand over the circuit.  Makes for a good random number generator, but isn&#8217;t very useful for any kind of a push-a-button,make-something-happen circuit.</p>
<pre>
    bit_set_8(TCCR0B, BIT(CS01));
    bit_set_8(TIMSK0, BIT(TOIE0));
</pre>
<p>This block of code configures one of the chip&#8217;s timer&#8217;s into a mode where it counts from 0 (default) to 255 and, upon rolling over to 0, sends an overflow interrupt signal.</p>
<p>Setting bit <code>TOIE0</code> of <code>TIMSK0</code> turns on the overflow interrupt whenever Counter0 overflows.  Counter0 simply counts up 1 unit per clock cycle, unless configured otherwise.</p>
<p>Setting bit <code>CS01</code> of <code>TCCR0B</code> configures the timer to only increment once per every 8 clock cycles.</p>
<p>Since the clock is running at 1mhz, every 8 clock cycles times 256 counts between interrupts yields one interrupt every 2 milliseconds or so (unless my math is whack).</p>
<p>I use this once-every-2-milliseconds signal to sample the inputs and debounce using the vertical stack counter.</p>
<pre>
    sei(); // turn on interrupts
</pre>
<p>Finally, the sei() call simply enables interrupts.  That is, it effectively causes the configured set of interrupts (and other stuff) to become active and start doing their thing.</p>
<p>This instruction is equivalent to setting the <code>I</code> bit of the AVR status register (<code>SREG</code>).</p>
<hr />
<p>The &#8220;main loop&#8221; is rather straightforward.</p>
<pre>
volatile unsigned char ledState = 0;
....
int main(void) {
	// ... initialization code (see above) ....
    while (1) {
        PORTB = ~ledState;
    }
}
</pre>
<p>It simply updates the output pins on <code>PORTB</code> to be the currently desired LED state.</p>
<p>Or, since the LEDs turn ON when their corresponding pin is OFF, it simply writes the inverse of the current state of the LEDs to <code>PORTB</code>.    This allows the internal program logic to be that bit much more straightforward.</p>
<p>Obviously, the real program functionality is squirreled away in the logic that maintains the <code>ledState</code>.</p>
<hr />
<p>Now that everything is configured to rely upon an overflow interrupt to do the actual work of tracking user input and translating that to state changes, exactly how is that done?</p>
<pre>
ISR(TIMER0_OVF_vect) {
</pre>
<p>First, declare a handler for the TIMER0 overflow signal.</p>
<pre>
    unsigned char sample = PINC;
    unsigned char changes = debounceB(sample);
</pre>
<p>Then, read the current state of the PINC inputs.   In this case, I&#8217;m reading all 8 bits even though only 2 pins are configured as inputs.   The other 6 will be effectively ignored.</p>
<p>The <code>debounceB</code> function contains the vertical stack counter based debouncing logic.  We&#8217;ll get to that next.</p>
<p>changes will contain the bits of <code>PINC</code> that have remained stable over the last 4 samples.  Thus, the bits that are set in changes are the bits that have either been set or cleared for all 4 of the last passes through this function;  they are debounced.</p>
<pre>
    if (bit_read_8(changes, BIT(PC0)) &#038;&#038;
        (!bit_read_8(sample, BIT(PC0)))) {
        ledState ++;
        ledState = ledState % 8;
    }
    if (bit_read_8(changes, BIT(PC1)) &#038;&#038;
        (!bit_read_8(sample, BIT(PC1)))) {
        ledState --;
        ledState = ledState % 8;
    }
</pre>
<p>These two bits of logic simply test to see if either the switch on pin PC0 or PC1 are pushed (and debounced).</p>
<p>Since the pins are configured to use pull-up resistors and the switches are connected to GND, pushing the switch yields a logical zero on the corresponding pin.</p>
<p>The test in <code>changes</code> determines if the bit is stable and the test in <code>sample</code> determines the state of the switch; on or off.</p>
<pre>
}
</pre>
<p>And that is it.</p>
<hr />
<p>Almost.  The real work is done in the routine that does the debouncing itself.</p>
<p>A vertical stack counter works by effectively &#8220;stacking&#8221; the bits in multiple bytes.   In this case, there are two bytes.  One byte contains all of the least-significant-bits and the other byte contains all of the most-significant-bits.</p>
<p>End result?  2 bytes represent 8 2 bit counters.</p>
<p>In this case, I&#8217;m only using 2 of the 2 bit counters.   This leaves me considerable room to expand and the bitwise math is quite efficient.</p>
<pre>
static unsigned char debounceB0,debounceB1,debouncedBState;
</pre>
<p>The debouncing routine requires three bytes of persistent state;  the vertical counters live in <code>debounceB0</code> and <code>debounceB1</code>.   The previous state is held in <code>debouncedBState</code>.</p>
<pre>
unsigned debounceB(unsigned char sample)
{
    unsigned char delta, changes;

    // Set delta to changes from last sample
    delta = sample ^ debouncedBState;
</pre>
<p>This sets <code>delta</code> to be the difference between the previous state (<code>debouncedBState</code>) and the latest <code>sample</code>.   Any bits that have changed will be set in <code>delta</code>.</p>
<pre>
    // Increment counters
    debounceB1 = debounceB1 ^ debounceB0;
    debounceB0  = ~debounceB0;
</pre>
<p>This tricksy bit of bitwise math simply increments all of the vertical counters.   If they overflow, they wrap back to 0.</p>
<pre>
    // reset any unchanged bits
    debounceB0 &#038;= delta;
    debounceB1 &#038;= delta;
</pre>
<p>Any counters associated with bits that didn&#8217;t change between the last sample and this sample are reset.</p>
<pre>
    // update state &#038; calculate returned change set
    changes = ~(~delta | debounceB0 | debounceB1);
    debouncedBState ^= changes;
    return changes;
}
</pre>
<p>This sets <code>changes</code> to be the set of bits for which no change was detected and for which the counter has rolled back around to zero.   If either the bit has changed in this pass (thus causing the counter to reset to 0) or the counter has yet to overflow, the state will still be considered to be volatile and, thus, the corresponding bit in <code>changes</code> will be zero.</p>
<p>It is a terribly elegant little routine.  I found allusions to it in a couple of different AVR forums and finally found a <a href="http://everything2.com/e2node/vertical%2520counter">description of the vertical counter portion of the algorithm here.</a>   From there, it was a matter of figuring out how to use changing bits in the sample to appropriately reset the counters.</p>
<p>Here is another <a href="http://www.dattalo.com/technical/software/pic/debounce.html">explanation and a bit of pseudo code</a>.  I found it helpful in vetting my implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/04/05/using-a-vertical-stack-counter-to-debounce-switches/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Multitasking in the AVR Microcontroller</title>
		<link>http://www.friday.com/bbum/2008/03/16/multitasking-in-the-avr-microcontroller/</link>
		<comments>http://www.friday.com/bbum/2008/03/16/multitasking-in-the-avr-microcontroller/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 07:01:27 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/16/multitasking-in-the-avr-microcontroller/</guid>
		<description><![CDATA[Well, multitasking would be stretching it&#8230; When writing AVR micro-controller code, you typically end up with something like this: int main(void) { ... initialization code ... while(1) { ... main loop that never exists here ... } } The main loop spins forever and is generally the bit of code that updates various output ports [...]]]></description>
			<content:encoded><![CDATA[<p>Well, <em>multitasking</em> would be stretching it&#8230;</p>
<p>When writing AVR micro-controller code, you typically end up with something like this:</p>
<pre>
int main(void) {
	... initialization code ...
	while(1) {
		... main loop that never exists here ...
	}
}
</pre>
<p>The main loop spins forever and is generally the bit of code that updates various output ports based on program state.  It might likely also read inputs, too.   And it might contain bits of code that delays execution for a while.  And it is very likely rife with conditionals that&#8217;ll cause any given pass through the loop to very in execution time.</p>
<p>Not a very good place to do time sensitive stuff like, say, debouncing a button press or responding to other user events.</p>
<p><span id="more-1013"></span></p>
<p>Really, it is far more effective to separate input processing entirely from the execution of the main loop.   Input processing can update a global once the input has been fully validated and the main event loop can then process the event and reset the global.</p>
<p>Fortunately, the AVR has an exceedingly flexible interrupt system that can allow a chunk of code to effectively be executed &#8220;out of band&#8221; from the main loop.</p>
<p>Specifically, you can configure the chip to process an interrupt when an input pin changes state or based on a timer.   Timers can be configured to count up over time and then send an overflow interrupt when the counter overflows either an 8 bit or 16 bit value.   Furthermore, the timer can be prescaled such that it increments only every 8, 64, 256, or 1024 clock cycles, effectively causing the interrupt to be fired every 8x or 16x the prescaled values number of clock cycles.</p>
<p>And that is just the internal mode.  The timer can also be incremented based on a clock signal provided on one of a couple of pins on the chip.</p>
<p>There are a boatload of other options and configurations available.</p>
<p>So, starting with the same circuit as described in the previous post (two LEDs), the following code uses a timer with maximum prescaler (so you can see the state change!) to cause the LEDs to act as a 2 bit counter.</p>
<pre>
#include &lt;avr/io.h>
#include &lt;avr/interrupt.h>
#include &lt;util/delay.h>

#define bit_set_8(var, mask)   ((var) |= (uint8_t)(mask))
#define bit_clear_8(var, mask)   ((var) &#038;= (uint8_t)~(mask))
#define bit_toggle_8(var, mask)   ((var) ^= (uint8_t)(mask))
#define bit_read_8(var, mask)   ((var) &#038; (uint8_t)(mask))

#define BIT(x)   (1 &lt;&lt; (x))

volatile unsigned char ledState = 0;

// timer 0 overflow interrupt handler
ISR(TIMER0_OVF_vect) {
    // cycle LED state
    ledState ++;
    ledState = ledState % 4;
}

int main(void) {
    DDRB = 0xFF; // Make all PB* -- PORT B -- pins output.
    PORTB = 0xFF; // turn all PB* -- PORT B -- pins off.

	// increment timer every 1024 clock cycles
    bit_set_8(TCCR0B, BIT(CS02) | BIT(CS00));
    bit_set_8(TIMSK0, BIT(TOIE0)); // turn on overflow interrupt for timer 0

    sei(); // turn on interrupts

    while (1) {
        PORTB = ledState;
    }
}
</pre>
<p>Note that the timer updates the ledState global completely independently of the while(){} loop in main().  That is, main() simply renders the user interface, as it were, while the interrupt updates the state.</p>
<p>And, thus, we have the foundation for dealing with a button press, debounce and all,  in isolation from rendering the UI (which will eventually be a flipper coil &#8212; a rather time sensitive operation that will require the main loop to be quite consistent in execution speed).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/16/multitasking-in-the-avr-microcontroller/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Blinking Two LEDs; Bit Manipulation Macros Oh My!</title>
		<link>http://www.friday.com/bbum/2008/03/15/blinking-two-leds-bit-manipulation-macros-oh-my/</link>
		<comments>http://www.friday.com/bbum/2008/03/15/blinking-two-leds-bit-manipulation-macros-oh-my/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 00:57:21 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Industrial Design]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/15/blinking-two-leds-bit-manipulation-macros-oh-my/</guid>
		<description><![CDATA[Before dealing with switches and debouncing switches, I wanted to add a second LED to the circuit. Trivial: #include &#60;avr/io.h> #include &#60;util/delay.h> int main(void) { DDRB = 255U; // Make all PB* -- PORT B -- pins output PORTB = 0x0; // turn all PB* -- PORT B -- pins off. while (1) { PORTB [...]]]></description>
			<content:encoded><![CDATA[<p>Before dealing with switches and debouncing switches, I wanted to add a second LED to the circuit.</p>
<p>Trivial:</p>
<pre>
#include &lt;avr/io.h>
#include &lt;util/delay.h>

int main(void) {
    DDRB = 255U; // Make all PB* -- PORT B -- pins output
    PORTB = 0x0; // turn all PB* -- PORT B -- pins off.

    while (1) {
        PORTB = 0x1; // B0 on, B1 off
        _delay_ms(200);
        PORTB |= 0x2; // B0 and B1 on
        _delay_ms(100);
        PORTB = 0x2; // B0 off, B1 on
        _delay_ms(200);
        PORTB = 0X0; // All off
        _delay_ms(2500); // 2.5 seconds off
    }
}
</pre>
<p>Each on/off port is represented by a single bit.  So, each of the pins in PORTA, PORTB, PORTC, or PORTD &#8212; assuming they are in straight digital input/output mode and whatever AVR chip you are targeting has enough pins to have 4 port sets &#8212; will be controlled by a single bit in one of four bytes.</p>
<p>Clearly, some macros to toggle bits are in order.  Now, it turns out that macros to toggle bits are a big source of contention amongst the AVR development community.   They hide too much magic, or so they say, and, if you are going to be programming embedded systems, you ought to be comfortable with C level bit twiddling, damnit.</p>
<p><span id="more-1012"></span></p>
<p>Seriously &#8212; I read about 25 messages on the subject of bit twiddling as a part of the AVR API.  The arrogance and close-mindedness was pretty silly.</p>
<p>Whatever.</p>
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2336447708" title="View 'Two LEDs a Blinkin'' on Flickr.com"><img src="http://farm3.static.flickr.com/2343/2336447708_3a72c7ebca.jpg" alt="Two LEDs a Blinkin'" border="0" width="316" height="500" /></a></div>
<p>Now that the bit twiddling is going to be hidden by macros, it is time to also modify the circuit to connect the LEDs through to VCC.  Thus, the circuit will be more inline with basically every tutorial and document found on the net.</p>
<p>I also moved to using 1K ohm resistors &#8212; less current draw on the chip and just as bright (meaning that I was driving them with way too much current before).</p>
<p>The code now looks like this:</p>
<pre>
#define LED_ON(port, nr) port &#038;= ~(1 &lt;&lt; (nr))
#define LED_OFF(port, nr) port |= (1 &lt;&lt; (nr))

int main(void) {
    DDRB = 255U; // Make all PB* -- PORT B -- pins output
    PORTB = 0xFF; // turn all PB* -- PORT B -- pins off.

    while (1) {
        LED_ON(PORTB, PB0);
        _delay_ms(200);
        LED_ON(PORTB, PB1);
        _delay_ms(100);
        LED_OFF(PORTB, PB0);
        _delay_ms(200);
        LED_OFF(PORTB, PB1);
        _delay_ms(2500); // 2.5 seconds off
    }
}
</pre>
<p>The LED_ON/LED_OFF macros take care of inverting the logic.</p>
<p>For additional bit manipulation operations, here are some useful macros <a href="http://osdir.com/ml/hardware.avr.libc.devel/2005/msg00255.html">culled from the discussion about a possible bit manipulation API that may or may not be added to the avr-gcc distribution someday</a>:</p>
<pre>
#define bit_set_8(var, mask)   ((var) |= (uint8_t)(mask))
#define bit_clear_8(var, mask)   ((var) &#038;= (uint8_t)~(mask))
#define bit_toggle_8(var, mask)   ((var) ^= (uint8_t)(mask))
#define bit_read_8(var, mask)   ((var) &#038; (uint8_t)(mask))

#define bit_set_16(var, mask)   ((var) |= (uint16_t)(mask))
#define bit_clear_16(var, mask)   ((var) &#038;= (uint16_t)~(mask))
#define bit_toggle_16(var, mask)   ((var) ^= (uint16_t)(mask))
#define bit_read_16(var, mask)   ((var) &#038; (uint16_t)(mask))

/* equivalent to the poorly named _BV */
#define BIT(x)   (1 &lt;&lt; (x))
</pre>
<p>The above enables expressions like:</p>
<pre>
bit_set(PORTD, BIT(0) | BIT(2) | BIT(4) | BIT(7));
bit_clear(PORTG, BIT(1) | BIT(6));
bit_toggle(PORTE, BIT(5) | BIT(3));
bit_read(PORTF, BIT(7));
</pre>
<p><br clear="left"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/15/blinking-two-leds-bit-manipulation-macros-oh-my/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Subversion repository for ATmegaXX8 target board hacks</title>
		<link>http://www.friday.com/bbum/2008/03/15/subversion-repository-for-atmegaxx8-target-board-hacks/</link>
		<comments>http://www.friday.com/bbum/2008/03/15/subversion-repository-for-atmegaxx8-target-board-hacks/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 19:19:06 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Micro-controllers]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/15/subversion-repository-for-atmegaxx8-target-board-hacks/</guid>
		<description><![CDATA[I have created a directory in my public subversion repository for EMSL ATmegaXX8 target board code. http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/]]></description>
			<content:encoded><![CDATA[<p>I have created a directory in my public subversion repository for <a href="http://www.evilmadscientist.com/article.php/card">EMSL ATmegaXX8 target board</a> code.</p>
<p><a href="http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/">http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/15/subversion-repository-for-atmegaxx8-target-board-hacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AVR: Programming the EMSL Target Board from Mac OS X</title>
		<link>http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/</link>
		<comments>http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 07:37:30 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Industrial Design]]></category>
		<category><![CDATA[Micro-controllers]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/</guid>
		<description><![CDATA[The EMSL Target Board is built around the ATmega 168 micro-controller (same controller as the Arduino &#8212; which, frankly, I couldn&#8217;t care less about other than as a source of knowledge&#8230;). It is an extremely easy to use and surprisingly powerful micro-controller. If it weren&#8217;t so convenient, I wouldn&#8217;t be writing this. Seriously. If you [...]]]></description>
			<content:encoded><![CDATA[<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2333767699" title="View 'EMSL Atmega168 Target Board' on Flickr.com"><img src="http://farm3.static.flickr.com/2285/2333767699_20d670d92a.jpg" alt="EMSL Atmega168 Target Board" border="0" width="374" height="500" /></a></div>
<p>The <a href="http://www.evilmadscientist.com/article.php/card">EMSL Target Board</a> is built around the <a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=3303">ATmega 168</a> micro-controller (same controller as the <a href="http://www.arduino.cc/">Arduino</a> &#8212; which, frankly, I couldn&#8217;t care less about other than as a source of knowledge&#8230;).</p>
<p>It is an extremely easy to use and surprisingly powerful micro-controller.  If it <a href="http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/">weren&#8217;t so convenient</a>, I wouldn&#8217;t be writing this.</p>
<p>Seriously.  If you have <em>any</em> interest in screwing around with micro-controllers, there is little excuse not to dive in now.  It is <a href="http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/">cheap, easy, and powerful</a>.</p>
<p>Beyond the <a href="http://www.evilmadscientist.com/article.php/card">EMSL Target Board</a>, you&#8217;ll also need a <a href="http://www.ladyada.net/make/usbtinyisp/index.html">Lady Ada USBTinyISP programmer</a> that has been <a href="http://forums.ladyada.net/viewtopic.php?t=5342">appropriately patched (when assembled)</a>.</p>
<p>First, <a href="http://www.obdev.at/products/avrmacpack/index-de.html">grab and install AVR Mac Pack</a> from the fine folks at <em>Objective Development</em> (same source of <a href="http://www.obdev.at/products/launchbar/index.html">LaunchBar</a> and <a href="http://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a> &#8212; both awesome products in their own right).</p>
<p>AVR Mac Pack has everything needed to talk to the AVR, a compiler that can target the AVR, and support for Xcode based development.</p>
<p><br clear="right"/></p>
<p><span id="more-1010"></span></p>
<p>Once installed, the next step is to verify that the programmer can talk to the board using <a href="http://www.bsdhome.com/avrdude/">avrdude</a> (all commands assume that $PATH has been updated to include the AVR Mac Pack stuff &#8212; be forewarned that the installation of AVR Mac Pack will edit some files in /etc/ to change the shell.  It doesn&#8217;t work if you are using tcsh):</p>
<pre>
avrdude -p m168 -c usbtiny -P usb

avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.
</pre>
<p>Uh oh!  That ain&#8217;t good!   Oh, that happened because I hadn&#8217;t flipped on the &#8220;power the target board&#8221; switch on my programmer.  With the stock USBTinyISP, it&#8217;ll be a jumper.  Replace it with a switch.   You&#8217;ll be happier.</p>
<p>Anyway, once on:</p>
<pre>
avrdude -p m168 -c usbtiny -P usb

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK
</pre>
<p>Woot!</p>
<p>You could use AVR Mac Pack&#8217;s <em>avr-project</em> command to create an Xcode project, but it produces an Xcode project that can&#8217;t install the built executable from within Xcode.   I find it easier to start with the <a href="http://svn.red-bean.com/bbum/trunk/avr/peggybum/makefile">Peggy Makefile</a>.   Xcode&#8217;s Organizer can be trivially configured such that cmd-b will cause the makefile to build and install the desired chunk of code.</p>
<p>Firs,t you&#8217;ll need to edit the opening bits of the maekfile to successfully target the m168 part (this assumes that your source file </p>
<pre>
PRG            = buttflip
OBJ            = buttflip.o
PROGRAMMER     = usbtiny
PORT		   = usb
MCU_TARGET     = atmega168
AVRDUDE_TARGET = m168
OPTIMIZE       = -Os
DEFS           =
LIBS           =
</pre>
<p>Now, the makefile claims no need to edit below that particular header.   It lies.   There are these evil things called &#8220;fuses&#8221; in AVR micr-controllers that you have to deal with exceedingly carefully.   Seriously.  Wrong value can lead to a nice bit of inert plastic encased silicon.</p>
<p>Actually, you really want to change the makefile preamble to also include a CPU speed indicator (which is set via the ungodly confusing fuse values mentioned below):</p>
<pre>
AVRDUDE_TARGET = m168
OPTIMIZE       = -Os
DEFS           =
LIBS           =

HZ          = 1000000
</pre>
<p>And, slightly below that, change the definition of CFLAGS to this:</p>
<pre>
override CFLAGS = -g -DF_CPU=$(HZ) -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
</pre>
<p>You&#8217;ll see why in a second.</p>
<p>Ben pointed me to the <a href="http://palmavr.sourceforge.net/cgi-bin/fc.cgi">AVR Fuse Calculator</a>.  God send.   For now, I&#8217;m sticking with the default fuse values because I&#8217;m too lazy to go read the spec sheet closely enough to figure out what the more optimal settings might be:</p>
<pre>
install:  $(PRG).hex
	avrdude -p $(AVRDUDE_TARGET) -c $(PROGRAMMER) -P $(PORT) -v  \
	 -U lfuse:w:0x62:m \
	 -U hfuse:w:0xDF:m \
	 -U efuse:w:0x01:m \
     -U flash:w:$(PRG).hex
</pre>
<p><em>I totally don&#8217;t understand the fuse values.  The default fuse calculator came up with a different value for <strong>efuse</strong>.  avrdude complained.  I set it to 0&#215;01 because that was the value avrdude indicated was expected.  It works.  I have no clue why.</em></p>
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2334733044" title="View 'Blinky' on Flickr.com"><img src="http://farm4.static.flickr.com/3113/2334733044_90728ec918.jpg" alt="Blinky" border="0" width="500" height="383" /></a></div>
<p>OK&#8230; great&#8230; now&#8230; need some kind of <em>Hello, World!</em> for a micro-controller.  Sounds like it is time to Blink an LED or something.</p>
<p>Of course, you&#8217;ll need an LED.  I used a random red LED because they are the cheapest and most commonly available.  Thus, if I melted the LED, no real pain incurred.</p>
<p>You&#8217;ll also need a resistor to drop the voltage a bit for the LED.   I used a 120 ohm resistor as that was handy &#8212; anything in the 120 to 220 ohm range should do fine.</p>
<p>LEDs have polarity.  That is, they only work one way.  The lead coming out of the flattened side of the LED is the negative lead (or, if you haven&#8217;t clipped them, the longer lead is the positive lead).</p>
<p>To make this code make the most sense, I wired up the LED such that it turns on when the output pin is turned on and turns off when off.  That is, the positive lead of the LED &#8212; the round side &#8212; is connected to the <strong>PB0</strong> pin of the ATmega168 chip.  The negative is connected to one lead of the resistor.  The other lead of the resistor is then connected to ground (GND) on the target board.</p>
<p><em>Aside:  Usually, the LED will be hooked from VCC [positive] to the chip through the resistor.  I&#8217;m not fully sure why, but it makes the code backwards&#8211; setting the bit turns off the LED, and vice-versa.  Confusing.  For this, I hooked it up the intuitive way.</em></p>
<p>The code is rather straightforward:</p>
<pre>
#include &lt;avr/io.h>
#include &lt;util/delay.h>

int main(void) {
    DDRB = 255U; // Make all PB* pins output

    while (1) {
        PORTB = 0x1; // high
        _delay_ms(250);  // 1/4 second on
        PORTB = 0X0; // low
        _delay_ms(2500); // 2.5 seconds off
    }
}
</pre>
<p>That is it!</p>
<p>Setting <strong>DDRB</strong> simply configures all PB# pins to be outputs.  Overkill for only one pin, assuredly.</p>
<p>Setting PORTB to 0&#215;1 simply turns on pin PB0 &#8212; takes pin PB0 high [5v].  If the LED were hooked to PB1, that would be 0&#215;2.  PB3? 0&#215;4.  PB4?  0&#215;8.  Etc&#8230; It is just basic bitwise I/O. </p>
<p>The calls to _delay_ms() entirely rely upon the setting of HZ in the makefile (which sets F_CPU).  The ATmega168 part has an internal oscillator running at 8 MHZ, but that is subdivided to yield a 1 MHZ CPU speed.</p>
<p>End result?</p>
<p>The LED should blink;  short tim on, longer time off.</p>
<p>Next up?</p>
<p>Two LEDs &#038; some useful tools for manipulating bits.  And the circuit will be refactored into a more standard form (LEDs connected to VCC).</p>
<p><em>The latest source code for this project is available in my personal subversion repository here:  <a href="http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/one-led-blinker/">http://svn.red-bean.com/bbum/trunk/avr/ATmegaXX8/one-led-blinker/</a>.</em><br />
<br clear="left"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/15/avr-programming-the-emsl-target-board-from-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>AVR: Prototype Board Ready for Prototyping Pinball Flippers</title>
		<link>http://www.friday.com/bbum/2008/03/14/avr-prototype-board-ready-for-prototyping-pinball-flippers/</link>
		<comments>http://www.friday.com/bbum/2008/03/14/avr-prototype-board-ready-for-prototyping-pinball-flippers/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 03:30:56 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Industrial Design]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/14/avr-prototype-board-ready-for-prototyping-pinball-flippers/</guid>
		<description><![CDATA[Ben picked up a ton of SIP machine pin sockets from Halted recently. I grabbed about 200 from him and populated my EMSL Atmega target board with enough to provide for both on-board prototyping and to easily break out to a bread, board when needed. Each point accepts a 24 gauge (or so) wire quite [...]]]></description>
			<content:encoded><![CDATA[<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2333594733" title="View 'EMSL Atmel Board Populated for Prototyping Madness' on Flickr.com"><img src="http://farm4.static.flickr.com/3256/2333594733_4d307a6649.jpg" alt="EMSL Atmel Board Populated for Prototyping Madness" border="0" width="294" height="500" /></a></div>
<p>Ben picked up a ton of SIP machine pin sockets from <a href="http://www.halted.com/">Halted</a> recently.</p>
<p>I grabbed about 200 from him and populated my EMSL Atmega target board with enough to provide for both on-board prototyping and to easily break out to a bread, board when needed.</p>
<p>Each point accepts a 24 gauge (or so) wire quite nicely.  Makes for easy prototyping while not obscuring the documentation silkscreen on the board.</p>
<p>Next up?</p>
<p>I have all the parts needed to replace an entire flipper circuit in <a href="http://www.pinrepair.com/wpc/">any modern Williams/Bally pinball machine</a>.</p>
<p>Thus, I should have enough parts to drive a solenoid or flash-lamp from the AVR micro-controller.</p>
<p>First, though, I&#8217;ll flash some LEDs in response to button presses, though.   All one voltage and relatively little chance of blowing up chips, bulbs, or shocking myself.</p>
<p>Once that works, I&#8217;ll wire up higher voltage / current drivers.  I figure I ought to be able to both replace the flipper drivers with a much more maintainable system while also adding some automatic diagnostics that will light some LEDs inside the pinball when the flippers need to be rebuilt or maintained.<br />
<br clear="left"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/14/avr-prototype-board-ready-for-prototyping-pinball-flippers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AVR Microcontroller Prototype Board</title>
		<link>http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/</link>
		<comments>http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 04:44:54 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Industrial Design]]></category>
		<category><![CDATA[Micro-controllers]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/</guid>
		<description><![CDATA[The folks at Evil Mad Scientist Laboratories whipped up an elegant little kit that includes an ATmega168 AVR Micro-controller, 4 or 5 discrete components, and a circuit board. The Atmel AVR micro-controllers are awesome. They cross three particular barriers to entry that I arbitrarily chose prior to screwing around with micro-controllers. Specifically: Price: $10 per [...]]]></description>
			<content:encoded><![CDATA[<div class="imgLeft"><a href="http://www.flickr.com/photos/oskay/2310115590/" title="XX8_complete by oskay, on Flickr"><img src="http://farm3.static.flickr.com/2261/2310115590_8ccd44b0fd.jpg" width="500" height="375" alt="XX8_complete" /></a>
</div>
<p>The folks at <a href="http://www.evilmadscientist.com/">Evil Mad Scientist Laboratories</a> whipped up an <a href="http://www.evilmadscientist.com/article.php/card">elegant little kit</a> that includes an ATmega168 AVR Micro-controller, 4 or 5 discrete components, and a circuit board.</p>
<p>The Atmel AVR micro-controllers are awesome.  They cross three particular barriers to entry that I arbitrarily chose prior to screwing around with micro-controllers.</p>
<p>Specifically:</p>
<ul>
<li><b>Price: $10 per useful part</b>  The Atmel series ranges from less than $1/part to a bit north of $10/part for the &uuml;ber-deluxe controllers.  The ATmega168 in this kit can be had for less than $5/each and includes 23 I/O lines (6 of which can be used for ADC), 16K of program memory, and can run up at speeds up to 20MHZ.</li>
<li><b>USB based Programmer less than $50</b>  <a href="http://www.adafruit.com/">LadyAda sells</a> a simple USB programmer (based on the Atmel chips &#8212; it implements a USB stack in software!) for $22.   It works great, once you <a href="http://www.ladyada.net/forums/viewtopic.php?t=5342">fix this particular bug (which involves replacing two resistors with wires;  not hard)</a>.</li>
<li><b>Easy &#038; Powerful Programmability (on a Mac)</b> Code for the Atmel series of chips is written in C and compiled quite easily via gcc.  The ObDev folks have made an <a href="http://www.obdev.at/products/avrmacpack/index.html">easy to install package available</a>.  It just works.  Better, the chips support in system programming (without sacrificing pins for I/O!) and, thus, &#8220;build and run&#8221; in Xcode re-loads the code on the target chip without having to either power down the board or remove the chip from the circuit.  Edit-compile-run is very very fast.
<p>The code, itself, is pretty straightforward.  The header files provide all the #defines needed to deal with all the random I/O based hardware functionality quite straightforward.   The chips, themselves, are exceptionally flexible, with the ability to reconfigure what pins do what in software.</p>
<p>The hardest part is remembering which pin maps to what random #define&#8217;d symbol.</p>
<div class="imgRight"><a href="http://www.flickr.com/photos/bbum/2230509295/" title="Mooninites &amp; Lemur by bbum, on Flickr"><img src="http://farm3.static.flickr.com/2351/2230509295_5b6fc9f5bd_m.jpg" width="240" height="131" alt="Mooninites &amp; Lemur" /></a></div>
<p>The Atmel chips are, in fact, the same chips (almost the same exact chip &#8212; the proto boards use a slightly less expensive part in that it doesn&#8217;t have quite as many I/O ports) used in the <a href="http://www.friday.com/bbum/2008/01/30/january-31st-2007-never-forget/">Peggy Board</a> (also from EMSL).  I picked up the ladyada programmer and grabbed the <a href="http://www.evilmadscientist.com/article.php/peggy">source from EMSL</a>.</p>
<p>I had simple animation up and running within a couple of hours, most of that time being consumed by dealing with the now fixed USBTiny programmer bug.  Not much longer after that and I had a pretty neat line based animation.</p>
<p>Jamie over at <a href="http://www.noiselandarcade.net/">Noise Land Arcade</a> else has grabbed the code and made a neat <a href="http://www.noiselandarcade.net/index.php/2008/03/08/its-aliveits-aliveits-alive/">animated pacman sign</a> (<a href="http://www.youtube.com/watch?v=VhYS56ku_i0">video here</a>).</p>
</li>
</ul>
<p>Which brings me to this kit:  This credit card sized board is designed quite specifically for prototyping ATmega168 (and several others) based projects.  Beyond including a bit of room for adding a couple of 8-pin DIPs (or other random components), the silk screen fully documents the various mnemonics associated with each pin.</p>
<p>First project?</p>
<p>I&#8217;m going to build modern style flipper replacement for &#8217;80s and early &#8217;90s Williams/Bally pinball machines.  The old school flippers require more maintenance and tend to fail gracelessly, taking out other discrete components upon failure.</p>
<p>This board is total overkill.  I really only need an 8 pin Atmel controller per flipper; maybe one chip for both flippers, if I optimize.</p>
<p>But at $9/each for the board, controller and discrete components (including shipping and CA tax) in lots of 10,  I might just stick with building it out on the EMSL prototype board.</p>
<p>As with many EMSL projects, everything is open source.  The board is single sided and easy to etch, but silk screening on the various documentation bits would be difficult.<br />
<br clear="left"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/03/09/avr-microcontroller-prototype-board/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Aqua Teen Day &#8212; January 31st, 2007: Never Forget.</title>
		<link>http://www.friday.com/bbum/2008/01/30/january-31st-2007-never-forget/</link>
		<comments>http://www.friday.com/bbum/2008/01/30/january-31st-2007-never-forget/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 18:24:50 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Government]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[Micro-controllers]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/01/30/january-31st-2007-never-forget/</guid>
		<description><![CDATA[Update: Evil Mad Scientists Laboratory has made the foundation of this build available as The Peggy for $80. In typical EMSL fashion, that link includes tons and tons of information, including full details, board design, source, and loads of implementation notes. So, apparently, it is being called Aqua Teen Day. Good enough. Better yet, though, [...]]]></description>
			<content:encoded><![CDATA[<p><b>Update:</b></p>
<p>Evil Mad Scientists Laboratory has made the foundation of this build available as <a href="http://www.evilmadscientist.com/article.php/peggy">The Peggy</a> for $80.</p>
<p>In typical EMSL fashion, that link includes tons and tons of information, including full details, board design, source, and loads of implementation notes.</p>
<hr />
<p>So, apparently, it is being called <em><a href="http://bostonist.com/2008/01/31/never_forget_fi.php">Aqua Teen Day</a></em>.   Good enough.</p>
<p>Better yet, though, is that the fine folks of boston &#8212; the level headed public that makes the city such a great place &#8212; are celebrating the first annual &#8220;Aqua Teen Day&#8221; <a href="http://blog.makezine.com/archive/2008/01/led_art_all_over_boston_t.html">by decorating the city with LED art</a>.</p>
<hr />
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2230509295" title="View 'Mooninites &amp; Lemur' on Flickr.com"><img src="http://farm3.static.flickr.com/2351/2230509295_5b6fc9f5bd.jpg" alt="Mooninites &amp; Lemur" border="0" width="500" height="274" /></a></div>
<p>On January 31st, 2007, the authorities in Boston completely lost their minds.   It wasn&#8217;t <a href="http://www.boingboing.net/2007/02/28/boston-police-blow-u.html">the first time</a>, but this particular date was heavily reported and even the most head-in-the-sand die-hard &#8220;OMGWTFBINLADENFTChildren!!!one!!!&#8221; fear mongers found it ridiculous.</p>
<p>I am, of course, referring to the <a href="http://en.wikipedia.org/wiki/2007_Boston_bomb_scare">Aqua Teen Hunger Force &#8220;Hoax Device&#8221; bomb scare.</a></p>
<p>I could go on a political rant about fear based leadership and the general stupidity of the security theater played out in our cities and airports.</p>
<p>But that is boring.<br />
<br clear="left"/></p>
<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2229764347" title="View 'Lemur in Blue' on Flickr.com"><img src="http://farm3.static.flickr.com/2006/2229764347_e263469315.jpg" alt="Lemur in Blue" border="0" width="333" height="500" /></a></div>
<p>I&#8217;d rather remind people of the jackassery that has happened and, once again, laugh at it.   Then vote appropriately.</p>
<p>To that end, I purchased memorial kits from the fine folks at  <a href="http://www.evilmadscientist.com/">Evil Mad Scientist Laboratories</a> and <a href="http://www.friday.com/bbum/2008/01/28/mmm-the-smell-of-hot-solder-in-the-evening/">put them together over the last few days</a>.</p>
<p>The results are just stunning.   And effective.  I brought the boards into work on Monday and, on the way home, stopped for a beer with boards in hand.   Several folks asked about them and, upon explaining the history of the boards, they became just a touch more enlightened as to the stupidity of certain leadership and just a slight bit more inclined to learn more and vote accordingly.<br />
<br clear="right"/></p>
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2230509695" title="View 'Mooninite' on Flickr.com"><img src="http://farm3.static.flickr.com/2154/2230509695_a88e67101e_m.jpg" alt="Mooninite" border="0" width="240" height="240" align="left" /></a><a href="http://www.flickr.com/photos/49503114554@N01/2230509523" title="View 'Mooninite' on Flickr.com"><img src="http://farm3.static.flickr.com/2291/2230509523_735c78c936_m.jpg" alt="Mooninite" border="0" width="240" height="240" align="left" /></a></div>
<p>Mission accomplished.   With laughter included.</p>
<p>(The kits were a <a href="http://www.evilmadscience.com/tinykitlist/35-tinykitcat/53-013107kit">special edition from EMSL</a> &#8212; you&#8217;ll have to contact them for availability.   The LED &#8220;peg board&#8221; is generic;  you can lay out the LEDs anyway you want to make any kind of similar display, including a &#8220;charlieplexed&#8221; mode that allows simple animations.  I believe EMSL will be offering the generic form of the kit sometime soon.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/01/30/january-31st-2007-never-forget/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>MMm&#8230;. the smell of hot solder in the evening.</title>
		<link>http://www.friday.com/bbum/2008/01/28/mmm-the-smell-of-hot-solder-in-the-evening/</link>
		<comments>http://www.friday.com/bbum/2008/01/28/mmm-the-smell-of-hot-solder-in-the-evening/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 08:48:18 +0000</pubDate>
		<dc:creator>bbum</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Micro-controllers]]></category>

		<guid isPermaLink="false">http://www.friday.com/bbum/2008/01/28/mmm-the-smell-of-hot-solder-in-the-evening/</guid>
		<description><![CDATA[I spent a chunk of the evenings this weekend soldering together the aforementioned kits from Evil Mad Scientist Laboratories. As I said before, truly awesome kits. While assembling the kits, I whipped out the camera and took a few random photos. The kits are done, but I&#8217;m holding on the final photos until tomorrow. So, [...]]]></description>
			<content:encoded><![CDATA[<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2225750946" title="View 'Lots of Soldering to Look Forward To!' on Flickr.com"><img src="http://farm3.static.flickr.com/2057/2225750946_b7e44e890f.jpg" alt="Lots of Soldering to Look Forward To!" border="0" width="500" height="333" /></a></div>
<p>I spent a chunk of the evenings this weekend soldering together the aforementioned kits from <a href="http://www.evilmadscientist.com/">Evil Mad Scientist Laboratories</a>.</p>
<p><a href="http://www.friday.com/bbum/2008/01/26/lemurtronics/">As I said before</a>, truly awesome kits.</p>
<p>While assembling the kits, I whipped out the camera and took a few random photos.</p>
<p>The kits are done, but I&#8217;m holding on the final photos until tomorrow.</p>
<p>So, for now, click on through for a bit of macro electronic assembly pr0n.<br />
<br clear="left"/></p>
<p><span id="more-986"></span></p>
<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2224959447" title="View 'Pile o' Big LEDs' on Flickr.com"><img src="http://farm3.static.flickr.com/2403/2224959447_585c92bbe2.jpg" alt="Pile o' Big LEDs" border="0" width="500" height="333" /></a></div>
<p>The kits included a huge pile of 10 mm LEDs.  Big frosty LEDs in several different colors.</p>
<p>That are completely impossible to tell which color is which without powering &#8216;em up.</p>
<p>Not a problem &#8212; the LEDs are nicely separated by color.<br />
<br clear="right"/></p>
<div class="imgLeft"><a href="http://www.flickr.com/photos/49503114554@N01/2224954581" title="View 'Bags of Resistors' on Flickr.com"><img src="http://farm3.static.flickr.com/2082/2224954581_7ee6262c70.jpg" alt="Bags of Resistors" border="0" width="500" height="333" /></a></div>
<p>One thing that has changed since I built kits over 2 decades ago (Sheesh!!) is the prevalence of digital over analog.</p>
<p>One aspect of digital is that it tends to result in fairly repetitive circuits.  And repetitive means lots of the same kinds of components.</p>
<p>I really appreciate the big bag of zero ohm resistors, too!<br />
<br clear="left"/></p>
<div class="imgRight"><a href="http://www.flickr.com/photos/49503114554@N01/2225746536" title="View 'More LEDs' on Flickr.com"><img src="http://farm3.static.flickr.com/2111/2225746536_240437b1c7.jpg" alt="More LEDs" border="0" width="500" height="334" /></a></div>
<p>The boards are designed such that the LEDs sit completely flush to the board.</p>
<p>Took me a moment to realize that components with fat bottoms area easy to keep flush by simply bending both leads the same direction.</p>
<p>Once I made that realization, I could populate the boards with all LEDs of one color and then solder &#8216;em all in one pass, doing one lead of each LED at a time to minimize heat.<br />
<br clear="right"/></p>
<p>In any case, I had a lot of fun building these kits.  And I have some awesome photos of the final products.</p>
<p>More soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.friday.com/bbum/2008/01/28/mmm-the-smell-of-hot-solder-in-the-evening/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

