<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hack a Day &#187; how-to</title>
	<atom:link href="http://hackaday.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Tue, 24 Nov 2009 19:06:31 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='hackaday.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/5560f98f805877b0e332f191cb9e0af3?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Hack a Day &#187; how-to</title>
		<link>http://hackaday.com</link>
	</image>
			<item>
		<title>Introduction to FTDI bitbang mode</title>
		<link>http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/</link>
		<comments>http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 14:53:53 +0000</pubDate>
		<dc:creator>Phil Burgess</dc:creator>
				<category><![CDATA[classic hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[led hacks]]></category>
		<category><![CDATA[bit bang]]></category>
		<category><![CDATA[bitbang]]></category>
		<category><![CDATA[centronics]]></category>
		<category><![CDATA[ftdi]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[rs232]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=15652</guid>
		<description><![CDATA[
It was an interface that launched a thousand hacks. Near trivial to program, enough I/O lines for useful work, and sufficiently fast for a multitude of applications: homebrew logic analyzers, chip programmers, LCD interfaces and LED light shows, to name a few.
Today the parallel printer port is on the brink of extinction (and good riddance, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=15652&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-15720" title="officespace" src="http://hackadaycom.files.wordpress.com/2009/09/officespace.jpg?w=470&#038;h=248" alt="officespace" width="470" height="248" /></p>
<p>It was an interface that launched a thousand hacks. Near trivial to program, enough I/O lines for useful work, and sufficiently fast for a multitude of applications: <a href="http://hackaday.com/2008/01/28/parallel-port-logic-analyzer/">homebrew logic analyzers</a>, <a href="http://hackaday.com/2006/11/08/five-dollar-eprom-programmer/">chip programmers</a>, <a href="http://hackaday.com/2005/11/19/hacking-an-lcd/">LCD interfaces</a> and <a href="http://hackaday.com/2009/06/08/simple-computer-controlled-lights/">LED light shows</a>, to name a few.</p>
<p>Today the parallel printer port is on the brink of extinction (and good riddance, some would say). Largely rendered obsolete by USB, few (if any) new peripherals even include a parallel connector, and today’s shrinking computers — nettops, netbooks, media center PCs — wouldn’t have space for it anyway. That’s great for tidy desks, but not so good if you enjoyed the dirt-cheap hacks that the legacy parallel port made possible.</p>
<p>Fear not, for there’s a viable USB alternative that can resurrect many of these classic hacks! And if you’ve done much work with Arduino, there’s a good chance it’s already lurking in your parts drawer.</p>
<p><span id="more-15652"></span>A recurring element among many recent hacks is the use of an Arduino or other USB-connected microcontroller as an intermediary between a PC and an external circuit. Code running on the microcontroller will poll some sensor to detect a change (for example, an empty coffee pot), then send a message over USB to a host PC where another program then acts on it (updating a web page to tell the world there’s no coffee). This is a reasonable approach, the parts are affordable and simple to program, but for many projects we can get by with just half the code, complexity and expense…and some folks will be thrilled to hear, <em>no Arduino!</em></p>
<p>When the microcontroller on an Arduino board talks to a host PC over USB, all of the heavy lifting of USB communication is done by a separate chip: the FTDI FT232R USB to serial UART interface. This allows code on both the host and microcontroller to use much simpler asynchronous serial communication. As a size- and cost-cutting measure, some Arduino variants place this chip on a separate board to be attached only when programming the microcontroller, allowing it to be re-used for the next project.</p>
<p>This default USB-to-serial mode of the FT232R is what usually draws all the attention and gets all the girls. An alternate mode, less talked about but no less useful, is <em>bitbang mode.</em> This gives us independent software control of up to eight I/O lines, similar to the classic parallel port or the digital I/O lines of a microcontroller.</p>
<h2>Acquiring the Hardware</h2>
<p>If one isn’t already in your stash, FT232R breakout boards are easy to come by. Any shop that carries the Arduino Pro or LilyPad, or some of the bargain-priced Arduino derivatives (e.g. Boarduino), will also offer a programming cable that breaks out four of the FT232R I/O lines:</p>
<div id="attachment_15656" class="wp-caption alignnone" style="width: 480px"><img class="size-full wp-image-15656" title="basic-breakout" src="http://hackadaycom.files.wordpress.com/2009/09/basic-breakout.jpg?w=470&#038;h=390" alt="Above: The SparkFun FTDI Basic Breakout board (around $14) is surrounded by the FTDI TTL-232R converter cable (around $20). Both bring out four data lines that can be used for general-purpose I/O. There is a one pin difference in that the FTDI cable brings out the RTS pin, while the SparkFun board uses the DTR pin in the same position." width="470" height="390" /><p class="wp-caption-text">Above: The SparkFun FTDI Basic Breakout board (around $14) is surrounded by the FTDI TTL-232R converter cable (around $20). Both break out four data lines that can be used for general-purpose I/O. </p></div>
<p>Four data lines may seem constraining, but for many tasks this is sufficient; projects using SPI communication, shift registers and port expanders will be well served. If you need the full complement of I/O lines, more sophisticated breakout boards are available:</p>
<div id="attachment_15657" class="wp-caption alignnone" style="width: 480px"><img class="size-full wp-image-15657" title="full-breakout" src="http://hackadaycom.files.wordpress.com/2009/09/full-breakout.jpg?w=470&#038;h=360" alt="Above: just a few of the available FTDI breakout boards. Clockwise from top: SparkFun Breakout Board for FT232RL (around $15), Modern Device USB-BUB ($12), DLP Design DLP-USB232R ($18) and DLP-USB1232H ($25), and FTDI’s own FT4232HQ Mini Module ($30). The latter two are based on more capable chips, FTDI’s FT2232H and FT4232H, with additional features far exceeding the scope of this article." width="470" height="360" /><p class="wp-caption-text">Above: just a few of the available full breakout boards. Clockwise from top: SparkFun Breakout Board for FT232RL (around $15), Modern Device USB-BUB ($12), DLP Design DLP-USB232R ($18) and DLP-USB1232H ($25), and FTDI’s own FT4232HQ Mini Module ($30). The latter two are based on more capable chips, the FT2232H and FT4232H, backwardly compatible but with additional features far exceeding the scope of this article.</p></div>
<h2>Setting Up for Development</h2>
<p>Another encouraging aspect of the FTDI interface is cross-platform software support; the same hacks can be created whether you’re using Windows, Linux or Mac OS X. Two software components are required to begin development: a <em>device driver,</em> which operates behind the scenes to handle all the low-level USB communication, and an <em>API library,</em> which is linked with your own code and forwards requests to the driver. Complicating matters slightly, there are two different APIs to choose from, and the setup process is a little different for each OS.</p>
<p>FTDI’s own API is called <em>D2XX.</em> This library is proprietary and closed source, but they do not charge for its use, even in commercial situations. An alternate API, <em>libftdi,</em> is community-developed and fully open source. This library has similar capabilities, but different function names and syntaxes. Conversion between the two APIs is very straightforward, and we’ll provide an example for each.</p>
<p><strong>Windows users:</strong> if you’ve used Arduino before, the necessary driver is already installed. Otherwise, <a href="http://www.ftdichip.com/Drivers/D2XX.htm">download and extract the latest Windows driver from the FTDI web site</a>. When first connecting an FTDI cable or breakout board, use the Found New Hardware Wizard to locate and install the driver. If you want to use the D2XX library, the header and object files are included in the driver folder. This is the easier option. If you’d prefer the open source libftdi, you’ll need to download and install the both the <a href="http://sourceforge.net/projects/libusb-win32/files/">libusb-win32 device driver and source code</a>, then <a href="http://www.intra2net.com/en/developer/libftdi/">download and build libftdi</a>.</p>
<p><strong>Linux users:</strong> most current Linux distributions already have the necessary driver present as a kernel module. The D2XX library for Linux can be <a href="http://www.ftdichip.com/Drivers/D2XX.htm">downloaded from the FTDI driver page</a>, but <a href="http://www.intra2net.com/en/developer/libftdi/">libftdi</a> is easier to install: simply locate libftdi-dev in your favorite package manager and have it take care of the dependencies when installing. In either case, FTDI programs for Linux need to be run as root, e.g.</p>
<pre>sudo ./hello-ftdi</pre>
<p><strong>Mac OS X users:</strong> <a href="http://www.ftdichip.com/Drivers/D2XX.htm">download the D2XX library from the FTDI download page</a>. The included ReadMe file will explain how to install this library. If you’d prefer to use libftdi, download the source for <a href="http://www.libusb.org/">libusb</a> (legacy 0.1.12 version) and <a href="http://www.intra2net.com/en/developer/libftdi/">libftdi</a> from their respective sites, then use the following commands in a Terminal window to build and install each of the two libraries:</p>
<pre>./configure
make
sudo make install</pre>
<p>If you’ve used Arduino in the past or have the FTDI Virtual Com Port (VCP) driver installed for any other reason, this needs to be disabled before bitbang mode will work on the Mac; the two cannot coexist. In a Terminal window, type:</p>
<pre>sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext</pre>
<p>To restore the driver and resume using Arduino or other FTDI serial devices:</p>
<pre>sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext</pre>
<p><strong>Other operating systems:</strong> drivers for several other platforms are available. Please see the <a href="http://www.ftdichip.com/FTDrivers.htm">FTDI drivers page</a> for details and links.</p>
<p>Most of the FTDI sample code is written in C, and that’s what we’ll use here. Bindings for other languages are available on the FTDI web site.</p>
<h2>Hello World: Flash an LED</h2>
<p>The standard introductory program for nearly every microcontroller is the LED flasher, so let’s give that a try. You’ll need an FTDI cable or any of the breakout boards, one LED and a 220 Ohm resistor.</p>
<p>Connect the resistor to either leg of the LED, but keep note of which leg is the positive (anode) side. Then insert the LED/resistor pair into the socket on the end of the FTDI cable as shown below, with the negative leg connected to the GND line (the black wire on the FTDI cable) and the positive leg to the CTS line (brown wire).</p>
<p><img class="alignnone size-full wp-image-15659" title="ftdi-hello" src="http://hackadaycom.files.wordpress.com/2009/09/ftdi-hello.jpg?w=470&#038;h=360" alt="ftdi-hello" width="470" height="360" /></p>
<p>Here’s the C source code, using the libftdi API. If you plan on using D2XX, have a look at the second listing a bit later; the relationship between functions should be fairly obvious.</p>
<pre>/* hello-ftdi.c: flash LED connected between CTS and GND.
   This example uses the libftdi API.
   Minimal error checking; written for brevity, not durability. */

#include &lt;stdio.h&gt;
#include &lt;ftdi.h&gt;

#define LED 0x08  /* CTS (brown wire on FTDI cable) */

int main()
{
    unsigned char c = 0;
    struct ftdi_context ftdic;

    /* Initialize context for subsequent function calls */
    ftdi_init(&amp;ftdic);

    /* Open FTDI device based on FT232R vendor &amp; product IDs */
    if(ftdi_usb_open(&amp;ftdic, 0x0403, 0x6001) &lt; 0) {
        puts("Can't open device");
        return 1;
    }

    /* Enable bitbang mode with a single output line */
    ftdi_enable_bitbang(&amp;ftdic, LED);

    /* Endless loop: invert LED state, write output, pause 1 second */
    for(;;) {
        c ^= LED;
        ftdi_write_data(&amp;ftdic, &amp;c, 1);
        sleep(1);
    }
}</pre>
<p>If the program successfully compiles (all of the required headers and libraries in the appropriate locations, and properly linked with our own code), the LED should flash slowly.</p>
<p>The code is largely self-explanatory, but there are a couple of points worth highlighting:</p>
<ul>
<li>Note the second parameter to ftdi_enable_bitbang(). This is an 8-bit mask indicating which lines should be outputs (bit set) vs. inputs (bit clear). As we’re only using a single output line (CTS in this case), we set just the one bit corresponding to that line (0&#215;08). For additional outputs, we can OR the bit values together. The bitbang I/O pin mappings aren’t defined in either API’s header, so you might find it helpful to keep around a header such as this:
<pre>#define PIN_TX  0x01  /* Orange wire on FTDI cable */
#define PIX_RX  0x02  /* Yellow */
#define PIN_RTS 0x04  /* Green */
#define PIN_CTS 0x08  /* Brown */
#define PIN_DTR 0x10
#define PIN_DSR 0x20
#define PIN_DCD 0x40
#define PIN_RI  0x80</pre>
</li>
<li>Notice that the second parameter to ftdi_write_data() is a <em>pointer</em> to an 8-bit variable. The function normally expects an array (and the second example will demonstrate this), but for this simple case only one value is required. When issuing a single byte like this, remember to always pass by reference (a pointer), not a numeric constant. The last parameter to the function is the number of bytes.</li>
</ul>
<p>The value(s) passed to ftdi_write_data() indicate the desired state of the output lines: a set bit indicates a logic high state (3.3 or 5 volts, depending on the FTDI adapter used), and a clear bit indicates logic low (0 volts). The mapping of bits to I/O pins is exactly the same as for ftdi_enable_bitbang(), so the prior #defines may be helpful in that regard.</p>
<h2>More Bells and Whistles</h2>
<p>There are many project ideas that only occasionally need to toggle an I/O line: ring a bell when a web counter increments, flash a light when email arrives, send a Tweet when the cat uses the litter box. The code for such tasks will often be just as simple as the example above. But when communicating with more complex devices and protocols, this byte-at-a-time approach becomes very inefficient. Every call to ftdi_write_data(), even a single byte, issues a USB transaction that will be padded to a multiple of 64 bytes, and there can be latencies of a full millisecond or more before this request is actually sent down the wire. To efficiently send complex data streams, it’s necessary to pass an entire array to the ftdi_write_data() function.</p>
<p>Bitbang mode operates very differently than the chip’s default serial UART mode. In the serial configuration, one simply calls fwrite() to issue a block of data to the serial port, and the chip manages all the details of the transmission protocol: word length, start, stop and parity bits, and toggling the logic state of the TX line at the required baud rate. In Bitbang mode there is no implied protocol; this is raw access to the data lines, and we must take care to construct a meaningful signal ourselves, essentially creating an <em>image map</em> of the data lines over time:</p>
<p><img class="alignnone size-full wp-image-15660" title="analogy" src="http://hackadaycom.files.wordpress.com/2009/09/analogy.png?w=450&#038;h=580" alt="analogy" width="450" height="580" /></p>
<p>Suppose we want to communicate with a device that uses the SPI protocol (Serial Peripheral Interface, also sometimes called Microwire, synchronous serial or three- or four-wire serial, depending on the implementation). The required output would resemble the waveform in the illustration above: one output line provides a clock signal, another represents the data bits (in sync with the clock), and a third issues an end-of-data latch signal. If sending 8 bits of data, our output array would need to be twice that size (to represent the high and low state of each clock tick), plus two additional bytes for the latch high/low at the end. 8 * 2 + 2 = 18 bytes in the output array (possibly a few extra bytes, if a specific device requires a short delay before the latch signal).</p>
<p>SPI might be too esoteric for an introductory article; not everyone will have the right components around. Instead, let’s make something visually gratifying: we’ll drive a group of LEDs using pulse width modulation. This is of dubious utility but it’s flashy and hints at the speed and fine control that’s possible using this port.</p>
<p>The hardware setup is similar to the first example, but repeated four times: four LEDs, four 220 Omh resistors (we’re limiting it to four in order to work with the FTDI cable or SparkFun Basic Breakout, but it’s easily expandable to eight with the other boards). The negative legs are all connected in common to the GND line (black wire on the FTDI cable), while the positive legs are connected to CTS, TX, RX and RTS (brown, orange, yellow and green wires, respectively). The SparkFun Basic Breakout has DTR in place of RTS for the last pin, but the example code will work the same with either one…we’ll explain how shortly.</p>
<p>Here’s how the components look on a breadboard. Notice that the +5V line (red wire on FTDI cable) is skipped:</p>
<p><img class="alignnone size-full wp-image-15661" title="ftdi-pwm" src="http://hackadaycom.files.wordpress.com/2009/09/ftdi-pwm.jpg?w=470&#038;h=360" alt="ftdi-pwm" width="470" height="360" /></p>
<p>And here’s the source code, using the D2XX API. Adapting this to libftdi is straightforward; see the first example for the different syntaxes.</p>
<pre>/* pwmchase.c: 8-bit PWM on 4 LEDs using FTDI cable or breakout.
   This example uses the D2XX API.
   Minimal error checking; written for brevity, not durability. */

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;math.h&gt;
#include &lt;ftd2xx.h&gt;

#define LED1 0x08  /* CTS (brown wire on FTDI cable) */
#define LED2 0x01  /* TX  (orange) */
#define LED3 0x02  /* RX  (yellow) */
#define LED4 0x14  /* RTS (green on FTDI) + DTR (on SparkFun breakout) */

int main()
{
    int i,n;
    unsigned char data[255 * 256];
    FT_HANDLE handle;
    DWORD bytes;

    /* Generate data for a single PWM 'throb' cycle */
    memset(data, 0, sizeof(data));
    for(i=1; i&lt;128; i++) {
        /* Apply gamma correction to PWM brightness */
        n = (int)(pow((double)i / 127.0, 2.5) * 255.0);
        memset(&amp;data[i * 255], LED1, n);         /* Ramp up */
        memset(&amp;data[(256 - i) * 255], LED1, n); /* Ramp down */
    }   

    /* Copy data from first LED to others, offset as appropriate */
    n = sizeof(data) / 4;
    for(i=0; i&lt;sizeof(data); i++)
    {
        if(data[i] &amp; LED1) {
            data[(i + n    ) % sizeof(data)] |= LED2;
            data[(i + n * 2) % sizeof(data)] |= LED3;
            data[(i + n * 3) % sizeof(data)] |= LED4;
        }
    }   

    /* Initialize, open device, set bitbang mode w/5 outputs */
    if(FT_Open(0, &amp;handle) != FT_OK) {
        puts("Can't open device");
        return 1;
    }
    FT_SetBitMode(handle, LED1 | LED2 | LED3 | LED4, 1);
    FT_SetBaudRate(handle, 9600);  /* Actually 9600 * 16 */

    /* Endless loop: dump precomputed PWM data to the device */
    for(;;) FT_Write(handle, &amp;data, (DWORD)sizeof(data), &amp;bytes);
}</pre>
<p>When successfully compiled and run, the LEDs should slowly pulsate in a repeating “chaser” cycle. There are some notable differences from the first example:</p>
<ul>
<li>LED4 is defined by two bits, a logical OR of both RTS and DTR, and the two bits are always toggled in unison. This isn’t a mandatory requirement, it simply makes the program compatible with different hardware: the FTDI cable and the SparkFun Basic Breakout use a different signal on the last pin, and toggling both bits makes it work the same regardless.</li>
<li>The baud rate is explicitly set to 9600 bps (bitbang mode will actually run at 16 times the baud rate). This is so the PWM speed will be the same whether using libftdi or D2XX. The former library normally initializes the port to 9600 baud by default, while the latter API (used here) opens the port at maximum speed and we need to slow it down to match. In practice, at maximum speed we’re able to get about 650,000 8-bit samples per second out this port.</li>
<li>In Mac OS X 10.6, you may find it necessary to pass the -m32 flag to gcc in order to compile and link with the D2XX library. And Windows programmers using Cygwin may need some additional header files:
<pre>#include &lt;stdarg.h&gt;
#include &lt;windef.h&gt;
#include &lt;winnt.h&gt;
#include &lt;winbase.h&gt;</pre>
</li>
</ul>
<p>Pulse width modulation makes for a nice visual demonstration of speed but unfortunately can’t really be put to serious use. In addition to the previously-mentioned I/O latency, other devices may be sharing the USB bus, and the sum total is that we can’t count on this technique to behave deterministically nor in realtime. PWM with an LED looks just fine to the eye…the timing is close enough…but trying to PWM-drive a servo is out of the question. For a synchronous serial protocol such as SPI, where a clock signal accompanies each data bit, this method works perfectly, and hopefully that can be demonstrated in a follow-up article.</p>
<h2>Not a Panacea</h2>
<p>FTDI bitbang mode comes in handy for many projects, but it’s not a solution to every problem. There are many situations where a microcontroller is still preferable:</p>
<ul>
<li>For extended standalone use, it’s a no-brainer: a microcontroller board costs less than a fancy meal and runs for days on a 9-volt battery. Only when a project is going to involve a full-on PC anyway should bitbang mode be considered.</li>
<li>If a task involves basic analog-to-digital conversion, you’re almost certainly better off using a USB-connected microcontroller with built-in ADC. It’s just less hassle than the alternative.</li>
<li>For tasks that require continual high-speed polling of a sensor, bitbang mode will needlessly gobble USB bandwidth and CPU cycles. Most microcontrollers have an interrupt-on-change feature that avoids polling entirely, using resources only when a change actually occurs.</li>
</ul>
<p>We hope this introduction has planted the seeds of new hacks in your mind, or will breathe new life into forgotten classic parallel port hacks. To dig deeper, the <a href="http://www.ftdichip.com/">FTDI web site</a> is the best resource. Here you’ll find <a href="http://www.ftdichip.com/Documents/DataSheets.htm">data sheets</a>, <a href="http://www.ftdichip.com/Documents/Articles.htm">articles</a>, and most useful of all are the <a href="http://www.ftdichip.com/Documents/AppNotes.htm">application notes</a>. There’s also <a href="http://www.ftdichip.com/Projects/CodeExamples.htm">information for working with other languages</a>: Java, Perl, Python and Visual Basic, among others.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/15652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/15652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/15652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/15652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/15652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/15652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/15652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/15652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/15652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/15652/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=15652&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philburgess</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/officespace.jpg" medium="image">
			<media:title type="html">officespace</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/basic-breakout.jpg" medium="image">
			<media:title type="html">basic-breakout</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/full-breakout.jpg" medium="image">
			<media:title type="html">full-breakout</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/ftdi-hello.jpg" medium="image">
			<media:title type="html">ftdi-hello</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/analogy.png" medium="image">
			<media:title type="html">analogy</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/09/ftdi-pwm.jpg" medium="image">
			<media:title type="html">ftdi-pwm</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Bus Pirate probe cable</title>
		<link>http://hackaday.com/2009/07/02/how-to-bus-pirate-probe-cable/</link>
		<comments>http://hackaday.com/2009/07/02/how-to-bus-pirate-probe-cable/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 19:08:22 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[bus pirate cable]]></category>
		<category><![CDATA[cable]]></category>
		<category><![CDATA[probe]]></category>
		<category><![CDATA[test hooks]]></category>
		<category><![CDATA[test lead]]></category>
		<category><![CDATA[test probes]]></category>
		<category><![CDATA[tweezer]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=10585</guid>
		<description><![CDATA[
Update, Saturday July 4th, 2009: All preorders are closed.
A probe cable makes it easy to connect the  Bus Pirate to a circuit and get  hacking. Good test clips make quick connections on cramped PCBs without causing short circuits. We made two cables for the Bus Pirate v2, keep reading for an overview of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10585&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-12279" title="cover" src="http://hackadaycom.files.wordpress.com/2009/07/cover.jpg?w=470&#038;h=323" alt="cover" width="470" height="323" /></p>
<p><strong>Update, Saturday July 4th, 2009: </strong>All preorders are closed.</p>
<p>A probe cable makes it easy to connect <a href="http://www.buspirate.com">the  Bus Pirate</a> to a circuit and get  hacking. Good test clips make quick connections on cramped PCBs without causing short circuits. We made two cables for the <a href="http://hackaday.com/2009/06/25/how-to-the-bus-pirate-v2-with-usb/">Bus Pirate v2</a>, keep reading for an overview of our designs and list of part suppliers.</p>
<p>Friday, July 3, 2009 is the last day to pre-order a Bus Pirate. There&#8217;s only two days left to <a href="http://hackaday.com/2009/06/25/bus-pirate-preorders-open/">get your own Bus Pirate</a>, fully assembled and shipped worldwide, for only $30.</p>
<p><span id="more-10585"></span></p>
<p><strong>Overview</strong></p>
<p><img class="alignnone size-full wp-image-12259" title="cables.450" src="http://hackadaycom.files.wordpress.com/2009/07/cables-450.jpg?w=450&#038;h=298" alt="cables.450" width="450" height="298" /></p>
<p>We use these cables to connect the Bus Pirate&#8217;s I/O pins to a microchip or test circuit. A cable consists of a 2&#215;5 connector, a cable, and some kind of attachable probe like an alligator clip or test hook.</p>
<p>The gray cable (top) is a &#8216;junk box&#8217; cable, we recycled it from scrap parts and old computer hardware.  The &#8216;expensive&#8217; cable (bottom) uses high quality and special-order parts.</p>
<p><strong>2&#215;5pin female  connector</strong></p>
<p><img class="alignnone" src="http://hackadaycom.files.wordpress.com/2009/04/brd25450.png?w=437&amp;h=354&#038;h=354" alt="" width="437" height="354" /></p>
<p>The Bus Pirate&#8217;s I/O header is two rows of five 0.1&#8243; spaced pins. We used a 2&#215;5 arrangement because 2&#215;5pin <a href="http://en.wikipedia.org/wiki/Ribbon_cable#Cable_connectors">female ribbon cable connectors</a> are common and cheap. We decided against a single row of 10 pins because the connector is an expensive specialty item.</p>
<p>The pin names are shown above, and are silk-screened on the  bottom of the PCB. See the <a href="http://www.buspirate.com">Bus Pirate page</a> for detailed descriptions of each pin function.</p>
<p><img class="alignnone size-full wp-image-12264" title="connector-comapre.450" src="http://hackadaycom.files.wordpress.com/2009/07/connector-comapre-450.jpg?w=450&#038;h=293" alt="connector-comapre.450" width="450" height="293" /></p>
<p>The junk box cable uses a 2&#215;5pin female connector from an old PC ISA card.</p>
<p>The expensive cable uses a black connector with a reinforced cable holder. Mouser has <a href="http://mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMvT7Of4ktfHLp7HEgRb%252bXNqM189BZwCjls%3d">gray connectors</a> ($0.69) and <a href="http://mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMvT7Of4ktfHLryB5cuqtTOwUtyVZIBqjDM%3d">black connectors</a> ($1.15).</p>
<p><img class="alignnone size-full wp-image-12266" title="connector-apart.450" src="http://hackadaycom.files.wordpress.com/2009/07/connector-apart-450.jpg?w=450&#038;h=270" alt="connector-apart.450" width="450" height="270" /></p>
<p>Ribbon cable connectors have internal pins that pierce the cable when the top part is pressed onto the bottom part.</p>
<p><strong>Ribbon cable</strong></p>
<p><img class="alignnone size-full wp-image-12265" title="cables-compare.450" src="http://hackadaycom.files.wordpress.com/2009/07/cables-compare-450.jpg?w=450&#038;h=215" alt="cables-compare.450" width="450" height="215" /></p>
<p>Standard 2&#215;5pin female connectors attach to <a href="http://en.wikipedia.org/wiki/Ribbon_cable#Cable_sizes">0.05&#8243;</a> 10-strand ribbon cable. The wire thickness is usually 22, 24, or 26 AWG. We think 12inches (30cm) is a useful length that doesn&#8217;t get in the way.</p>
<p>Grey ribbon cable is pretty common. We salvaged a piece from an old computer connector, you might get lucky and  find one with a 2&#215;5  connector already attached.</p>
<p>A color coded cable makes it easy to identify each connection. DigiKey has <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=MC10M-5-ND">5 foot sections</a> ($3.03), Mouser has it by the foot (<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMsJiFh04Lj2rqXP8f7Pzi2%2fH6f0Eu5UWzk%3d">$1.16</a>, <a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMsJiFh04Lj2rrQIKM9xOMEOhuPHGzW6dSg%3d">$1.19</a>).</p>
<p>Ribbon cable is cheap and readily available, but  it tends to tangle and kink. A really nice probe could use a ribbon cable stub attached to thicker test leads.</p>
<p><strong>Test clips</strong></p>
<p>Test clips are the most important part of the cable. They have to be easy to position, and maintain  contact with the circuit. Alligator clips work, but there&#8217;s a lot of exposed metal that can create short circuits. Professional test clips have a  grabber that retracts into the probe leaving less metal exposed.</p>
<p><em>Alligator clips</em></p>
<p><img class="alignnone size-full wp-image-12260" title="gator.450" src="http://hackadaycom.files.wordpress.com/2009/07/gator-450.jpg?w=450&#038;h=215" alt="gator.450" width="450" height="215" /></p>
<p>The junk box cable has alligator clip probes, we pulled them off test leads <a href="http://cgi.ebay.com/40-ALLIGATOR-CLIP-TEST-LEAD-INSULATED-COLOR-JUMPER-WIRE_W0QQitemZ350216518161QQcmdZViewItem">like these</a> (40 leads for $12). You could also use  loose <a href="http://www.dealextreme.com/details.dx/sku.6359"> red and black clips</a> (20 for $2.30).</p>
<p>Remember to put the rubber housing on the cable before soldering the wire to the alligator clip, it won&#8217;t go on later. In the photos you can see that some of our covers are cut to fit over the front of the clip because we forgot.</p>
<p><em>Round test hooks</em></p>
<p><img class="alignnone size-full wp-image-12258" title="barrel-hooker-action.forget" src="http://hackadaycom.files.wordpress.com/2009/07/barrel-hooker-action-forget.jpg?w=450&#038;h=238" alt="barrel-hooker-action.forget" width="450" height="238" /></p>
<p>This is the classic, round-bodied test hook. These are great for grabbing onto 0.1&#8243; pin headers, wires, and the leads of through-hole components. The hooks are usually too big to use with surface mount components, and the round body makes it hard to fit more than a few in a small space.</p>
<p><img class="alignnone size-full wp-image-12327" title="rndhook-open.ii" src="http://hackadaycom.files.wordpress.com/2009/07/rndhook-open-ii.jpg?w=450&#038;h=202" alt="rndhook-open.ii" width="450" height="202" /></p>
<p>Test hooks are easy to position. Squeeze the probe to extend a  single metal hook, grab something, then release. The hook retracts into the body of the probe, securing it in place and preventing short circuits.</p>
<p><img class="alignnone size-full wp-image-12219" title="rndhook-apart" src="http://hackadaycom.files.wordpress.com/2009/06/rndhook-apart.jpg?w=450&#038;h=249" alt="rndhook-apart" width="450" height="249" /></p>
<p>Most hooks come apart by pulling the top  away from the body. Put the test lead through the hole in the cap and solder it to the metal tab.  Push the halves together when the joint is cool.</p>
<p><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=461-1015-ND">DigiKey</a> ($17.26) and <a href="http://www.frys.com/product/32861#detailed">Fry&#8217;s</a> ($14.95) have multi-colored hooks in sets of 10. Deal Extreme has dirt-cheap 10 packs of <a href="http://www.dealextreme.com/details.dx/sku.7218">yellow</a> ($2.30)   and <a href="http://www.dealextreme.com/details.dx/sku.8391">black</a> ($2.33) hooks, but the reviews say the quality matches the price so buy extra (via [<a href="http://hackaday.com/2009/06/29/parts-shiftbrite-rgb-led-module-a6281/#comment-79694">haku</a>]).</p>
<p><em>Flat test tweezers</em></p>
<p><em><img class="alignnone size-full wp-image-12261" title="hooker-action.450" src="http://hackadaycom.files.wordpress.com/2009/07/hooker-action-450.jpg?w=450&#038;h=281" alt="hooker-action.450" width="450" height="281" /><br />
</em></p>
<p>Tweezer-probes are great for clipping onto the legs of through-hole, surface mount, and many smaller chips. They usually have a flat body so they fit better in tight spaces than round hook probes.</p>
<p><img class="alignnone size-full wp-image-12328" title="hook-open.ii" src="http://hackadaycom.files.wordpress.com/2009/07/hook-open-ii.jpg?w=450&#038;h=175" alt="hook-open.ii" width="450" height="175" /></p>
<p>This type of probe has tiny tweezers instead of a hook. Accidental short circuits are rare because there&#8217;s so little exposed metal when the tweezers  retract.</p>
<p><img class="alignnone size-full wp-image-12216" title="hook-apart" src="http://hackadaycom.files.wordpress.com/2009/06/hook-apart.jpg?w=450&#038;h=254" alt="hook-apart" width="450" height="254" /></p>
<p>Most tweezer-probes pull apart and have a metal solder tab inside. Run a cable strand through the hole in the cap, solder it to the metal tab, and then press the halves back together.</p>
<p>Tweezer quality varies dramatically among brands, we&#8217;ve used no-name probes that bend easily or don&#8217;t grip well. The <a href="http://www.e-z-hook.com/Html/MicroHooks.html">X- series micro-hooks</a> from E-Z-Hook are the Cadillac of tweezer-probes, we first used  the  XKM version that comes with the <a href="http://hackaday.com/2009/03/06/tools-saleae-logic-logic-analyzer/">Saleae Logic</a>. They&#8217;re intended to fit specialty  test leads, but it&#8217;s  easy to solder a wire to them instead. About $2 each, available directly from the <a href="http://www.e-z-hook.com/Html/OrderingInformation.html">E-Z-Hook website</a>.</p>
<p><strong>Conclusion</strong></p>
<p>We highly recommend a cable with hook or tweezer-probes for secure connections without causing shorts. The right probe depends on the parts you use. Round test hooks work best with  through-hole parts and wires. Flat test tweezers attach well to small, surface mount chips.</p>
<p>Please share any additional part sources in the comments. We did our best to provide a variety of sources, but there&#8217;s going to be some great places we&#8217;ve missed.</p>
<p>Friday, July 3, 2009 is the last day to pre-order a Bus Pirate. There&#8217;s only two days left to  <a href="http://hackaday.com/2009/06/25/bus-pirate-preorders-open/">get your own Bus Pirate</a>, fully assembled and shipped worldwide, for only $30.</p>
<p><img class="alignnone size-full wp-image-10467" title="buspiratev2goii450" src="http://hackadaycom.files.wordpress.com/2009/04/buspiratev2goii450.jpg?w=450&#038;h=314" alt="buspiratev2goii450" width="450" height="314" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/10585/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/10585/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/10585/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/10585/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/10585/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/10585/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/10585/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/10585/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/10585/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/10585/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10585&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/07/02/how-to-bus-pirate-probe-cable/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/cover.jpg" medium="image">
			<media:title type="html">cover</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/cables-450.jpg" medium="image">
			<media:title type="html">cables.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/brd25450.png?w=437&#38;h=354" medium="image" />

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/connector-comapre-450.jpg" medium="image">
			<media:title type="html">connector-comapre.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/connector-apart-450.jpg" medium="image">
			<media:title type="html">connector-apart.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/cables-compare-450.jpg" medium="image">
			<media:title type="html">cables-compare.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/gator-450.jpg" medium="image">
			<media:title type="html">gator.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/barrel-hooker-action-forget.jpg" medium="image">
			<media:title type="html">barrel-hooker-action.forget</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/rndhook-open-ii.jpg" medium="image">
			<media:title type="html">rndhook-open.ii</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/rndhook-apart.jpg" medium="image">
			<media:title type="html">rndhook-apart</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/hooker-action-450.jpg" medium="image">
			<media:title type="html">hooker-action.450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/hook-open-ii.jpg" medium="image">
			<media:title type="html">hook-open.ii</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/hook-apart.jpg" medium="image">
			<media:title type="html">hook-apart</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/buspiratev2goii450.jpg" medium="image">
			<media:title type="html">buspiratev2goii450</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: The Bus Pirate V2 with USB</title>
		<link>http://hackaday.com/2009/06/25/how-to-the-bus-pirate-v2-with-usb/</link>
		<comments>http://hackaday.com/2009/06/25/how-to-the-bus-pirate-v2-with-usb/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 00:15:21 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[1-wire]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[jtag]]></category>
		<category><![CDATA[midi]]></category>
		<category><![CDATA[pc keyboard]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[the bus pirate]]></category>
		<category><![CDATA[uart]]></category>
		<category><![CDATA[universal serial interface]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=10041</guid>
		<description><![CDATA[
Update, Saturday July 4th, 2009: All preorders are closed.
The Bus Pirate is a universal serial interface tool, we use it to test new chips without writing any code. It currently supports most serial protocols, including 1-Wire, I2C, SPI, JTAG, asynchronous serial, MIDI, and more. We added some other features we frequently need, like pulse-width modulation, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10041&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-10467" title="buspiratev2goii450" src="http://hackadaycom.files.wordpress.com/2009/04/buspiratev2goii450.jpg?w=450&#038;h=314" alt="buspiratev2goii450" width="450" height="314" /></p>
<p><strong>Update, Saturday July 4th, 2009: </strong>All preorders are closed.</p>
<p>The <a href="http://www.buspirate.com">Bus Pirate</a> is a universal serial interface tool, we use it to <a href="http://hackaday.com/category/parts/">test new chips</a> without writing any code. It currently supports most serial protocols, including 1-Wire, I2C, SPI, JTAG, asynchronous serial, MIDI, and more. We added some other features we frequently need, like pulse-width modulation, frequency measurement, voltage measurement, bus sniffers, pull-up resistors, and switchable 3.3volt and 5volt power supplies.</p>
<p>The new v2 family adds USB power and connectivity to the best Bus Pirate design yet.  We also reduced the part count and cost wherever possible. If you want to get your hands on some Bus Pirate USB goodness, Seeed Studio has assembled hardware for $30 (including worldwide shipping).</p>
<p>Read about the new design after the break.</p>
<p><span id="more-10041"></span></p>
<p><strong>Concept overview</strong></p>
<p><img class="alignnone size-full wp-image-10458" title="overview450" src="http://hackadaycom.files.wordpress.com/2009/04/overview450.png?w=450&#038;h=212" alt="overview450" width="450" height="212" /></p>
<p>The Bus Pirate connects to a PC USB port. The user send commands to the Bus Pirate from a serial terminal on the PC. Commands are translated to the bus protocols that control microchips. See our <a href="http://www.buspirate.com">Bus Pirate page</a> for full documentation.</p>
<p>The latest firmware supports 1-Wire, I2C, SPI, JTAG, asynchronous serial, MIDI, and PC keyboards. Bit-wise 2- and 3-wire libraries can interface most proprietary serial protocols.  More protocols are being added all the time, check out the source code on our <a href="http://code.google.com/p/the-bus-pirate/">Google Code SVN page</a>.</p>
<p><strong>Hardware</strong></p>
<p><strong><img class="alignnone size-full wp-image-10048" title="cct25450" src="http://hackadaycom.files.wordpress.com/2009/04/cct25450.jpg?w=450&#038;h=209" alt="cct25450" width="450" height="209" /></strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/05/cct25a.png">Click for a large image of the schematic</a> (PNG). The schematic and board layout were made with the freeware version of <a href="http://www.cadsoft.de">Cadsoft Eagle</a>. Download the latest files from our <a href="http://code.google.com/p/the-bus-pirate/downloads/list">Google Code</a> page.</p>
<p><em>PIC24F</em></p>
<p><em><img class="alignnone size-full wp-image-10480" title="pic24f-highlight" src="http://hackadaycom.files.wordpress.com/2009/04/pic24f-highlight.jpg?w=450&#038;h=329" alt="pic24f-highlight" width="450" height="329" /><br />
</em></p>
<p>A Microchip <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F series</a> microcontroller generates the user interface and translates input into bus communications. V2 uses the same <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">24FJ64GA002</a> as the previous Bus Pirate versions. It&#8217;s cheap, has a ton of memory,  a couple 5volt tolerant input pins, and the peripheral pin select feature lets us assign hardware modules anywhere we want.</p>
<p>The PIC (IC1) is powered by a 3.3volt regulator (VR2, C23). Each PIC power pin gets a 0.1uF bypass capacitor (C1,2). The internal 2.5volt regulator requires a 10uF tantalum capacitor (C20). The programming pins are brought to a five pin header (ICSP) on the edge of the PCB.</p>
<p><em>USB interface<br />
</em></p>
<p><em><img class="alignnone size-full wp-image-10471" title="ftdi-450ii1" src="http://hackadaycom.files.wordpress.com/2009/04/ftdi-450ii1.jpg?w=450&#038;h=229" alt="ftdi-450ii1" width="450" height="229" /></em></p>
<p>The Bus Pirate is powered from the USB 5volt supply, which is first filtered with a ferrite bead (L1) and 10uF tantalum capacitor (C21). We used the small, still-not-quite-common, <a href="http://en.wikipedia.org/wiki/USB#Types_of_USB_connector">USB mini-b</a> connector (J2).</p>
<p>Choosing a ferrite bead is a common hangup. Its purpose is to filter small power fluctuations, all the current for the circuit will go through it. We can guestimate that the Bus Pirate&#8217;s worst case current consumption is 525ma (3 power supplies @ 150ma, the FTDI chip @ 25ma, 2 LEDs @ 50ma max). Use a ferrite bead rated for at least 1000ma to be safe. We used <a href="http://www.mouser.com/Search/ProductDetail.aspx?R=BLM21PG331SN1Dvirtualkey64800000virtualkey81-BLM21P331SG">this one</a>, which is rated for 1500ma and costs 10 cents.</p>
<p>An FTDI <a href="http://www.ftdichip.com/Products/FT232BM.htm">FT232BL</a> USB-&gt;serial chip (IC2) handles the USB connection. You might be familiar with this chip from various <a href="http://hackaday.com/category/arduino-hacks/">Arduino</a> boards. FTDI has <a href="http://www.ftdichip.com/Drivers/VCP.htm">extensive driver support</a> for most platforms, we used the virtual com port drivers.  This is the latest generation chip, and it&#8217;s only available in small SSOP and QFN packages. We had no problem hand-soldering it to a professional PCB, but it&#8217;s not for everyone.</p>
<p>The FT232BL is powered directly from the filtered, unregulated USB supply. C4 is a  decoupling capacitor for the FTDI232BL supply pin. A single LED (LED4/USB) indicates USB status and activity. The FT232BL RXLED pin sinks current, so we powered the LED from the 5volt USB supply through a 1.1K resistor (R3).</p>
<p>While the FT232BL runs at 5volts from the USB supply, its serial IO pins have an independent supply input &#8211; they can operate at another voltage. Since the microcontroller is 3.3volts, we just feed the FT232BL IO pins a 3.3volt supply and eliminate any funky translation circuitry. We used the chip&#8217;s internal 3.3volt regulator to supply the IO pins because it was the easiest trace to route. The IO pins get their own 0.1uF bypass capacitor (C5).</p>
<p><em>Switchable power supplies</em></p>
<p><em><img class="alignnone size-full wp-image-10475" title="vreg-450ii" src="http://hackadaycom.files.wordpress.com/2009/04/vreg-450ii.jpg?w=449&#038;h=297" alt="vreg-450ii" width="449" height="297" /><br />
</em></p>
<p>The Bus Pirate has on-board 3.3volt and 5volt supplies (VR3, VR4) that can power a test circuit. The  supplies are switchable, so we can reset the circuit from software when something goes wrong. To be extra safe, the supplies are held off until activated in the terminal.</p>
<p>[<a href="http://www.sparkfun.com/commerce/account.php?id=7185">Nathan Seidle</a>] at <a href="http://www.sparkfun.com">SparkFun</a> recommended that we replace the  <a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMsGz1a6aV8DcPXeWoVS0Fnzr3zi8%252bAr99Q%3d">TPS796xx</a> ($2.50) we used in <a href="http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface">The Bus Pirate v1a</a> with a <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=576-1259-1-ND">MIC5205-xxYM5</a> ($0.90). They supply just 150ma maximum current, compared to 800ma from the TPS796xx, but the cost savings and reduced part-count are worth it.</p>
<p>The regulators are fed from the 5volt USB supply. The 5volt regulator drops a few millivolts below optimal because there&#8217;s no headroom, but it&#8217;s within the minimum level specified by  most 5volt parts.</p>
<p>The MIC5205 requires a large output filter capacitor (C22-24, 10uF), but no input capacitor. An optional small-value capacitor on the BP pin can decrease power supply noise, but we left this off because it didn&#8217;t make much difference in practice.</p>
<p>A small voltage on the <em>EN</em> pin enables the supply, we used a 10K pull-down resistor (R18, not shown) to ensure that the supplies stay off while the PIC initializes. LED3/VREG, with current limiting resistor R32, lights when the power supplies are active.</p>
<p><em>On-board pull-up resistors</em></p>
<p><em><img class="alignnone size-full wp-image-10469" title="resis" src="http://hackadaycom.files.wordpress.com/2009/04/resis.jpg?w=450&#038;h=298" alt="resis" width="450" height="298" /><br />
</em></p>
<p>Bus Pirate V2 has multi-voltage, software controlled pull-up resistors via the <a href="http://www.fairchildsemi.com/ds/CD%2FCD4066BC.pdf">4066</a> (PDF) quad bilateral switch (IC3). When enabled, the 4066 connects the four on-board bus pull-up resistors (R20-23, 10K) to any external signal on the Vpullup pin (0 to 5volts). When disabled, the outputs are high-impedance and have no effect on the bus lines.</p>
<p>The 4066 can&#8217;t switch an input voltage greater than the supply voltage. To give it the widest possible range, we powered it from the USB supply (5volts).</p>
<p>When operated at 5volts, it takes 4volts+ to enable the 4066. The PIC pins have a maximum output of 3.3volts, so we have a problem. We  solve it with a 5volt tolerant PIC pin and a pull-up resistor.  We turn on the 4066 with a pull-up resistor to 5volts (R19, 10K), and then disable it by switching the connected PIC pin to ground.</p>
<p>For a brief instant at power-on, the PIC pin is high-impedance and the 4066 outputs are active because the pull-up resistor holds the control pins at 5volts. This is a concern if the Vpullup input is connected to an external 5volt supply while the bus is connected to a 3.3volt device &#8211; the brief exposure to 5volts might harm the device. If you&#8217;re worried about this, make sure there&#8217;s no active power supply connected to the Vpullup input before powering the Bus Pirate. This isn&#8217;t a concern if you use one of the on-board power supplies for the pull-up voltage because they&#8217;re disabled at startup.</p>
<p><em>Voltage monitoring</em></p>
<p><em><img class="alignnone size-full wp-image-10474" title="cct-adcin" src="http://hackadaycom.files.wordpress.com/2009/04/cct-adcin.jpg?w=450&#038;h=309" alt="cct-adcin" width="450" height="309" /><br />
</em></p>
<p>Four <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage dividers</a> (R10-17, 10K), attached to <a href="http://en.wikipedia.org/wiki/Analog-to-digital_converter">analog to digital converters</a>, allow the 3.3volt PIC to safely measure up to 6volts DC.</p>
<p>Two voltage monitors measure the switchable power supply output. One measures the Vpullup input voltage, and another connects to the external voltage measurement probe.</p>
<p><em>Indicator LEDs</em></p>
<p><em><img class="alignnone size-full wp-image-10463" title="front-back2450" src="http://hackadaycom.files.wordpress.com/2009/04/front-back2450.jpg?w=450&#038;h=191" alt="front-back2450" width="450" height="191" /><br />
</em></p>
<p>Three LEDs indicate power, mode, and voltage regulator status (LED1-3). LED4/USB displays USB activity.</p>
<p>There are pads for resistors R30-32 and LEDs 1-3 on the front and back of the PCB. Only one set should be populated. We put pads on both sides so the board could be mounted with the indicator LEDs abutting the top of an enclosure.</p>
<p><em>V2a vs V2go</em></p>
<p><em><img class="alignnone size-full wp-image-10441" title="bpv2450" src="http://hackadaycom.files.wordpress.com/2009/04/bpv2450.jpg?w=450&#038;h=354" alt="bpv2450" width="450" height="354" /><br />
</em></p>
<p>Click for large <a href="http://hackadaycom.files.wordpress.com/2009/04/cct1.png">schematic</a> (PNG) and <a href="http://hackadaycom.files.wordpress.com/2009/04/brd.png">layout</a> (PNG) images of the version 2a hardware. The Eagle layout files are available in our <a href="http://code.google.com/p/the-bus-pirate/downloads/list">Google Code SVN</a>.</p>
<p>Bus Pirate V2a is a developer&#8217;s board. In addition to all the features of V2go, it includes a jack (J1) for an external power supply and an additional 5volt regulator (VR1).  A switch (S1) selects between USB power and the external supply.</p>
<p>The FT232BL chip on V2a is powered directly from the USB supply, and is not connected to the external supply. This is useful if you want to disable USB and use the Bus Pirate with a serial port on a PC or PDA.</p>
<p>The V2a 4066 enable pull-up resistor is powered by the switchable 5volt regulator. The 5volt regulator must be enabled for the 4066 to be active. Don&#8217;t forget to install the 4066 pull-up resistor (R19), located on the back of the v2a PCB.</p>
<p><strong>PCB</strong></p>
<p><img class="alignnone size-full wp-image-10047" title="brd25450" src="http://hackadaycom.files.wordpress.com/2009/04/brd25450.png?w=437&#038;h=354" alt="brd25450" width="437" height="354" /></p>
<p>The PCB is a compact, 2-layer design. We <a href="http://hackaday.com/2009/01/15/how-to-prepare-your-eagle-designs-for-manufacture/">prepared gerbers</a> and had PCBs made by our usual service, <a href="https://www.batchpcb.com/">BatchPCB</a> ($21, shipped to EU), and tried a new service offered by <a href="http://www.seeedstudio.com/wiki/index.php?title=Main_Page">Seeed Studio</a> ($32, shipped worldwide).</p>
<p>Seeed has a PCB service specifically for open source hardware projects. For $32 (including worldwide shipping) we got 5 small PCBs, and Seeed made a few extra to sell in their shop. We liked the idea that there would be extra PCBs available.</p>
<p>You might know Seeed Studio from their cheap, improved <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=MKSEEED2">Seeeduino</a> Arduino clone. They&#8217;re located in Shenzhen, a Chinese electronics manufacturing hot-spot. A bunch of notable bloggers recently <a href="http://www.sparkfun.com/commerce/news.php?id=236">visited the region</a> and wrote about the <a href="http://www.sparkfun.com/commerce/news.php?id=237">huge electronic component markets</a>.</p>
<p><img class="alignnone size-full wp-image-10461" title="seeed-batchpcb4501" src="http://hackadaycom.files.wordpress.com/2009/04/seeed-batchpcb4501.jpg?w=450&#038;h=232" alt="seeed-batchpcb4501" width="450" height="232" /></p>
<p>The Seed order arrived in 14 days (left), the BatchPCB order arrived in 30 days (right).  Seeed and BatchPCB both make beautiful PCBs. Seeed has a much faster turn-around, and has better minimum trace widths and separation (8mil vs 6mil). BatchPCB has standard green PCBs, Seeed gives you the choice of green, black, or white; red, blue and yellow are $7.50 extra.</p>
<p>We really like the Seeed PCB service, extra Bus Pirate <a href="http://www.seeedstudio.com/depot/the-bus-pirate-v2-go-pcb-p-331.htmlhttp://www.seeedstudio.com/depot/the-bus-pirate-v2-go-pcb-p-331.html">v2go</a> and <a href="http://www.seeedstudio.com/depot/the-bus-pirate-v2-pcb-p-330.html">v2a</a> PCBs from our order are available in the Seeed shop. BatchPCB remains the cheapest prototyping option if you want a single board, closed source work, or don&#8217;t mind the extra wait.</p>
<p><em>Parts list</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Part</strong></td>
<td><strong>Value (package)</strong></td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=V/yyTCAHA4D/h5r3CRQDtA==">PIC24J64GA002</a> (SOIC)</td>
</tr>
<tr>
<td>IC2</td>
<td><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=650">FT232RL</a> (SSOP)</td>
</tr>
<tr>
<td>IC3</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=CD4066BCM-ND">CD4066D</a> (SOIC-N)</td>
</tr>
<tr>
<td>VR2,3</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=576-1259-1-ND">MIC5205-3.3YM5 3.3volt regulator</a> (SOT23-5)</td>
</tr>
<tr>
<td>VR4</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=576-1261-1-ND">MIC5205-5.0YM5 5volt regulator</a> (SOT23-5)</td>
</tr>
<tr>
<td>C1-5</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C20-24</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=293D106X96R3A2TE3virtualkey61320000virtualkey74-293D106X96R3A2TE3">10uF tantalum capacitor</a> (SMC-A)</td>
</tr>
<tr>
<td>L1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=BLM21PG331SN1Dvirtualkey64800000virtualkey81-BLM21P331SG">1000ma+ Ferrite bead</a> (0805)</td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=jBethxrBxZb5NLDetw123g==">2000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R3,30</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=DZvKvnD5UYWyFJjgnPvJ4g%3d%3d">1100 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R10-23</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMtlubZbdhIBIADEshVnklemK%252bhrLNEuMe8%3d">10,000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R31,32</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=2BMLUTrrT4P7Xm58YbKmPg==">390 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>LED1-4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>J2</td>
<td><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=587">USB MINI-B</a> (SMD)</td>
</tr>
<tr>
<td>I/O</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header</a> (2&#215;05)</td>
</tr>
<tr>
<td>ICSP</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header</a> (1&#215;05)</td>
</tr>
<tr>
<td>ST</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header</a> (1&#215;03) <em>*unpopulated, optional*</em></td>
</tr>
<tr>
<td><strong><br />
</strong></td>
<td></td>
</tr>
</tbody>
</table>
<table border="0">
<tbody>
<tr>
<td><em><strong>Optional</strong></em></td>
<td><em><strong>Parts for V2a</strong></em></td>
</tr>
<tr>
<td>C6-10</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=b2tC%2fwvzm2TxaPjSsb%252bCzQ%3d%3d">2.1mm power jack</a> (SMD)</td>
</tr>
<tr>
<td>LED5,6</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>R33,34,40</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=DZvKvnD5UYWyFJjgnPvJ4g%3d%3d">1100 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>S1</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=679-1849-ND">Slide switch, SPDT, rt angle</a></td>
</tr>
<tr>
<td>VR1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S50TRvirtualkey51120000virtualkey511-LD1117S50">LD1117s50 5volt regulator</a> (SOT223)</td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The latest Bus Pirate firmware for all hardware version is always available on our <a href="http://code.google.com/p/the-bus-pirate/">Google Code page</a>. The code is written in C, and is compiled with the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en534868&amp;redirects=c30">Microchip C30 demonstration compiler</a>.</p>
<p><em>Bootloader</em></p>
<p>The biggest change in the latest firmware is the addition of a <a href="http://en.wikipedia.org/wiki/Boot_loader#Boot_loader">bootloader</a>. Now the firmware can be updated through the USB or serial connection.</p>
<p>A bootloader is small program that sits at the beginning of the PIC program memory. It accepts updated firmware through the USB or serial port and saves it to the chip.</p>
<p><img class="alignnone size-full wp-image-10449" title="bootload-jumper4501" src="http://hackadaycom.files.wordpress.com/2009/04/bootload-jumper4501.jpg?w=450&#038;h=112" alt="bootload-jumper4501" width="450" height="112" /></p>
<p>The bootloader comes from Microchip application note <a href="http://en.wikipedia.org/wiki/Boot_loader#Boot_loader">AN1157</a>. We modified the bootloader to check for a jumper between the programming clock (PGC) and data (PGD) pins at power-up (update, above left). If there&#8217;s a connection, the bootloader takes over and waits for new code. Without a connection, the bootloader exits and runs the main program.</p>
<p>There&#8217;s a very minor chance of accidentally entering the bootloader with no jumper installed. This won&#8217;t damage the Bus Pirate, but you will need to connect it again.  You can prevent it by moving the jumper over one position,  between the ground pin and the inner programming pin (normal, above right).</p>
<p><em>Upgrading the firmware with the bootloader</em></p>
<p><em><img class="alignnone size-full wp-image-10443" title="pic24fqp" src="http://hackadaycom.files.wordpress.com/2009/04/pic24fqp.png?w=450&#038;h=141" alt="pic24fqp" width="450" height="141" /><br />
</em></p>
<p>If you&#8217;re using a fresh chip, first program it with the bootloader firmware (vxx-PIC Bootloader.hex) through the ICSP header using a &#8216;real&#8217; programmer like an <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010046">ICD2</a> or <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010046">PicKit</a>.</p>
<p>If you&#8217;re upgrading, follow this procedure or refer to the instructions in the firmware download.</p>
<ul>
<li>Disconnect the Bus Pirate from any power supply such as the USB cable.</li>
<li>Place a jumper between the programming data and clock pins of the ICSP header. This will trigger the bootloader mode.</li>
<li>Connect the Bus Pirate to a USB port (or, if applicable, power and serial cable).</li>
<li>Start the MS Windows P24QP.exe programmer utility. You may need to modify the COM port (portindex=) in P24qp.ini to match your system.  Programmer source is available, and the simple bootloader protocol is documented in AN1157 if you want to write an app for a non-Windows system.</li>
<li>Click the connect to device icon (#1). The program will connect to the PIC.</li>
<li>Click the folder icon (#2) and open the firmware update file (vxx-Firmware for BL.hex).</li>
<li> Click the erase device icon (#3) to erase the chip. DO NOT SKIP THIS STEP. Programming may not be successful if you forget to erase the chip.</li>
<li> Click the write device icon (#4) to program the new firmware. Ignore any verify errors between 0&#215;400 and 0xBFF, the bootloader lives in this region and doesn&#8217;t get updated.</li>
<li> Click the green arrow icon (#5) to exit the bootloader and start the program.  Click OK at the warning, we use the jumper to re-enter the bootloader.</li>
<li> Remove the jumper from the programming pins, or move it over one position to connect the inner PGx pin to ground (GND).</li>
<li>***IMPORTANT*** Now restart the Bus Pirate by disconnecting and reconnecting the USB cable (or power cable). Some features won&#8217;t work until after a complete hardware reset.</li>
</ul>
<p><strong>Using it</strong></p>
<p><em>USB device driver<br />
</em></p>
<p>You may need to install an <a href="http://www.ftdichip.com/Drivers/VCP.htm">FTDI virtual serial port driver</a> for your platform.</p>
<p>On Windows, go to the Device Manager to configure the FTDI driver or check the COM port number.</p>
<p><em>Menus and Syntax</em></p>
<p><em><img class="alignnone size-full wp-image-10444" title="term450" src="http://hackadaycom.files.wordpress.com/2009/04/term450.png?w=420&#038;h=195" alt="term450" width="420" height="195" /><br />
</em></p>
<p>Use a serial terminal to communicate with the Bus Pirate. We like <a href="http://www.ayera.com/teraterm/">Tera Term</a>.</p>
<p>The Bus Pirate works best with the terminal set to 115200bps, 8 databits, no parity, 1stopbit. Disable local echo in the terminal, and use CR for line breaks. Some modes also require Xon/Xoff software flow control.</p>
<p>In the serial terminal, press ? for the help menu. Read more about the Bus Pirate&#8217;s menu and syntax on the <a href="http://www.buspirate.com">Bus Pirate page</a>. There&#8217;s lots of demonstrations in our recent <a href="http://hackaday.com/category/parts/">parts posts</a>.</p>
<p><em>LED indicators</em></p>
<p><em><img class="alignnone size-full wp-image-10476" title="leds-450" src="http://hackadaycom.files.wordpress.com/2009/04/leds-450.jpg?w=450&#038;h=81" alt="leds-450" width="450" height="81" /><br />
</em></p>
<ul>
<li><strong>PWR</strong> indicates power to the Bus Pirate.</li>
<li><strong>MODE</strong> is off when the I/O pins are in a safe, high-impedance state. MODE is lit when a bus mode is engaged, the pins may be active.</li>
<li><strong>VREG</strong> indicates that the on-board switchable power supplies are active.</li>
<li><strong>UR</strong> is a single USB activity indicator LED. It displays data coming <em>from</em> the PC <em>to</em> the Bus Pirate. You can probably change what this LED displays with the <a href="http://www.ftdichip.com/Resources/Utilities.htm">FTDI configuration utility</a>.</li>
</ul>
<p><em>Connections</em></p>
<p>Pin location diagrams: <a href="http://hackadaycom.files.wordpress.com/2009/01/brd3.png">v2a</a>, <a href="http://hackadaycom.files.wordpress.com/2009/01/brd251.png">v2g0</a>.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Pin name |<br />
</strong></td>
<td><strong>Description (Bus Pirate is the master)</strong></td>
</tr>
<tr>
<td>MOSI</td>
<td>Master data out, slave in (SPI, JTAG), Serial data (1-Wire, I2C, KB), TX* (UART)</td>
</tr>
<tr>
<td>CLK</td>
<td>Clock signal (I2C, SPI, JTAG, KB)</td>
</tr>
<tr>
<td>MISO</td>
<td>Master data in, slave out (SPI, JTAG) RX (UART)</td>
</tr>
<tr>
<td>CS*</td>
<td>Chip select (SPI), TMS (JTAG)</td>
</tr>
<tr>
<td>AUX</td>
<td>Auxiliary IO, frequency probe</td>
</tr>
<tr>
<td>ADC</td>
<td>Voltage measurement probe (max 6volts)</td>
</tr>
<tr>
<td>Vpu</td>
<td>Voltage input for on-board pull-up resistors (0-5volts).</td>
</tr>
<tr>
<td>+3.3v</td>
<td>+3.3volt switchable power supply, max 150ma</td>
</tr>
<tr>
<td>+5.0v</td>
<td>+5volt switchable power supply, max 150ma</td>
</tr>
<tr>
<td>GND</td>
<td>Ground, connect to ground of test circuit</td>
</tr>
</tbody>
</table>
<p>Notes: * TX moved from CS to MOSI in firmware v0g.</p>
<p>The 10 pin I/O block contains the data signals and power supplies that connect to a test circuit. Each pin is labeled on the back of the PCB, refer to the table above for a detailed description.</p>
<p>The pinout on V2 is similar to V1, but we moved the power supply output and Vpullup input  to the cable bundle. We also eliminated the second, unused auxiliary pin.</p>
<p><strong>Conclusion</strong></p>
<p>If you want a complete Bus Pirate or a kit, here&#8217;s a couple options:</p>
<ul>
<li> Seeed Studio is accepting pre-orders for assembled Bus Pirate v2go hardware until the end of Friday, July 3.  An assembled Bus Pirate v2go is $30, including worldwide shipping.</li>
<li>Seeed Studio also has the extra <a href="http://www.seeedstudio.com/depot/the-bus-pirate-v2-go-pcb-p-331.html">v2g0</a> ($5.90) and <a href="http://www.seeedstudio.com/depot/the-bus-pirate-v2-pcb-p-330.html">v2a</a> ($6.50) PCBs from our order.</li>
<li>Fundamental Logic sells a <a href="http://spiffie.org/kits/buspirate/">through-hole kit</a> version of the Bus Pirate V1a ($29.50). <strong>***v1a is serial port only***</strong></li>
</ul>
<p>Thanks to everyone who contributed to this project. The Bus Pirate wouldn&#8217;t be possible without a ton of great feedback from the comments. If you&#8217;d like to get involved, join the <a href="http://code.google.com/p/the-bus-pirate/">Bus Pirate project</a> at Google Code.</p>
<p><strong>Hack a Day review disclosure</strong>: We asked Seeed Studio to make our first order of PCBs for free. Since then, we&#8217;ve made several paid orders.</p>
<p><img class="alignnone size-full wp-image-12042" title="bpv2goiii" src="http://hackadaycom.files.wordpress.com/2009/06/bpv2goiii.jpg?w=450&#038;h=330" alt="bpv2goiii" width="450" height="330" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/10041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/10041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/10041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/10041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/10041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/10041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/10041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/10041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/10041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/10041/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10041&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/06/25/how-to-the-bus-pirate-v2-with-usb/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/buspiratev2goii450.jpg" medium="image">
			<media:title type="html">buspiratev2goii450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/overview450.png" medium="image">
			<media:title type="html">overview450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/cct25450.jpg" medium="image">
			<media:title type="html">cct25450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/pic24f-highlight.jpg" medium="image">
			<media:title type="html">pic24f-highlight</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/ftdi-450ii1.jpg" medium="image">
			<media:title type="html">ftdi-450ii1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/vreg-450ii.jpg" medium="image">
			<media:title type="html">vreg-450ii</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/resis.jpg" medium="image">
			<media:title type="html">resis</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/cct-adcin.jpg" medium="image">
			<media:title type="html">cct-adcin</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/front-back2450.jpg" medium="image">
			<media:title type="html">front-back2450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/bpv2450.jpg" medium="image">
			<media:title type="html">bpv2450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/brd25450.png" medium="image">
			<media:title type="html">brd25450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/seeed-batchpcb4501.jpg" medium="image">
			<media:title type="html">seeed-batchpcb4501</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/bootload-jumper4501.jpg" medium="image">
			<media:title type="html">bootload-jumper4501</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/pic24fqp.png" medium="image">
			<media:title type="html">pic24fqp</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/term450.png" medium="image">
			<media:title type="html">term450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/leds-450.jpg" medium="image">
			<media:title type="html">leds-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/bpv2goiii.jpg" medium="image">
			<media:title type="html">bpv2goiii</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Build your own spot welder</title>
		<link>http://hackaday.com/2009/06/23/how-to-build-your-own-spot-welder/</link>
		<comments>http://hackaday.com/2009/06/23/how-to-build-your-own-spot-welder/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 15:30:03 +0000</pubDate>
		<dc:creator>Steve Watkins</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[home made]]></category>
		<category><![CDATA[microwave]]></category>
		<category><![CDATA[MOT]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[spot welder]]></category>
		<category><![CDATA[welder]]></category>
		<category><![CDATA[welding]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=11565</guid>
		<description><![CDATA[
Spot welders are used in the fabrication of automobiles, PC cases, power supplies, microwave ovens, electrical junction boxes, Faraday cages, and various electronics. A spot welder is used because it produces a highly defined point of contact weld. The materials are welded without excessive heating, so working pieces are handled easily. The weld is also [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=11565&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-11607" title="Welding stainless steel" src="http://hackadaycom.files.wordpress.com/2009/06/100_04111.jpg?w=450&#038;h=337" alt="Welding stainless steel" width="450" height="337" /></p>
<p>Spot welders are used in the fabrication of automobiles, PC cases, power supplies, microwave ovens, electrical junction boxes, Faraday cages, and various electronics. A spot welder is used because it produces a highly defined point of contact weld. The materials are welded without excessive heating, so working pieces are handled easily. The weld is also highly controlled and repeatable. In this how-to we cover the basics of a spot welder, and then show you how to build one from a microwave oven transformer.</p>
<p><span id="more-11565"></span> A spot welder&#8217;s electrodes serve at least three functions. They transfer electrical energy to the material while also holding it together; this also controls resistance. The greater the pinch force the less the resistance, which results in decreased resistive heating. A lesser pinch force results in increased resistive heating. The electrodes also conduct heat away from the material, while in the off cycles, helping to cool and temper the weld. A resistive spot weld is commonly referred to as a &#8216;nugget&#8217;.  Spot welders are generally confined to ferrous materials which somewhat limits their application range. Most produce a weld with low voltage and high current. The welder in this How-to operates from a secondary of 3vac. The primary is 120vac line voltage that should be treated with respect. The low voltage secondary makes the welder very safe, so the electrical shock hazard from the electrode is virtually non-existent. There is however the risk of burn due to the high temperatures as with any welder.</p>
<p>This particular welder is not intended to weld a body panel on your 1966 Jeep; it will not work well on material heavier than 20gauge sheet metal. The intended use is for small projects, for it is not capable of continuous operation. Possible uses are as follows: Welding electrode material for <a href="http://hackaday.com/?s=hydrogen+fuel" target="_blank">electrolysis cells</a>. Working with the fine <a href="http://hackaday.com/2008/01/07/how-to-make-a-vacuum-tube/" target="_blank">components of a vacuum tube</a>. Building a light weight frame for a small robotic platform.  Most of us have enough parts laying around to build a spot welder. If you have a <a href="http://www.kronjaeger.com/hv/hv/src/mot/index.html" target="_blank">microwave oven transformer (MOT)</a> laying around, then you are half way there. On a related note, we had covered a <a href="http://hackaday.com/2006/09/21/microwave-oven-arc-welder/" target="_blank">microwave oven arc welder</a> in 2006.</p>
<p><img class="alignnone size-full wp-image-11608" title="Materials needed" src="http://hackadaycom.files.wordpress.com/2009/06/100_03641.jpg?w=450&#038;h=337" alt="Materials needed" width="450" height="337" /></p>
<p>We also needed some heavy gauge copper wire. We used about four feet of 4AWG wire to build the spot welder in the photo. Other materials included scrap 2&#215;6, 2&#215;2, two copper screw type lugs, two copper welding cable lugs, two MIG welder tips, two 4&#8243; x 3/4&#8243; zinc plated corner braces, drywall screws, and three washers.</p>
<p><img class="alignnone size-full wp-image-11609" title="MOT" src="http://hackadaycom.files.wordpress.com/2009/06/100_03682.jpg?w=450&#038;h=337" alt="MOT" width="450" height="337" /></p>
<p>Pictured above is a working MOT. The first thing we had to do was remove the secondary coils. Namely the high voltage winding, and the low voltage winding. We used an angle grinder with cut off wheel while being careful not to cut the primary winding.</p>
<p><img class="alignnone size-full wp-image-11610" title="Removing secondary" src="http://hackadaycom.files.wordpress.com/2009/06/100_03741.jpg?w=450&#038;h=337" alt="Removing secondary" width="450" height="337" /></p>
<p>We cut the secondary flush with the MOT <a href="http://wiki.answers.com/Q/What_is_the_purpose_of_laminating_an_iron_core_in_transformers" target="_blank">laminate core</a>. Both sides of the MOT should be cut. Inspect the MOT for signs that the laminate has been welded. We have found that welded MOTs can handle a little more abuse than their sealed only counter parts. If possible try to keep the core insulation intact, where the secondary will be wound. Though it is not a show stopper if the insulation becomes damaged. The insulation makes it a little easier to wrap the heavy gauge secondary.</p>
<p><img class="alignnone size-full wp-image-11611" title="Removed secondary" src="http://hackadaycom.files.wordpress.com/2009/06/100_03791.jpg?w=450&#038;h=337" alt="Removed secondary" width="450" height="337" /></p>
<p>After removal of the secondary we had something that resembles the above photo. If the magnetic shunt material falls out be sure to replace it as it was before. The shunt keeps the core from transferring too much power to the secondary. A magnetic ballast if you will. The shunt acts to control the saturation of the core. A brute force project like this relies on such a shunt for proper operation.</p>
<p><img class="alignnone size-full wp-image-11614" title="Winding the secondary" src="http://hackadaycom.files.wordpress.com/2009/06/100_03821.jpg?w=450&#038;h=337" alt="Winding the secondary" width="450" height="337" /></p>
<p><a href="http://www.geocities.com/CapeCanaveral/Campus/5361/chlorate/winding.html" target="_blank">Rewinding a MOT</a> with 4AWG is no walk in the park. If you&#8217;ve damaged the core insulators, we suggest wrapping a layer of electrical tape in their place. This will help to avoid damaging the insulation on the wire as it is pulled through the core.  Our experience is that 3-4 windings is plenty. After all, this spot welder relies on high current and marginal resistance. Not high voltage.</p>
<p><img class="alignnone size-full wp-image-11616" title="Helical winding" src="http://hackadaycom.files.wordpress.com/2009/06/100_03851.jpg?w=450&#038;h=337" alt="Helical winding" width="450" height="337" /></p>
<p>We were careful to ensure that the secondary <a href="http://en.wikipedia.org/wiki/Helix" target="_blank">coil was wrapped in a helical</a> manner to complete the secondary.</p>
<p><img class="alignnone size-full wp-image-11617" title="Mount the MOT and 2x2 on 2x6 base" src="http://hackadaycom.files.wordpress.com/2009/06/100_03882.jpg?w=450&#038;h=337" alt="Mount the MOT and 2x2 on 2x6 base" width="450" height="337" /></p>
<p>We mounted the MOT and 2&#215;2 to the 2&#215;6 base. This particular build used 12&#8243; 2&#215;6 with two 7&#8243; 2&#215;2. These dimensions may or may not work depending on the physical size of your MOT. The only critical part here is keeping the wire length as short as possible.</p>
<p><img class="alignnone size-full wp-image-11618" title="Attch the upper jaw" src="http://hackadaycom.files.wordpress.com/2009/06/100_03911.jpg?w=450&#038;h=337" alt="Attch the upper jaw" width="450" height="337" /></p>
<p>After the lower jaw was mounted, we also attached the corner braces. It was found that a spare piece of 2&#215;2 as a shim worked well to align the upper and lower jaw. After the upper jaw was aligned we attached it to the corner braces with screws. This formed the hinged portion of the jaw.</p>
<p><img class="alignnone size-full wp-image-11619" title="Assemble electrode" src="http://hackadaycom.files.wordpress.com/2009/06/100_03941.jpg?w=450&#038;h=337" alt="Assemble electrode" width="450" height="337" /></p>
<p>The picture above shows the MIG welder tip and the screw type copper lug. This is an improvement from an earlier model we had built. Initially, we used copper tubing with a hole and a piece of 6AWG grounding wire serving as the welding electrode. The grounding wire was held in place by a screw that threaded inside the copper tube perpendicular to the electrode. It was very crude, but it worked. This new method is much more practical.</p>
<p><img class="alignnone size-full wp-image-11630" title="Assembled electrodes" src="http://hackadaycom.files.wordpress.com/2009/06/100_03962.jpg?w=446&#038;h=169" alt="Assembled electrodes" width="446" height="169" /></p>
<p>Here are the two electrodes ready to be fixed to the lower and upper jaws. We double checked the MIG electrodes to make sure they were tight. A loose connection will take heat away from the <a href="http://www.naun.org/journals/mechanics/m-20.pdf" target="_blank">weld nugget</a>.</p>
<p><img class="alignnone size-full wp-image-11621" title="Align electrodes with jaws" src="http://hackadaycom.files.wordpress.com/2009/06/100_03971.jpg?w=450&#038;h=600" alt="Align electrodes with jaws" width="450" height="600" /></p>
<p>Evenly aligning the welding electrodes, we were careful to keep the upper jaw in the natural position where it was mounted. This maintained a flat contact area for the welding electrodes. After we were sure that the electrodes had been properly aligned, the jaws were marked. We then drilled a small hole. Since we mounted with the grain of the 2&#215;2 the holes helped to protect from splitting the 2&#215;2.</p>
<p><img class="alignnone size-full wp-image-11622" title="Attach electrodes to jaws" src="http://hackadaycom.files.wordpress.com/2009/06/100_04001.jpg?w=450&#038;h=337" alt="Attach electrodes to jaws" width="450" height="337" /></p>
<p>With the electrodes mounted, we cut the wire to proper length. We never cut the exact amount we need. We always cut more than we need. This rule of thumb should apply to all electrical wiring. After all it is much easier to cut off excess than wrap a new secondary.</p>
<p><img class="alignnone size-full wp-image-11623" title="Prepare wires for crimp lugs" src="http://hackadaycom.files.wordpress.com/2009/06/100_04021.jpg?w=450&#038;h=337" alt="Prepare wires for crimp lugs" width="450" height="337" /></p>
<p>We bent the wires in to the approximate positions in which they were to be assembled and stripped the wire in preparation for the crimp type welding lugs. It is a good idea to strip more than is needed here as well. Simply cut off excess after sizing up the lugs depth. Never crimp insulation with the lug. This will create a potential problem area due to the loss of conduction.</p>
<p><img class="alignnone size-full wp-image-11624" title="Wires with crimped lugs" src="http://hackadaycom.files.wordpress.com/2009/06/100_04041.jpg?w=450&#038;h=337" alt="Wires with crimped lugs" width="450" height="337" /></p>
<p>Using a good non insulation crimp tool to secure the wire. We inspected the crimp and gave it the tug test. Simply tug on the wire if it is loose it will pull out. It if doesn&#8217;t pull out then an adequate crimp suitable for high current has been made.</p>
<p><img class="alignnone size-full wp-image-11625" title="Align electrodes" src="http://hackadaycom.files.wordpress.com/2009/06/100_04061.jpg?w=450&#038;h=337" alt="Align electrodes" width="450" height="337" /></p>
<p>The crimped wires were attached to the welding electrodes with screws. We were careful not to over tighten the screws. If a drywall screw had stripped out of the wood, we would have had to use a larger wood screw in its place. After both welding electrodes were fixed to the jaws, we aligned the electrodes. Using pliers we bent the electrodes so that they contacted each other evenly. The electrodes should be fairly close already since they were aligned before drilling.</p>
<p><img class="alignnone size-full wp-image-11626" title="Test secondary voltage" src="http://hackadaycom.files.wordpress.com/2009/06/100_04091.jpg?w=450&#038;h=337" alt="Test secondary voltage" width="450" height="337" /></p>
<p>We opened the jaws and wired the primary to an electrical cord and then tested the secondary. If the breaker trips, check for the following:</p>
<ol>
<li>The secondary is  shorted (the jaws are closed)</li>
<li>The magnetic shunts are missing or not properly reinstalled</li>
<li>Faulty line wiring to primary or shorted primary</li>
<li>Too much load on the circuit of test or undersized breaker</li>
</ol>
<p>We observed proper electrical wiring practices. It is also stressed that this is a welder and it should have a dedicated circuit as any other welder would have.</p>
<p><img class="alignnone size-full wp-image-11627" title="Check electrode and material alignment" src="http://hackadaycom.files.wordpress.com/2009/06/100_04101.jpg?w=450&#038;h=337" alt="Check electrode and material alignment" width="450" height="337" /></p>
<p>With the power physically disconnected we verified the welding electrode alignment with the material we intended to work on. Before connecting the power and performing an initial weld, we observed a few safety guidelines.  This is a welder and will produce very high temperatures. Keep fingers away from the welding electrodes. Allow the material to cool prior to handling. Always wear eye protection. You may be interested in reading about <a href="http://www.robot-welding.com/Welding_parameters.htm" target="_blank">spot welder parameters</a>. There&#8217;s also the problem of combustible materials&#8230;</p>
<p><img class="alignnone size-full wp-image-11649" title="Compaq screen support frame" src="http://hackadaycom.files.wordpress.com/2009/06/100_0413.jpg?w=450&#038;h=337" alt="Compaq screen support frame" width="450" height="337" /></p>
<p>This Compaq used very thin aluminum to support the screen and connect the hinges. The metal broke and destroyed most of the lower plastic. We were able to make new supports from 22AWG stainless steel sheet metal. All the welds were made using the spot welder with a special power controller. The power controller will be covered in another how-to.</p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2009/06/23/how-to-build-your-own-spot-welder/"><img src="http://img.youtube.com/vi/VG1xVNpm7k8/2.jpg" alt="" /></a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/11565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/11565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/11565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/11565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/11565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/11565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/11565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/11565/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/11565/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/11565/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=11565&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/06/23/how-to-build-your-own-spot-welder/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">2s2t2e</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04111.jpg" medium="image">
			<media:title type="html">Welding stainless steel</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03641.jpg" medium="image">
			<media:title type="html">Materials needed</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03682.jpg" medium="image">
			<media:title type="html">MOT</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03741.jpg" medium="image">
			<media:title type="html">Removing secondary</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03791.jpg" medium="image">
			<media:title type="html">Removed secondary</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03821.jpg" medium="image">
			<media:title type="html">Winding the secondary</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03851.jpg" medium="image">
			<media:title type="html">Helical winding</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03882.jpg" medium="image">
			<media:title type="html">Mount the MOT and 2x2 on 2x6 base</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03911.jpg" medium="image">
			<media:title type="html">Attch the upper jaw</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03941.jpg" medium="image">
			<media:title type="html">Assemble electrode</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03962.jpg" medium="image">
			<media:title type="html">Assembled electrodes</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_03971.jpg" medium="image">
			<media:title type="html">Align electrodes with jaws</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04001.jpg" medium="image">
			<media:title type="html">Attach electrodes to jaws</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04021.jpg" medium="image">
			<media:title type="html">Prepare wires for crimp lugs</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04041.jpg" medium="image">
			<media:title type="html">Wires with crimped lugs</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04061.jpg" medium="image">
			<media:title type="html">Align electrodes</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04091.jpg" medium="image">
			<media:title type="html">Test secondary voltage</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_04101.jpg" medium="image">
			<media:title type="html">Check electrode and material alignment</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/100_0413.jpg" medium="image">
			<media:title type="html">Compaq screen support frame</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/VG1xVNpm7k8/2.jpg" medium="image" />
	</item>
		<item>
		<title>How-to: Fix your stupid internet</title>
		<link>http://hackaday.com/2009/04/01/how-to-fix-your-stupid-internet/</link>
		<comments>http://hackaday.com/2009/04/01/how-to-fix-your-stupid-internet/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:41:50 +0000</pubDate>
		<dc:creator>Eliot Phillips</dc:creator>
				<category><![CDATA[classic hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[april fools]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[lolinternet]]></category>
		<category><![CDATA[omgponies]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=10063</guid>
		<description><![CDATA[
Dear Hack a Day,
Websites keep publishing poorly executed jokes today; how can I fix this?
We&#8217;ve been getting a lot of questions on the tip line like the one above, so we put together this one-step illustrated how-to. If you&#8217;re not the physical labor type, you can use [Steve Lambert]&#8217;s SelfControl.
[Related: Hack a Day goes autonomous, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10063&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="aligncenter size-full wp-image-10064" title="aprilfools-1" src="http://hackadaycom.files.wordpress.com/2009/04/aprilfools-1.jpg?w=450&#038;h=281" alt="aprilfools-1" width="450" height="281" /></p>
<blockquote><p>Dear Hack a Day,<br />
Websites keep publishing poorly executed jokes today; how can I fix this?</p></blockquote>
<p>We&#8217;ve been getting a lot of questions on the <a title="Contact Hack a Day Hack a Day" href="http://hackaday.com/contact-hack-a-day/">tip line</a> like the one above, so we put together this one-step illustrated how-to. If you&#8217;re not the physical labor type, you can use [Steve Lambert]&#8217;s <a title="Steve Lambert » SelfControl" href="http://visitsteve.com/work/selfcontrol/">SelfControl</a>.</p>
<p>[Related: <a title="Hack a Day goes autonomous  - Hack a Day" href="http://hackaday.com/2006/04/01/hack-a-day-goes-autonomous/">Hack a Day goes autonomous</a>, <a title="We’re giving up  - Hack a Day" href="http://hackaday.com/2007/04/01/were-giving-up/">Craft a Day</a>]</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/10063/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/10063/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/10063/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/10063/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/10063/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/10063/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/10063/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/10063/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/10063/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/10063/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=10063&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/04/01/how-to-fix-your-stupid-internet/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">RobotSkirts</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/04/aprilfools-1.jpg" medium="image">
			<media:title type="html">aprilfools-1</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Bus Pirate v1, improved universal serial interface</title>
		<link>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/</link>
		<comments>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 02:43:56 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[interface tools]]></category>
		<category><![CDATA[jtag]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[pc at keyboard]]></category>
		<category><![CDATA[scancode]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[uart]]></category>
		<category><![CDATA[universal interface]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=7361</guid>
		<description><![CDATA[
We use the Bus Pirate to interface a new chip without writing code or designing a PCB. Based on your feedback, and our experience using the original Bus Pirate to demonstrate various parts, we updated the design with new features and cheaper components.
There&#8217;s also a firmware update for both Bus Pirate hardware versions, with bug [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7361&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-8068" title="front450a" src="http://hackadaycom.files.wordpress.com/2009/01/front450a.jpg?w=450&#038;h=269" alt="front450a" width="450" height="269" /></p>
<p>We use the Bus Pirate to interface a new chip without writing code or designing a PCB. Based on your feedback, and our experience using <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">the original Bus Pirate</a> to demonstrate various <a href="http://hackaday.com/category/parts/">parts</a>, we updated the design with new features and cheaper components.</p>
<p>There&#8217;s also a firmware update for both Bus Pirate hardware versions, with bug fixes, and a PC AT keyboard decoder. Check out the new <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>, and browse the Bus Pirate source code in our <a href="http://code.google.com/p/the-bus-pirate/source/browse/">Google code SVN repository</a>.</p>
<p>We cover the design updates and interface a digital to analog converter below.</p>
<p><span id="more-7361"></span></p>
<p><strong>Concept overview</strong></p>
<p><strong><img class="alignnone size-full wp-image-8067" title="overview-diagram1" src="http://hackadaycom.files.wordpress.com/2009/01/overview-diagram1.png?w=450&#038;h=212" alt="overview-diagram1" width="450" height="212" /><br />
</strong></p>
<p>The Bus Pirate started as a collection of code fragments we used to test new chips without endless compile-program-run development cycles. We released it in a how-to and used it to demonstrate a bunch of serial interface ICs in our <a href="http://hackadaycom.wordpress.com/category/parts/">parts posts</a>. This article introduces an updated design with new features and a bunch of improvements.</p>
<ul>
<li>Surface mount design</li>
<li>Pull-up resistors on all bus lines with external voltage source</li>
<li>Software resettable 3.3volt and 5volt power supplies</li>
<li>Voltage monitoring of all power supplies</li>
<li>An external voltage measurement probe</li>
<li>Cheaper parts</li>
</ul>
<p><img class="alignnone size-full wp-image-7996" title="top" src="http://hackadaycom.files.wordpress.com/2009/01/top.jpg?w=450&#038;h=254" alt="top" width="450" height="254" /></p>
<p><strong>Hardware</strong></p>
<p><strong><img class="alignnone size-full wp-image-8001" title="cct-450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-450.jpg?w=450&#038;h=140" alt="cct-450" width="450" height="140" /></strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/cct1.png">Click for a full size schematic image</a><strong> </strong>(PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de/">Cadsoft Eagle</a>. All the files for this project are included in the project archive linked at the end of the article.</p>
<p><em>Microcontroller</em></p>
<p>We used a Microchip <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002</a> 28pin SOIC microcontroller (IC1) in this project. The power pins have 0.1uF bypass capacitors to ground (C1,2). The 2.5volt internal regulator requires a 10uF tantalum capacitor (C20). The chip is programmed through a five pin header (ICSP). A 2K pull-up resistor (R1) is required for the MCLR function on pin 1. Read more about this chip in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F introduction</a>.</p>
<p><em>RS-232 transceiver<br />
</em></p>
<p>An inexpensive <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1068">MAX3232CSE</a> RS232 transceiver (IC2) interfaces the PIC to a PC serial port. This chip replaces the expensive through-hole <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a> used in the previous version of the Bus Pirate. The serial interface will work with a USB-&gt;serial adapter.</p>
<p><em>Bus pull-up resistors</em></p>
<p><em><img class="alignnone size-full wp-image-8006" title="cct-pu450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-pu450.png?w=450&#038;h=137" alt="cct-pu450" width="450" height="137" /><br />
</em></p>
<p>The original Bus Pirate has 3.3volt pull-up resistors on 2 pins, but most of our tests required additional external resistors. The updated design has pull-up resistors (R20-23) on the three main bus signals (data in, data out, clock) and the chip select (CS) pin.</p>
<p>A row of jumpers (SV5) connects each resistor to an external voltage supplied through the Vext terminal (X4). Through-hole resistors are used like jumper-wires to make the PCB easier to etch at home.</p>
<p>We couldn&#8217;t find an elegant way to control an arbitrary voltage pull-up resistor array from a 3.3volt microcontroller. If you have any ideas, please share them in the comments.</p>
<p><em>Power supply</em></p>
<p>VR1 is a 3.3volt supply for the microcontroller and RS232 transceiver. VR2 is a 5volt supply. Both require two 0.1uF bypass capacitors (C3-C6). J1 is a power supply jack for a common <a href="http://en.wikipedia.org/wiki/DC_connector">2.1mm DC barrel plug</a>. 7-10volts DC is probably the ideal power supply range.</p>
<p><img class="alignnone size-full wp-image-8008" title="cct-vr4" src="http://hackadaycom.files.wordpress.com/2009/01/cct-vr4.png?w=450&#038;h=230" alt="cct-vr4" width="450" height="230" /></p>
<p>The original Bus Pirate had dual power supplies, 3.3volts and 5volts, so most ICs could be interfaced without an additional power supply. A major annoyance was the lack of a power reset for connected chips. If a misconfigured IC needed to be power-cycled, we had to disconnect a wire. We got so tired of this routine that we added a software controlled reset to the updated design.</p>
<p>VR3 (3.3volts) and VR4 (5volts) are TI <a href="http://focus.ti.com/docs/prod/folders/print/tps79650.html">TPS796XX</a> voltage regulators with an enable switch. A high level on pin 1 enables the regulator. A pull-down resistor (R13,R12) ensures that the regulators are off when the PIC isn&#8217;t actively driving the line, such as during power-up initialization. The datasheet specifies a hefty capacitor on the input (C23, C21) and output (C24, C22) pins, we used the same 10uF tantalum we use everywhere. An additional, optional, 0.1uF capacitor (C12,C11) can improve regulation.</p>
<p>The switchable regulators are powered by VR2, a 5volt supply.  We did this because the maximum input for VR3 and VR4 is 6volts, leaving the device with a narrow 5.2-6volt power supply range. VR2 will work well above 10volts, and provides an adequate supply for the other regulators.</p>
<p>VR3 (3.3volts) has plenty of headroom to operate from a 5volt supply. VR4 (5volts) will lose about 0.2volts, but 4.8volts remains well within the acceptable range for most 5volt chips. In practice, and under light loads, we see less than 0.1volts drop-out from VR4.</p>
<p><em>Voltage monitoring</em></p>
<p><em><img class="alignnone size-full wp-image-8003" title="cct-adcin" src="http://hackadaycom.files.wordpress.com/2009/01/cct-adcin.png?w=373&#038;h=76" alt="cct-adcin" width="373" height="76" /><br />
</em></p>
<p>Voltage monitoring is a new feature we&#8217;re really excited about. Has your project ever mysteriously stopped responding because of an accidental short circuit? The Bus Pirate&#8217;s power supplies are equipped with voltage monitoring that can detect a change in power levels.</p>
<p>Each monitored signal is connected to an <a href="http://en.wikipedia.org/wiki/Analog-to-digital_converter">analog to digital converter</a> (ADC) through a resistor voltage divider. Two 10K resistors (R10,R11 above) divide the input voltage in half, making it possible to measure up to 6.6volts with the 3.3volt PIC microcontroller.</p>
<p>The Bus Pirate has four voltage monitors. The 3.3volt and 5volt power supplies are monitored, as is the external voltage fed to the pull-up resistors. A fourth monitor is connected to pin 9 of the output header to make a voltage probe.</p>
<p><strong>PCB</strong></p>
<p><strong><img class="alignnone size-large wp-image-8134" title="brd450alt" src="http://hackadaycom.files.wordpress.com/2009/01/brd450alt.png?w=450&#038;h=330" alt="brd450alt" width="450" height="330" /><br />
</strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/brd.png">Click for a full size placement diagram</a> (PNG). The board is a quasi single-sided design, we etched ours in the lab on a single-sided photo-resist PCB. At the top, near C13, two jumper wires meet at a single via; we soldered one jumper wire to the other on the back of the board.</p>
<p><em>Part list</em></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Part</td>
<td>Value</td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=V/yyTCAHA4D/h5r3CRQDtA==">PIC24FJ64GA002</a> (SOIC)</td>
</tr>
<tr>
<td>IC2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=SN75C3232EDvirtualkey59500000virtualkey595-SN75C3232ED">MAX3232CSE</a> (SOIC-N)</td>
</tr>
<tr>
<td>VR1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S33CTRvirtualkey51120000virtualkey511-LD1117S33C">LD1117S33</a> 3.3volt regulator (SOT223)</td>
</tr>
<tr>
<td>VR2</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S50TRvirtualkey51120000virtualkey511-LD1117S50">LD1117s50</a> 5volt regulator (SOT223)</td>
</tr>
<tr>
<td>VR3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMsGz1a6aV8DcPXeWoVS0Fnzr3zi8%252bAr99Q%3d">TPS79633</a> 3.3volt regulator (SOT223-6)</td>
</tr>
<tr>
<td>VR4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=TPS79650DCQRvirtualkey59500000virtualkey595-TPS79650DCQR">TPS79650</a> 5volt regulator (SOT223-6)</td>
</tr>
<tr>
<td>C1-13</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C20-24</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=293D106X96R3A2TE3virtualkey61320000virtualkey74-293D106X96R3A2TE3">10uF tantalum capacitor</a> (SMC A)</td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=jBethxrBxZb5NLDetw123g%3d%3d">2000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R2,3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=2BMLUTrrT4P7Xm58YbKmPg==">390 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R4-13</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMtlubZbdhIBIADEshVnklemK%252bhrLNEuMe8%3d">10000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R20-23</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8tsW7z%2fc78pkoLNVKn1xoQ%3d%3d">2.2K</a>-<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMtMTfExsNintTsTnthYiOMx%2fND7UkWzrMM%3d">10K</a> ohm resistor (through-hole)</td>
</tr>
<tr>
<td>LED1,2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8xMK%2bwDsXhcfMNb/YnnwLQ==">2.1mm power jack</a></td>
</tr>
<tr>
<td>X2,X4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=wjes1ZhMGKfGv3iS94oZ%252bQ%3d%3d">screw clamp (2 terminals)</a> *untested</td>
</tr>
<tr>
<td>X3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d"></a><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d">db9 female serial port connector</a> *untested</td>
</tr>
<tr>
<td>ICSP</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header, straight</a></td>
</tr>
<tr>
<td>SV4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header</a> or shrouded header</td>
</tr>
<tr>
<td>SV5</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header, straight</a></td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>.</p>
<p>The latest firmware is posted on the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>. The latest source is in our <a href="http://code.google.com/p/the-bus-pirate/source/checkout">Google Code SVN repository</a>.</p>
<p><strong>Using it</strong></p>
<p><strong><img class="alignnone size-full wp-image-8004" title="cct-pinout450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-pinout450.png?w=450&#038;h=179" alt="cct-pinout450" width="450" height="179" /><br />
</strong></p>
<p>The diagram above shows the Bus Pirate pinout.</p>
<p>We made a cable with alligator clips on the end, and added labels to each wire so we don&#8217;t have to refer to this table every time we interface a new chip.</p>
<p>If you know of any cool connectors or cables, please link to them in the comments.</p>
<p><img class="alignnone size-full wp-image-8066" title="ltc2640" src="http://hackadaycom.files.wordpress.com/2009/01/ltc2640.jpg?w=450&#038;h=354" alt="ltc2640" width="450" height="354" /></p>
<p><em>LTC2640 SPI digital to analog voltage converter</em></p>
<p>The Linear Technology <a href="http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1155,C1005,C1156,P85250">LTC2640-LZ8</a> is an 8bit <a href="http://en.wikipedia.org/wiki/Digital-to-analog_converter">digital to analog converter</a> (DAC) programmed over <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a>. A DAC is essentially a programmable voltage divider. They&#8217;re useful for recreating waveforms, such as audio signals. An 8bit DAC has 255 even intervals between 0 and the reference voltage, the L part we used has an internal 2.5volt reference.</p>
<p>The LTC2640 only comes in a small SOT223-8 package, so we made a breadboard adapter in the profile of a DIP-8 chip.  Our LTC2640 footprint is included in the project archive attached at the end of this article.</p>
<p><img class="alignnone size-large wp-image-8019" title="ltc2640450" src="http://hackadaycom.files.wordpress.com/2009/01/ltc2640450.png?w=450&#038;h=218" alt="ltc2640450" width="450" height="218" /></p>
<p>The schematic above shows our test circuit for the LTC2640. It requires a 2.7-5volt power supply, we used the Bus Pirate&#8217;s 3.3volt supply. C1 is a bypass capacitor between the power pin and ground. Pin 8 is an active-low reset pin, tie it high for normal operation. Pin 7 is the DAC output, connect the Bus Pirate voltage measurement probe (ADC) here.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>LTC2640 (pin #)</strong></td>
</tr>
<tr>
<td>MOSI</td>
<td>SDI (3)</td>
</tr>
<tr>
<td>CLOCK</td>
<td>SCK (2)</td>
</tr>
<tr>
<td>CS</td>
<td>CS/LD (1)</td>
</tr>
<tr>
<td>ADC</td>
<td>VOUT (7)</td>
</tr>
<tr>
<td>+3.3volts</td>
<td>CLR (8 )</td>
</tr>
<tr>
<td>+3.3volts</td>
<td>VDD (5)</td>
</tr>
<tr>
<td>GND</td>
<td>GND (4)</td>
</tr>
</tbody>
</table>
<p>We connected the Bus Pirate to the LTC2640 as shown in the table. The LTC2640 doesn&#8217;t have a data output pin, this SPI connection remains unused.</p>
<p>The Bus Pirate&#8217;s hardware SPI library and software RAW3WIRE library are compatible with the LTC2640&#8217;s SPI interface. We used the SPI library; if you use the RAW3WIRE library be sure to choose <em>normal pin output</em>.</p>
<blockquote><p>HiZ&gt;m<strong>&lt;&#8211;select mode</strong><br />
1. HiZ<br />
2. 1-WIRE<br />
3. UART<br />
4. I2C<br />
5. SPI<br />
6. JTAG<br />
7. RAW2WIRE<br />
8. RAW3WIRE<br />
9. PC AT KEYBOARD<br />
MODE&gt;5<strong>&lt;&#8211;SPI or RAW3WIRE</strong><br />
900 MODE SET<br />
Set speed:<br />
1. 30KHz<br />
2. 125KHz<br />
3. 250KHz<br />
4. 1MHz<br />
SPEED&gt;1 <strong>&lt;&#8211;test at low speed</strong><br />
&#8230;<br />
102 SPI READY<br />
SPI&gt;</p></blockquote>
<p>Press M for the Bus Pirate mode menu, choose 5 for SPI mode. There are a bunch of configuration options for the SPI module, use the default options for all of them. After SPI mode is ready we need to configure the power supply.</p>
<blockquote><p>SPI&gt;p<strong>&lt;&#8211;power supply setup</strong><br />
W/w toggles 3.3volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;2<strong>&lt;&#8211;use 3.3volt supply</strong><br />
W/w toggles 5volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;1<strong>&lt;&#8211;don&#8217;t use 5volt supply</strong><br />
9xx SUPPLY CONFIGURED, USE W/w TO TOGGLE<br />
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 0.0 | VPULLUP: 0.0 |<br />
SPI&gt;</p></blockquote>
<p>p opens the Bus Pirate power supply menu. We use the 3.3volt supply but not the 5volt supply. The voltage monitor verifies that the power supplies are off.</p>
<blockquote><p>SPI&gt;W<strong>&lt;&#8211;capital W (<a href="http://www.w3.org/TR/CSS2/text.html#caps-prop">silly CSS</a>) enables power supply</strong><br />
9xx 3.3VOLT SUPPLY ON<br />
SPI&gt;v<strong>&lt;&#8211;voltage monitor</strong><br />
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 3.3 | VPULLUP: 0.0 |<br />
SPI&gt;</p></blockquote>
<p>Capital &#8216;W&#8217; enables any power supplies selected in the previous menu, a small &#8216;w&#8217; disables them. V displays the supply voltage monitor, which now shows 3.3volts output from the 3.3volt supply.</p>
<p>Now that configuration is finished, we can send commands to the LTC2640 over the SPI bus. The LTC2640 has a 24bit (3byte) interface protocol. The first byte is a command, followed by two data bytes. The LTC2640 is available in 8,10, and 12bit versions; the 8bit version uses the first byte to set the DAC value, and ignores the second byte.</p>
<blockquote><p>SPI&gt;[0b00110000 255 0]<strong>&lt;&#8211;set DAC to full</strong><br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0xFF<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
SPI&gt;</p></blockquote>
<p>Every SPI command begins by enabling the chip select pin ([). The first byte is the command to update the DAC (0b00110000), followed by the value to output (255), and a third byte that's ignored (0). The command ends by disabling chip select (]).</p>
<p>We used an 8bit DAC with 255 even voltage steps, output set to 255 is 100%. We can use the Bus Pirate voltage probe to measure the output.</p>
<blockquote><p>SPI&gt;d<strong>&lt;&#8211;measure voltage</strong><br />
9xx VOLTAGE PROBE: 2.5VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>D triggers a voltage measurement. The DAC output voltage is 100% (255/255) of the internal reference, 2.5volts.</p>
<blockquote><p>SPI&gt;[0b00110000 0 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>The same command with a DAC value of 0 outputs 0% (0/255) of 2.5volts; 0volts.</p>
<blockquote><p>SPI&gt;[0b00110000 128 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0&#215;80<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 1.2VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>A DAC value of 128 is about 50% (128/255) of the reference voltage, 1.2volts.</p>
<blockquote><p>SPI&gt;[0b01000000 0 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;40<strong>&lt;&#8211;power down command</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;DAC off</strong><br />
SPI&gt;</p></blockquote>
<p>The LTC2640 has a low power mode, triggered by the command 0b01000000 and two bytes that are ignored. After the power down command we can verify that there&#8217;s output from the DAC. Write any DAC value to exit low power mode.</p>
<p><strong>Taking it further</strong></p>
<p>What&#8217;s the next step for the Bus Pirate? We&#8217;ll eventually make a final update to the design that includes USB on a professionally made, double-sided PCB. Power supply indicator LEDs were slated for this version, but didn&#8217;t get included. It would also be handy to have an AT  keyboard connector for debugging without a PC. Check out the roadmap and wishlists on the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>.</p>
<p><strong>Download: <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v1a.zip">buspirate.v1a.zip</a></strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/7361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7361&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/front450a.jpg" medium="image">
			<media:title type="html">front450a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/overview-diagram1.png" medium="image">
			<media:title type="html">overview-diagram1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/top.jpg" medium="image">
			<media:title type="html">top</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-450.jpg" medium="image">
			<media:title type="html">cct-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-pu450.png" medium="image">
			<media:title type="html">cct-pu450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-vr4.png" medium="image">
			<media:title type="html">cct-vr4</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-adcin.png" medium="image">
			<media:title type="html">cct-adcin</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/brd450alt.png?w=450" medium="image">
			<media:title type="html">brd450alt</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-pinout450.png" medium="image">
			<media:title type="html">cct-pinout450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/ltc2640.jpg" medium="image">
			<media:title type="html">ltc2640</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/ltc2640450.png?w=450" medium="image">
			<media:title type="html">ltc2640450</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Prepare your Eagle designs for manufacture</title>
		<link>http://hackaday.com/2009/01/15/how-to-prepare-your-eagle-designs-for-manufacture/</link>
		<comments>http://hackaday.com/2009/01/15/how-to-prepare-your-eagle-designs-for-manufacture/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 00:11:39 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[cadsofteagle]]></category>
		<category><![CDATA[circuit boards]]></category>
		<category><![CDATA[digital picture frame]]></category>
		<category><![CDATA[diy pcb]]></category>
		<category><![CDATA[eagle]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[gerbers]]></category>
		<category><![CDATA[pcb]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=7678</guid>
		<description><![CDATA[
Cadsoft Eagle is a multi-platform freeware circuit layout program. Lots of open source hardware is designed in Eagle, and it&#8217;s become a hobbyist favorite. We use it for all of our hardware designs.
There are several ways to turn an Eagle design into an actual printed circuit board (PCB). We&#8217;ll show you how to save Eagle [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7678&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-7596" title="back" src="http://hackadaycom.files.wordpress.com/2009/01/back.jpg?w=450&#038;h=290" alt="back" width="450" height="290" /></p>
<p><a href="http://www.cadsoft.de">Cadsoft Eagle</a> is a multi-platform freeware circuit layout program. Lots of open source hardware is designed in Eagle, and it&#8217;s become a hobbyist favorite. We use it for all of our <a href="http://hackaday.com/category/how-to/">hardware designs</a>.</p>
<p>There are several ways to turn an Eagle design into an actual <a href="http://en.wikipedia.org/wiki/Printed_circuit_board">printed circuit board</a> (PCB). We&#8217;ll show you how to save Eagle designs as industry-standard gerber files that are accepted by any PCB manufacturer. You can use the gerbers to order a single prototype, or a full panel.</p>
<p><span id="more-7678"></span><strong>Introduction</strong></p>
<p>Toner transfer is the beginners&#8217; favorite way to make a PCB because the investment in materials is minimal. We&#8217;ve <a href="http://hackaday.com/2008/07/28/how-to-etch-a-single-sided-pcb/">covered toner transfer before</a>. Most PCBs in our <a href="http://hackaday.com/category/how-to/">how-tos</a> are made with the <a href="http://www.ladyada.net/library/pcb/inhouseetch.html">photo-resist process</a>.  The photo process makes nice boards, but requires a bit of equipment; sensitized boards, developer, and an ultra-violet light source.</p>
<p>Some board manufacturers, like <a href="http://www.olimex.com/pcb/index.html">Olimex</a>, make PCBs directly from Eagle .brd files. Most require a minimum order of one <a href="http://en.wikipedia.org/wiki/Eurocard_(printed_circuit_board)">eurocard-sized</a> PCB (100mmx160mm). Good if you need a few boards, expensive for a single experimental prototype.</p>
<p>The cheapest option is to submit <a href="http://en.wikipedia.org/wiki/Gerber_File">gerber files</a> like the professionals. Any PCB manufacturer will accept gerber formatted design files. <a href="http://www.goldphoenixpcb.biz/index.php">Gold Pheonix</a> sells 155square inches of PCB panel for $110. If you&#8217;re looking for something smaller, services like <a href="http://www.batchpcb.com/">BatchPCB</a> and <a href="http://www.pcb-pool.com/ppuk/info.html">PCB-Pool</a> combine small orders and submit them as a full panel. Either way, you&#8217;ll submit gerber files to the board house. This is the process we describe.</p>
<p><strong>Process overview</strong></p>
<ul>
<li>Prepare the design.</li>
<li>Create gerbers, generic files accepted by any PCB fab house.</li>
<li>Verify that the gerbers are correct.</li>
<li>Send the design for production.</li>
</ul>
<p><strong>Prepare the design</strong></p>
<p>We&#8217;re going to walk you through the process of preparing our <a href="http://hackaday.com/2009/01/08/how-to-digital-picture-frame-100-diy/">digital picture frame</a> PCB for production. This design requires a double-sided board with fairly small traces.</p>
<p><img class="alignnone size-full wp-image-7792" title="eagle1" src="http://hackadaycom.files.wordpress.com/2009/01/eagle1.png?w=450&#038;h=355" alt="eagle1" width="450" height="355" /></p>
<p>Download the <a href="http://blog.mahalo.com/hackaday/howto/dpf.v1.zip">project archive</a> (ZIP) from last week. Open the .brd file with the freeware version of <a href="http://www.cadsoft.de/freeware.htm">Cadsoft Eagle</a>.</p>
<p><img class="alignnone size-full wp-image-7793" title="eagle2" src="http://hackadaycom.files.wordpress.com/2009/01/eagle2.png?w=451&#038;h=276" alt="eagle2" width="451" height="276" /></p>
<p>The ground fill is empty when the file opens. Press the ratsnest button (<em>or Tools-&gt;Ratsnest</em>) to fill in the empty polygons.</p>
<p><img class="alignnone size-full wp-image-7799" title="rules" src="http://hackadaycom.files.wordpress.com/2009/01/rules.png?w=450&#038;h=225" alt="rules" width="450" height="225" /></p>
<p>Board manufacturers publish specifications outlining their production capabilities, such as the smallest possible traces, spacing, and drill size. BatchPCB has 8mil <a href="http://www.batchpcb.com/index.php/Faq#What%20are%20the%20PCB%20rules%20and%20limits">minimum traces and spacing</a>, and 20mil minimum holes.</p>
<p><img class="alignnone size-full wp-image-7794" title="pcb-justsayno" src="http://hackadaycom.files.wordpress.com/2009/01/pcb-justsayno.png?w=449&#038;h=290" alt="pcb-justsayno" width="449" height="290" /></p>
<p>Don&#8217;t torture the manufacturer. Just because they advertise 8mils, doesn&#8217;t mean it&#8217;s safe to make every trace 8mils. Slightly larger-than-minimum tolerances will reduce <a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=115">manufacturing errors</a>. The digital picture frame has 8mil traces around the tiny <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=570">LCD connector</a>, shown above. The traces are 8mils only until there&#8217;s enough clearance to use 10mil traces.</p>
<p><img class="alignnone size-full wp-image-7796" title="drc2" src="http://hackadaycom.files.wordpress.com/2009/01/drc2.png?w=450&#038;h=314" alt="drc2" width="450" height="314" /></p>
<p>Use Eagle&#8217;s <em>design rule check</em> to make sure your board doesn&#8217;t exceed the manufacturer&#8217;s production abilities. Download the <a href="http://www.sparkfun.com/tutorial/Eagle-DFM/SparkFun.dru">SparkFun design rules</a> (DRU) for BatchPCB, or the Olimex <a href="http://www.olimex.com/pcb/8mils.dru">8mil</a> (DRU) or <a href="http://www.olimex.com/pcb/10mils.dru">10mil</a> (DRU) design rules.  Click the DRC icon (or, <em>Tools-&gt;DRC</em>) and load the design rule file. Eagle analyzes the design and highlights any areas that violate the design rule parameters.</p>
<p>Correct any errors. Here, the spacing between traces is too close. Sometimes the spacing on a part footprint is too small to be manufactured. Sparkfun&#8217;s default footprint for the  Nokia LCD connector had pad spacing less than 8mils. We <a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=110">edited the part library</a> to make the pads smaller, and the separation larger.</p>
<p><img class="alignnone size-full wp-image-7797" title="smash" src="http://hackadaycom.files.wordpress.com/2009/01/smash.png?w=448&#038;h=269" alt="smash" width="448" height="269" /></p>
<p>It&#8217;s helpful to include part numbers on the printed silkscreen layer. BatchPCB prints a silkscreen on both sides. Be sure to see what your board house offers, some charge extra. Use the smash tool to unlink obscured labels, then move them to a better location.</p>
<p><strong>Create gerber files<br />
</strong></p>
<p>Gerber files are the <a href="http://en.wikipedia.org/wiki/Portable_Document_Format">PDFs</a> of PCBs. Gerber files describe a PCB exactly as it should appear, agnostic of the display hardware. It&#8217;s a final production format that isn&#8217;t intended to be edited. We created our gerber files in Eagle using the procedure outlined in <a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=109">SparkFun&#8217;s Eagle tutorial</a>.</p>
<p><img class="alignnone size-full wp-image-7800" title="cam1" src="http://hackadaycom.files.wordpress.com/2009/01/cam1.png?w=450&#038;h=313" alt="cam1" width="450" height="313" /></p>
<p>The Eagle CAM processor writes gerber files, open it from the menu under <em>File-&gt;CAM processor</em>.</p>
<p>SparkFun has a <a href="http://www.sparkfun.com/tutorial/BeginningEmbedded/9-EaglePCBs/sfe-gerb274x.cam">script</a> (CAM) that configures the CAM processor to make gerber files. Load the CAM script using <em>File-&gt;Open-&gt;Job&#8230;</em></p>
<p><img class="alignnone size-full wp-image-7801" title="cam2" src="http://hackadaycom.files.wordpress.com/2009/01/cam2.png?w=450&#038;h=358" alt="cam2" width="450" height="358" /></p>
<p>By default, SparkFun&#8217;s silkscreen configuration only includes the <em>place</em> layer. Our parts usually have labels on the <em>names</em> and <em>docu</em> layers, activate these layers on the top and bottom silkscreen tabs to add them to the output.</p>
<p>Click <em>Process Job</em> to create the gerber files.</p>
<p><img class="alignnone size-full wp-image-7803" title="files2" src="http://hackadaycom.files.wordpress.com/2009/01/files2.png?w=363&#038;h=221" alt="files2" width="363" height="221" /></p>
<p>The CAM processor creates seven files that we need.</p>
<ul>
<li>Top and bottom copper (.GTL, .GBL)</li>
<li>Top and bottom solder mask (.GTS, .GBS)</li>
<li>Top and bottom silkscreen (.GTO, .GBO)</li>
<li>Drill file, 2.4 leading (.TXT)</li>
</ul>
<p><strong>Verify that the gerbers are correct<br />
</strong></p>
<p>Verify the CAM output in a <a href="http://www.mitsi.com/PCB/free%20viewers.htm">gerber viewer</a> to make sure everything was positioned correctly. We followed SparkFun&#8217;s suggestion and used <a href="http://www.viewplot.com/">Viewplot</a>.</p>
<p><img class="alignnone size-full wp-image-7806" title="24leading" src="http://hackadaycom.files.wordpress.com/2009/01/24leading.png?w=450&#038;h=305" alt="24leading" width="450" height="305" /></p>
<p>Load the seven files with Viewplot. <em>Be sure to specify the drill file type as 2.4 leading.</em></p>
<p><img class="alignnone size-full wp-image-7807" title="viewplot1" src="http://hackadaycom.files.wordpress.com/2009/01/viewplot1.png?w=450&#038;h=350" alt="viewplot1" width="450" height="350" /></p>
<p>Check for errant vias, mirrored layers, and alignment. We&#8217;ve noticed that text added to the silkscreen layer is usually bigger than it was in Eagle. Correct any problems and run the CAM processor again.</p>
<p>When everything looks good, the board is ready for production.</p>
<p><strong>Send the design for production</strong></p>
<p><a href="http://en.wikipedia.org/wiki/ZIP_(file_format)">Zip</a> the seven gerber files and submit them to the PCB fab house. <em>Remember to tell them that the drill file format is 2.4 leading.</em><strong><br />
</strong></p>
<p>BatchPCB is a pooled panel service that sells space by the square inch. Other manufacturers and batch services require you to order <em>at least</em> a full eurocard. We use BatchPCB for prototyping because we never need the extra board space of a full eurocard, and we don&#8217;t mind the average 20day wait.</p>
<p>At BatchPCB, $2.50/square inch buys a PCB with silkscreen on both sides, unlimited vias, and a huge range of drill sizes; stuff that usually costs extra. BatchPCB&#8217;s minimum traces, spacing, and drill are similar to other prototyping services. There&#8217;s a $10 <em>per order </em>setup fee, but an order can include multiple designs. Shipping, even internationally, isn&#8217;t outrageous.</p>
<p>If you need a lot of the same board, look at Gold Phoenix. They manufacture boards for BatchPCB. A 100 square inch panel is $100, a 155 square inch panel is $110.</p>
<p><img class="alignnone size-full wp-image-7789" title="bpcb11" src="http://hackadaycom.files.wordpress.com/2009/01/bpcb11.png?w=450&#038;h=229" alt="bpcb11" width="450" height="229" /></p>
<p>Create an account at <a href="http://www.batchpcb.com/">BatchPCB</a>. Click upload to add a new design. Name the design and upload the zip archive containing the 7 gerber files.</p>
<p><img class="alignnone size-full wp-image-7786" title="bpcb2" src="http://hackadaycom.files.wordpress.com/2009/01/bpcb2.png?w=450&#038;h=276" alt="bpcb2" width="450" height="276" /></p>
<p>Verify that the gerber layers were successfully detected.</p>
<p><img class="alignnone size-full wp-image-7787" title="bpcb3" src="http://hackadaycom.files.wordpress.com/2009/01/bpcb3.png?w=451&#038;h=223" alt="bpcb3" width="451" height="223" /></p>
<p>Verify that the correct size was detected.</p>
<p><img class="alignnone size-full wp-image-7788" title="bpcb4" src="http://hackadaycom.files.wordpress.com/2009/01/bpcb4.png?w=450&#038;h=287" alt="bpcb4" width="450" height="287" /></p>
<p>The BatchPCB rule check &#8216;robot&#8217; will verify that your design meets production standards, and send an e-mail in a few minutes. Since we ran our own rule check prior to sending the design, we can expect that everything will be fine. Click continue and you&#8217;ll have the option to order the board. For more help, see the BatchPCB <a href="http://www.batchpcb.com/index.php/Help">help</a> and <a href="http://www.sparkfun.com/cgi-bin/phpbb/viewforum.php?f=16">support forum</a>.</p>
<p><strong>Receive your boards</strong></p>
<p><strong><img class="alignnone size-full wp-image-7862" title="boards" src="http://hackadaycom.files.wordpress.com/2009/01/boards.jpg?w=450&#038;h=213" alt="boards" width="450" height="213" /><br />
</strong></p>
<p>Boards arrive from BatchPCB in about 20 days. Check the boards for obvious errors before soldering. Some manufacturers test PCBs, BatchPCB doesn&#8217;t. We&#8217;ve ordered PCBs from two of the popular hobbyist board houses, Olimex and BatchPCB, and all the boards have been satisfactory.</p>
<p><strong>Taking it further</strong></p>
<p>It&#8217;s easy to order professional PCBs using gerber files. Why not build that awesome DIY project you&#8217;ve been putting off?</p>
<p>What has been your experience with PCB fab houses?</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/7678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/7678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/7678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/7678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/7678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/7678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/7678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/7678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/7678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/7678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7678&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/01/15/how-to-prepare-your-eagle-designs-for-manufacture/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/back.jpg" medium="image">
			<media:title type="html">back</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/eagle1.png" medium="image">
			<media:title type="html">eagle1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/eagle2.png" medium="image">
			<media:title type="html">eagle2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/rules.png" medium="image">
			<media:title type="html">rules</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/pcb-justsayno.png" medium="image">
			<media:title type="html">pcb-justsayno</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/drc2.png" medium="image">
			<media:title type="html">drc2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/smash.png" medium="image">
			<media:title type="html">smash</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cam1.png" medium="image">
			<media:title type="html">cam1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cam2.png" medium="image">
			<media:title type="html">cam2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/files2.png" medium="image">
			<media:title type="html">files2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/24leading.png" medium="image">
			<media:title type="html">24leading</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/viewplot1.png" medium="image">
			<media:title type="html">viewplot1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/bpcb11.png" medium="image">
			<media:title type="html">bpcb11</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/bpcb2.png" medium="image">
			<media:title type="html">bpcb2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/bpcb3.png" medium="image">
			<media:title type="html">bpcb3</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/bpcb4.png" medium="image">
			<media:title type="html">bpcb4</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/boards.jpg" medium="image">
			<media:title type="html">boards</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Digital picture frame, 100% DIY</title>
		<link>http://hackaday.com/2009/01/08/how-to-digital-picture-frame-100-diy/</link>
		<comments>http://hackaday.com/2009/01/08/how-to-digital-picture-frame-100-diy/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 00:07:04 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[home hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[digital photo frame]]></category>
		<category><![CDATA[digital picture frame]]></category>
		<category><![CDATA[diy electronics]]></category>
		<category><![CDATA[DIY Projects]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=7561</guid>
		<description><![CDATA[
There are a ton of digital picture frame tutorials out there. Most are old laptops with crafty case reconfigurations that fit a photo frame profile.
We set out to build a 100% DIY, scratch-built digital picture frame. Our frame has a 12bit color LCD, gigabytes of storage on common, FAT-formatted microSD cards, and you can build [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7561&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-7597" title="frontii" src="http://hackadaycom.files.wordpress.com/2009/01/frontii.jpg?w=450&#038;h=296" alt="frontii" width="450" height="296" /></p>
<p>There are a ton of <a href="http://www.instructables.com/id/Digital_Picture_Frames/">digital picture frame tutorials</a> out there. Most are old laptops with crafty case reconfigurations that fit a photo frame profile.</p>
<p>We set out to build a 100% DIY, scratch-built digital picture frame. Our frame has a 12bit color LCD, gigabytes of storage on common, FAT-formatted microSD cards, and you can build it at home. We&#8217;ve got the details below.</p>
<p><span id="more-7561"></span><strong>Concept overview</strong></p>
<p><img class="alignnone size-full wp-image-7593" title="overview" src="http://hackadaycom.files.wordpress.com/2009/01/overview.jpg?w=450&#038;h=272" alt="overview" width="450" height="272" /></p>
<p>The bitmap images are stored on common, PC-readable microSD cards. A PIC microcontroller reads the images over a three wire SPI bus. The PIC processes the image data and writes it to a color LCD over a unidirectional, 9bit SPI-like bus. A configuration file on the SD card defines the delay between images.</p>
<p><strong>Hardware</strong></p>
<p><strong><img class="alignnone size-full wp-image-7571" title="cct450" src="http://hackadaycom.files.wordpress.com/2009/01/cct450.png?w=450&#038;h=181" alt="cct450" width="450" height="181" /><br />
</strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/cct.png">Click for a full size schematic image</a> (PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de/">Cadsoft Eagle</a>. All the files for this project are included in the project archive linked at the end of the article.</p>
<p><img class="alignnone size-full wp-image-7596" title="back" src="http://hackadaycom.files.wordpress.com/2009/01/back.jpg?w=450&#038;h=290" alt="back" width="450" height="290" /></p>
<p><em>Microcontroller</em></p>
<p>We used a Microchip <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002</a> 28pin SOIC microcontroller (IC1) in this project. We really like this chip because the peripheral pin select feature lets us put important features on the pins we want; this gives a smaller, simpler, more compact PCB. Each power pin has a 0.1uF bypass capacitor to ground (C1,2). The internal 2.5volt regulator requires a 10uF tantalum capacitor (C12). The chip is programmed through a five pin header, SV1. R1 is a pull-up resistor for the MCLR function on pin 1. Read more about this chip in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F introduction</a>.</p>
<p>A 32.768kHz crystal (Q1) and two 27pF capacitors (C10,11) provide an oscillator for the real-time clock calendar (RTCC). These parts are optional, the initial firmware doesn&#8217;t use them. The RTCC could be used as part of a function that superimposes the current time on the screen. Buttons connected to the programming header could be used to set the time.</p>
<p><em>SD card</em></p>
<p><a href="http://en.wikipedia.org/wiki/MicroSD">MicroSD</a> cards are completely compatible with regular SD cards, microSD cards can be used in an SD card reader/writer with an adapter. We <a href="http://hackaday.com/2008/10/06/parts-microsd-memory-card-holders/">tested several microSD card holders</a>, and settled on one from SparkFun Electronics. The microSD card requires a bypass capacitor between the power pin and ground (C3). An LED indicates microSD read activity, but its also useful for general debugging (LED1, R2).</p>
<p><em>Color LCD 128&#215;128 Nokia knock-off</em></p>
<p>This project is designed around <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=569">SparkFun&#8217;s $20 color LCD panel</a>. The LCD logic runs at 3.3volts and requires a decoupling capacitor (C4). The LED backlight requires a separate 7volt supply, and appears to have an internal current limiter because example designs don&#8217;t use external resistors.</p>
<p>The LCD has a separate input for the 3.3volt display supply. Many report noise in the display if this voltage isn&#8217;t clean. We used a ferrite bead (L1) and 0.1uF capacitor (C5) to filter the supply, and haven&#8217;t experienced any problems. This even worked on a dirty home-etched prototype. The ferrite bead type isn&#8217;t important, we used one left over from our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2">tiny web server project</a>.</p>
<p>The small connector is easy to solder on a professional board with a solder mask, but buy several as insurance. SparkFun has a PCB footprint for this part in their <a href="http://www.opencircuits.com/SFE_Footprint_Library_Eagle">Eagle parts library</a>, but the spacing between the pads is smaller than <a href="http://www.olimex.com/pcb/">Olimex</a> or <a href="http://www.batchpcb.com/">BatchPCB</a> will manufacture. We fudged it by decreasing the pad size to get more space between.  Don&#8217;t depend on the connector to hold the LCD in place, use tape to hold it down. We used sticky-tack to attach the LCD temporarily.</p>
<p>We prototyped an LCD carrier board prior to sending the final design for manufacture. We recommend against using a ground fill under the connector without a solder mask.</p>
<p><em>Power supply</em></p>
<p>A 3.3volt supply, provided by an LD1117S33 (IC2), powers the PIC, microSD card, LCD logic, and LCD display. IC2 requires a 0.1uF bypass capacitor (C6) on the supply side, and a 10uF capacitor (C13) on the output. We used the same tantalum capacitor that we used for the PIC internal regulator.</p>
<p>The LCD backlight is powered by an LM317 adjustable regulator (IC3) configured to 7volts with 240 (R5) and 1100 (R6) ohm resistors. C7 and C8 are 0.1uF bypass capacitors for the LM317.</p>
<p>J1 is a SMD power jack for a common <a href="http://en.wikipedia.org/wiki/DC_connector">2.1mm DC barrel plug</a>. C11 is a 10uF electrolytic capacitor that smooths any lag in the supply voltage. C11 has a maximum 16volt input rating, so the supply voltage is best kept under 12volts. 9-12 volts is probably the idea power supply range.</p>
<p><strong>PCB</strong></p>
<p><strong><img class="alignnone size-full wp-image-7589" title="board4501" src="http://hackadaycom.files.wordpress.com/2009/01/board4501.png?w=451&#038;h=328" alt="board4501" width="451" height="328" /><br />
</strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/board1.png">Click for a full size placement diagram</a> (PNG). L1, C5, and the LCD are on the opposite side. We can&#8217;t prototype two-sided boards in mom&#8217;s basement, so we sent this design to <a href="http://www.batchpcb.com/">BatchPCB</a>. Next week we&#8217;ll show you how we did it.<strong><br />
</strong></p>
<p><em>Partslist</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Part</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=V/yyTCAHA4D/h5r3CRQDtA==">PIC 24FJ64GA002</a> (SOIC)</td>
</tr>
<tr>
<td>IC2</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S33CTRvirtualkey51120000virtualkey511-LD1117S33C">LD1117S33</a> 3.3volt regulator (SOT223)</td>
</tr>
<tr>
<td>IC3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=LM317MDCYRvirtualkey59500000virtualkey595-LM317MDCYR">LM317 adjustable regulator</a> (SOT223)</td>
</tr>
<tr>
<td>U$1</td>
<td><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=569">Color LCD 128&#215;128 Nokia knock-off<br />
</a></td>
</tr>
<tr>
<td>-</td>
<td><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=570">Nokia knock-off connector<br />
</a></td>
</tr>
<tr>
<td>C1-8</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C10,11</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=0ZUpllj3bsbA9A7Pajx4jA%3d%3d">27pF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C12,13</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=293D106X96R3A2TE3virtualkey61320000virtualkey74-293D106X96R3A2TE3">10uF tantalum capacitor</a> (SMCA)</td>
</tr>
<tr>
<td>C14</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=UWF1C100MCL1GBvirtualkey64700000virtualkey647-UWF1C100MCL1GB">10uF electrolytic capacitor</a> (SMD)</td>
</tr>
<tr>
<td>L1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=BLM21BB600SN1Dvirtualkey64800000virtualkey81-BLM21BB600SN1D">ferrite bead</a> (0805)</td>
</tr>
<tr>
<td>LED1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>Q1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=CM200S-32.768KDZF-UTvirtualkey69500000virtualkey695-CM200S-327KF-U">32.768kHz crystal</a></td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=jBethxrBxZb5NLDetw123g%3d%3d">2000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=2BMLUTrrT4P7Xm58YbKmPg==">390 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R5</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=B6sMDe4C%252beDvUrZZzlhhcA%3d%3d">240 ohm resistor </a>(0805)</td>
</tr>
<tr>
<td>R6</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=DZvKvnD5UYWyFJjgnPvJ4g%3d%3d">1100 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>SD1</td>
<td><a href="http://www.sparkfun.com/commerce/product_info.php?products_id=127">microSD card holder</a></td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=b2tC%2fwvzm2TxaPjSsb%252bCzQ%3d%3d">2.1mm power jack</a> (SMD)</td>
</tr>
<tr>
<td>SV1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">0.1” male pin header, right angle</a></td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>. The firmware is included in the project archive at the end of the article.</p>
<p><em>FAT12/16/32 disk library</em></p>
<p><a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1824&amp;appnote=en532040">Microchip&#8217;s FAT 12/16/32 library</a> gives us easy access to files stored on SD cards. We gave a detailed description of this library in our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2">web server on a business card project</a>. If you&#8217;re having trouble reading a card with the library, check that it was formatted in a digital camera or using <a href="http://panasonic.jp/support/global/cs/sd/download/sd_formatter.html">Panasonic&#8217;s SD card formatter</a>.</p>
<p><em>Nokia 6100 LCD driver</em></p>
<p>SparkFun has a <a href="http://www.sparkfun.com/Code/Nokia_LCD_driver.zip">basic 8bit color driver</a> (ZIP) for the Nokia 6100. We ported it to the PIC, and updated it for the 2byte-per-pixel <a href="http://www.idcomm.com/personal/lorenblaney/sparkfun.html">12bit color mode</a>. With a small amount of added complexity, the pixel write rate could easily be increased by using a different 12bit mode that delivers two pixels using 3 bytes.</p>
<p>The LCD uses a 9bit protocol, one bit more than most SPI hardware will handle. The first bit tells the LCD whether the next 8bits are data or a command. On the PIC 24F it&#8217;s impossible to manually bang in the first bit, and then use the SPI peripheral to send the remaining 8bits. We lose direct control of the pins when hardware SPI is enabled. The data entry has to be completely bit-banged, which dramatically reduces the screen refresh rate.</p>
<p><em>Reading Bitmaps</em></p>
<p>There are a ton of <a href="http://en.wikipedia.org/wiki/Windows_bitmap">bitmap formats</a>.  Windows compatibility keeps everyone using the ancient <a href="http://en.wikipedia.org/wiki/Windows_bitmap#Bitmap_information_.28DIB_header.29">Windows v3 format</a>. We created two C structs to read the V3 bitmap data.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Offset</strong></td>
<td><strong>Bytes</strong></td>
<td><strong>Bitmap file header</strong></td>
</tr>
<tr>
<td>0</td>
<td>2</td>
<td>Always 0&#215;42 0&#215;4D (hex for BM)</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>File size (bytes)</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
<td>Reserved, ignored</td>
</tr>
<tr>
<td>8</td>
<td>2</td>
<td>Reserved, ignored</td>
</tr>
<tr>
<td>10</td>
<td>4</td>
<td>Location in file of the first bitmap data</td>
</tr>
</tbody>
</table>
<p>Bitmap files start with a 14byte file header. The first two bytes are the letters &#8216;BM&#8217;, indicating a bitmap.  If the first two bytes are correct, the firmware loads the information header. The last four bytes indicate the beginning of bitmap data, but the current firmware just assumes it will begin at the end of the headers.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Offset</strong></td>
<td><strong>Bytes</strong></td>
<td><strong>Bitmap information header</strong></td>
</tr>
<tr>
<td>14</td>
<td>4</td>
<td>Length of bitmap information header (40bytes for Windows V3 bitmaps)</td>
</tr>
<tr>
<td>18</td>
<td>4</td>
<td>Width (pixels)</td>
</tr>
<tr>
<td>22</td>
<td>4</td>
<td>Height (pixels)</td>
</tr>
<tr>
<td>26</td>
<td>2</td>
<td>Color planes, always 1</td>
</tr>
<tr>
<td>28</td>
<td>2</td>
<td>Color bits per pixel (1, 4, 8, 16, 24 and 32)</td>
</tr>
<tr>
<td>30</td>
<td>4</td>
<td>Compression method, we only read uncompressed (type 0)</td>
</tr>
<tr>
<td>34</td>
<td>4</td>
<td>Image data length</td>
</tr>
<tr>
<td>38</td>
<td>4</td>
<td>Horizontal resolution (pixels per meter)</td>
</tr>
<tr>
<td>42</td>
<td>4</td>
<td>Vertical resolution (pixel per meter)</td>
</tr>
<tr>
<td>46</td>
<td>4</td>
<td>Number of colors, ignored.</td>
</tr>
<tr>
<td>50</td>
<td>4</td>
<td>Number of important colors, ignored.</td>
</tr>
</tbody>
</table>
<p>A Windows V3 bitmap information header is 40bytes long. The firmware verifies that the header length (offset 14) is 40, indicating a V3 bitmap. If the width (132), height (132), color depth (24), and compression (0) all check out, the image data is processed and output to the screen.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Offset</strong></td>
<td><strong>Bytes</strong></td>
<td><strong>24bit image bitmap data</strong></td>
</tr>
<tr>
<td>54+(3n)</td>
<td>1</td>
<td>pixel n red value</td>
</tr>
<tr>
<td>54+(3n+1)</td>
<td>1</td>
<td>pixel n green value</td>
</tr>
<tr>
<td>54+(3n+2)</td>
<td>1</td>
<td>pixel n blue value</td>
</tr>
</tbody>
</table>
<p>Bitmap images have uncompressed, 1:1 representations of pixel data stored in three byte sequences.  The data starts at the lower right-hand corner of the image; first the red value, then green and blue. Wikipedia has a <a href="http://en.wikipedia.org/wiki/Windows_bitmap#Example_of_a_2x2_Pixel.2C_24-Bit_Bitmap">complete bitmap walk through</a>.</p>
<p>If the color depth of a bitmap image (24bits) is greater than the LCD can display (12bits), we need to discard the least significant bits of color data. To convert from 24bit color to 12bit color, we just chuck half the color data; an 8bit value of 11110011 is pushed four bits to the right, giving 1111.</p>
<p><em>Firmware walk-through</em></p>
<ol>
<li>Init PIC, SD, LCD.</li>
<li>Read config.ini, create if it does not exist.</li>
<li>Use first character of config.ini to set between image delay.</li>
<li>Look for images, open next image.</li>
<li>Read and check bitmap file header for proper format.</li>
<li>Read and check bitmap information header for version, size, color.</li>
<li>Read and display each pixel value. Adjust bit depth as needed.</li>
<li>Delay, then repeat from 4.</li>
</ol>
<p><strong>Preparing images</strong></p>
<p><strong><img class="alignnone size-full wp-image-7573" title="newyear" src="http://hackadaycom.files.wordpress.com/2009/01/newyear.jpg?w=132&#038;h=132" alt="newyear" width="132" height="132" /><img class="alignnone size-full wp-image-7579" title="hackaday" src="http://hackadaycom.files.wordpress.com/2009/01/hackaday.jpg?w=132&#038;h=132" alt="hackaday" width="132" height="132" /><img class="alignnone size-full wp-image-7580" title="tulips1" src="http://hackadaycom.files.wordpress.com/2009/01/tulips1.jpg?w=132&#038;h=132" alt="tulips1" width="132" height="132" /><br />
</strong></p>
<p>To keep this demo simple, the photo frame only displays the most common bitmap format. Images must be sized to 132&#215;132pixels, with 24bit color.</p>
<ol>
<li>Open a picture with an image editing program.</li>
<li>Draw a square selection box over the part of the image you want to use, usually using shift and drag.</li>
<li>Crop the image.</li>
<li>Size the image to 132&#215;132pixels.</li>
<li>Save the image as a windows bitmap, 24bits of color depth.</li>
</ol>
<p>Other image sizes and formats could be supported with a firmware upgrade (PNG, JPG), especially with a pin-compatible microcontroller upgrade to a <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en532302">giant dsPIC 33F</a>.</p>
<p><strong>Using it</strong></p>
<p>Put images in the root directory of a FAT formatted SD card. Depending on the last device to format the card, it might need to be formatted with a digital camera or the Panasonic SD formatter.</p>
<p>Optional: make a config.ini file with a text editor. Enter a single digit, from 0-9, to set the between picture delay. Save the file. If you don&#8217;t create your own config.ini file, one will be created for you with a 1 second delay.</p>
<p>Put the card in the socket, and plug in the digital picture frame. Images will cycle on the screen with the defined delay.</p>
<p><strong>Taking it further</strong></p>
<p>We see a lot of potential in this simple digital picture frame. Many features can be added with a firmware upgrade, some are the basis for future hardware.<strong><br />
</strong></p>
<ul>
<li>Display other image formats, scale images</li>
<li>Random fades and wipes</li>
<li>Display time and date over image, set with buttons connected to programming pins</li>
<li>Extend the configuration options in config.ini to include longer delays, fade or wipe type</li>
<li>Use a sub directory for images because there are some file limitations to the root directory of a FAT formatted SD card.</li>
<li>Add an ethernet connection for networked display updates.</li>
</ul>
<p><strong>Download:</strong> <a href="http://blog.mahalo.com/hackaday/howto/dpf.v1.zip">dpf.v1.zip</a></p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2009/01/08/how-to-digital-picture-frame-100-diy/"><img src="http://img.youtube.com/vi/AKlQwLkeWdE/2.jpg" alt="" /></a></span></p>
<p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fhardware%2FHow_to_Digital_picture_frame_100_DIY' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/7561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/7561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/7561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/7561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/7561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/7561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/7561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/7561/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/7561/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/7561/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=7561&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/01/08/how-to-digital-picture-frame-100-diy/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/frontii.jpg" medium="image">
			<media:title type="html">frontii</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/overview.jpg" medium="image">
			<media:title type="html">overview</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct450.png" medium="image">
			<media:title type="html">cct450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/back.jpg" medium="image">
			<media:title type="html">back</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/board4501.png" medium="image">
			<media:title type="html">board4501</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/newyear.jpg" medium="image">
			<media:title type="html">newyear</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/hackaday.jpg" medium="image">
			<media:title type="html">hackaday</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/tulips1.jpg" medium="image">
			<media:title type="html">tulips1</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/AKlQwLkeWdE/2.jpg" medium="image" />
	</item>
		<item>
		<title>How-to: Programmable logic devices (CPLD)</title>
		<link>http://hackaday.com/2008/12/11/how-to-programmable-logic-devices-cpld/</link>
		<comments>http://hackaday.com/2008/12/11/how-to-programmable-logic-devices-cpld/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 02:41:20 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[complex programmable logic device]]></category>
		<category><![CDATA[cpld]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[fpga]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[programmable logic]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=6790</guid>
		<description><![CDATA[
Complex programmable logic devices (CPLDs) contain the building blocks for hundreds of 7400-serries logic ICs. Complete circuits can be designed on a PC and then uploaded to a CPLD for instant implementation. A microcontroller connected to a CPLD is like a microcontroller paired with a reprogrammable circuit board and a fully stocked electronics store.
At first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=6790&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-6845" title="cover-450" src="http://hackadaycom.files.wordpress.com/2008/12/cover-450.jpg?w=450&#038;h=257" alt="cover-450" width="450" height="257" /></p>
<p><a href="http://en.wikipedia.org/wiki/CPLD">Complex programmable logic devices</a> (CPLDs) contain the building blocks for hundreds of <a href="http://en.wikipedia.org/wiki/7400_series">7400-serries logic ICs</a>. Complete circuits can be designed on a PC and then uploaded to a CPLD for instant implementation. A microcontroller connected to a CPLD is like a microcontroller paired with a reprogrammable circuit board and a fully stocked electronics store.</p>
<p>At first we weren&#8217;t sure of the wide appeal and application of CPLDs in hobbyist projects, but we&#8217;ve been convinced. A custom logic device can eliminate days of reading datasheets, finding the <a href="http://en.wikipedia.org/wiki/7400_series#7400_series_subfamilies">ideal logic IC combination</a>, and then waiting for chips to arrive. Circuit boards are simpler with CPLDs because a single chip with programmable pin placement can replace <a href="http://en.wikipedia.org/wiki/List_of_7400_series_integrated_circuits">100s of individual logic ICs</a>. Circuit mistakes can be corrected by uploading a new design, rather than etching and stuffing a new circuit board. CPLDs are fast, with reaction times starting at 100MHz. Despite their extreme versatility, CPLDs are a mature technology with chips starting at $1.</p>
<p>We&#8217;ve got a home-etchable, self programming development board to get you started. Don&#8217;t worry, this board has a serial port interface for working with the CPLD, and doesn&#8217;t require a separate (usually parallel port) JTAG programmer.</p>
<p><span id="more-6790"></span><strong>Intro to CPLDs</strong></p>
<p><strong><img class="alignnone size-full wp-image-6840" title="bitclone-24fv1final" src="http://hackadaycom.files.wordpress.com/2008/12/bitclone-24fv1final.jpg?w=450&#038;h=191" alt="bitclone-24fv1final" width="450" height="191" /><br />
</strong></p>
<p><em>When to use a CPLD</em><strong><br />
</strong></p>
<p>Consider using a CPLD when a design calls for more than one 7400 series logic ICs. A CPLD will be cheaper, faster, and can be programmed with your ideal pin-out configuration for simpler PCBs.</p>
<p>Use a CPLD in tricky designs that might require several iterations. It&#8217;s easier to design a new circuit in software and upload it to the CPLD than it is to design, etch, and stuff a new circuit board.</p>
<p>For maximum speed and instant response, choose a CPLD. The difference in speed is amazing; CPLDs start at a 100MHz, while microcontrollers respond to interrupts at a few MHz. CPLD designs form circuits that react to external stimulus, reactions occur almost instantaneously. A microcontroller executes code to react to events, even interrupt routines have comparatively high latency.</p>
<p><em>CPLD vs FPGA</em></p>
<p><a href="http://en.wikipedia.org/wiki/Field-programmable_gate_array">FPGA</a>s are better known than CPLDs, but they share many characteristics. This analogy isn&#8217;t perfect, but we like it: where FPGAs are a reprogrammable processor core, a CPLD is a reprogrammable circuit board or breadboard. FPGAs replace microcontrollers, memory, and other components. CPLDs absorb logic ICs, and work well with a microcontroller.</p>
<p><em>Manufacturers</em></p>
<p><a href="http://www.altera.com/">Altera</a> and <a href="http://www.xilinx.com/">Xilinx</a>, the biggest CPLD manufacturers, are better known for their FPGAs. <a href="http://www.latticesemi.com/">Lattice Semiconductor</a> is another large CPLD manufacturer with less community following. <a href="http://www.atmel.com">Atmel</a> makes <a href="http://www.atmel.com/dyn/products/devices.asp?family_id=653">pin-compatible versions</a> of old industry-standard CPLDs.</p>
<p>If you plan to work at 5volts, your options are limited. Xilinx XC9500 CPLDs are still available as new old stock, but cost four times more than newer 3.3volt equivalents. Atmel&#8217;s <a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=2123">ATF1502 series</a> works at 5volts, but they don&#8217;t offer a free development environment.</p>
<p>At 3.3volts there&#8217;s more options, but new CPLDs increasingly have a core that runs at 2.5volts, 1.8volts, or lower. The Altera <a href="http://www.altera.com/products/devices/cpld/max2/mx2-index.jsp">MAXII</a> and the Xilinx <a href="http://www.xilinx.com/products/xc9500xl/index.htm">XC9500XL</a> series are probably the most popular 3.3volt CPLDs. Xilinx also makes the <a href="http://www.xilinx.com/products/coolrunner2/">CoolrunnerII</a> CPLD, but it only comes in a TQFP package and requires a separate 1.8volt supply for the core.</p>
<p><em>Packages</em></p>
<p>Most manufacturers offer one or two CPLDs in a hobbyist friendly<a href="http://en.wikipedia.org/wiki/Plastic_leaded_chip_carrier"> PLCC 44 package</a>, though this is starting to disappear. PLCC is an SOIC-sized surface mount chip with pins on all four sides. PLCC44 sockets are commonly available in through-hole and SMD versions. Unfortunately, newer CPLD families are starting to eliminate the PLCC package and offer only 44 pin and larger TQFP chips, such as Xilinx&#8217;s CoolrunnerII.</p>
<p><em>Development environments</em></p>
<p>Most manufacturers offer a free development environment that supports design entry using simple schematics, as well as <a href="http://en.wikipedia.org/wiki/Verilog">Verilog</a> or <a href="http://en.wikipedia.org/wiki/VHDL">VHDL</a>. Many won&#8217;t support the latest FPGAs in the free version, but we only need the CPLD parts anyway. Altera has <a href="https://www.altera.com/support/software/download/sof-download_center.html">Quartus</a>, Xilinx has <a href="http://www.xilinx.com/products/design_resources/design_tool/index.htm">ISE</a>, and Lattice has <a href="http://www.latticesemi.com/dynamic/index.cfm?fuseaction=view_category&amp;document_type=65&amp;source=topnav">ispLever</a>. Atmel has <a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2756">ProChip Designer</a> for the ATF15xx series, but they only offer a 6month trial license &#8212; which they wouldn&#8217;t actually give us.</p>
<p><em>Programmers</em></p>
<p>The development board we present doesn&#8217;t need a separate JTAG programmer because the PIC microcontroller already programs the CPLD.  If you want an external programmer, the cheapest are the parallel port programmers: <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8460">Parallel Cable III for Xilinx</a> and <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8705">BytleBlaster for Altera</a>. Inexpensive clones, and schematics, are available at SparkFun.  The<a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8278"> OpenOCD</a> is a generic USB JTAG programmer that will work with many CPLDs, FPGAs, and ARMs.</p>
<p><em>Our choice</em></p>
<p>We eventually settled on the Xilinx XC9500XL series because it had a cheap development kit we could use to <a href="http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/">test our JTAG programmer</a> prior to implementing an entire design.</p>
<p>The <a href="http://www.xilinx.com/products/devkits/DO-CPLD-DK-G.htm">DO-CPLD-DK</a> from <a href="http://www.digilentinc.com/Products/Detail.cfm?Prod=XC2XL&amp;Nav1=Products&amp;Nav2=Programmable">Digilent</a> includes a XC9572XL, a CoolrunnerII, and parallel port programmer. Nu Horizons has some <a href="https://webapps.nuhorizons.com/storefront/PartSearch.do;jsessionid=916F131647DF384D1C7D5D21956D5A63?PostAction=GO&amp;ItemsPerPage=25&amp;PartNumberHolder=&amp;Mode=initSearch&amp;Commodity=ALL&amp;InStockOnly=FALSE&amp;I6.y=0&amp;Manufacturer=ALLMFG&amp;InStockOnly1=N&amp;PartNumberSearch=DO-CPLD-DK&amp;pSearchType=CompanyPart&amp;PageNum=1&amp;PbFreeOnly1=N&amp;NextPage=1&amp;I6=go&amp;ResultsPerPage=10&amp;PbFreeOnly=FALSE&amp;I6.x=0&amp;prevSearchType=">old non-ROHS models for $40</a>, but due to sloppy variable type handling in their credit card processing scripts, we couldn&#8217;t complete an order online. We tried to do it over the phone but they refused to take such a small order on the phone, even during a website malfunction. In the end, it was cheaper to pay full price at Digikey (#<a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=122-1512-ND">122-1512-ND</a>) after including New Horizon&#8217;s exorbitant shipping charges. We wouldn&#8217;t normally mention this, but with only two places to buy the board it&#8217;s probably worth noting our experience.</p>
<p><strong>CPLD development board</strong></p>
<p><strong><img class="alignnone size-full wp-image-6844" title="cct-crop-450" src="http://hackadaycom.files.wordpress.com/2008/12/cct-crop-450.jpg?w=450&#038;h=202" alt="cct-crop-450" width="450" height="202" /></strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/12/cct.png">Click here for a full size schematic image</a> (PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de">Cadsoft Eagle</a>. All the files for this project are included in the project archive linked at the end of the article.</p>
<p><em>Circuit</em></p>
<p>A PIC <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1335&amp;dDocName=en026374">24FJ64GA002</a> microcontroller (IC1) provides the user and programming interface to the CPLD. We use this $4 PIC in a lot of projects because the peripheral pin select feature makes board routing really easy. Check out our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC24F</a> for more details. The PIC needs to communicate with a PC serial port, so we added an inexpensive MAX3232 RS232 transceiver. The serial interface should work with a USB-&gt;serial adapter.</p>
<p>Our choice of CPLD (IC3), a Xilinx <a href="http://www.xilinx.com/support/documentation/data_sheets/ds057.pdf">XC9572XL</a> (PDF), is connected between the PIC and several other components. We can create an endless variety of circuitry between the PIC and other chips using the reprogrammable logic inside the CPLD.<em> </em>The PIC will program the CPLD with code sent from a PC serial port, but we still brought the JTAG pins to a header for easy external debugging.</p>
<p>A <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3491">DS1085 digital programmable oscillator</a> (IC4) generates clock frequencies between 8KHz and 133MHz, at 10KHz increments. This is very similar to the <a href="http://hackaday.com/2008/11/28/parts-133mhz-162khz-programmable-oscillator-ds1077/">DS1077 we covered earlier,</a> but it has even steps between all frequencies. The DS1085 requires a 5volt supply (VR2). The I2C interface also runs at 5volts, so we connected it to 5volt tolerant PIC pins. It&#8217;s possible to use the 3.3volt 66MHz 1085L instead, and remove the 5volt supply.</p>
<p>We used a cheap 3.3volt SOT223 voltage regulator (VR1) to power most of the circuit.  The 5volt supply (VR2) can be excluded if you use a slower 1085L 3.3volt oscillator.</p>
<p>CPLDs are commonly used as a memory controller, so we included 32K of SRAM (IC5) on the development board. A 3.3volt latch with 5volt tolerant inputs interface the memory inputs to a wide range of external voltages (IC6). The latch inputs are held low with a 1Mohm resistor network (RN1). We&#8217;ll discuss this section extensively in an upcoming article.</p>
<p><em>PCB</em></p>
<p>The board is a quasi one-sided design. We made several compromises so we could prototype this highly experimental PCB ourselves. We present the board &#8216;as is&#8217; for other die-hards that might want to etch this board at home. If you send the PCB to a board house, try to correct these issues prior to producing a &#8216;real&#8217; double-sided board.</p>
<p>One power pin of the CPLD is missing a decoupling capacitor entirely; there was no way to put a capacitor in that area. One CPLD decoupling capacitor, and the SRAM decoupling capacitor, are through-hole parts. Using these through-hole parts eliminated a few jumper wires.</p>
<p><img class="alignnone size-full wp-image-6839" title="backside-450" src="http://hackadaycom.files.wordpress.com/2008/12/backside-450.jpg?w=450&#038;h=257" alt="backside-450" width="450" height="257" /></p>
<p>The jumper wires on the back of the board are optimized for single-sided production, rather than good design practices. We faked a double-sided board by soldering the power bus on the back. A real double-sided board design should route the power bus to avoid crossing signal paths, and include the missing decoupling capacitors.</p>
<p>We used an surface mount PLCC chip socket, but a through-hole version is definitely a better idea. We though the SMD version would be easy to solder, but it turned out to be a nightmare. We really wanted the CPLD to be on the front of the board for the coolest possible presentation. A proper two-sided board with plated through-holes can have a through-hole socket on the front, but this wasn&#8217;t possible with our 1-sided prototype board.</p>
<p><em>Parts list</em></p>
<p><em><img class="alignnone size-full wp-image-6841" title="brd-450" src="http://hackadaycom.files.wordpress.com/2008/12/brd-450.png?w=450&#038;h=256" alt="brd-450" width="450" height="256" /></em></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/12/brd.png">Click here for a full size placement diagram</a> (PNG).<em><br />
</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Part</strong></td>
<td><strong>Value</strong></td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=V%2fyyTCAHA4D%2fh5r3CRQDtA%3d%3d">PIC25FJ64GA002</a> (SOIC)</td>
</tr>
<tr>
<td>IC2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=SN75C3232EDvirtualkey59500000virtualkey595-SN75C3232ED">MAX3232CSE</a> (SOIC-N)</td>
</tr>
<tr>
<td>IC3</td>
<td><a href="XC9572XL-10PCG44C">XC9572XL-10PCG44C</a> (PLCC)</td>
</tr>
<tr>
<td>&#8211;</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=PLCC-44-AT-SMTvirtualkey64610000virtualkey737-PLCC-44-AT-SMT">PLCC44 socket</a>, SMD</td>
</tr>
<tr>
<td>IC4</td>
<td><a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3491">DS1085</a> or <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=DS1085LZ-25%2B-ND">DS1085L</a> (SOIC)</td>
</tr>
<tr>
<td>IC5</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=AI63Xxb%2f5RSO5sZcRck%2fyw%3d%3d">32Kx8, 3.3v, SRAM</a> (SOJ)</td>
</tr>
<tr>
<td>IC6</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=74LVT573WMvirtualkey51210000virtualkey512-74LVT573WM">74LVT573D</a> (SOIC)</td>
</tr>
<tr>
<td>VR1</td>
<td>3.3v regulator, <a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S33CTRvirtualkey51120000virtualkey511-LD1117S33C">LD1117S33</a> (SOT223)</td>
</tr>
<tr>
<td>VR2</td>
<td>5v regulator, <a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S50TRvirtualkey51120000virtualkey511-LD1117S50">LD1117S50</a> (SOT223)</td>
</tr>
<tr>
<td>C1-11,13-17</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF decoupling capacitors</a> (0805)</td>
</tr>
<tr>
<td>C12</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=6ARB0lp6jlXWqZF4lhG52w%3d%3d">0.01uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C15,16</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=9AX3phJxokWIpR5WRGtIJw%3d%3d">0.1uF decoupling capacitors</a> (through-hole)</td>
</tr>
<tr>
<td>C18</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=293D106X96R3A2TE3virtualkey61320000virtualkey74-293D106X96R3A2TE3">10uF tantalum capacitor</a> (A)</td>
</tr>
<tr>
<td>R1,2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=2BMLUTrrT4P7Xm58YbKmPg%3d%3d">390ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R3-5</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=jBethxrBxZb5NLDetw123g%3d%3d">2000ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>RN1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=4609X-101-105LFvirtualkey65210000virtualkey652-4609X-1LF-1M">1Mohm resistor network</a> (9 pin)</td>
</tr>
<tr>
<td>LED1,2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>X1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d">db9 female serial port connector</a> *untested</td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8xMK%2bwDsXhcfMNb/YnnwLQ==">2.1mm power jack</a></td>
</tr>
<tr>
<td>ICSP, JTAG, SV1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">0.1&#8243; pin header, right angle</a></td>
</tr>
<tr>
<td>S1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=101-0164-EVvirtualkey12040000virtualkey101-0164-EV">Tactile switch</a> (DTSM-6)</td>
</tr>
</tbody>
</table>
<p><em>Firmware</em></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>. The firmware is included in the project archive at the end of the article.</p>
<p>We wanted a super easy way to interact with the hardware on the board without endless compile-program-test cycles. We made a custom version of the <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">Bus Pirate firmware</a> that  provides a simple ASCII terminal interface to the DS1085 clock chip (I2C), the CPLD programing interface (JTAG), and a 3 wire (SPI) interface to the CPLD. Check out the Bus Pirate tutorial for background on the simple syntax used with the firmware.</p>
<p>The original Bus Pirate firmware handles several protocols that share the same pins. For the CPLD version, we changed the pin assignments to fit the connections on the development board. We also removed unused modules and options.</p>
<p><strong>CPLD blinky LED examples</strong></p>
<p>We prepared several designs in Xilinx&#8217;s ISE development environment. The schematics, pin placement files, and compiled designs (XSVF) are included in the project archive linked at the end of the article.  A full explanation of ISE is beyond the scope of this article; we found the help files sufficiently useful to make these examples.</p>
<p><em><img class="alignnone size-full wp-image-6855" title="ex1" src="http://hackadaycom.files.wordpress.com/2008/12/ex1.png?w=450&#038;h=222" alt="ex1" width="450" height="222" /><br />
</em></p>
<p>The first design simply lights the LED connected to pin 8 of the CPLD.</p>
<p><em>Prepare the XSVF file</em></p>
<p>XSVF is a compressed JTAG programming format, as described by Xilinx in <a href="http://www.xilinx.com/support/documentation/application_notes/xapp058.pdf">this application note</a> (PDF). XSVF isn&#8217;t limited to programming Xilinx devices, and can be prepared for any chip that provides a common <a href="http://en.wikipedia.org/wiki/Boundary_scan_description_language">BSDL</a> JTAG definition file.</p>
<p>Open the iMPACT programming tool from the ISE Design Suite project panel under <em>Configure target device-&gt;iMPACT</em>.</p>
<ul>
<li> Choose the option to <em>create a boundary scan file</em>,  and set the type to XSVF.</li>
<li>Give the XSVF output a file name and then add a compiled CPLD image (ex1.jed) when prompted to add a device.</li>
<li>You should see a JTAG chain that contains a single device.</li>
</ul>
<p><img class="alignnone size-full wp-image-6856" title="boundaryscan" src="http://hackadaycom.files.wordpress.com/2008/12/boundaryscan.png?w=365&#038;h=174" alt="boundaryscan" width="365" height="174" /></p>
<p>Click on the device and choose program; iMPACT will record the programming sequences to an XSVF file.</p>
<p>With XSVF file in hand, it&#8217;s time to open up a terminal and program the CPLD. We like <a href="http://www.ayera.com/teraterm/">Tera Term</a> and <a href="http://www.hw-group.com/products/hercules/index_en.html">Hercules</a> on Windows. You <em>must</em> enable XON/XOFF flow control in the client to use the JTAG interface. The default PC side setting for the development board terminal is 115200bps, 8N1.</p>
<blockquote><p>HiZ&gt;m <strong>&lt;&#8211;select mode</strong><br />
1. HiZ<br />
2. I2C<br />
3. JTAG<br />
4. RAW3WIRE<br />
MODE&gt;3 <strong>&lt;&#8211;JTAG</strong><br />
900 MODE SET<br />
602 JTAG READY<br />
JTAG&gt;(2) <strong>&lt;&#8211;probe JTAG chain macro<br />
</strong> xxx JTAG INIT CHAIN<br />
xxx JTAGSM: RESET<br />
xxx JTAGSM: RESET-&gt;IDLE<br />
xxx JTAGSM: IDLE-&gt;Instruction Register (DELAYED ONE BIT FOR TMS)<br />
xxx JTAGSM: IR-&gt;IDLE<br />
xxx JTAGSM: IDLE-&gt;Data Register<br />
xxx JTAGSM: DR-&gt;IDLE<br />
xxx JTAGSM: RESET<br />
xxx JTAGSM: RESET-&gt;IDLE<br />
xxx JTAGSM: IDLE-&gt;Data Register<br />
xxx JTAG CHAIN REPORT:<br />
0&#215;01 DEVICE(S)<br />
#0&#215;01 : 0xC9 0&#215;02 0&#215;06 0&#215;9A <strong>&lt;&#8211;XC9572XL responds</strong><br />
xxx JTAGSM: DR-&gt;IDLE<br />
JTAG&gt;</p></blockquote>
<p>In the terminal we enter the mode menu (m), and choose JTAG (3). Macro 2 probes the JTAG chain, in our case this is just the CPLD.  The chain report tells us that the chip is connected and responding. <a href="http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/">Read more about the JTAG interface</a>.</p>
<p><img class="alignnone size-full wp-image-6857" title="up" src="http://hackadaycom.files.wordpress.com/2008/12/up.png?w=451&#038;h=265" alt="up" width="451" height="265" /></p>
<p>Now we can run the XSVF programmer, macro (3), and upload the XSVF file from the terminal <em>in binary mode</em>. The first example just lights the LED on pin 8. If the LED lights, we can verify that programming was successful. If your LED doesn&#8217;t light, don&#8217;t despair; sometimes the JTAG programmer sticks and a reset macro (1) will get the chip going.</p>
<p><img class="alignnone size-full wp-image-6867" title="ex1a" src="http://hackadaycom.files.wordpress.com/2008/12/ex1a.jpg?w=450&#038;h=285" alt="ex1a" width="450" height="285" /></p>
<p>LED at full brightness.</p>
<p><em>74LS32/4071 OR gate, blink at half rate (/2)<br />
</em></p>
<p><img class="alignnone size-full wp-image-6862" title="ex21" src="http://hackadaycom.files.wordpress.com/2008/12/ex21.png?w=450&#038;h=128" alt="ex21" width="450" height="128" /></p>
<p>A major component of the CPLD development board is the 1085(L) frequency synthesizer connected to pin 7 of the CPLD. The next example uses a <a href="http://en.wikipedia.org/wiki/OR_gate">logic OR gate</a>, like a <a href="http://en.wikipedia.org/wiki/OR_gate#Hardware_description_and_pinout">74LS32 or 4071</a> IC, to blink the LED whenever the clock signal is high. At even the slowest clock rate the blinking will be too fast to see, but we should get a nice PWM dimming effect compared to the first example.</p>
<blockquote><p>JTAG&gt;m <strong>&lt;&#8211;select mode</strong><br />
1. HiZ<br />
2. I2C<br />
3. JTAG<br />
4. RAW3WIRE<br />
MODE&gt;2 <strong>&lt;&#8211;I2C interface to DS1085</strong><br />
900 MODE SET<br />
202 I2C READY<br />
I2C&gt;(1) <strong>&lt;&#8211;address search macro</strong><br />
xxx Searching 7bit I2C address space.<br />
Found devices at:<br />
0xB0 0xB1<strong> &lt;&#8211;found the DS1085 address</strong><br />
I2C&gt;</p></blockquote>
<p>Program the CPLD as before, and then switch to I2C mode to access the DS1085 clock. We could look up the device address in the datasheet, but we save a few seconds by running the address search macro; the report tells us the chip answers to 0xb0 (write) and 0xb1 (read).</p>
<blockquote><p>I2C&gt;{0xb0 0&#215;02 0b00011111 0b10000000}<strong>&lt;&#8211;max prescaler</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;02 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;1F GOT ACK: YES<br />
220 I2C WRITE: 0&#215;80 GOT ACK: YES<br />
240 I2C STOP CONDITION<br />
I2C&gt;{0xb0 1 0b11111111 0b11000000}<strong>&lt;&#8211;max divider</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;01 GOT ACK: YES<br />
220 I2C WRITE: 0xFF GOT ACK: YES<br />
220 I2C WRITE: 0xC0 GOT ACK: YES<br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>The DS1085 is almost exactly like the <a href="http://hackaday.com/2008/11/28/parts-133mhz-162khz-programmable-oscillator-ds1077/">DS1077 we covered earlier</a>, but has a DAC controlled oscillator for even steps between all frequencies. We programmed the clock to the slowest frequency using the commands shown above. The LED is dimmed by the pulse-width modulation effect of the clock signal.</p>
<p><img class="alignnone size-full wp-image-6868" title="ex2a" src="http://hackadaycom.files.wordpress.com/2008/12/ex2a.jpg?w=450&#038;h=285" alt="ex2a" width="450" height="285" /></p>
<p>LED at half brightness.</p>
<p><em>74F269 16bit synchronous counter, blink slowly (/</em>65535<em>)</em></p>
<p><img class="alignnone size-full wp-image-6865" title="ex3" src="http://hackadaycom.files.wordpress.com/2008/12/ex3.png?w=449&#038;h=282" alt="ex3" width="449" height="282" /></p>
<p>We just programmed the CPLD with a logic OR gate similar to a 74LS32. Now, we&#8217;re going to reprogram the chip with a 16bit counter like two cascaded <a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=lp01TYqEl4mFnzVVG95LCg%3d%3d">74F269s</a>.  At $1.15 each, two 74F269 Ics are more expensive than the XC9572XL CPLD. A 16bit counter rolls over once per 65535 ticks, so a LED attached to the last bit will toggle once every 65535/2 ticks.</p>
<p>Now we can see the cool part of CPLDs. The CPLD is like a programmable breadboard; we just popped out the 74LS32 and put in a 74F269, without buying parts, reading datasheets, etching, wiring, etc. A microcontroller connected to a CPLD can reconfigure its own circuit board to fix errors, add features, or re-purpose it for entirely different applications.</p>
<p>We upload the new design as before, but now the clock is divided by 65535 and the LED toggles about once per second.</p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2008/12/11/how-to-programmable-logic-devices-cpld/"><img src="http://img.youtube.com/vi/wNfJKHV0ylg/2.jpg" alt="" /></a></span></p>
<p><strong>Taking it further</strong><br />
Next time we&#8217;ll look at discrete 7400-series logic chips, and implement a ton of them in the CPLD to make a high-speed bus sniffer and logic analyzer.</p>
<p><strong>Download:</strong> <a href="http://blog.mahalo.com/hackaday/howto/bitclone.v1.zip">bitclone.v1.zip</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/6790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/6790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/6790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/6790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/6790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/6790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/6790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/6790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/6790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/6790/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=6790&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/12/11/how-to-programmable-logic-devices-cpld/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/cover-450.jpg" medium="image">
			<media:title type="html">cover-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/bitclone-24fv1final.jpg" medium="image">
			<media:title type="html">bitclone-24fv1final</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/cct-crop-450.jpg" medium="image">
			<media:title type="html">cct-crop-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/backside-450.jpg" medium="image">
			<media:title type="html">backside-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/brd-450.png" medium="image">
			<media:title type="html">brd-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/ex1.png" medium="image">
			<media:title type="html">ex1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/boundaryscan.png" medium="image">
			<media:title type="html">boundaryscan</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/up.png" medium="image">
			<media:title type="html">up</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/ex1a.jpg" medium="image">
			<media:title type="html">ex1a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/ex21.png" medium="image">
			<media:title type="html">ex21</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/ex2a.jpg" medium="image">
			<media:title type="html">ex2a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/ex3.png" medium="image">
			<media:title type="html">ex3</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/wNfJKHV0ylg/2.jpg" medium="image" />
	</item>
		<item>
		<title>How-to: Read a FedEx Kinko&#8217;s smart card (SLE4442)</title>
		<link>http://hackaday.com/2008/11/25/how-to-read-a-fedex-kinkos-smart-card-sle4442/</link>
		<comments>http://hackaday.com/2008/11/25/how-to-read-a-fedex-kinkos-smart-card-sle4442/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 01:29:43 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[2 wire interface]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[data dump]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[sle4442]]></category>
		<category><![CDATA[smart card]]></category>
		<category><![CDATA[snooping]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=6059</guid>
		<description><![CDATA[
Our wallets are filling up with SIM and RFID cards that contain hidden information. Using our latest project, the Bus Pirate universal serial interface, we can dump the memory from many common smart cards. In today&#8217;s How-to, we show you how to interface common smart cards, and walk you through the data stored on a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=6059&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-6091" title="overview" src="http://hackadaycom.files.wordpress.com/2008/11/overview.jpg?w=450&#038;h=338" alt="overview" width="450" height="338" /></p>
<p>Our wallets are filling up with SIM and RFID cards that contain hidden information. Using our latest project, the <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">Bus Pirate universal serial interface</a>, we can dump the memory from many common smart cards. In today&#8217;s How-to, we show you how to interface common <a href="http://en.wikipedia.org/wiki/Smart_card">smart cards</a>, and walk you through the data stored on a <a href="http://hackaday.com/2006/03/02/fedex-kinkos-smart-cards-hacked/">FedEx Kinko&#8217;s prepaid value card</a>.</p>
<p><span id="more-6059"></span></p>
<p><strong>Background</strong></p>
<p>The <a href="http://www.kinkos.com/">FedEx Kinko&#8217;s</a> prepaid card is actually a SLE4442 smart card. There&#8217;s nothing secret about the SLE4442, it&#8217;s completely documented in the <a href="http://www.smartcardsupply.com/PDF/DS_sle4432_42_0795.pdf">datasheet</a> (PDF), and you can <a href="http://www.smartcardworld.com/SLE4442.htm">buy blank cards on the web</a>.</p>
<p>The card is openly readable, we&#8217;ll be able to look at the contents without any sort of malicious intrusion. It&#8217;s protected from writes by a three byte password, with a &#8216;three strikes you&#8217;re out&#8217; policy that renders the card useless after three failed password attempts.</p>
<p>Due to its wide-spread use, in Kinko&#8217;s and other capacities, the SLE4442 has been the target of several high-profile hacks.  At the &#8216;06 Toorcon,  [bunnie] and [<a href="http://hackaday.com/2008/05/31/silicon-hacking/">Chris Tarnovsky</a>] hosted a discussion on the card. [Chris] examined the silicon die and suggested that shorting a trace might defeat the security measures. You can see high-resolution images of the die <a href="http://www.flylogic.net/blog/?p=17">on his site</a>. [<a href="http://hackaday.com/author/stromcarlson/">Strom Carlson</a>] went right to the source and <a href="http://hackaday.com/2006/03/02/fedex-kinkos-smart-cards-hacked/">snooped the password with a logic analyzer</a>, as documented in his famous <a href="http://www.dc414.org/download/confs/defcon14/DC-14-Presentations/DC-14-Carlson/?C=M;O=A">&#8216;06 Defcon presentation</a>. The card even makes appearances in <a href="http://flickr.com/photos/hackaday/2259126114/">artwork</a>.</p>
<p>We&#8217;re not planning on <a href="http://www.setchief.com/ProductShow.asp?ID=83">maliciously intruding on the card</a>, but we can still look at the contents and demonstrate how to interface arbitrary protocols with our latest project, <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">the Bus Pirate</a>.</p>
<p><strong>Connecting to the SLE4442<br />
</strong></p>
<p><img class="alignnone size-full wp-image-6094" title="sle4442-connection" src="http://hackadaycom.files.wordpress.com/2008/11/sle4442-connection.jpg?w=450&#038;h=338" alt="sle4442-connection" width="450" height="338" /></p>
<table border="0">
<tbody>
<tr>
<td><strong>Pin</strong></td>
<td><strong>Function</strong></td>
<td><strong>Bus Pirate pin</strong></td>
</tr>
<tr>
<td><strong>1</strong></td>
<td>+5volts</td>
<td>+5volt supply</td>
</tr>
<tr>
<td><strong>2</strong></td>
<td>Reset</td>
<td>AUX</td>
</tr>
<tr>
<td><strong>3</strong></td>
<td>Clock</td>
<td>SCL</td>
</tr>
<tr>
<td><strong>4</strong></td>
<td>Data IO</td>
<td>SDA</td>
</tr>
<tr>
<td><strong>5</strong></td>
<td>N/C</td>
<td>-</td>
</tr>
<tr>
<td><strong>6</strong></td>
<td>Ground</td>
<td>Ground</td>
</tr>
</tbody>
</table>
<p>Grab the <a href="http://www.smartcardsupply.com/PDF/DS_sle4432_42_0795.pdf">SLE4442 datasheet</a> (PDF) if you haven&#8217;t already. The pinout is shown in the picture above. If you&#8217;re having trouble orienting the card, note that the large center pad connects to ground.</p>
<p>The card requires 5volts DC (datasheet page 27, table 3.2.2), we used the Bus Pirate&#8217;s handy 5volt supply. Interfacing at five volts is no problem because the Bus Pirate inputs are all 5volt tolerant.</p>
<p>A two-wire interface is used, with a clock line and bi-directional data line. We connected these to the Bus Pirate&#8217;s SDA and SCL pins. A third signal, reset, is required to initialize the chip; we used the Bus Pirate&#8217;s auxiliary output to control the reset line. The maximum clock frequency we can use to interface the device is 50kHz, with a 7kHz stated minimum (page 28, table 3.2.4:fCLK). The Bus Pirate&#8217;s raw 2 wire protocol runs at about 5kHz, but we didn&#8217;t have any problems interfacing the device.</p>
<p><img class="alignnone size-full wp-image-6093" title="cct1" src="http://hackadaycom.files.wordpress.com/2008/11/cct1.png?w=451&#038;h=189" alt="cct1" width="451" height="189" /></p>
<p>The sle4442 has <a href="http://en.wikipedia.org/wiki/Open_collector">open collector outputs</a>, and depends on pull-up resistors to hold the bus high. Instead of switching the data pin between ground and 5volts, it switches between ground and <a href="http://en.wikipedia.org/wiki/High_impedance">high-impedance</a> states. High-impedance means that the chip exerts no state on the line, it lets it float, like a microcontroller input pin.</p>
<p>Each of the signal lines need to be pulled-up to 5volts with a 2K-10K resistor, the value isn&#8217;t particularly important.  Without the pull-up resistor, we&#8217;ll never see anything but 0 (ground) on the bus because the sle4442 doesn&#8217;t exert a voltage of it&#8217;s own. A benefit of this technique is that the Bus Pirate, which only switches at 3.3volts, will talk to the sle4442 at a full 5volts, in compliance with the 3.5volt minimum voltage for a high level (datasheet, page 27, table 3.2.3:Vih).</p>
<p><strong>Initializing the card<br />
</strong></p>
<p>Before we can read data from the card, we have to initialize it. This is done with a standard ISO 7816-3 Answer to Reset (ATR) command. After initialization, we can read from the card using a simple two wire protocol.</p>
<p><em>Setup raw 2 wire mode</em></p>
<p>The interface shares some characteristics with I2C, but it&#8217;s not compatible. We used the Bus Pirate&#8217;s raw 2 wire bus mode to interface the device.</p>
<blockquote><p>RAW2&gt;m<br />
1. SPI<br />
2. I2C<br />
3. UART<br />
4. RAW 2 WIRE<br />
5. RAW 3 WIRE<br />
MODE&gt;4 <strong>&lt;&#8211; raw 2 wire bus mode</strong><br />
900 MODE SET<br />
&#8230;<br />
SPEED&gt;1 <strong>&lt;&#8211; speed setting is ignored in current firmware<br />
</strong> 901 SPEED SET<br />
1. High-Z outputs (H=input, L=GND)<br />
2. Normal outputs (H=Vcc, L=GND)<br />
MODE&gt;1 <strong>&lt;&#8211; high impedance output type</strong><br />
9xx OUTPUT HIGHZ<br />
402 RAW2WIRE READY, P FOR PULLUPS<br />
RAW2&gt;</p></blockquote>
<p>The Bus Pirate has on-board pull-up resistors, but they only pull to 3.3volts. We must use external pull-ups to 5volts, as shown in the picture. High-Z output mode is compatible with the bus, normal outputs would put 3.3volts on the bus, potentially damaging something.</p>
<blockquote><p>RAW2&gt;l <strong>&lt;&#8211;configure MSB/LSB</strong><br />
1. MSB first<br />
2. LSB first<br />
MODE&gt;2 <strong>&lt;&#8211; LSB first</strong><br />
9xx LSB: LEAST SIG BIT FIRST<br />
RAW2&gt;</p></blockquote>
<p>The card reads and writes each byte least significant bit first (datasheet page 10). We use menu option L to set the data mode to LSB first.</p>
<p><em>Send 7816-3 ISO answer to reset command</em><span style="text-decoration:underline;"><br />
</span></p>
<p><img class="alignnone size-full wp-image-6096" title="atr" src="http://hackadaycom.files.wordpress.com/2008/11/atr.png?w=450&#038;h=215" alt="atr" width="450" height="215" /></p>
<p>ISO 7816-3 &#8220;answer to reset&#8221; is a standardized command used among many smart cards. The ATR sequence is shown above: reset is held high, one clock pulse is sent, reset is released. The next 32 clock pulses (4 bytes) read a generic ATR header from the card. The header contains information about the card type and protocol. Multi-card smart card readers use this to determine how to read each card.</p>
<blockquote><p>RAW2&gt;@^arrrr <strong>&lt;&#8211; aux high (highz), clock tick, aux low, read 4 bytes</strong><br />
952 AUX HIGH IMP, READ: 1<br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS<br />
950 AUX LOW<br />
430 RAW2WIRE READ: 0xA2 <strong>&lt;&#8211;begin ATR header bytes</strong><br />
430 RAW2WIRE READ: 0&#215;13<br />
430 RAW2WIRE READ: 0&#215;10<br />
430 RAW2WIRE READ: 0&#215;91<br />
RAW2&gt;</p></blockquote>
<p>We issue the command @^arrrr to the Bus Pirate. @ puts the auxiliary pin in high-impedance input mode, the pull-up resistor holds the reset at 5volts. ^ issues one clock pulse, with delay. a returns the auxiliary pin to output and holds the reset line at ground.</p>
<p>r issues 8 clock pulses and displays the returned bits as a byte. This is one instance where the protocol is incompatible with I2C. I2C includes an additional acknowledge bit between each byte, the sle4442 outputs 32bits consecutively.</p>
<p>Page 25 of the datasheet explains the ISO7816-3 header. It&#8217;s easiest to interpret in binary. Rather than convert everything to binary, we set the Bus Pirate to binary display mode and issued another ATR command.</p>
<blockquote><p>RAW2&gt;o <strong>&lt;&#8211;setup the output mode</strong><br />
1. HEX<br />
2. DEC<br />
3. BIN<br />
4. RAW<br />
OUTPUT MODE&gt;3 <strong>&lt;&#8211;show numbers in binary</strong><br />
903 OUTPUT MODE SET<br />
RAW2&gt;@^arrrr <strong>&lt;&#8211;another ATR command</strong><br />
952 AUX HIGH IMP, READ: 1<br />
4xx RAW2WIRE 0b00000001 CLOCK TICKS<br />
950 AUX LOW<br />
430 RAW2WIRE READ: 0b10100010 <strong>&lt;&#8211;0xA2</strong><br />
430 RAW2WIRE READ: 0b00010011 <strong>&lt;&#8211;0&#215;13</strong><br />
430 RAW2WIRE READ: 0b00010000 <strong>&lt;&#8211;0&#215;10</strong><br />
430 RAW2WIRE READ: 0b10010001 <strong>&lt;&#8211;0&#215;91</strong><br />
RAW2&gt;</p></blockquote>
<p>The first 2 bytes are protocol header bytes according to ISO 7816-3 (datasheet page 25).</p>
<p>Byte 1 identifies the protocol type.</p>
<blockquote><p>0b10100010<br />
7:4 &#8211; Protocol type (1010=2 wire)<br />
3:3 &#8211; RFU (0)<br />
2:0 &#8211; Structure Identifier (010=general)</p></blockquote>
<p>Byte 2, protocol parameters, tells us about the card if we didn&#8217;t have a datasheet.</p>
<blockquote><p>0b00010011<br />
7:7 &#8211; Supports random read lengths (0=no, read to end)<br />
6:3 &#8211; Data units (0010=256units)<br />
2:0 &#8211; Data unit bits (011=8bits per unit)</p></blockquote>
<p>From the header we can tell that the protocol type is 10, a two wire bus. The card must be read all the way to the end before it accepts a new command. It has 8bits to a unit, and 256units; 256bytes total storage. The final two bytes are 7814-4 data, which seems uninteresting (see datasheet page 26).</p>
<p><strong>Dump main memory (256 bytes)</strong></p>
<p>Once the card is reset and the ATR bytes are read, we can send commands to the card. Commands are three bytes long; they begin with a I2C-style <a href="http://www.esacademy.com/faq/i2c/busevents/i2cstast.htm">start condition</a>, and end with an I2C-style stop condition. Start and stop conditions can be generated manually with \-/_\ and _/-\, but the raw 2 wire library also includes the shortcuts { and }. The start and stop conditions are the same as I2C, but they&#8217;re used at a different point in the transmission.</p>
<p>The read main memory command is <em>0&#215;30</em>, followed by a read start address (<span style="text-decoration:underline;">0</span>), and a third byte that doesn&#8217;t matter (0xff).  After the stop condition, the card outputs data on every clock until it reaches the end of the memory.  As described by the ATR header, no new commands can be sent until the card reaches the last byte of memory.  Starting at read address 0, it takes 256*8 clock pulses to complete the read cycle.</p>
<blockquote><p>RAW2&gt;{<em>0&#215;30</em> <span style="text-decoration:underline;">0</span> 0xff} 0r255 0r10 <strong>&lt;&#8211;command </strong><br />
410 RAW2WIRE START CONDITION (\-/_\)<br />
420 RAW2WIRE WRITE: 0&#215;30<br />
420 RAW2WIRE WRITE: 0&#215;00<br />
420 RAW2WIRE WRITE: 0&#215;00<br />
440 RAW2WIRE STOP CONDITION (_/-\)<br />
431 RAW2WIRE BULK READ, 0xFF BYTES: <strong>&lt;&#8211;bulk read of 255 bytes</strong><br />
0xA2 0&#215;13 0&#215;10 0&#215;91 0&#215;46 0xFF 0&#215;81 0&#215;15<br />
0xFF 0&#215;01 0&#215;4B 0&#215;03 0&#215;00 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xD2 0&#215;76 0&#215;00<br />
0&#215;00 0&#215;04 0&#215;09 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0&#215;7B 0&#215;14 0xAE 0&#215;47 0xE1 0&#215;7A 0&#215;94 0&#215;3F<br />
0&#215;4C 0&#215;46 0xC6 0&#215;3B 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;20 0&#215;08 0&#215;03 0&#215;04 0&#215;09 0x** 0x** 0x**<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0&#215;30 0&#215;31 0&#215;3* 0&#215;3* 0&#215;30 0&#215;30 0&#215;31 0&#215;33<br />
0&#215;3* 0&#215;3* 0&#215;3* 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;43 0&#215;61 0&#215;73 0&#215;68<br />
0&#215;20 0&#215;43 0&#215;75 0&#215;73 0&#215;74 0&#215;6F 0&#215;6D 0&#215;65<br />
0&#215;72 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;39<br />
0&#215;39 0&#215;31 0&#215;31 0&#215;00 0&#215;31 0&#215;30 0&#215;31 0&#215;00<br />
0&#215;30 0&#215;30 0&#215;30 0&#215;30 0&#215;30 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;03 0&#215;00 0&#215;00 0&#215;01 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;20<br />
0&#215;08 0&#215;03 0&#215;04 0&#215;09 0x** 0x** 0x** 0&#215;00<br />
0&#215;00 0&#215;00 0&#215;00 0&#215;00 0&#215;00 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0&#215;00 0&#215;00<br />
431 RAW2WIRE BULK READ, 0&#215;0A BYTES: <strong>&lt;&#8211;again to get last byte (256)</strong><br />
0&#215;00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF<br />
RAW2&gt;</p></blockquote>
<p>{ issues the bus start condition. 0&#215;30 sends the read address, 0 is the start byte, and 0xff could be anything. } sends the bus stop condition. 0r255 clocks in 255 8bit bytes and displays them on the screen. The card actually has 256 bytes of main memory, so we issue an additional read command to get the last byte and verify that the bus returns to high after the read is over. We can&#8217;t use 0r256 because the Bus Pirate doesn&#8217;t understand decimal numbers greater than 255 (we should address that).</p>
<p><em>What does the data mean?</em><strong><br />
</strong></p>
<p>We dissected the card according the datasheet, [Strom]&#8217;s Defcon presentation, and <a href="http://www.stromcarlson.com/projects/smartcard/format.pdf">this handy guide</a> (PDF).</p>
<p><em>32byte Header&#8230;</em></p>
<blockquote><p>0xA2 0&#215;13 0&#215;10 0&#215;91 <strong>&lt;&#8211;The first four bytes are a repeat of the ATR data</strong><br />
0&#215;46 0xFF 0&#215;81 0&#215;15<strong>&lt;&#8211;manufacturer tags, other junk</strong><br />
0xFF 0&#215;01 0&#215;4B 0&#215;03 0&#215;00 <strong>&lt;&#8211;ICCF, IC card fabricator id</strong><br />
0xFF 0xFF 0xFF 0xFF <strong>&lt;&#8211;ICCN, IC serial number, 0</strong><br />
0xFF 0xFF 0xFF 0xFF<strong>&lt;&#8211; misc tags and lengths, 0</strong><br />
0xD2 0&#215;76 0&#215;00 0&#215;00 0&#215;04 0&#215;09<strong> &lt;&#8211;application identifier (Kinko&#8217;s?)</strong><br />
0xFF 0xFF 0xFF 0xFF 0xFF <strong>&lt;&#8211;all other bytes 0</strong></p></blockquote>
<p>The first 32 bytes are a permanently burned header with serial numbers, manufacturer codes, and other unique data (datasheet page 24). This header prevents exact duplication of cards, even if you have a blank card and a security code. Kinko&#8217;s didn&#8217;t have a custom serial number permanently burned into each card.</p>
<p><em>Now data&#8230;.</em></p>
<blockquote><p>0&#215;7B 0&#215;14 0xAE 0&#215;47 0xE1 0&#215;7A 0&#215;94 0&#215;3F <strong>&lt;&#8211; IEEE-754 value, $0.02</strong></p></blockquote>
<p>This is the value stored on the card, in IEEE-754 format. You can use <a href="http://babbage.cs.qc.edu/IEEE-754/64bit.html">this utility</a> to make it readable. 0&#215;3f947ae147ae147b=$0.02.</p>
<blockquote><p>&#8230;8 bytes of junk&#8230;<br />
0&#215;20 <strong>&lt;&#8211; 0&#215;20 after copy, 0&#215;00 after computer time</strong><br />
0&#215;08 0&#215;03 0&#215;04 0&#215;09 0x** 0x** 0x**<strong>&lt;&#8211;date/time purchased</strong></p></blockquote>
<p>This is the date and time the card was purchased, 2008 March 4, 9:**:**.**. Some digits have been obscured to protect the anonymity of our supplier.</p>
<blockquote><p>&#8230;40 bytes of junk&#8230;<br />
0&#215;30 0&#215;31 0&#215;3* 0&#215;3* <strong>&lt;&#8211;Store number: 01**</strong><br />
0&#215;30 0&#215;30 0&#215;31 0&#215;33 0&#215;3* 0&#215;3* 0&#215;3* <strong>&lt;&#8211; SN: 0013***</strong></p></blockquote>
<p>The card serial number consists of the store number and a unique, seven digit number. Some digits obscured.</p>
<blockquote><p>&#8230;more bytes&#8230;<br />
0&#215;08 0&#215;03 0&#215;04 0&#215;09 0x** 0x** 0x** <strong>&lt;&#8211; another time</strong><br />
&#8230;more bytes&#8230;<br />
0xFF 0xFF 0xFF 0xFF 0xFF 0&#215;00 0&#215;00 0&#215;00<strong>&lt;&#8211; last 8 bytes on the card</strong><br />
0xFF 0xFF&#8230; <strong>&lt;-not real data bytes</strong></p></blockquote>
<p><strong>Dump protection memory (4 bytes)</strong></p>
<p>The first 32 bytes of the data memory can be write protected. Each bit of the four byte data protection register (command 0&#215;34) represents a byte of data memory. A bit set to 1 cannot be overwritten. We can read the data protection register and find out which bytes of the main memory are write protected. This is easiest to understand in binary, so we did this operation in binary output mode.</p>
<blockquote><p>RAW2&gt;{0&#215;34 0 0} 0r4 <strong>&lt;&#8211;command</strong><br />
410 RAW2WIRE START CONDITION (\-/_\)<br />
420 RAW2WIRE WRITE: 0b00110100<br />
420 RAW2WIRE WRITE: 0b00000000<br />
420 RAW2WIRE WRITE: 0b00000000<br />
440 RAW2WIRE STOP CONDITION (_/-\)<br />
431 RAW2WIRE BULK READ, 0b00000100 BYTES:<br />
0b00100000 0b11100001 0b00011111 0b11111000 <strong>&lt;&#8211;data protection register</strong><br />
RAW2&gt;</p></blockquote>
<p>Each bit corresponds with one of the first 32 bytes of the card memory. If the bit is one, the corresponding byte is write protected. This register can be written, but only if you have the correct password.</p>
<p><strong>Dump security memory (4 bytes)</strong></p>
<p>The security memory contains a password verification attempt counter, and the three byte password. We can read the read the security memory without the password, but the password bytes will read as 0. The security memory address is 0&#215;31.</p>
<blockquote><p>RAW2&gt;{0&#215;31 0 0} 0r4 <strong>&lt;&#8211;command</strong><br />
410 RAW2WIRE START CONDITION (\-/_\)<br />
420 RAW2WIRE WRITE: 0b00110001<br />
420 RAW2WIRE WRITE: 0b00000000<br />
420 RAW2WIRE WRITE: 0b00000000<br />
440 RAW2WIRE STOP CONDITION (_/-\)<br />
431 RAW2WIRE BULK READ, 0b00000100 BYTES:<br />
0b00000100 0b00000000 0b00000000 0b00000000<strong>&lt;&#8211;bytes</strong><br />
RAW2&gt;</p></blockquote>
<p>The attempt counter starts at three (0b00000111), and counts down to 0. When the counter reads 0, the card is essentially destroyed. We used two access attempts to test the password commands, this card has one try left.</p>
<p><strong>Taking it further</strong></p>
<p>We&#8217;d like to demonstrate all the capabilities of this card, including password verification and data updates, but we need to buy a new card with a known security code.</p>
<p>Due to the range of interesting smart cards cards out there, it might be handy to add an ISO 7816-3 ATR command macro and reply decoder to the Bus Pirate.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/6059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/6059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/6059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/6059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/6059/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=6059&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/11/25/how-to-read-a-fedex-kinkos-smart-card-sle4442/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/overview.jpg" medium="image">
			<media:title type="html">overview</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/sle4442-connection.jpg" medium="image">
			<media:title type="html">sle4442-connection</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/cct1.png" medium="image">
			<media:title type="html">cct1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/atr.png" medium="image">
			<media:title type="html">atr</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: The Bus Pirate, universal serial interface</title>
		<link>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/</link>
		<comments>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 22:17:57 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debugging tools]]></category>
		<category><![CDATA[eeprom reader]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hacking tools]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[ic interface]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[uart]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=5882</guid>
		<description><![CDATA[
UPDATE: New firmware with JTAG and more
We&#8217;re always excited to get a new chip or SIM card to interface, but our enthusiasm is often dampened by the prototyping process. Interfacing any chip usually means breadboarding a circuit, writing code, and hauling out the programmer; maybe even a prototyping PCB.
A few years ago we built the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=5882&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-5904" title="i2ceeprom" src="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg?w=450&#038;h=308" alt="i2ceeprom" width="450" height="308" /></p>
<p><strong>UPDATE:</strong> <a href="http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/">New firmware with JTAG and more</a></p>
<p>We&#8217;re always excited to get a new chip or SIM card to interface, but our enthusiasm is often dampened by the prototyping process. Interfacing any chip usually means breadboarding a circuit, writing code, and hauling out the programmer; maybe even a prototyping PCB.</p>
<p>A few years ago we built the first &#8216;Bus Pirate&#8217;, a universal bus interface that talks to most chips from a PC serial terminal. Several standard serial protocols are supported at 3.3-5volts, including <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C</a>, <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a>, and <a href="http://en.wikipedia.org/wiki/Asynchronous_start-stop">asynchronous serial</a>. Additional &#8216;raw&#8217; 2- and 3- wire libraries can interface almost any proprietary serial protocols. Since this has been such a useful tool for us, we cleaned up the code, documented the design, and released it here with specs, schematic, and source code.</p>
<p><span id="more-5882"></span></p>
<p><strong>Concept Overview</strong></p>
<p><strong><img class="alignnone size-full wp-image-6028" title="overview-diagram-new" src="http://hackadaycom.files.wordpress.com/2008/11/overview-diagram-new.png?w=450&#038;h=161" alt="overview-diagram-new" width="450" height="161" /><br />
</strong></p>
<p><strong><br />
</strong></p>
<p>The Bus Pirate is a serial terminal bridge to multiple IC interface protocols. We type commands into a serial terminal on the computer. The commands go to the Bus Pirate through the PC serial port. The Bus Pirate talks to a microchip in the proper protocol, and returns the results to the PC.</p>
<p>All pins output 3.3volts, but are 5volt tolerant. On-board 3.3volt and 5volt power supplies are available to power the connected chip. Software configurable I2C <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up resistors</a> complete the package.</p>
<p><img class="alignnone size-full wp-image-5893" title="terminal-450" src="http://hackadaycom.files.wordpress.com/2008/11/terminal-450.png?w=401&#038;h=251" alt="terminal-450" width="401" height="251" /></p>
<p>The serial terminal interface works with any system: PC, Mac, Linux, Palm Pilots, WinCE devices, etc; no crapware required. We considered a USB device, but USB isn&#8217;t compatible with the huge number of hand-held devices that have a serial port. We also wanted a 3.3volt device with 5volt tolerant inputs, but most popular through-hole USB microcontollers were 5volt parts (e.g. the <a href="http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=111&amp;mid=10&amp;lang=en&amp;pageId=74">PIC18Fx550</a>).</p>
<p>The Bus Pirate currently &#8217;speaks&#8217; three hardware protocols for high-speed interfacing, and has two software protocol libraries for easy bus manipulation. The theory and specification of each protocol is beyond what we can cover here, but check out some of these tutorials:</p>
<p><em>I2C</em></p>
<p>A slow 2 wire bus. Wikipedia is a great place to start for <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C background</a>. <a href="http://www.i2c-bus.org/">I2C-Bus.org</a>, <a href="http://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm">Robot Electronics</a>, <a href="http://www.esacademy.com/faq/i2c/">Embedded Systems Academy</a>, and <a href="http://www.embedded.com/story/OEG20010718S0073">Embedded.com</a> have decent I2C tutorials.</p>
<p><em>SPI</em></p>
<p>A simple 3 wire bus. Wikipedia has <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">background</a>; Embedded.com has a great <a href="http://www.embedded.com/columns/beginerscorner/9900483">tutorial and comparison to I2C</a>.</p>
<p><em>Universal Asynchronous Receiver Transmitter (UART or serial)</em></p>
<p>A clock and timing dependent serial protocol best known for its appearance as the PC serial port protocol. Wikipedia has background on <a href="http://en.wikipedia.org/wiki/Asynchronous_start-stop">asynchronous serial protocols</a>.</p>
<p><em>Raw 2 wire</em></p>
<p>This is a generic 2 wire protocol library, similar to I2C but without an ACK bit. I2C and many proprietary 2 wire protocols can be formed using the bus manipulations available in this mode. Use this library to work with non-I2C 2 wire devices, like <a href="http://www.smartcardsupply.com/Content/Cards/SLE4442.htm">smartcards</a> or <a href="http://www.sensirion.com/en/01_humidity_sensors/02_humidity_sensor_sht11.htm">Sensirion SHT11</a> temperature/humidity sensors.</p>
<p><em>Raw 3 wire</em></p>
<p>This is a generic 3 wire protocol library, similar to SPI but without the constraints of a hardware module. Use this library to work with devices that use non-8bit compatible 3-wire protocols, like the <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=569">Sparkfun Nokia 6100 LCD knock-off</a>. Many 3 wire protocols can be formed using the bus manipulations available in this mode.</p>
<p><strong>Hardware</strong></p>
<p><img class="alignnone size-full wp-image-5897" title="brd-450" src="http://hackadaycom.files.wordpress.com/2008/11/brd-450.png?w=451&#038;h=325" alt="brd-450" width="451" height="325" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/11/brd.png">Click for a full size PCB placement image</a> (PNG). Screw terminals connect to the power supplies. A row of seven pin headers connect to the IO pins. Despite the label, only 7volts DC is required.</p>
<table style="text-align:left;" border="0">
<tbody>
<tr>
<td>
<div><strong>PIN</strong></div>
</td>
<td>
<div><strong>SPI</strong></div>
</td>
<td>
<div><strong>I2C</strong></div>
</td>
<td>
<div><strong>RS232</strong></div>
</td>
</tr>
<tr>
<td>
<div><strong>B9</strong></div>
</td>
<td>
<div>MOSI</div>
</td>
<td>
<div>SDA</div>
</td>
<td>
<div>-</div>
</td>
</tr>
<tr>
<td>
<div><strong>B8</strong></div>
</td>
<td>
<div>CLK</div>
</td>
<td>
<div>SCL</div>
</td>
<td>
<div>-</div>
</td>
</tr>
<tr>
<td>
<div><strong>B7</strong></div>
</td>
<td>
<div>MISO</div>
</td>
<td>
<div>-</div>
</td>
<td>
<div>RX</div>
</td>
</tr>
<tr>
<td>
<div><strong>B6</strong></div>
</td>
<td>
<div>CS</div>
</td>
<td>
<div>-</div>
</td>
<td>
<div>TX</div>
</td>
</tr>
<tr>
<td>
<div><strong>B5</strong></div>
</td>
<td>
<div>AUX</div>
</td>
<td>
<div>AUX</div>
</td>
<td>
<div>AUX</div>
</td>
</tr>
<tr>
<td>
<div><strong>Ground</strong></div>
</td>
<td>
<div>GND</div>
</td>
<td>
<div>GND</div>
</td>
<td>
<div>GND</div>
</td>
</tr>
</tbody>
</table>
<p>This table shows the pin connections for each bus mode. Raw 2 wire mode uses the same pin configuration as I2C. Raw 3 wire mode uses the same pin configuration as SPI.</p>
<p><img class="alignnone size-full wp-image-5899" title="cct-450" src="http://hackadaycom.files.wordpress.com/2008/11/cct-450.png?w=450&#038;h=191" alt="cct-450" width="450" height="191" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/11/cct.png">Click for a full size circuit image</a> (PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de">Cadsoft Eagle</a>. Download the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP).</p>
<p><em>PIC 24FJ64GA002</em></p>
<p>We used a <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002</a> microcontroller in the Bus Pirate; this is the same chip we used in our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">mini-server project</a>. It&#8217;s fast enough to do everything we want (16MIPS), and the peripheral pin select feature allows the hardware SPI, UART, and I2C modules to share output pins. Each power pin needs a decoupling capacitor(C12,13), and the MCLR function requires a resistor (R7) between pin 1 and 3.3volts. The PIC has an internal voltage regulator that requires a 10uF tantalum capacitor (C3), though we used a plain electrolytic capacitor without issue. Read about programming and working with this chip in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F tutorial</a>. If you don&#8217;t have a PIC debugger, several readers recommend the under-$40 ICD2 clones on eBay.</p>
<p>The PIC runs at 3.3volts, but the digital-only pins are 5volt tolerant for interfacing 5volt logic. Pins 14,15,16,17,18,21, and 22, are digital only, which we determined by looking through the datasheet and eliminating any pins with an analog connection type (table 1-2, pages 11-16). According to the datasheet, I2C pins are also 5volt tolerant. There&#8217;s a bunch of conflicting information on the web, but datasheet page 230, parameter DI28, clearly states that the max input for a 24FJ64GA002 I2C pin without analog circuitry is 5.5volts.</p>
<p>Pins 21 and 22 (RB10/11) can pull-up SDA/SCL through resistors R4 and R5.</p>
<p><em>MAX3223CPP</em></p>
<p>This chip converts 3.3volt serial output to +/-10volt RS232 signals compatible with a PC serial port. The MAX3223CPP is a 3-5volt version of the MAX202, with extra power saving features. MAX RS232 transceivers require four 0.1uF capacitors for a charge pump (C4,5,7,8), and one decoupling capacitor (C17). We used the same capacitors for everything.</p>
<p>We used a MAX3223CPP, which doesn&#8217;t seem to be available anymore. <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a> is a pin-compatible newer version, available at Digikey for $7. Ouch! None of the 3223&#8217;s power saving features are used, so a cheaper, simpler 3.3volt RS232 transceiver should be substituted if at all possible.</p>
<p><em>Power supplies</em></p>
<p>Most chips can be powered from the Bus Pirate&#8217;s on-board 3.3volt and 5volt supplies. 5volts is supplied by a common 7805 regulator (VR2) and two decoupling capacitors (C9,10). An LM317 adjustable regulator (VR1) is set to 3.3volts using two resistors (R2,3), and requires two decoupling capacitors (C6,7). The circuit requires a 7-10volt DC supply (J1).</p>
<p><em>Part list</em></p>
<table style="text-align:left;" border="0">
<tbody>
<tr>
<td><strong>Part </strong></td>
<td><strong>Value</strong></td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=PIC24FJ64GA002-I/SP-ND">PIC24FJ64GA002-DIP</a></td>
</tr>
<tr>
<td>IC2</td>
<td>MAX3223CPP (try <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a>)</td>
</tr>
<tr>
<td>C3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=M%252b5JCWh%252b1ty3RFguvdcdsg%3d%3d">10uF capacitor</a> (preferably tantalum)</td>
</tr>
<tr>
<td>C4-13,17</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=9AX3phJxokWIpR5WRGtIJw%3d%3d">0.1uF capacitors</a></td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=ULgY8XwKjTmmv2gtdH4CoQ%3d%3d">330 ohm resistor</a></td>
</tr>
<tr>
<td>R2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=4eNa8160l8VHA9lUHkRdvw%3d%3d">240 ohm resistor</a></td>
</tr>
<tr>
<td>R3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=X3IDIfI%252bJAVuAq1Yim8fmg%3d%3d">390 ohm resistor</a></td>
</tr>
<tr>
<td>R4,5,7</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8tsW7z%2fc78pkoLNVKn1xoQ%3d%3d">2K2  ohm resistor</a></td>
</tr>
<tr>
<td>VR1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=swDD%252bF%252bps7c8uLyY%252b3mJJw%3d%3d">LM317</a></td>
</tr>
<tr>
<td>VR2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=cnIeywgme7bzmZ37%2fiFT9w%3d%3d">LM7805</a></td>
</tr>
<tr>
<td>X1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=wjes1ZhMGKfGv3iS94oZ%252bQ%3d%3d">Screw clamp (3 terminals)</a> *untested</td>
</tr>
<tr>
<td>X2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d">DB9 Female connector (serial port)</a> *untested</td>
</tr>
<tr>
<td>ICSP,SV3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">.1&#8243; pin header, right angle</a></td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8xMK%252bwDsXhcfMNb%2fYnnwLQ%3d%3d">Power jack, 2.1mm pin</a></td>
</tr>
<tr>
<td>LED1</td>
<td>3mm LED (optional)</td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>. Download the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP).</p>
<p>main.c &#8211; Handles the user terminal interface.</p>
<p>busPirate.c &#8211; Abstraction routines that convert syntax to actions on the proper bus.</p>
<p>uartIO.c &#8211; IO routines for both hardware UARTs.</p>
<p>m_i2c_1.c &#8211; Software I2C routines by [<a href="http://www.microchipc.com/sourcecode/#i2c">Michael Pearce</a>]. We couldn&#8217;t get the PIC hardware I2C to work, so we used this helpful library. The software doesn&#8217;t take into account the I2C speed setting, and seems to work at about 5KHz.</p>
<p>SPI.c &#8211; Routines that drive the hardware SPI module.</p>
<p>raw2wire.c &#8211; Software 2-wire interface library.</p>
<p>raw3wire.c &#8211; Software 3-wire (SPI) interface library.</p>
<p>User input is held in a 4000 byte buffer until a newline character (enter) is detected. If the first character of the input is a menu option (see below), the menu dialog is shown, otherwise the string is parsed for data to send over the bus (see syntax). The code consists of an embarrassing number of switch statements and spaghetti code.</p>
<p><strong>Terminal interface</strong></p>
<p>Rather than write a junk piece of software to control the device, we gave it a serial command line interface that will work with any ASCII terminal.  The bus pirate responds to commands with three digit result codes and a short message. The codes are designed with PC automation in mind. We&#8217;ve included a table of result codes in the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (zip).</p>
<p><em>Menu options</em></p>
<p>Menu options are single character commands that don&#8217;t involve data transfers. Enter the character, followed by &lt;enter&gt;, to access the menu.</p>
<p><strong>?</strong> &#8211; Show a help menu with commands and syntax.</p>
<p><strong>M</strong> &#8211; Set the bus mode (SPI, I2C, UART, raw 2 wire, raw 3 wire). Followed immediately by a prompt for speed, polarity, and output state (mode dependent).</p>
<ul>
<li>Bus speeds: SPI:30, 125, 250, 1000KHz. I2C:100, 400, 1000KHz. UART: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200bps. Raw modes: 1, 10, 50KHz.</li>
<li>Inverse clock setting sets the idle state opposite of normal (normal SPI:idle low; normal UART:idle high): SPI:idle high; UART:idle low.</li>
<li>Some modes have optional high-z output modes for use with pull-up resistors (Low=ground, High=input).</li>
</ul>
<p><strong>L &#8211; </strong>Toggle bit transmit/receive order: most/least significant bit first.</p>
<p><strong>P</strong> &#8211; SDA/SCL pin pull-up resistor toggle (3.3volts). Only valid in I2C and raw 2 wire modes.</p>
<p><strong>O</strong> &#8211; Set number output display format. The terminal can display numbers as decimal, hexadecimal, and binary ASCII values. A fourth format sends the raw, unprocessed byte for reading ASCII formatted text.</p>
<p><em>Syntax</em></p>
<p>A simple syntax is used to communicate with chips over a bus.  Syntax commands have generic functions that generally apply to all bus types.</p>
<p><strong>A/a/@ </strong> &#8211; Toggle auxiliary pin. Capital &#8220;A&#8221; sets AUX high, small &#8220;a&#8221; sets to ground. @ sets aux to input (high impedance mode) and reads the pin value.</p>
<p><strong>[ </strong> - Start data write. SPI/raw 3 wire: chip select enabled. I2C/raw 2 wire: start condition. RS232: open UART, discard received bytes.</p>
<p><strong>{ </strong> - Start data write with reads. Same as [, except: SPI/raw 3 wire: show the read byte for each write. RS232: display data as it arrives asynchronously.</p>
<p><strong>] or }</strong> &#8211; End data write. SPI/raw 3 wire: chip select disabled. I2C/raw 2 wire: stop condition. RS232: close UART.</p>
<p><strong>R/r</strong> &#8211; Read byte. SPI/raw 3 wire: send dummy byte, return read. I2C: read byte with ACK. Raw 2 wire: read 8 bits. RS232: check UART for byte and return, or fail if empty. Use 0r1&#8230;255 for bulk reads up to 255 bytes.</p>
<p><strong>0b</strong> &#8211; Write this binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001.</p>
<p><strong>0h or 0x</strong> &#8211; Write this HEX value. Format is 0h01 or 0&#215;01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters.</p>
<p><strong>0-255</strong> &#8211; Write this decimal value. Any number not preceded by 0x, 0h, or 0b is interpreted as a decimal value.</p>
<p><strong>, or space</strong> -	Value delimiter. Use a coma or space to separate numbers. Any combination is fine, no delimiter is required between non-number values: {0xa6,0, 0 16 5 0b111 0haF}.</p>
<p><em>Direct bus manipulation commands for raw 2 wire mode and raw 3 wire mode.</em><br />
<strong>^</strong> &#8211; Send one clock tick. Use 0^1&#8230;255 for multiple clock ticks.</p>
<p><strong>/ and \</strong> &#8211; Toggle clock level high (/) and low (\). Includes clock delay (100uS).</p>
<p><strong>-/_</strong> &#8211; Toggle data state high (-) and low (_). Includes data setup delay (20uS).</p>
<p><strong>! </strong>- Read one bit with clock.</p>
<p><strong>. </strong>- Read data pin state (no clock).</p>
<p><strong>&amp;</strong> &#8211; Delay 1uS. Use 0&amp;1&#8230;255 for multiple delays.</p>
<p><strong>Using it</strong></p>
<p><strong><img class="alignnone size-full wp-image-5902" title="buspirate-24fv0a" src="http://hackadaycom.files.wordpress.com/2008/11/buspirate-24fv0a.jpg?w=450&#038;h=330" alt="buspirate-24fv0a" width="450" height="330" /><br />
</strong></p>
<p>Here are two examples that show the Bus Pirate in action. Terminals should be set to ASCII mode with local echo, we used the Windows serial terminal. The PC-side serial connection is 115200bps, 8N1. The Bus Pirate should respond to any single line feed type (0&#215;0a, 0&#215;0d), or both (Windows style).</p>
<p><em><a name="EEPROM">.</a>I2C/SPI &#8211; Flash 24LC1025 EEPROM</em></p>
<p><a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=80">Microchip&#8217;s EEPROMS</a> are popular permanent-storage memory chips, the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en024636">24LC1025</a> has 128Kbytes of storage with an I2C interface.  We can test this chip without bread-boarding a big circuit or writing code.</p>
<p><img class="alignnone size-full wp-image-5904" title="i2ceeprom" src="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg?w=450&#038;h=308" alt="i2ceeprom" width="450" height="308" /></p>
<p>The picture shows an 24LC1025 connected to the Bus Pirate. The EEPROM works from 2.7 to 5volts, so we used the 3.3volt supply from the Bus Pirate to power the circuit. The on-board SDA/SCL pull-up resistors hold the I2C bus high, and eliminate the need for external resistors. A single 0.1uF capacitor decouples the EEPROM from the power supply.</p>
<p><span style="text-decoration:underline;">Setup I2C mode</span></p>
<p>First, we setup the Bus Pirate for I2C mode and enable the pull-up resistors. Since the Bus Pirate currently uses a software I2C library, the speed setting doesn&#8217;t really have an effect.</p>
<blockquote><p>SPI&gt;m  <strong>&lt;&#8211;enter m for mode select</strong><br />
1. SPI<br />
2. I2C<br />
3. UART<br />
4. RAW 2 WIRE<br />
5. RAW 3 WIRE<br />
MODE&gt;2  <strong>&lt;&#8211;enter 2 for I2C</strong><br />
900 MODE SET<br />
Set speed:<br />
1. 100KHz (Standard)<br />
2. 400KHz (Fast Mode)<br />
3. 1MHz (High Speed)<br />
SPEED&gt;1 <strong>&lt;&#8211;speed doesn&#8217;t really do anything&#8230;</strong><br />
901 SPEED SET<br />
202 I2C READY, P/p FOR PULLUPS<br />
I2C&gt;P   <strong>&lt;&#8211;enable the I2C pull-up resistors</strong><br />
205 I2C PULLUP ON<br />
I2C&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Write to EEPROM (I2C)</span></p>
<p>All I2C operations begin with a start condition { or [, and end with a stop condition } or ]. A write begins by addressing the device (1 byte) and looking for an acknowledgment bit (ACK). If the EEPROM responds, we can send the data location to write (2 bytes) and data payload (n bytes). The Bus Pirate automatically checks for an ACK at the end of each write, and ACKs each read.</p>
<p>The 24LC1025 base address is 1010xxy, where xx is determined by the state of pins 2 and 3, and y is read (1) or write (0) mode. We tied pins 2 and 3 high, making the full write address <strong>1010110</strong>.  We&#8217;ll start writing to the device at the first data location (<em>0 0</em>), and write one to thirteen using a mix of data input formats (<span style="text-decoration:underline;">1&#8230;13</span>).</p>
<blockquote><p>I2C&gt;{<strong>0b10100110 </strong><em>0 0 </em><span style="text-decoration:underline;">1 2 3 4 5 6 7 8 9 10 0xb 0xc 13</span>} <strong>&lt;&#8211;I2C command </strong><br />
210 I2C START CONDITION <strong>&lt;&#8211;bus start</strong><br />
220 I2C WRITE: 0xA6 GOT ACK: YES <strong>&lt;&#8211;address sent and ACK received</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES <strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES <strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;01 GOT ACK: YES <strong>&lt;&#8211;data</strong><br />
&#8230;<br />
220 I2C WRITE: 0&#215;0D GOT ACK: YES<br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Read from EEPROM (I2C)</span></p>
<p>Reading the 24LC1025 takes two steps. First, a write command with no data sets the address pointer. Second, a read command outputs data starting at the location set in step 1.</p>
<p>The first command is a write command, we use the hexadecimal equivalent of the write address (0b10100110 = 0xa6) to save a bit of typing. The address pointer is set to the location where we wrote our data (0 0).</p>
<blockquote><p>I2C&gt;{0xa6 0 0} <strong>&lt;&#8211;set write pointer command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xA6 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<br />
240 I2C STOP CONDITION</p></blockquote>
<p>With the pointer set, we can start reading data. The read address is the device address, with the last bit set to 1 ( 0b10100111 or 0xa7). We used thirteen r commands to read the data, but we could have used the shorthand version: 0r13.</p>
<blockquote><p>I2C&gt;{0b10100111 rrrrrrrrrrrrr}<strong> &lt;&#8211;read command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xA7 GOT ACK: YES <strong>&lt;&#8211;chip ACKed the read address</strong><br />
230 I2C READ: 0&#215;01 <strong>&lt;&#8211;data byte 1</strong><br />
230 I2C READ: 0&#215;02 <strong>&lt;&#8211;data byte 2</strong><br />
&#8230;<br />
230 I2C READ: 0&#215;0D <strong>&lt;&#8211;data byte 13</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>We know the operation was a success because the output matches the data we wrote earlier.</p>
<p><em>UART &#8211; EM406 SurfIII GPS</em></p>
<p><img class="alignnone size-full wp-image-5905" title="gps" src="http://hackadaycom.files.wordpress.com/2008/11/gps.jpg?w=450&#038;h=338" alt="gps" width="450" height="338" /></p>
<p>The <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=465">EM406</a> is a tiny 5volt GPS module that tracks up to 20 satellites. By default, it outputs NMEA formatted data from a serial port at 4800bps, 8N1. The output format is standard serial, but at 2.8volts it&#8217;s incompatible with PC serial ports. The Bus Pirate can interface this GPS without the need for a separate RS232 transceiver or 5volt power supply.</p>
<p><span style="text-decoration:underline;">Setup the UART</span></p>
<p>First, we setup the Bus Pirate UART to receive serial data at 4800bps.</p>
<blockquote><p>I2C&gt;m <strong>&lt;&#8211;setup mode</strong><br />
1. SPI<br />
2. I2C<br />
3. UART<br />
4. RAW 2 WIRE<br />
5. RAW 3 WIRE<br />
MODE&gt;3 <strong>&lt;&#8211;UART</strong><br />
900 MODE SET<br />
Set speed:<br />
(bps)<br />
1. 300<br />
2. 1200<br />
3. 2400<br />
4. 4800<br />
&#8230;<br />
9. 115200<br />
SPEED&gt;4  <strong>&lt;&#8211;4800bps</strong><br />
901 SPEED SET<br />
302 UART READY<br />
UART&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Enable UART and data reads</span></p>
<p>An important thing to remember about UARTs is that the data arrives asynchronously. Unlike SPI and I2C, where data transfer is controlled by the master, serial data can arrive at the UART at any time. The GPS is a great example of this because it spits out location data continuously, without user intervention.</p>
<p>We developed two read modes to cope with asynchronous data .  { echos all incoming data as it arrives.  New data will displace and garble data entry, but all input is still accepted normally.  [ opens the UART in a send only mode that discards incoming bytes. } or ] closes the UART, regardless of the mode.</p>
<blockquote><p>UART&gt;{ <strong>&lt;&#8211;open UART with async reads</strong><br />
310 UART OPEN, } TO CLOSE<br />
330 UART READ: 0&#215;80 <strong>&lt;&#8211;GPS data</strong><br />
330 UART READ: 0&#215;78</p></blockquote>
<p><span style="text-decoration:underline;">Write to the UART</span></p>
<p>Type in values to send out the UART. Even if the input is broken up by incoming data, it will be processed on &lt;enter&gt;.  We sent <em>0&#215;40</em> as an example, but this has no particular meaning to the GPS module.</p>
<blockquote><p>330 UART READ: 0&#215;80 <em>0&#215;40</em><strong>&lt;&#8211;random byte to write</strong><br />
320 UART WRITE: 0&#215;40 <strong>&lt;&#8211;byte written</strong></p></blockquote>
<p><span style="text-decoration:underline;">Close the UART</span></p>
<p>&#8220;}&#8221; followed by &lt;enter&gt; closes the UART.</p>
<blockquote><p>330 UART READ: 0&#215;78<br />
303 UART READ: 0&#215;60 <em>} </em><strong>&lt;&#8211;close UART command</strong><br />
330 UART READ: 0xE6<br />
340 UART CLOSED<br />
UART&gt;</p></blockquote>
<p>Don&#8217;t think you can use this GPS data to track us, we don&#8217;t actually get satellite reception down here in mom&#8217;s basement.</p>
<p><strong>Taking it further</strong></p>
<p>The Bus Pirate is an important development tool in our lab. We keep updating it as we use it, and we&#8217;ll release new firmware as we add protocols and features. Expect to see the Bus Pirate in future articles.</p>
<p>These improvements are at the top of our list. Do you have any suggestions?</p>
<ul>
<li>New protocols: One Wire, CAN, ???</li>
<li>Controls for polarity and other settings</li>
<li>Adjustable instruction delay</li>
<li>Get hardware I2C module working.</li>
<li>Enable protocol speed settings.</li>
<li>Cheaper, easier to get RS232 transceiver</li>
</ul>
<p>The <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP) has everything you need to build your own Bus Pirate.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/5882/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=5882&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" medium="image">
			<media:title type="html">i2ceeprom</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/overview-diagram-new.png" medium="image">
			<media:title type="html">overview-diagram-new</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/terminal-450.png" medium="image">
			<media:title type="html">terminal-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/brd-450.png" medium="image">
			<media:title type="html">brd-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/cct-450.png" medium="image">
			<media:title type="html">cct-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/buspirate-24fv0a.jpg" medium="image">
			<media:title type="html">buspirate-24fv0a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" medium="image">
			<media:title type="html">i2ceeprom</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/gps.jpg" medium="image">
			<media:title type="html">gps</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: USB remote control receiver</title>
		<link>http://hackaday.com/2008/10/30/how-to-usb-remote-control-receiver/</link>
		<comments>http://hackaday.com/2008/10/30/how-to-usb-remote-control-receiver/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 01:34:08 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[home entertainment hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[peripherals hacks]]></category>
		<category><![CDATA[computer remote control]]></category>
		<category><![CDATA[decode ir signals]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[IR remote]]></category>
		<category><![CDATA[logic analyzer]]></category>
		<category><![CDATA[pc remote control]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[remote control]]></category>
		<category><![CDATA[usb ir receiver]]></category>
		<category><![CDATA[usb remote]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=5239</guid>
		<description><![CDATA[
Now that we listen to MP3s, and watch XVIDs or x264s, a computer is the entertainment center in at least one room of most homes. Unless you have a special HTPC, though, you&#8217;re probably stuck using the keyboard to pause, change the volume, and fast-forward through annoying Mythbusters recaps. PC remote control receivers range from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=5239&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-5305" title="remir" src="http://hackadaycom.files.wordpress.com/2008/10/remir.jpg?w=450&#038;h=346" alt="" width="450" height="346" /></p>
<p>Now that we listen to <a title="MP3 - Mahalo" href="http://www.mahalo.com/MP3">MP3s</a>, and watch XVIDs or x264s, a computer is the entertainment center in at least one room of most homes. Unless you have a special HTPC, though, you&#8217;re probably stuck using the keyboard to pause, change the volume, and fast-forward through annoying Mythbusters recaps. PC remote control receivers range from ancient serial port designs (who has one?) to USB devices not supported by popular software. In this how-to we design a USB infrared receiver that imitates a common protocol supported by software for Windows, Linux, and <a title="Mac Hacks - Mahalo" href="http://www.mahalo.com/Mac_Hacks">Mac</a>. We&#8217;ve got a full guide to the protocol plus schematics and a parts list.</p>
<p><span id="more-5239"></span><strong>Design overview</strong></p>
<p><strong><img class="alignnone size-full wp-image-5306" title="overview" src="http://hackadaycom.files.wordpress.com/2008/10/overview.png?w=450&#038;h=174" alt="" width="450" height="174" /><br />
</strong></p>
<p>Remote controls transmit data on an modulated infrared beam. An infrared receiver IC separates the modulated beam into a clean stream of 0s and 1s. The data stream is decoded by a microcontroller and sent to a computer over a USB connection. Software processes the codes and triggers actions on the computer.</p>
<p><strong>Background</strong></p>
<p><em>Computer infrared receivers</em></p>
<p>The <a href="http://www.lirc.org/receivers.html">oldest PC infrared receiver design</a> uses a receiver IC to toggle a serial port pin, usually DCD. This design probably originated on <a href="http://en.wikipedia.org/wiki/USENET">Usenet</a>, and it&#8217;s still the most popular on the web: <a href="http://www.engadget.com/2006/05/16/how-to-ir-remote-control-your-computer/">Engadget</a>, <a href="http://www.instructables.com/id/IR-Remote-Control-For-your-Computer/">Instructables</a>, etc. These aren&#8217;t true serial devices because they don&#8217;t send data to the PC. Instead, a computer program times pulses on the serial port and demodulates the signal. This is a super simple design, but it depends on direct interrupt access and timing precision that&#8217;s no longer available in Windows. Linux or Mac users can try this receiver, if you still have a serial port. We couldn&#8217;t get this type of receiver to work with the serial port on a modern Windows XP PC, and don&#8217;t expect the precise timing to transfer through a USB-&gt;serial converter.</p>
<p>Some more advanced infrared receivers are true serial port devices that measure or decoding infrared signals before sending data to the computer. The <a href="http://fly.cc.fer.hr/~mozgic/UIR/">UIR/IRMan</a> and <a href="http://users.skynet.be/sky50985/">UIR2</a> incorporate a classic PIC 16F84, but don&#8217;t provide firmware and/or source code. These devices should work on a modern computer, through a USB-&gt;serial converter if necessary. The <a href="http://www.xs4all.nl/~dicks/avr/usbtiny/">USBTINY</a> and <a href="http://usbirboy.sourceforge.net/">USBIRBOY</a> are native USB devices, but lack wide support.</p>
<p><em>Receiver software</em></p>
<p>Regardless of receiver type, the computer needs a program to listen for incoming remote commands and convert them to actions on the computer. Linux and Mac users have <a href="http://www.lirc.org/">LIRC</a>, which supports a bunch of different receiver types. Windows users are a bit less fortunate. <a href="http://winlirc.sourceforge.net/">WinLIRC</a> is an abandoned Windows port of LIRC for simple interrupt-based serial port receivers; WinLIRC was last developed in 2003. <a href="http://www.promixis.com/products.php">Girder</a> was originally a freeware PC automation utility, but has become expensive bloatware with a 30 day trial. Fortunately, the last <a href="http://www.oldversion.com/talk/showthread.php?t=1465">freeware version of Girder (3.2.9b)</a> is still available for download.</p>
<p><strong>Working with IR remote protocols</strong></p>
<p><em>Decoding IR signals</em><strong><br />
</strong></p>
<p>Remote controls encode commands in the spacing or timing of a 38KHz carrier pulse, [San Bergmans] has an <a href="http://www.sbprojects.com/knowledge/ir/ir.htm">explanation of the principals involved</a>. An infrared receiver IC separates the data stream from the carrier. Our job is to decode the data stream with a microcontroller. There are dozens of remote control protocols, but Phillips&#8217; <a href="http://www.sbprojects.com/knowledge/ir/rc5.htm">RC5</a> is widespread and commonly used by hobbyists.</p>
<p>RC5 is stream of 14 equal length bits of exactly 1.778ms per bit time. A pulse during the first half of the bit time represents 0, a pulse in the second half represents 1. This scheme is called <a href="http://en.wikipedia.org/wiki/Manchester_coding">Manchester coding</a>.</p>
<p><img class="alignnone size-full wp-image-5293" title="logic-450" src="http://hackadaycom.files.wordpress.com/2008/10/logic-450.png?w=450&#038;h=134" alt="" width="450" height="134" /></p>
<p>We used a logic analyzer to examine the output of a Happauge WinTV remote control, a <a href="http://osdir.com/ml/hardware.lirc/2006-04/msg00061.html">known</a> RC5 remote. The diagram shows two presses of the 1 button, and two presses of the 2 button; note that the output is inversed and the Manchester coding is backwards from the above description.</p>
<p>The first two bit times are start bits, followed by a toggle bit. The toggle bit inverses each time a button is pressed so the receiver can tell the difference between a hold and a repeated press. The next 5 bits are the address (0b11110=0&#215;1E), followed by the command (0b000001=0&#215;01, 0b000010=0&#215;02). A backwards compatible extension to RC5 uses the second start bit as command bit 7.</p>
<p><em>Representing remote codes to the computer</em></p>
<p>Looking at previous designs, we saw three general methods of communicating remote commands to a computer:</p>
<ul>
<li>Protocol specific receivers decode one protocol, and send actual decoded commands to the PC</li>
<li>A more general type of receiver measures the timing and spacing of each pulse and sends the full waveform to the PC for analysis.</li>
<li>Some receivers create a unique hash for a signal, but don&#8217;t actually include enough data to fully recreate the waveform.</li>
</ul>
<p>While our preference is towards the general hash method, our only remote uses RC5 and it was more interesting to build an RC5 specific decoder. We describe modifications for a more general version in the firmware section.</p>
<p><em>Computer interface protocol</em></p>
<p>We didn&#8217;t want to write our own receiver software or driver, so we looked for an existing, well established communication protocol to imitate. The  UIR/IRMAN/IRA/CTInfra/Hollywood+ type receiver is supported by Girder and LIRC, and uses a <a href="http://www.raphnet.net/divers/documentation/irman_protocol.txt">simple serial protocol with handshake</a>:</p>
<ul>
<li>The device is initialized by the DTS and DTR pins of the serial port. We don&#8217;t have these and don&#8217;t care.</li>
<li>The computer sends &#8220;IR&#8221;, with an optional delay. The device replies &#8220;OK&#8221;. We&#8217;ll just send &#8220;OK&#8221; on every &#8220;R&#8221;</li>
<li>Remote control codes are sent as a unique six byte hash. We&#8217;ll decode an RC5 signal and send the actual values, but a generic hash could be used instead.</li>
</ul>
<p>This protocol is for a serial port device, but our USB receiver will appear as a virtual serial port and the program won&#8217;t know the difference.</p>
<p><strong>Hardware</strong></p>
<p><img class="alignnone size-full wp-image-5294" title="cct" src="http://hackadaycom.files.wordpress.com/2008/10/cct.png?w=453&#038;h=253" alt="" width="453" height="253" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/10/cct-large2.png">Click here for a full size schematic</a> (png). Our receiver is based on a USB enabled PIC <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010273">18F2455</a> microcontroller, the smaller, cheaper version of the 18F2550. The 18F family is programmable with the hobbyist favorite <a href="http://www.instructables.com/id/Business-Card-PIC-Programmer/">JDM-style programmers</a> if <a href="http://www.diylife.com/2008/02/15/program-a-pic-microcontroller/">a diode is used</a> to drop VPP to a safe level. The PIC gets one decoupling capacitor (C1), and a diode (D1) and resistor(R1) on the <a href="http://www.instructables.com/id/Understanding-ICSP-for-PIC-Microcontrollers/">ICSP programming header</a>. We exposed the serial port on a pin header for debugging or a mixed USB/serial port version using a <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1369">MAX RS232 transceiver</a> IC.</p>
<p>The USB peripheral requires a 20MHz external clock (Q1, C5,6), and a .220uF capacitor. We faked the capacitor using 2 x .1uF decoupling capacitors (C2,3). A 3mm LED (LED1) and a 330ohm current limiting resistor (R2) show USB connection status.</p>
<p>We used a TSOP-1738 infrared receiver IC which calls for a 4.7uF decoupling capacitor (C4). If you can&#8217;t find this particular IC, <a href="http://www.lirc.org/receivers.html">any receiver listed here</a> should work. The TSOP-1738 output is the inverse of the received signal, it pulls to ground when a pulse is detected, so a pull-up resistor (R3) holds the pin high when no signal is present. Check if you use a different receiver, you may need to use a pull-down resistor and reverse the Manchester decoding routine in the firmware.</p>
<p>The circuit draws power from the USB bus, so we don&#8217;t need an additional power supply.</p>
<p><em>Parts list</em></p>
<p><img class="alignnone size-full wp-image-5295" title="brd" src="http://hackadaycom.files.wordpress.com/2008/10/brd.png?w=451&#038;h=324" alt="" width="451" height="324" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/10/brd-large.png">Click here for a full size placement diagram</a> (png).<em> </em>The PCB design is 100% through-hole and single sided. The schematic and PCB were made with<a href="http://www.cadsoft.de"> Cadsoft Eagle</a>, freeware versions are available for most platforms. All the files are included in the <a href="http://blog.mahalo.com/hackaday/howto/USBIRr.v1a.zip">project archive</a> (zip).</p>
<table style="text-align:center;height:302px;" border="0" width="299">
<tbody>
<tr>
<td width="43">
<div><strong>Part</strong></div>
</td>
<td width="135">
<div><strong>Description</strong></div>
</td>
</tr>
<tr>
<td>
<div>IC1</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=W2ndVjZwIIJcNNcdKyvBpg%3d%3d">PIC 18F2455</a></div>
</td>
</tr>
<tr>
<td>
<div>&#8211;</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=571-1-390261-9">28 pin .300 socket</a></div>
</td>
</tr>
<tr>
<td>
<div>C1,2,3</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=9AX3phJxokWIpR5WRGtIJw%3d%3d">0.1uF capacitor</a></div>
</td>
</tr>
<tr>
<td>
<div>C4</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=uVOgrT8JCzAhqeVLfh7brw==">4.7uF capacitor</a></div>
</td>
</tr>
<tr>
<td>
<div>C5,6</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=MQgq2qvN%2feSRs7vKBDt0OA%3d%3d">27pF capacitor</a> (<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=x3u4YJAyqD7XMSE5%2fJr6lg%3d%3d">15pF</a> might be better)</div>
</td>
</tr>
<tr>
<td>
<div>D1</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=TNTIDjy6APqozHdyHHFUGA%3d%3d">1N4181 diode</a></div>
</td>
</tr>
<tr>
<td>
<div>Q1</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=ECS-200-S-1Xvirtualkey59070000virtualkey520-HCA2000-SX">20MHz crystal</a></div>
</td>
</tr>
<tr>
<td>
<div>R1,3</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=IP4CA2YhK0BxnZulBOfonw%3d%3d">10K ohm resistor</a></div>
</td>
</tr>
<tr>
<td>
<div>R2</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=ULgY8XwKjTmmv2gtdH4CoQ%3d%3d">330 ohm resistor</a></div>
</td>
</tr>
<tr>
<td>
<div>TSOP</div>
</td>
<td>
<div>TSOP1738 (obsolete, try <a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=oNDV51lhjEM7P54c1MlVIg%3d%3d">TSOP1138</a>)</div>
</td>
</tr>
<tr>
<td>
<div>USB</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=N76qWb2E9MJwqgFT2KIWcQ%3d%3d">USB &#8216;B&#8217; plug, female</a></div>
</td>
</tr>
<tr>
<td>
<div>SER</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">.1&#8243; pin header</a></div>
</td>
</tr>
<tr>
<td>
<div>ICSP</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">.1&#8243; pin header</a></div>
</td>
</tr>
</tbody>
</table>
<p><img class="alignnone size-full wp-image-5296" title="render" src="http://hackadaycom.files.wordpress.com/2008/10/render.jpg?w=450&#038;h=229" alt="" width="450" height="229" /></p>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using Microchip&#8217;s free demonstration <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010014">C18 compiler</a>. Firmware and source are included in the <a href="http://blog.mahalo.com/hackaday/howto/USBIRr.v1a.zip">project archive</a> (zip).</p>
<p>We used <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=2680&amp;dDocName=en537044">version 2.3 of Microchip&#8217;s USB stack</a> to create a USB serial port using the default drivers already available on most systems. The USB stack has simple functions to enumerate the USB device and transfer data between device and host. It only took a few pin changes to get  the CDC demonstration working on our custom hardware.</p>
<p>Our implementation of the UIR/IRMAN/IRA/CTInfra/Hollywood+ protocol simply responds to the letter &#8216;R&#8217; with &#8216;OK&#8217;. This should satisfy the handshake requirements of any implementation of this protocol.</p>
<p>We chose to specifically decode RC5 (and RC5x) because it&#8217;s a widely used protocol, and the only type of remote we have to work with. Most of the decoding is done in the interrupt handler:</p>
<ul>
<li>The first signal change triggers an interrupt that starts a 889us (one-half bit period) timer.</li>
<li>On each timer interrupt, one-half of a Manchester coded bit is sampled.</li>
<li>Every other interrupt the measurements are compared, and the bit value is calculated to be 0, 1, or an error. Errors reset the decoding routing.</li>
<li>At the end of each transmission the address and command bytes are decoded, and sent to the host with 4 buffer bytes(0). We discard the toggle bit because it would confuse the PC software into thinking every other press was a unique code. We append the second start bit to the command bit for RC5x compliance; this just adds 0&#215;40 to non RC5x remote codes.</li>
</ul>
<p>A more general version can be made by removing the Manchester coding step (3), and sending 48 sample bits (all 6 bytes) to the computer.</p>
<p><strong>Installing the USB infrared receiver</strong></p>
<p>Most operating systems already have drivers that support a virtual serial port device like the receiver. Windows XP has the required drivers, but needs help from an .inf file to properly associate them with our device.</p>
<p>Windows will show the new hardware dialog the first time you plug in the receiver. Choose to use a custom driver and point it to the .inf file included in the <a href="http://blog.mahalo.com/hackaday/howto/USBIRr.v1a.zip">project archive</a> (zip). This links the device to a driver already included in Windows, and adds the receiver as a COM port. You can check the COM port number in the control panel.</p>
<p>Mac and Linux users can use the receiver with LIRC, but Windows users will be faced with the choice of the old, freeware Girder, or the new, 30-day trial shareware version. We used the freeware version of Girder, but hope you guys can suggest a great, open source alternative that we overlooked.</p>
<p><img class="alignnone size-full wp-image-5297" title="girder" src="http://hackadaycom.files.wordpress.com/2008/10/girder.png?w=427&#038;h=213" alt="" width="427" height="213" /></p>
<p>Regardless of the computer-side control software you use, configure it for a UIR/IRMAN/IRA/CTInfra/Hollywood+ style receiver, and enter the COM port or serial address assigned to it. Our receiver is also compatible with any protocol options like &#8216;Fast UIR Init&#8217; and &#8216;Skip UIR Init Check&#8217;, which shorten or eliminate the &#8220;IR&#8221;-&gt;&#8221;OK&#8221; handshake.  Now test the receiver and add a remote according to the documentation for your software.</p>
<p><strong>Manual terminal interface and debugging</strong></p>
<p>If you have a problem with the receiver, or you&#8217;re just curious, try to interface it from a serial terminal. We really like the serial terminal on <a href="http://www.hw-group.com/products/hercules/index_en.html">Hercules</a>. Set the correct COM port, but the speed and configuration settings are ignored by the USB serial port driver.</p>
<p><img class="alignnone size-full wp-image-5298" title="hercu" src="http://hackadaycom.files.wordpress.com/2008/10/hercu.png?w=450&#038;h=216" alt="" width="450" height="216" /></p>
<p>A capital &#8216;R&#8217; will prompt the receiver to reply &#8216;OK&#8217;. RC5 codes are returned as raw bytes, so be sure to set your terminal to show HEX values rather than interpret it as <a title="ASCII - Mahalo" href="http://www.mahalo.com/ASCII">ASCII</a> text. The first byte is the RC5 address byte (0&#215;1E), followed by the command byte (0&#215;41), and then four buffer 0s to comply with the UIR/IRman protocol. The image shows the handshake, and the output of a short press on the 1,2, and 3 buttons.</p>
<p><img class="alignnone size-full wp-image-5299" title="portmon-irman" src="http://hackadaycom.files.wordpress.com/2008/10/portmon-irman.png?w=450&#038;h=127" alt="" width="450" height="127" /></p>
<p>A free utility called <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx">Portmon</a> logs COM port activity for review. This is helpful for spying on existing receiver protocols, and debugging the interaction of our custom hardware and closed/proprietary software. The image shows Girder sending the initialization string &#8216;IR&#8217; (0&#215;49,0&#215;52), and the receiver reply &#8216;OK&#8217; (0&#215;4F,0&#215;4B).</p>
<p><strong>Taking it further</strong></p>
<p>Our RC5x compliant receiver follows a widely used interface protocol. There&#8217;s a ton of possibilities for additional features in an open source infrared receiver:</p>
<ul>
<li>Support all remotes through a generic hash generator, like the original UIR/IRman hardware.</li>
<li>Add additional remote protocol decoders, like <a href="http://www.sbprojects.com/knowledge/ir/rc6.htm">RC6</a>.</li>
<li>Support multiple, configurable interface protocols.</li>
<li>Implement the serial port I/O.</li>
<li>Store configuration options in EEPROM, including protocol, interface mode, timing options, serial port, etc.</li>
</ul>
<p><img class="alignnone size-full wp-image-5292" title="ird" src="http://hackadaycom.files.wordpress.com/2008/10/ird.jpg?w=450&#038;h=372" alt="" width="450" height="372" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/5239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/5239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/5239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/5239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/5239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/5239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/5239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/5239/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/5239/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/5239/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=5239&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/10/30/how-to-usb-remote-control-receiver/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/remir.jpg" medium="image">
			<media:title type="html">remir</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/overview.png" medium="image">
			<media:title type="html">overview</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/logic-450.png" medium="image">
			<media:title type="html">logic-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/cct.png" medium="image">
			<media:title type="html">cct</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/brd.png" medium="image">
			<media:title type="html">brd</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/render.jpg" medium="image">
			<media:title type="html">render</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/girder.png" medium="image">
			<media:title type="html">girder</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/hercu.png" medium="image">
			<media:title type="html">hercu</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/portmon-irman.png" medium="image">
			<media:title type="html">portmon-irman</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/ird.jpg" medium="image">
			<media:title type="html">ird</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Make an e-paper clock from Esquire magazine</title>
		<link>http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/</link>
		<comments>http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 20:16:25 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[classic hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[e-ink]]></category>
		<category><![CDATA[e-paper]]></category>
		<category><![CDATA[e-paper clock]]></category>
		<category><![CDATA[eink]]></category>
		<category><![CDATA[epaper]]></category>
		<category><![CDATA[esquire]]></category>
		<category><![CDATA[esquire cover]]></category>
		<category><![CDATA[hack esquire e-paper cover]]></category>
		<category><![CDATA[recycling]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=4602</guid>
		<description><![CDATA[
If you&#8217;ve never heard about electronic paper, crawl out from under that rock and read up on the Sony Reader and the Amazon Kindle. E-paper is a flexible display made of color-changing beads that mimic ink-on-paper for easy daylight reading. The revolutionary thing about e-paper is that after it&#8217;s set, it stays that way without [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=4602&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-4675" title="final-clock-450" src="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450.jpg?w=450&#038;h=322" alt="" width="450" height="322" /></p>
<p>If you&#8217;ve never heard about electronic paper, crawl out from under that rock and read up on the <a href="http://en.wikipedia.org/wiki/Sony_Reader">Sony Reader</a> and the <a href="http://en.wikipedia.org/wiki/Amazon_Kindle">Amazon Kindle</a>. E-paper is a flexible display made of color-changing beads that mimic ink-on-paper for easy daylight reading. The revolutionary thing about e-paper is that after it&#8217;s set, it stays that way without additional power.</p>
<p>This sounds great in theory, but <a href="http://www.esquire.com/the-side/video/hacking-the-e-ink-cover">Esquire&#8217;s cover</a> is the first time everybody can afford to hack an e-paper display. We took the cover into the Hack a Day lab to document, test, and hack. In the end, we recycled it into something useful that anyone can build. We&#8217;ve got all the details on how the display works and what it takes to use it in your own projects. Read about our e-paper clock hack below.<span id="more-4602"></span></p>
<p><strong>Background</strong></p>
<p><img class="alignnone size-full wp-image-4720" title="esquire_cover" src="http://hackadaycom.files.wordpress.com/2008/10/esquire_cover.jpg?w=450&#038;h=295" alt="" width="450" height="295" /></p>
<p>The Esquire e-paper cover hit big on the net, but was <a href="http://blog.wired.com/business/2008/09/esquires-first.html">quickly panned</a>. NOTCOT has beautiful <a href="http://www.notcot.com/archives/2008/09/dissecting_esqu.php">scans of the circuit board and e-paper</a>. Popular Science posted instructions for <a href="http://www.popsci.com/diy/article/2008-09/hacking-esquire-e-ink-cover-update">reading the code with a PICkit2</a>. [Slaxter] <a href="http://mybitbox.com/view.php?p=11">verified that the PIC chip can be read</a>, and that the code protection fuses are off. [Matt] manipulated the e-paper cells directly with <a href="http://antipastohw.blogspot.com/2008/10/hacking-esquire-cover-e-ink-screen-with.html">skillful soldering and an Arduino</a>. So far, there hasn&#8217;t been a lot of interest in repurposing the e-paper, or reprogramming the existing microcontroller.</p>
<p><strong>E-paper panels</strong></p>
<p><img class="alignnone size-full wp-image-4721" title="panel-bare-450" src="http://hackadaycom.files.wordpress.com/2008/10/panel-bare-450.jpg?w=450&#038;h=328" alt="" width="450" height="328" /></p>
<p>The actual e-paper panels, manufactured by <a href="http://mahalo.com/E-ink">E-Ink</a>, aren&#8217;t that exciting. Each panel has a set of predefined segments, 11 on the front panel and 3 on the rear Ford advertisement. This isn&#8217;t a matrix that we can reprogram into an e-reader. [just_mike] has a great set of <a href="http://flickr.com/photos/just_mike/2833061896/in/set-72157607133868125/">ultra close-up shots of the individual beads</a> that make up each segment.</p>
<p><img class="alignnone size-full wp-image-4685" title="eink1" src="http://hackadaycom.files.wordpress.com/2008/10/eink1.png?w=450&#038;h=291" alt="" width="450" height="291" /></p>
<p>Each e-paper segment has an individual connection, and a connection that&#8217;s shared with other cells on the panel.  The segments become white or black depending on the direction of current applied to the cell. When common is low, any segment that is also connected high will darken. When common is high, each cell connected to ground will clear. The PCB uses 16 volts from five 3.3volt batteries to switch the cells, but [Slaxter] showed that 5volts was sufficient with his Arduino project.</p>
<p><em>Performance testing</em><br />
We made several observations about the e-paper operating specifications.</p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/"><img src="http://img.youtube.com/vi/T6GTFvNjRCk/2.jpg" alt="" /></a></span></p>
<p>First, it takes nearly 0.5 seconds to completely darken or clear a cell. In the video you can see the partial states created by switching the e-paper too fast. We&#8217;re not quite sure of the optimal change time, but between 0.25 and 0.5 seconds seems to be the minimum.</p>
<p>This also raised questions about the maximum change time. Does it damage the e-paper to apply current for longer than necessary? Does the e-paper continue to consume current as long as it&#8217;s applied, wasting the batteries? We took special care in our code to return all outputs to ground after a change to avoid a continuous current through the panel.</p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/"><img src="http://img.youtube.com/vi/hix9-h5UuSc/2.jpg" alt="" /></a></span></p>
<p>Clearing and darkening must be done separately. It takes two complete operations to fully refresh the screen; one to clear old segments, one to darken new segments. A smart programmer will think they can save a cycle when only adding or removing items, and not doing both. This is true to some extent, but continuous manipulation of one cell without refreshing adjacent cells causes color &#8216;creep&#8217;. In the video, a flashing background without updates to any other segments quickly drives the inactive segments to a mid-state between dark and light.</p>
<p><strong>Driver board</strong></p>
<p><img class="alignnone size-full wp-image-4722" title="driver-board" src="http://hackadaycom.files.wordpress.com/2008/10/driver-board.jpg?w=450&#038;h=152" alt="" width="450" height="152" /></p>
<p>The driver consists of an eight-pin Microchip <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010113">PIC12F629</a>, two <a href="http://www.nxp.com/#/pip/pip=[pip=HEF4094B_CNV_3]|pp=[t=pip,i=HEF4094B_CNV_3]">4094</a> <a href="http://en.wikipedia.org/wiki/Shift_register">shift registers</a>, and some supporting components.</p>
<p><img class="alignnone size-full wp-image-4686" title="pin-out-illu-450" src="http://hackadaycom.files.wordpress.com/2008/10/pin-out-illu-450.png?w=450&#038;h=248" alt="" width="450" height="248" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/10/pin-out-illu.png">Click here for a full size pin diagram of the e-paper driver board</a>(PNG).</p>
<p><em>Batteries</em></p>
<p>Esquire <a href="http://www.esquire.com/the-side/video/hacking-the-e-ink-cover">invited hacks of their cover</a> with the rather lame suggestion of replacing the batteries. This makes sense, the covers were <a href="http://www.esquire.com/features/how-e-ink-was-made">shipped all over the world in refrigerated containers</a> to help extend the battery life. Even with that effort, Esquire says that the batteries will last a few months.</p>
<p>Batteries 1-5 are in series and provide a 15-16volt switching current for the e-paper. The sixth battery provides 3volts for the PIC. No word yet on which batteries die first. If you want to &#8216;replace&#8217; your batteries, you&#8217;ll need to desolder the old ones, and provide a 5-16volt e-paper supply, and 3volt microcontroller supply, at the points indicated.</p>
<p><img class="alignnone size-full wp-image-4724" title="final-clock-450-new-bat-narrow" src="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450-new-bat-narrow.jpg?w=449&#038;h=235" alt="" width="449" height="235" /></p>
<p>We eventually had to replace our microcontroller battery because we abused it a bit during development. A button battery holder with 20mm pin spacing will fit the existing holes. Mouser #<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=Q3RoVmURDolnMuconA2vXg%3d%3d">534-106</a> will probably work, but this is unconfirmed.</p>
<p><em>4094 shift registers (IC1, IC2)</em></p>
<p>The shift registers switch the e-paper segment controls at 16 volts.</p>
<p><img class="alignnone size-full wp-image-4689" title="4094b1" src="http://hackadaycom.files.wordpress.com/2008/10/4094b1.png?w=450&#038;h=156" alt="" width="450" height="156" /><br />
The two 4094 ICs are shift registers setup to cascade data from IC1 to IC2. This simple shift register is a slight variation on the 74HTC595 we used in our <a href="http://hackaday.com/2008/10/02/how-to-networked-graffiti-wall/">graffiti wall</a>. The main difference is that the 4094 strobe line is normally low, and briefly pulled high to put new values on the output pins. We noticed that the 4094 requires long clock and strobe pulses. This could be due to lazy drive circuitry between the PIC and the 4094, or just the nature of the <a href="http://en.wikipedia.org/wiki/4000_series">4000 series</a>.</p>
<p><em>4094 segment output map</em></p>
<table border="0">
<tbody>
<tr>
<td>
<div><strong>IC</strong></div>
</td>
<td>
<div><strong>Output</strong></div>
</td>
<td>
<div><strong>Address</strong></div>
</td>
<td>
<div><strong>Connection</strong></div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q1</div>
</td>
<td>
<div>0&#215;01</div>
</td>
<td>
<div>FRONT_BOX_SYMBOL_DNA</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q2</div>
</td>
<td>
<div>0&#215;02</div>
</td>
<td>
<div>FRONT_BOX_GUY</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q3</div>
</td>
<td>
<div>0&#215;04</div>
</td>
<td>
<div>FRONT_BOX_FIREWORKS</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q4</div>
</td>
<td>
<div>0&#215;08</div>
</td>
<td>
<div>FRONT_ON_THE_WEST_COAST</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q5</div>
</td>
<td>
<div>0&#215;10</div>
</td>
<td>
<div>FRONT_THREE_HOURS_LATER</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q6</div>
</td>
<td>
<div>0&#215;20</div>
</td>
<td>
<div>FRONT_ESQUIRE</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q7</div>
</td>
<td>
<div>0&#215;40</div>
</td>
<td>
<div>FRONT_BOX_GIRL</div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>Q8</div>
</td>
<td>
<div>0&#215;80</div>
</td>
<td>
<div>FRONT_NOW</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q1</div>
</td>
<td>
<div>0&#215;100</div>
</td>
<td>
<div>FRONT_BEGINS</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q2</div>
</td>
<td>
<div>0&#215;200</div>
</td>
<td>
<div>FRONT_21ST_CENTURY</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q3</div>
</td>
<td>
<div>0&#215;400</div>
</td>
<td>
<div>FRONT_BACKGROUND</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q4</div>
</td>
<td>
<div>0&#215;800</div>
</td>
<td>
<div>FRONT_COMMON</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q5</div>
</td>
<td>
<div>0&#215;1000</div>
</td>
<td>
<div>BACK_COMMON</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q6</div>
</td>
<td>
<div>0&#215;2000</div>
</td>
<td>
<div>BACK_LEFT</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q7</div>
</td>
<td>
<div>0&#215;4000</div>
</td>
<td>
<div>BACK_CENTER</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>Q8</div>
</td>
<td>
<div>0&#215;8000</div>
</td>
<td>
<div>BACK_RIGHT</div>
</td>
</tr>
</tbody>
</table>
<p><em>12F629</em></p>
<p><img class="alignnone size-full wp-image-4690" title="cct-4501" src="http://hackadaycom.files.wordpress.com/2008/10/cct-4501.png?w=448&#038;h=173" alt="" width="448" height="173" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/10/cct-large1.png">Click here for a full size schematic drawing</a>(PNG). An eight pin PIC12F629 drives the 4094 shift registers that control each e-paper segment. Two pins are unused (GP4, GP5).</p>
<p>The MCLR feature is enabled with resistor R8. The design doesn&#8217;t include a diode to protect the PIC from the 13volt programming current. Microchip recommends this, but there&#8217;s no other sensitive ICs sharing the circuit so perhaps the designer felt a resistor was sufficient protection.</p>
<p>Three pins drive the data, clock, and strobe lines of the 4094 (GP0, GP1, GP2). The 4094 has to be interfaced at the same voltage it switches, 16 volts, so the PIC switches the interface pins through transistors. As far as we can tell, the 4094 control lines are pulled high with a resistor. The PIC switches a transistor on, and it pulls the line to ground. <em>The interface to the 4094 is backwards</em>. A PIC high pin is seen as low at the shift register, and low is seen as high. The interface won&#8217;t work unless reversed.</p>
<p>The programming pins are brought to a header at the top of the PCB. We soldered standard .1&#8243; pin header into the holes provided (Mouser #<a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">571-41033290</a>). The two programming pins, PGD and PGC, are shared with the circuitry that drives the shift registers. We were able to read the device with an ICD2 debugger. We couldn&#8217;t reprogram it though, probably because of the shift register driver. Has anyone had success? Regardless, the shared pin arrangement makes it impossible to do in-circuit debugging on this device.</p>
<p><em>PIC pin connections</em></p>
<table border="0">
<tbody>
<tr>
<td>
<div><strong>Pin</strong></div>
</td>
<td>
<div><strong>Name</strong></div>
</td>
<td>
<div><strong>Connection</strong></div>
</td>
</tr>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>VDD</div>
</td>
<td>
<div>+3.3volts</div>
</td>
</tr>
<tr>
<td>
<div>2</div>
</td>
<td>
<div>GP5</div>
</td>
<td>
<div>&#8211;</div>
</td>
</tr>
<tr>
<td>
<div>3</div>
</td>
<td>
<div>GP4</div>
</td>
<td>
<div>&#8211;</div>
</td>
</tr>
<tr>
<td>
<div>4</div>
</td>
<td>
<div>GP3</div>
</td>
<td>
<div>MCLR (program VPP)</div>
</td>
</tr>
<tr>
<td>
<div>5</div>
</td>
<td>
<div>GP2</div>
</td>
<td>
<div>4094 Strobe</div>
</td>
</tr>
<tr>
<td>
<div>6</div>
</td>
<td>
<div>GP1</div>
</td>
<td>
<div>4094 Clock (program clock)</div>
</td>
</tr>
<tr>
<td>
<div>7</div>
</td>
<td>
<div>GP0</div>
</td>
<td>
<div>4094 Data (program data)</div>
</td>
</tr>
<tr>
<td>
<div>8</div>
</td>
<td>
<div>VSS</div>
</td>
<td>
<div>Ground</div>
</td>
</tr>
</tbody>
</table>
<p><strong>Tap the board</strong></p>
<p><img class="alignnone size-full wp-image-4693" title="tap-board2" src="http://hackadaycom.files.wordpress.com/2008/10/tap-board2.jpg?w=450&#038;h=304" alt="" width="450" height="304" /></p>
<p>It&#8217;s easy to tap into the board and use it with your favorite microcontroller. All but one of the required interface signals are already brought to a header. The strobe line can be tapped through the via indicated by the arrow. You don&#8217;t want the PIC to interfere with your new controller, so remove it or deactivate it by severing the power pin.</p>
<p><strong>Interface library</strong></p>
<p><img class="alignnone size-full wp-image-4694" title="debug-with-wsbc1" src="http://hackadaycom.files.wordpress.com/2008/10/debug-with-wsbc1.jpg?w=450&#038;h=264" alt="" width="450" height="264" /></p>
<p>Our first effort to drive the board involved our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F</a>-based <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">mini web server</a>. It was handy, and the PIC24F is easy to work with. We perfected our interface library on a low-power MSP430. Both versions are in the <a href="http://blog.mahalo.com/hackaday/howto/esquire.epaper.clock.v1.zip">project archive</a>(ZIP), but the MSP430 version of the library is more mature.</p>
<p>The library includes a software <a href="http://en.wikipedia.org/wiki/Bit-banging">bit-bang</a> routine, functions for interfacing the board, and address definitions for the segment and common lines. Options in esquire_eink.h enable a bit-bang delay and set its length; we found the 4094 lazy and in need of a lengthy clock pulse. The initBang() function sets the direction of the pins, and should be changed to suit your microcontroller. Call it, or set your IO pins to output elsewhere:</p>
<pre class="brush: cpp;">
bangInit(); //set bitbang pins to output
</pre>
<p>The setSeg() function sets the passed segments dark (1) or clear (0):</p>
<pre class="brush: cpp;">
setSeg(FRONT_BOX_GUY+FRONT_BACKGROUND, 1); //set(dark) these segments
setSeg(FRONT_21ST_CENTURY,0);//clear (light) these segments
</pre>
<p>The setSeg() function includes a color change delay defined by EINK_DELAY in esquire_eink.h. At the end of the delay it returns the shift register pins to ground. We want to avoid damaging to the e-paper or wasting the batteries, though we don&#8217;t really know if this is necessary.</p>
<p>One thing we noticed about setSeg() was that manipulating single cells causes adjacent cells to regress toward a mid-color. We developed the setDisplay() function to combat this by fully refreshing the display every time. setDisplay() includes a pause for each change, and then returns the shift register outputs to ground. Just pass the segment arrangement for a fully refreshed display:</p>
<pre class="brush: cpp;">
setDisplay(FRONT_ESQUIRE+BACK_LEFT);//XX dark, everything else clear
</pre>
<p>You can access the shift registers directly with the bangIt() function, but consider returning the shift registers outputs to &#8216;0&#8242; after the e-paper color change is complete. You could damage the e-paper or cause excessive current drain if you leave it on, if that&#8217;s actually &#8216;a thing&#8217;.</p>
<pre class="brush: cpp;">
bangIt(0b1110000000000000);//all back panel segments on
pause();//wait for the color change
bangIt(0x0000);//return all outputs to ground
</pre>
<p>To port the library to your microcontroller, just check the pin configurations in esquire_eink.h, and the pin setup function bangInit() in esquire_eink.c. Keep in mind that the pin directions are reversed by the interface transistors.</p>
<p><strong>Putting it to use, an e-paper clock</strong></p>
<p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/"><img src="http://img.youtube.com/vi/kluFFU90qnI/2.jpg" alt="" /></a></span></p>
<p>We wanted to do something useful with the first cheap consumer e-paper panel. It had to be something pretty easy so that lots of people can recycle this cool piece of technology. We couldn&#8217;t resist doing what so many do with <a href="http://www.youtube.com/watch?v=-84v-QVdk2k&amp;feature=related">old display tech</a>: make a clock. Schematics, firmware, and art templates are in the <a href="http://blog.mahalo.com/hackaday/howto/esquire.epaper.clock.v1.zip">project archive</a>(.zip).</p>
<p><img class="alignnone size-full wp-image-4696" title="bezel-export" src="http://hackadaycom.files.wordpress.com/2008/10/bezel-export.png?w=450&#038;h=190" alt="" width="450" height="190" /></p>
<p>There&#8217;s so few segments on the e-paper that we can only partially represent the time. Six segments show time, each fades to reveal the time to the nearest ten minutes past the hour. We also flash eye-candy on the non-time segments of the panel. Here&#8217;s the custom bezel we created. This bezel, and a template to make your own, are included in the <a href="http://blog.mahalo.com/hackaday/howto/esquire.epaper.clock.v1.zip">project archive</a>(ZIP). We printed our bezel mirrored so the ink is protected from scratches.</p>
<p><em>Hardware</em></p>
<p><em></em>We were inspired by the low-power properties of e-paper to use <a href="http://focus.ti.com/mcu/docs/mcuprodoverview.tsp?sectionId=95&amp;tabId=140&amp;familyId=342">Texas Instruments&#8217; MSP430 line of 16-bit microcontrollers</a>. With the right configuration, the MSP430 draws so little power that it&#8217;s only limited by the shelf life of a battery. We can even give the original designers a run for their money, and see if we can make a lower power device.</p>
<p>The best thing about the MSP430 is that you can buy a kit with a <a href="http://www.ti-estore.com/">USB programmer/debugger and breakout board for only 20 bucks</a>.  It comes with <a href="http://focus.ti.com/docs/toolsw/folders/print/iar-kickstart.html">a free C compiler limited to 4K</a>, but the F2013 only has 2K of memory. This is a complete development tool, no soldering involved. Learn more about <a href="http://www.diylife.com/2008/03/28/program-a-msp430-microcontroller/">working with the MSP430 in this how-to</a>.</p>
<p><img class="alignnone size-full wp-image-4697" title="msp430-cct-4501" src="http://hackadaycom.files.wordpress.com/2008/10/msp430-cct-4501.png?w=449&#038;h=132" alt="" width="449" height="132" /></p>
<p>This schematic shows how we connected our MSP430 to the e-paper driver board. <a href="http://hackadaycom.files.wordpress.com/2008/10/mps430-cct-large2.png">Click here for a full size version</a>(PNG). The 47K resistor, MSP430, and an LED (not shown) are included on the breakout board.</p>
<p>We added a 32.768KHz crystal to keep time (Q1). Normally, we&#8217;d also add some capacitors to form an oscillator, but the MSP430 has built-in adjustable capacitors on P2.6 and P2.7.</p>
<p>We also added a <a href="http://hackaday.com/2008/09/15/tact-switches-for-your-next-project/">button</a> between P1.4 and P1.2 (S1). The internal <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up resistor</a> on P1.4 holds the button high, and we grounded it through P1.2. This isn&#8217;t the best arrangement, it would probably be wise to also connect P1.2 to ground.</p>
<p><img class="alignnone size-full wp-image-4699" title="msp430-connections" src="http://hackadaycom.files.wordpress.com/2008/10/msp430-connections.jpg?w=450&#038;h=357" alt="" width="450" height="357" /></p>
<p>We slid the MSP430 breakout board over the power and ground pins of the programming header. You can connect the clock and data pins to the header too, but we decided to route them all from the vias underneath. Remember to remove the PIC so it doesn&#8217;t interfere with signals from the MSP430.</p>
<table border="0">
<tbody>
<tr>
<td>
<div><strong>Parts</strong></div>
</td>
<td>
<div><strong>Number</strong></div>
</td>
<td>
<div><strong>Cost</strong></div>
</td>
</tr>
<tr>
<td>
<div>Esquire e-paper cover</div>
</td>
<td>
<div>&#8211;</div>
</td>
<td>
<div>&#8211;</div>
</td>
</tr>
<tr>
<td>
<div>MSP430 ez430 development kit</div>
</td>
<td>
<div><a href="http://www.ti-estore.com/">ez430USB</a></div>
</td>
<td>
<div>$20</div>
</td>
</tr>
<tr>
<td>
<div>32.768KHz crystal</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=m%2bUhWDcpCfZq/BFfwzExYQ==">815-AB26T-32.768KHZ </a></div>
</td>
<td>
<div>$0.27</div>
</td>
</tr>
<tr>
<td>
<div>Push button</div>
</td>
<td>
<div><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=MJTP1250virtualkey64200000virtualkey642-MJTP1250">642-mjtp1250</a></div>
</td>
<td>
<div>$0.16</div>
</td>
</tr>
</tbody>
</table>
<p><em>Firmware</em></p>
<p>The clock software is written with the free demo version of the TI/IAR Kickstart C compiler included with the ez430 programmer.</p>
<p>The MSP430 is very low power. It uses just 220uA at 1MHz, but less than 6uA when sleeping. The key to long battery life is to keep the chip asleep as much as possible. Our clock code is written with this in mind.</p>
<p>We use timer_a with the 32.768khz crystal to create an interrupt twice each second. The first interrupt triggers code that configures the segments to be displayed, sends these values to the e-paper, and then sleeps for the next 0.5 seconds. While the MSP430 sleeps, all the &#8216;off&#8217; segments have time to clear. The next interrupt flips the common lines the other way with a simple <a href="http://www.somacon.com/p125.php">XOR</a>, outputs the values, and goes to sleep for another 0.5 seconds. Next time the cycle will begin again. We don&#8217;t bother to reset the shift registers to the &#8216;0&#8242; position because the refresh is constantly in flux. Segment creep isn&#8217;t a problem because we refresh every segment each cycle.</p>
<p>A button press triggers an interrupt that advances the time to the next 10 minutes. To set the clock, wait until the time is a factor of 10 minutes past the hour and press the button to show the correct time. A small debouncing routine ensures that only one hit is detected per button press.</p>
<p><strong>Taking it further</strong></p>
<p>There are some lingering questions about the e-paper panels that would be nice to answer. What is the optimal change time? Will continuous current damage the segments or waste battery power? Why did the designer use a full 16volts to trigger the panels when only 5volts are required?</p>
<p>Everything you need to build the clock and interface the Esquire cover is included in the <a href="http://blog.mahalo.com/hackaday/howto/esquire.epaper.clock.v1.zip">project archive</a>(ZIP). It should be possible to interface any microcontroller with the Esquire e-paper cover using the interface library and three IO pins. In a future project we plan to build a custom driver board for the unused e-paper module.</p>
<p><img class="alignnone size-full wp-image-4726" title="final-clock-450-old-bat" src="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450-old-bat.jpg?w=450&#038;h=339" alt="" width="450" height="339" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/4602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/4602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/4602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/4602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/4602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/4602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/4602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/4602/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/4602/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/4602/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=4602&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/10/14/how-to-make-an-e-paper-clock-and-hack-esquire-magazine/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450.jpg" medium="image">
			<media:title type="html">final-clock-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/esquire_cover.jpg" medium="image">
			<media:title type="html">esquire_cover</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/panel-bare-450.jpg" medium="image">
			<media:title type="html">panel-bare-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/eink1.png" medium="image">
			<media:title type="html">eink1</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/T6GTFvNjRCk/2.jpg" medium="image" />

		<media:content url="http://img.youtube.com/vi/hix9-h5UuSc/2.jpg" medium="image" />

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/driver-board.jpg" medium="image">
			<media:title type="html">driver-board</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/pin-out-illu-450.png" medium="image">
			<media:title type="html">pin-out-illu-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450-new-bat-narrow.jpg" medium="image">
			<media:title type="html">final-clock-450-new-bat-narrow</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/4094b1.png" medium="image">
			<media:title type="html">4094b1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/cct-4501.png" medium="image">
			<media:title type="html">cct-4501</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/tap-board2.jpg" medium="image">
			<media:title type="html">tap-board2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/debug-with-wsbc1.jpg" medium="image">
			<media:title type="html">debug-with-wsbc1</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/kluFFU90qnI/2.jpg" medium="image" />

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/bezel-export.png" medium="image">
			<media:title type="html">bezel-export</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/msp430-cct-4501.png" medium="image">
			<media:title type="html">msp430-cct-4501</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/msp430-connections.jpg" medium="image">
			<media:title type="html">msp430-connections</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/final-clock-450-old-bat.jpg" medium="image">
			<media:title type="html">final-clock-450-old-bat</media:title>
		</media:content>
	</item>
		<item>
		<title>How to: Build your own Gyration Media Center remote</title>
		<link>http://hackaday.com/2008/10/08/how-to-build-your-own-gyration-media-center-remote/</link>
		<comments>http://hackaday.com/2008/10/08/how-to-build-your-own-gyration-media-center-remote/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 19:18:24 +0000</pubDate>
		<dc:creator>Joey Celis</dc:creator>
				<category><![CDATA[classic hacks]]></category>
		<category><![CDATA[home entertainment hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[dell]]></category>
		<category><![CDATA[gyration]]></category>
		<category><![CDATA[M2010]]></category>
		<category><![CDATA[remotes]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=3280</guid>
		<description><![CDATA[
Movea has just released a version of Gyration’s wireless remote control for Windows Media Center computers. Other than the wireless mouse controls that the remote offers, one nice feature of the remote is the ability to control Windows Media Player (WMP) while your display is off.
The remote interacts with WMP, by downloading data to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=3280&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-3284" title="m2010" src="http://hackadaycom.files.wordpress.com/2008/09/m2010.jpg?w=450&#038;h=253" alt="" width="450" height="253" /></p>
<p><a href="http://www.engadget.com/2008/09/09/moveas-gyration-air-music-remote-doubles-as-a-wireless-mouse/">Movea has just released</a> a version of <a href="http://www.gyration.com/p-68-media-center-universal-remote-control-windows-media-center-compatible.aspx">Gyration’s wireless remote control</a> for <a href="http://www.microsoft.com/windows/windows-vista/features/media-center.aspx">Windows Media Center</a> computers. Other than the wireless mouse controls that the remote offers, one nice feature of the remote is the ability to control <a title="Windows Media Player - Mahalo" href="http://www.mahalo.com/Windows_Media_Player">Windows Media Player</a> (WMP) while your display is off.</p>
<p>The remote interacts with WMP, by downloading data to be displayed using it’s built in LCD screen. From here you can view songs by album or artist and even access your playlist. Prices for the remote range from $179.99 to $229.99 with an included keyboard.</p>
<p>After a little searching we found that Gyration had made a similar version of the remote for <a title="Dell Computers - Mahalo" href="http://www.mahalo.com/Dell">Dell</a> that was packaged with the <a href="http://www.dell.com/content/products/productdetails.aspx/xpsnb_m2010?c=us&amp;cs=22&amp;l=en&amp;s=dfh">Dell XPS M2010</a> Based on this and a thread by [BENZONATE] <a href="http://www.avsforum.com/avs-vb/showthread.php?t=893705">on AVS Forum</a> we put together our own remote using the following parts:<span id="more-3280"></span></p>
<ul>
<li>Dell M2010 Premium Remote</li>
<li>Dell RH515 wireless card</li>
<li><a href="ftp://ftp.us.dell.com/video/R142872.EXE">Dell Thomson driver</a> (EXE)<a href="ftp://ftp.us.dell.com/video/R142872.EXE"><br />
</a></li>
<li>USB Cable</li>
</ul>
<p>We found our bare remote on <a href="http://shop.ebay.com/items/_W0QQ_fromZR46?_nkw=Dell+M2010+remote&amp;_fromfsb=&amp;_trksid=m270">eBay for $19.99</a>. When we asked [Greg] at Gyration for some help on this project he explained to us that the M2010 remote will only bind (RF Connect) with the Dell RF module due to the way Dell has chosen to write its drivers; the remote will not work with any of their standard RF receivers. If you do buy the remote on eBay be aware that the remote will only work with the RH515 card.</p>
<p>While finding the remote was easy, trying to locate the RH515 was another story. After searching online and calling Dell’s business support staff we were able to locate and purchase the RH515 card for $10.99 including shipping on <a href="http://accessories.us.dell.com/sna/category.aspx?c=us&amp;category_id=5188&amp;cs=28&amp;l=en&amp;s=dfb">Dell’s outlet site</a>.</p>
<p><img class="alignnone size-full wp-image-3285" title="rh515" src="http://hackadaycom.files.wordpress.com/2008/09/rh515.jpg?w=450&#038;h=253" alt="" width="450" height="253" /></p>
<p>Once we received our board we began to strip the wires on the included connector and paired it with our USB cable using the following:</p>
<ul>
<li>Red/Green to Black</li>
<li>Yellow to Green</li>
<li>White to White</li>
<li>Black to Red</li>
</ul>
<p>We wrapped the exposed wires in electrical tape, and then installed the Thomson driver on our computer. After plugging the board into an open <a title="USB - Mahalo" href="http://www.mahalo.com/USB">USB</a> slot, Windows quickly recognized the card and following the <a href="http://support.dell.com/support/edocs/acc/premrmt/">M2010 remote’s instruction</a> for pairing the devices gave us a working gyration remote.</p>
<p>The remote&#8217;s basic Media Center functions work like any other remote, the gyration feature allows us to control the cursor as well as perform left and right clicks from the comfort of our couch. The best part is: the remote gives us the ability to select our music using the built in LCD screen.</p>
<p>We did experience some lag while scrolling down the list of songs, but this could have been due to our excessive button smashing. Other than the delay, the remote itself has performed great and all for less than the cost of the Movea remote.</p>
<p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fmods%2FBuild_a_Gyration_Media_Center_remote' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/3280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/3280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/3280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/3280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/3280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/3280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/3280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/3280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/3280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/3280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=3280&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/10/08/how-to-build-your-own-gyration-media-center-remote/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Joey Celis</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/09/m2010.jpg" medium="image">
			<media:title type="html">m2010</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/09/rh515.jpg" medium="image">
			<media:title type="html">rh515</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Networked graffiti wall</title>
		<link>http://hackaday.com/2008/10/02/how-to-networked-graffiti-wall/</link>
		<comments>http://hackaday.com/2008/10/02/how-to-networked-graffiti-wall/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 00:05:29 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[classic hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[daft punk table]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[graffiti]]></category>
		<category><![CDATA[graffiti wall]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[internet graffiti wall]]></category>
		<category><![CDATA[large low resolution display]]></category>
		<category><![CDATA[llrd]]></category>
		<category><![CDATA[mini web server]]></category>
		<category><![CDATA[tcpip]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=4198</guid>
		<description><![CDATA[
Wondering what we did with our web server on a business card project from last week? It&#8217;s powering a giant LED graffiti wall. Animations can be user-submitted using the online designer. You can watch a live feed of user animations as well. The online interface runs on the Google App Engine for maximum scalability and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=4198&subd=hackadaycom&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="text-align:center; display: block;"><a href="http://hackaday.com/2008/10/02/how-to-networked-graffiti-wall/"><img src="http://img.youtube.com/vi/G8KprTVbHD4/2.jpg" alt="" /></a></span></p>
<p>Wondering what we did with our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">web server on a business card</a> project from last week? It&#8217;s powering a giant LED graffiti wall. Animations can be user-submitted using the <a href="http://graffiti-me.appspot.com/seq.html">online designer</a>. You can <a href="http://graffiti-me.appspot.com">watch a live feed</a> of user animations as well. The online interface runs on the <a href="http://code.google.com/appengine/">Google App Engine</a> for maximum scalability and resilience.</p>
<p>In today&#8217;s How-to we cover all the ins and outs of building your own networked graffiti wall.<span id="more-4198"></span></p>
<p><strong>Concept overview</strong></p>
<p><img class="alignnone size-full wp-image-3748" title="graffiti-wall-diagram-previ" src="http://hackadaycom.files.wordpress.com/2008/09/graffiti-wall-diagram-previ.jpg?w=450&#038;h=179" alt="" width="450" height="179" /></p>
<p>Graffiti sequences are designed online with the <a href="http://graffiti-me.appspot.com">JavaScript animation designer</a>. Finished sequences are validated and stored in a database; we made database backends for PHP/MYSQL and Google Apps (Python). Sequences are syndicated from a simple <a href="http://graffiti-me.appspot.com/feed.php?max=1&amp;last=0">datafeed API</a>. Our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">mini web server</a> retrieves animation sequences from the feed, and caches them on an SD card. Finally, the sequences are displayed on a giant LED matrix.</p>
<p><strong>Large, low resolution displays</strong><br />
Our graffiti display is a 1 meter square, 5&#215;5 matrix of LEDs. It&#8217;s inspired by the <a href="http://www.guardian.co.uk/lifeandstyle/2004/jul/09/homes">Daft Punk coffee table sold by Habitat</a> a few years ago. The Daft Punk table spawned many DIY replicas, including this excellent Instructable on <a href="http://www.instructables.com/id/How-to-build-a-Daft-Punk-Table-Replica/">building a Daft Punk table</a>. Over time, the trend morphed into several permutations, such as our <a href="http://www.instructables.com/id/Daft-Punk-Table-Replica-Graphics-Controller/">&#8220;Daft Punk table&#8221; wall-hanging</a>. Given the range of big, blinking furniture, we sought a better term than &#8220;Daft Punk table&#8221;. We came up with &#8220;large, low resolution display&#8221; or LLRD for short (pronounced &#8216;lard&#8217;).</p>
<p><img class="alignnone size-full wp-image-4194" title="dpt-couch-2" src="http://hackadaycom.files.wordpress.com/2008/10/dpt-couch-2.jpg?w=450&#038;h=309" alt="" width="450" height="309" /></p>
<p>The original Daft Punk table flashed randomly, or in time to music. [Mathieu Roncheau]&#8217;s <a href="http://www.dailymotion.com/miniDaftPunkTable">replica table</a> stored animation sequences in an EEPROM. Our first design took this a step further by storing the animation files on a FAT formatted SD card. Now, we&#8217;ve put the designer online so that we can fetch user-submitted animation sequences over the internet.</p>
<p><strong>Online interface</strong><br />
Graffiti animations for the LLRD are created with a simple JavaScript sequence maker. Watch a <a href="http://graffiti-me.appspot.com/">live feed</a> of user-submitted animations, or <a href="http://graffiti-me.appspot.com/seq.html">try it yourself</a>. The graffiti sequence designer and data backends written, for PHP/MYSQL and Google App Engine, are included in the <a href="http://blog.mahalo.com/hackaday/howto/graffitiV1.zip">project archive</a>.</p>
<p><img class="alignnone size-full wp-image-4091" title="designer-screenshot" src="http://hackadaycom.files.wordpress.com/2008/10/designer-screenshot.jpg?w=362&#038;h=405" alt="" width="362" height="405" /></p>
<p>The JavaScript graffiti sequence designer is easy to use:</p>
<ul>
<li>Click the boxes to toggle the LEDs shown in each frame of your animation.</li>
<li>Use the arrow buttons to navigate between frames.</li>
<li>The backup and restore tools provide an easy way to save your sequence locally in a text file.</li>
</ul>
<p>&#8220;Add text frames&#8221; inserts character frames using a bitmaped font. If you hate the default font, just create a new one:</p>
<ul>
<li> Click the &#8216;edit font&#8217; button to load the existing font.</li>
<li> Make your modifications.</li>
<li>Click &#8216;update font&#8217; to replace the default font with the new frames.</li>
</ul>
<p>The <em>font</em> array is a lookup table of bitmaps for the <a href="http://www.asciitable.com/">ASCII characters</a> between space and Z (ASCII characters 32 to 90, &#8221; !&#8221;#$%&amp;&#8217;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8221;). To add a new font permanently, just paste the updated fontset in the JavaScript code following the &#8216;font=&#8217; variable. The &#8220;font format&#8221; option in the backup box will generate variable formatted bitmaps that are ready to paste over the existing font.</p>
<p>When you&#8217;ve completed an animation, enter your name in the author box and press submit. The sequence code will be generated and sent to the server.</p>
<p>The online JavaScript-based graffiti designer is inspired by an offline version by [Mathieu Roncheau]. [Mathieu]&#8217;s Delphi source code and executable are <a href="http://www.instructables.com/id/Daft-Punk-Table-Replica-Graphics-Controller/">archived here</a>. Our JavaScript-based designer has a few extra features, is browser-based, and it doesn&#8217;t require you to run an unknown .exe file. Even though it&#8217;s intended to run on the web, the designer will also work from a local copy on your computer.</p>
<p>The script will work for any arbitrary matrix, just change the <em>dptRows</em> and <em>dptCols</em> variables to the dimensions of your LLRD.</p>
<p>The live viewer uses asynchronous HTTP (AJAX-ish) requests to show a streaming feed of user-submitted graffiti animations.  It will try to set a cookie so that it can start with fresh sequences each time the page loads. If you don&#8217;t allow the cookie, it &#8216;ll just start over at 0 on your next visit.</p>
<p><em>Sequence bitmap format</em><br />
The sequence builder outputs each column as an ASCII formatted bitmap. The bitmap for each column is separated by a space, and each full frame is terminated with a <a href="http://en.wikipedia.org/wiki/Newline#Representations">line feed</a> (nr). This format was defined by [Mathieu Roncheau]&#8217;s PC sequencer program, we kept it to maintain backwards compatibility.</p>
<p><img class="alignnone size-full wp-image-4101" title="image_map-squat" src="http://hackadaycom.files.wordpress.com/2008/10/image_map-squat.png?w=450&#038;h=221" alt="" width="450" height="221" /></p>
<p>Bitmap data is zeroed on the upper left hand corner of the frame. The top cells of each column are bit 0, and the bottom cells are bit 4. It seems more logical to follow standard mathematical notation and use the bottom left cell as the origin, but we didn&#8217;t design the specification.</p>
<p>The value for each column is found by treating lit LEDs as 1 in a binary number, and converting to decimal. For example, the first column above is 10000 binary, or 1 decimal. The last column is 11111 binary, or decimal 31. You can verify our conversions using an <a href="http://mistupid.com/computers/binaryconv.htm">online binary-decimal calculator</a>.</p>
<p><img class="alignnone size-full wp-image-4090" title="ascii2dec" src="http://hackadaycom.files.wordpress.com/2008/10/ascii2dec.png?w=450&#038;h=113" alt="" width="450" height="113" /></p>
<p>Note that the column bitmaps are represented by ASCII equivalents of the actual decimal values. Numeric digits are encoded according to the <a href="http://www.asciitable.com/">ASCII standard</a>, which is the actual value plus 0&#215;30h. Further, multi-digit numbers are stored as individual characters; 24 in the example is stored as 0&#215;32h,0&#215;34h.</p>
<p><strong>Server side</strong><br />
The backend is a simple piece of software that accepts animation sequences, does some validation, and saves them to a database. Stored sequences are accessible from the datafeed API.<br />
<em></em></p>
<p><em>Backend</em><br />
We wrote two versions of the backend; both are in the <a href="http://blog.mahalo.com/hackaday/howto/graffitiV1.zip">project archive</a>. The first is a simple PHP/MYSQL backend for low volume online LLRDs, the other is a <a href="http://code.google.com/appengine/">Google App Engine</a>/Python version that should be able to handle a bunch of Hack a Day readers.</p>
<p>It&#8217;s really easy to write a backend for your favorite platform. Change the graffiti designer&#8217;s submit form action to point at your backend; both versions currently POST to <em>backend.php</em>. Now, catch the &#8216;author&#8217; and &#8217;seq&#8217; variables on your server and save them to a database.</p>
<p>Our backend performs a bit of validation to prevent attacks on the system. We implemented checks in phases so they don&#8217;t waste too many resources. First, the overall size of the submission is checked to make sure its within reason. Next, the sequence is split into individual frames and each is checked for form. If it passes validation, it&#8217;s saved to the database.</p>
<p><em>Feed API</em><br />
Sequences are accessible through a simple <a href="http://graffiti-me.appspot.com/feed.php?max=1&amp;last=0">datafeed API</a>. The API has two variables:</p>
<p><img class="alignnone size-full wp-image-4092" title="feed-screenshot" src="http://hackadaycom.files.wordpress.com/2008/10/feed-screenshot.png?w=316&#038;h=153" alt="" width="316" height="153" /></p>
<p><a href="http://graffiti-me.appspot.com/feed.php?max=1&amp;last=0">http://graffiti-me.appspot.com/feed.php?<strong>max</strong>=1&amp;<strong>last</strong>=0</a></p>
<ul>
<li><strong>max</strong> &#8211; the maximum number of sequences to send.</li>
<li><strong>last</strong> &#8211; the last sequence read, only newer data is sent.</li>
</ul>
<p>The datafeed begins each animation sequence with the character &#8216;#&#8217;, followed by an ID number and line feed.  &#8216;#&#8217; is an invalid bitmap value that alerts clients to the beginning of a new sequence. Clients can use the ID number with <em>last</em> variable of the API to get fresh sequences on each pull.</p>
<p><strong>Hardware</strong><br />
<em>Mini web server</em><br />
<img class="alignnone size-full wp-image-4098" title="server-graffiti-connected-4" src="http://hackadaycom.files.wordpress.com/2008/10/server-graffiti-connected-4.jpg?w=450&#038;h=350" alt="" width="450" height="350" /><br />
We used our PIC24F mini web server as a TCP enabled client for this project. Read our previous articles to learn how to <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">build the web server</a>.</p>
<p><em>Daft punk table</em><br />
[mrgalleta] has a great <a href="http://www.instructables.com/id/How-to-build-a-Daft-Punk-Table-Replica/">construction tutorial</a> for the actual table part of a Daft Punk table replica. An LLRD can take many forms, though, such as our wall-hanging.</p>
<p>Most of Daft Punk table replica designs are controlled by a <a href="http://www.nxp.com/acrobat_download/datasheets/74HC_HCT595_4.pdf">74HCT595</a> (pdf) output expander and <a href="http://focus.ti.com/lit/ds/symlink/uln2803a.pdf">ULN2803A</a> (pdf) transistor array. The driver board from <a href="http://www.instructables.com/id/Daft-Punk-Table-Replica-Graphics-Card/">this Instructable</a> combines both into an easy-to-etch, through-hole PCB. Each driver board has two 74HTC595s, or 16 outputs; we needed two driver boards for our 25 cell LLRD.</p>
<p><img class="alignnone size-full wp-image-4183" title="spi-5953" src="http://hackadaycom.files.wordpress.com/2008/10/spi-5953.png?w=450&#038;h=183" alt="" width="450" height="183" /></p>
<p>The 74HCT595 is a serial output expander that&#8217;s controlled by an SPI-like interface. An update is initiated by dropping the <em>latch</em> line. The state of each LED (on or off) is put on the <em>data</em> line, followed by a pulse of the <em>clock</em>. Bits are put on the output pins once the latch signal returns to high. Data cascades from the data-output pin of one 595, to the data-input of the next.  Read this <a href="http://www.arduino.cc/en/Tutorial/ShiftOut">74xx595 tutorial</a> for a detailed look at interfacing this device.</p>
<p>It&#8217;s important to note that we used the 74<strong>HCT</strong>595, and not the 74<strong>HC</strong>595. The &#8220;HCT&#8221; part works over a wide range of voltages, including the operating voltage of the mini web server: 3.3volts.</p>
<p><img class="alignnone size-full wp-image-4089" title="595-driver" src="http://hackadaycom.files.wordpress.com/2008/10/595-driver.jpg?w=450&#038;h=251" alt="" width="450" height="251" /></p>
<p>The 74HCT595 sources current, meaning we could probably run a single LED directly from each output at 3.3volts. Since most LLRDs have 2-8 LEDs per cell, operating between 5 and 24volts, we employ a ULN2803A transistor array to switch the larger load. The ULN2803A sinks current, rather than sourcing it; it switches the ground connection of the LEDs, rather than the power.</p>
<p><img class="alignnone size-full wp-image-4095" title="led-holders-450" src="http://hackadaycom.files.wordpress.com/2008/10/led-holders-450.jpg?w=450&#038;h=417" alt="" width="450" height="417" /></p>
<p>Our LLRD has two LEDs per cell, running at 20mA with a 5 volt supply and 56ohm resistor. We soldered the LEDs around a piece of cardboard, rather than etching 25 tiny circuit boards.</p>
<p><em>Connections</em></p>
<p><img class="alignnone size-full wp-image-4097" title="pin-connections" src="http://hackadaycom.files.wordpress.com/2008/10/pin-connections.jpg?w=451&#038;h=206" alt="" width="451" height="206" /></p>
<p>A 5 wire connection between the mini web server and the driver boards controls the LLRD.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Server</strong></td>
<td><strong>LLRD</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>V+</td>
<td>Vsys</td>
<td>3.3volt supply for the 595s.</td>
</tr>
<tr>
<td>GND</td>
<td>GND</td>
<td>Shared ground connection.</td>
</tr>
<tr>
<td>RA0</td>
<td>Data in</td>
<td>Data  signal.</td>
</tr>
<tr>
<td>RA1</td>
<td>Clock</td>
<td>Clock signal.</td>
</tr>
<tr>
<td>RB15</td>
<td>Latch</td>
<td>Latch signal.</td>
</tr>
<tr>
<td>&#8212;</td>
<td>Vled</td>
<td>LED power supply.</td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong><br />
Our firmware is written in C using MPLAB and the Microchip C30 demo compiler. Learn more about programming and working with the PIC24F in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introductory tutorial</a>. Two firmware versions are included in the <a href="http://blog.mahalo.com/hackaday/howto/graffitiV1.zip">project archive</a>. The first just reads all *.seq sequence files from the SD card, the second version adds the Microchip TCP/IP stack for internet connectivity. Learn more about the Microchip SD card and TCP/IP libraries in our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">mini web server tutorial</a>.</p>
<p>All graphics functions, including the TCP client, can be found in <em>graffitigfx.c</em>. The TCP client is based on the generic TCP client example that&#8217;s included with the TCP/IP stack. We followed Microchip&#8217;s cooperative multitasking approach and broke our code into small segments that share CPU time with the rest of the TCP/IP stack.</p>
<p>The client periodically connects to the datafeed and requests new sequences. New sequences are parsed for ID numbers, and appended to a temporary file on the SD card.  The last ID detected is written to the very end of the temporary data file, and is appended to the <em>last</em> variable of the URL on subsequent datafeed requests. We record the ID at the end of the file to avoid repeated writes to the same sector on the SD card. Hopefully wear leveling inside a 1GB SD card is sufficient to avoid problems for the first few decades of use. If no network connection is available, the device plays any *.seq files in the root directory of the SD card.</p>
<p>A parser function decodes frames and sends them to the LLRD. The parser is fairly robust to errors. Bad data that makes it past the backend validation routine will be rejected at the device level without ill effect. If a few corrupt frames do manage to display, it&#8217;ll hardly be noticed amongst the other abstract patterns playing on the wall.</p>
<pre class="brush: cpp;">
#define GFX_USE_TCP_CLIENT //include the TCP client
#define GFX_TCP_ONLY //only do TCP and read temp file, don't read other files on the SD card.
#define GFX_CLEAR_TEMP_ON_RESET //optionally delete the temp file on reset. good for Google App Engine...
</pre>
<p>Three defines at the beginning of <em>graffitigfx.c</em> control which features are included at compile time. GFX_USE_TCP_CLIENT compiles the firmware with the TCP client enabled, comment this definition for a SD card only version of the firmware. GFX_TCP_ONLY ignores any .seq files on the SD card, and only plays sequences downloaded from the web. The GFX_CLEAR_TEMP_ON_RESET option will delete the temporary sequence file on each reset; this is helpful for databases that have non-sequential record IDs, like <a href="http://code.google.com/appengine/docs/datastore/">Google&#8217;s datastore</a>. In the future, these definitions could be changed to variables that are set by a configuration file on the SD card.</p>
<p><strong>Taking it further</strong><br />
Our simple firmware is a stable starting point for an online graffiti wall. While we were working on this project we came up with a ton of additional features that didn&#8217;t make it into the prototype.</p>
<ul>
<li>Display IP address on startup.</li>
<li>A configuration file on the SD card that sets the datafeed url, refresh frequency, and other variables.</li>
<li>A telnet or web interface for remote configuration.</li>
<li>A TCP server for direct access to the display; push animation frames from a remote PC.</li>
<li>A mail client that reports errors and status information.</li>
<li>Progress messages during startup and sequence downloads. SD card not present/full errors.</li>
<li>Scrolling Twitter feeds.</li>
<li>Your thoughts?</li>
</ul>
<p>Don&#8217;t just read about this project, <a href="http://graffiti-me.appspot.com">contribute some frames to the graffiti wall</a>.</p>
<p>Next time we&#8217;ll introduce our final PIC24F project, an ethernet backpack for the tiny <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=569">$20 color Nokia LCD knock-off from SparkFun Electronics</a>.</p>
<p><iframe src='http://digg.com/api/diggthis.php?u=http%3A%2F%2Fdigg.com%2Fmods%2FHow_to_Networked_graffiti_wall_Hack_a_Day' height='82' width='55' frameborder='0' scrolling='no' style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'></iframe></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/4198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/4198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/4198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/4198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/4198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/4198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/4198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/4198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/4198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/4198/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&blog=4779443&post=4198&subd=hackadaycom&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/10/02/how-to-networked-graffiti-wall/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/G8KprTVbHD4/2.jpg" medium="image" />

		<media:content url="http://hackadaycom.files.wordpress.com/2008/09/graffiti-wall-diagram-previ.jpg" medium="image">
			<media:title type="html">graffiti-wall-diagram-previ</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/dpt-couch-2.jpg" medium="image">
			<media:title type="html">dpt-couch-2</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/designer-screenshot.jpg" medium="image">
			<media:title type="html">designer-screenshot</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/image_map-squat.png" medium="image">
			<media:title type="html">image_map-squat</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/ascii2dec.png" medium="image">
			<media:title type="html">ascii2dec</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/feed-screenshot.png" medium="image">
			<media:title type="html">feed-screenshot</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/server-graffiti-connected-4.jpg" medium="image">
			<media:title type="html">server-graffiti-connected-4</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/spi-5953.png" medium="image">
			<media:title type="html">spi-5953</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/595-driver.jpg" medium="image">
			<media:title type="html">595-driver</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/led-holders-450.jpg" medium="image">
			<media:title type="html">led-holders-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/10/pin-connections.jpg" medium="image">
			<media:title type="html">pin-connections</media:title>
		</media:content>
	</item>
	</channel>
</rss>