<?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; serial interface</title>
	<atom:link href="http://hackaday.com/tag/serial-interface/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Sun, 12 Feb 2012 06:24:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hackaday.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/5560f98f805877b0e332f191cb9e0af3?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Hack a Day &#187; serial interface</title>
		<link>http://hackaday.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hackaday.com/osd.xml" title="Hack a Day" />
	<atom:link rel='hub' href='http://hackaday.com/?pushpress=hub'/>
		<item>
		<title>Parts: Unboxing the Bus Pirate</title>
		<link>http://hackaday.com/2009/07/20/parts-unboxing-the-bus-pirate/</link>
		<comments>http://hackaday.com/2009/07/20/parts-unboxing-the-bus-pirate/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 19:00:32 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></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[preorder]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[unboxing]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=12819</guid>
		<description><![CDATA[For months we&#8217;ve used our Bus Pirate universal serial interface tool to demonstrate electronics parts, so it&#8217;s only appropriate that the Bus Pirate get it&#8217;s own parts post. We recently had a Bus Pirate preorder, and today we received the pre-production Bus Pirate prototype from Seeed Studio. This prototype was mailed just a few days [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=12819&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-12833" title="bp-unbox-3" src="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-3.jpg" alt="bp-unbox-3" width="470" height="326" /></p>
<p>For months we&#8217;ve used our <a href="http://www.buspirate.com">Bus Pirate universal serial interface tool</a> to demonstrate <a href="http://hackaday.com/category/parts/">electronics parts</a>, so it&#8217;s only appropriate that the Bus Pirate  get it&#8217;s own parts post. We recently had a <a href="http://hackaday.com/2009/06/25/bus-pirate-preorders-open/">Bus Pirate preorder</a>, and today we received the pre-production Bus Pirate prototype from <a href="http://www.seeedstudio.com/depot/">Seeed Studio</a>. This prototype was mailed just a few days before <a href="http://hackaday.com/2009/07/16/bus-pirate-preorder-1-ships/">preorder 1 started to ship</a>, so those packages should  start arriving any day.</p>
<p>Follow along as we unbox the prototype Bus Pirate, and connect it to a debugger to determine  the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002-I/SO</a> revision that shipped with this board. Use this post to share your own Bus Pirate unboxing experience. Pictures and discussion after the break.</p>
<p><span id="more-12819"></span></p>
<p><img class="alignnone size-full wp-image-12831" title="bp-unbox-1" src="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-1.jpg" alt="bp-unbox-1" width="470" height="328" /></p>
<p>Most Bus Pirates will ship <a href="http://hackadaycom.files.wordpress.com/2009/07/ready-envelope-470.jpg?w=470&amp;h=312">in a padded envelope</a> (JPG), but ours came in a box with some PCBs for future projects and  an AVR programmer.</p>
<p><img class="alignnone size-full wp-image-12832" title="bp-unbox-2" src="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-2.jpg" alt="bp-unbox-2" width="470" height="287" /></p>
<p>Inside the box, the Bus Pirate is protected by a <em>static dissipative</em> bag. The Bus Pirate pin headers are stuck in foam to protect the packaging.</p>
<p><img class="alignnone size-full wp-image-12834" title="bp-unbox-5" src="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-5.jpg" alt="bp-unbox-5" width="470" height="350" /></p>
<p>We ran a battery of functionality tests that covered USB, the user terminal, protocol libraries, power supplies, and pullup resistors. Everything passed our tests.</p>
<p>Next, we used a Microchip ICD2 debugger/programmer to  make a backup of the firmware prior to doing a test upgrade/downgrade with the bootloader.</p>
<blockquote><p>Connecting to MPLAB ICD 2<br />
&#8230;Connected<br />
Setting Vdd source to target<br />
<strong>Target Device PIC24FJ64GA002 found, <span style="text-decoration:underline;">revision = Rev 0&#215;3042</span></strong><br />
&#8230;Reading ICD Product ID<br />
Running ICD Self Test<br />
&#8230;Passed<br />
MPLAB ICD 2 ready for next operation</p></blockquote>
<p>All of our previous Bus Pirate version were built using Rev 0&#215;3003 (A3) of the PIC 24FJ64GA002. Version A3 has a few issues, known as <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/80470a.pdf">errata</a> (PDF), one of which is a <a href="http://www.google.com/codesearch/url?ct=ext&amp;url=http://forum.microchip.com/tm.aspx%3Fm%3D271183%26mpage%3D1&amp;usg=AFQjCNFvedVtagkyXzTS-vmSKIk3OE0eiw">flaky hardware I2C module</a>. These chips aren&#8217;t &#8216;defective&#8217;, they just have a few quirks like any complicated integrated circuit. The Bus Pirate firmware works around these issues using software techniques. Most desktop computer processors go through a similar stepping process.</p>
<p>Our Bus Pirate appears to have a B4 revision PIC (0&#215;3042) that corrects some, but not all, of the errata from A3. This is no guarantee that every Bus Pirate will have a B4 PIC, preorder 1 and 2 are both sourced from multiple international vendors. Additionally, there&#8217;s no immediate benefit from having a B4 chip, someone will have to write software that takes advantage of the hardware. The next  firmware update will print the PIC revision in the user terminal, check the <a href="http://code.google.com/p/the-bus-pirate/source/browse/#svn/trunk/firmware/v0h-nightly">nightly compiles</a> if you&#8217;re anxious.</p>
<p>There is a revision B5 mentioned in the PIC errata. Some of these might find their way into preorder 2 boards.</p>
<p><img class="alignnone size-full wp-image-12830" title="bp-unbox-0" src="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-0.jpg" alt="bp-unbox-0" width="470" height="361" /></p>
<p>Now that you&#8217;ve got your Bus Pirate, what do you do with it? We&#8217;ve got a bunch of <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">part demonstrations</a> to get you started.</p>
<p>Please leave a comment about your unboxing experience, and the devices you plan to interface.</p>
<br />Posted in parts, tool hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/12819/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/12819/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/12819/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=12819&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/07/20/parts-unboxing-the-bus-pirate/feed/</wfw:commentRss>
		<slash:comments>43</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/bp-unbox-3.jpg" medium="image">
			<media:title type="html">bp-unbox-3</media:title>
		</media:content>

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

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

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

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/bp-unbox-0.jpg" medium="image">
			<media:title type="html">bp-unbox-0</media:title>
		</media:content>
	</item>
		<item>
		<title>Parts: 4&#215;20 VFD character display (NA204SD02)</title>
		<link>http://hackaday.com/2009/07/13/parts-4x20-vfd-character-display-na204sd02/</link>
		<comments>http://hackaday.com/2009/07/13/parts-4x20-vfd-character-display-na204sd02/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 17:28:48 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[character lcd]]></category>
		<category><![CDATA[futaba]]></category>
		<category><![CDATA[hd44780]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[vfd]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=11016</guid>
		<description><![CDATA[Futaba makes vacuum florescent character displays that can be used as a drop-in replacement for common character LCDs. VFDs have a wider viewing angle, and generally look cooler. Futaba&#8217;s character displays can be interfaced using the standard 8-bit or 4-bit parallel LCD interface, or a simple two-wire protocol. The protocol type is set by resistors [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=11016&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-12656" title="futuba-serial" src="http://hackadaycom.files.wordpress.com/2009/07/futuba-serial.jpg" alt="futuba-serial" width="470" height="267" /></p>
<p><a href="http://www.futaba.com/products/display_modules/module_products/character/index.asp">Futaba</a> makes <a href="http://en.wikipedia.org/wiki/Vacuum_fluorescent_display">vacuum florescent character displays</a> that can be used as a drop-in replacement for common character <a href="http://en.wikipedia.org/wiki/Lcd">LCDs</a>. VFDs have a wider viewing angle, and generally look cooler.</p>
<p>Futaba&#8217;s character displays can be interfaced using the standard <a href="http://ouwehand.net/~peter/lcd/lcd0.shtml">8-bit or 4-bit parallel LCD interface</a>, or a simple two-wire protocol. The protocol type is set by resistors on the back of the display, so it&#8217;s not particularly easy to change without a <a href="http://hackaday.com/2009/02/20/tools-aoyue-968-3-in-1-soldering-and-rework-station/">hot-air rework station</a>. Today we&#8217;ll demonstrate a serially-interfaced VFD using the Bus Pirate.</p>
<p><span id="more-11016"></span><strong><a href="http://www.futaba.com/products/display_modules/module_products/character/index.asp">Futuba VFD</a> character LCD replacement (<a href="http://www.primelec.com/Electronic-Components/LCDs-Displays/Futaba-4X20-LCD-Emulator-p7144243.html">NA204SD02</a></strong><strong>, $7.00). <a href="http://www.futaba.com/products/display_modules/lcd_emulator/products/index.asp">Datasheet </a>(PDF).</strong></p>
<table border="0">
<tbody>
<tr>
<td><strong>VFD (pin #)</strong></td>
<td><strong>Bus Pirate</strong></td>
</tr>
<tr>
<td>GND (1)</td>
<td>GND</td>
</tr>
<tr>
<td>+5volts (2)</td>
<td>+5volts, Vpullup</td>
</tr>
<tr>
<td>Data (3)</td>
<td>MOSI</td>
</tr>
<tr>
<td>Strobe (4)</td>
<td>CS</td>
</tr>
<tr>
<td>N/C (5)</td>
<td>&#8211;</td>
</tr>
<tr>
<td>Clock (6)</td>
<td>CLK</td>
</tr>
</tbody>
</table>
<p>We used our <a href="http://buspirate.com">Bus Pirate universal serial interface</a> to demonstrate the Futaba VFD, but the interface operations will be the same for any microcontroller implementation. The connections we made between the VFD and the Bus Pirate are shown in the table above.</p>
<p>We setup the Bus Pirate for raw2wire mode (menu M, 7) with <a href="http://hackaday.com/2009/07/01/mixed-voltage-interfacing-with-the-bus-pirate/">open drain outputs</a> (HiZ). The open drain outputs let us interface the 5volt VFD from the 3.3volt Bus Pirate using the on-board pull-up resistors (menu P, 2). Finally, we enabled the on-board power supply (capital ‘W’).</p>
<p>The VFD&#8217;s strobe pin is connected to the Bus Pirate CS pin.  The auxiliary pin doesn&#8217;t have it&#8217;s own pull-up resistor but CS does. CS is otherwise unused in raw2wire mode, so we reassigned the auxiliary commands to the CS pin (menu C,2).</p>
<p><em>Interfacing</em></p>
<p><em><img class="alignnone size-full wp-image-12648" title="vfd-serial" src="http://hackadaycom.files.wordpress.com/2009/07/vfd-serial.png" alt="vfd-serial" width="470" height="193" /><br />
</em></p>
<p>The two-wire interface uses a straight-forward 16bit (2byte)  protocol (datasheet page 20). The LCD control bits (R/W, RS) go in the first byte, and eight data bits go in the second. All transactions start with  strobe low and end with strobe high. Read operations are similar to writes, except the  R/W bit is set and the second byte is read.</p>
<p><img class="alignnone size-full wp-image-12649" title="vfd-command.pg27." src="http://hackadaycom.files.wordpress.com/2009/07/vfd-command-pg27.png" alt="vfd-command.pg27." width="470" height="197" /></p>
<p>The Futaba VFD accepts all the standard HD44780 LCD commands (datasheet page 27), see  <a href="http://ouwehand.net/~peter/lcd/lcd0.shtml#instruction_set">these tables</a> for a detailed description of each command. After a reset (power-up), the VFD expects the first command to be the function set command.</p>
<blockquote><p>RAW2WIRE&gt;@ <strong>&lt;&#8211;start with strobe high</strong><br />
AUX HIGH IMP, READ: 1 <strong>&lt;&#8211; aux pin (CS) is now input, pull-up resistor holds strobe high</strong><br />
RAW2WIRE&gt;a 0b11111000 0b00111000 @ <strong>&lt;&#8211;command</strong><br />
AUX LOW <strong>&lt;&#8211;strobe low</strong><br />
WRITE: 0xF8 <strong>&lt;&#8211;start byte (R/W=0, RS=0)</strong><br />
WRITE: 0&#215;38 <strong>&lt;&#8211;instruction byte (function set)</strong><br />
AUX HIGH IMP, READ: 1 <strong>&lt;&#8211;strobe high</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>Function set configures the data interface length (bit 4), display lines (bit 3), and  brightness/luminescence (bits 1,0).  Before we start we set the strobe pin high (@) in case it&#8217;s currently low. Then, we start the transaction by taking the strobe pin low (a), and send the first byte with the R/W and register select (RS) settings.</p>
<p>The second byte is the command. We set the data interface length to 8bits (bit 4 = 1), but in serial mode this is probably ignored. Our display has multiple lines (bit 3 = 1), and we set brightness to full (bits 1,0 = 0). The sequence concludes when the strobe pin returns high (@).</p>
<blockquote><p>RAW2WIRE&gt;a 0b11111000 0b00001111 @<br />
AUX LOW <strong>&lt;&#8211;strobe low</strong><br />
WRITE: 0xF8 <strong>&lt;&#8211;start byte (R/W=0, RS=0)</strong><br />
WRITE: 0x0F <strong>&lt;&#8211;instruction byte (display on/off control)</strong><br />
AUX HIGH IMP, READ: 1 <strong>&lt;&#8211;strobe high</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>The display ON/OFF command enables the display (bit 3), toggles the cursor (bit 1), and blinks the cursor (bit 0). We enabled the display (bit 3 = 1) with a blinking cursor (bit 1,0 = 1) so it&#8217;s obvious that the display is working.</p>
<blockquote><p>RAW2WIRE&gt;a 0b11111000 0b10000000 @<br />
AUX LOW <strong>&lt;&#8211;strobe low</strong><br />
WRITE: 0xF8 <strong>&lt;&#8211;start byte (R/W=0, RS=0)</strong><br />
WRITE: 0&#215;80 <strong>&lt;&#8211;instruction byte (DDRAM address set)</strong><br />
AUX HIGH IMP, READ: 1 <strong>&lt;&#8211;strobe high</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>Before writing characters to the display we need to position the cursor by sending the DDRAM address set command (0b10000000) summed with the desired cursor position. We set the cursor to the first character on line 1.</p>
<p>The second character on line 1  is located at 0&#215;01. To set this address we&#8217;d send 0b10000001 (0b10000000 +0b00000001).</p>
<p>Character display memory isn&#8217;t linear, the first line starts at 0&#215;00, the second line starts on position 0&#215;40, the third at 0&#215;14, and the last line begins with position 0&#215;54. Most displays have a similar configuration, here&#8217;s some  <a href="http://ouwehand.net/~peter/lcd/lcd0.shtml#visible_ddram">tables for determining the layout of different character displays</a>.</p>
<blockquote><p>RAW2WIRE&gt;a 0b11111010 0&#215;48 0&#215;61 0&#215;63 0x6b 0&#215;20 0&#215;61 0&#215;20 0&#215;44 0&#215;61 0&#215;79 @<br />
AUX LOW <strong>&lt;&#8211;strobe low</strong><br />
WRITE: 0xFA <strong>&lt;&#8211;start byte (R/W=0, RS=1)</strong><br />
WRITE: 0&#215;48 <strong>&lt;&#8211;ASCII letter &#8216;H&#8217;</strong><br />
&#8230;<br />
WRITE: 0&#215;79 <strong>&lt;&#8211;ASCII letter &#8216;y&#8217;</strong><br />
AUX HIGH IMP, READ: 1 <strong>&lt;&#8211;strobe high</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>Finally, we can enter some characters at the position  set with the previous command. Characters are entered as their <a href="http://web.cs.mun.ca/~michael/c/ascii-table.html">ASCII equivalent values</a>. We displayed &#8220;Hack a Day&#8221; with proper capitalization.</p>
<p>Multiple characters can be entered at once, but because the memory space isn&#8217;t contiguous it&#8217;s necessary to manually position the cursor at the beginning of each new line. After writing the last position of line 1, the cursor will advance to the first character of line 3. Use another position command, 0b10010100, to set the cursor to the beginning of line 2 (0b10000000 + 0&#215;14 = 0b10010100).</p>
<p>Like this post? Check out the <a href="http://hackaday.com/category/parts/">parts posts</a> you may have missed. Want to request a part post? Please leave your suggestions in the comments.</p>
<p><strong>Hack a Day review disclosure: We bought the serial VFD demonstrated here on eBay, Futaba also sent us a sample with a parallel interface that we&#8217;ll demo later (<a href="http://hackaday.com/2009/07/02/how-to-bus-pirate-probe-cable/">shown here</a>).</strong></p>
<p><strong><img class="alignnone size-full wp-image-12655" title="futuba-serial.ii" src="http://hackadaycom.files.wordpress.com/2009/07/futuba-serial-ii.jpg" alt="futuba-serial.ii" width="470" height="283" /><br />
</strong></p>
<br />Posted in misc hacks, parts  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/11016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/11016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/11016/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=11016&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/07/13/parts-4x20-vfd-character-display-na204sd02/feed/</wfw:commentRss>
		<slash:comments>22</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/futuba-serial.jpg" medium="image">
			<media:title type="html">futuba-serial</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/vfd-serial.png" medium="image">
			<media:title type="html">vfd-serial</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/vfd-command-pg27.png" medium="image">
			<media:title type="html">vfd-command.pg27.</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/07/futuba-serial-ii.jpg" medium="image">
			<media:title type="html">futuba-serial.ii</media:title>
		</media:content>
	</item>
		<item>
		<title>Parts: ShiftBrite RGB LED module (A6281)</title>
		<link>http://hackaday.com/2009/06/29/parts-shiftbrite-rgb-led-module-a6281/</link>
		<comments>http://hackaday.com/2009/06/29/parts-shiftbrite-rgb-led-module-a6281/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 18:00:00 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[led hacks]]></category>
		<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[blinkenlights]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[shiftbrite]]></category>
		<category><![CDATA[spi]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=10589</guid>
		<description><![CDATA[Macetech&#8217;s ShiftBrite is a high-power RGB LED coupled with an Allegro A6281 backpack. The A6281 uses three 10bit pulse-width modulators to mix millions of colors using the red, green, and blue elements in the RGB LED. Multiple modules can be chained together for bigger projects, like the ShiftBrite table. Below the break we demonstrate a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=10589&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-11066" title="shiftbriteii" src="http://hackadaycom.files.wordpress.com/2009/05/shiftbriteii.jpg" alt="shiftbriteii" width="450" height="307" /></p>
<p><a href="http://www.macetech.com/blog/">Macetech&#8217;s</a> <a href="http://macetech.com/blog/node/54">ShiftBrite</a> is a high-power RGB LED coupled with an <a href="http://www.allegromicro.com/en/Products/Part_Numbers/6281/">Allegro A6281</a> backpack. The A6281 uses three 10bit <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation">pulse-width modulators</a> to mix millions of colors using the red, green, and blue elements in the RGB LED.  Multiple modules can be chained together for bigger projects, like the  <a href="http://www.youtube.com/watch?v=C7aUaMiqoIE">ShiftBrite table</a>.</p>
<p>Below the break we demonstrate a ShiftBrite module using <a href="http://www.buspirate.com/">the Bus Pirate</a>. For a limited time you can <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-10589"></span></p>
<p><img class="alignnone size-full wp-image-11067" title="shiftbrite-over" src="http://hackadaycom.files.wordpress.com/2009/05/shiftbrite-over.jpg" alt="shiftbrite-over" width="450" height="356" /></p>
<p><strong><a href="http://macetech.com/blog/node/54">ShiftBrite</a> RGB LED module (<a href="http://macetech.com/store/index.php?main_page=product_info&amp;cPath=1&amp;products_id=1">Macetech</a>, $4.99). ShiftBrite <a href="http://docs.macetech.com/doku.php/shiftbrite">datasheet and example code</a>, Allegro <a href="http://www.allegromicro.com/en/Products/Part_Numbers/6281/">A6281</a> <a href="http://www.allegromicro.com/en/Products/Part_Numbers/6281/6281.pdf">datasheet</a> (PDF).</strong></p>
<p>The ShiftBrite module is a complete A6281 development board. It doesn&#8217;t require any extra parts, just a 5-9volt supply.</p>
<p>The A6281 is one of the most complete RGB LED driver ICs, but it&#8217;s only made in a tiny QFN package. The ShiftBrite is a good way to try the A6281 without soldering a small chip.</p>
<p><img class="alignnone size-full wp-image-11999" title="A6281-connect.470" src="http://hackadaycom.files.wordpress.com/2009/06/a6281-connect-470.png" alt="A6281-connect.470" width="470" height="207" /></p>
<p>A bunch of A6281 modules can be chained together. Each module repeats all of the serial input signals on separate output pins, so the A6281 will work over long cable runs.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>ShiftBrite </strong></td>
</tr>
<tr>
<td>MOSI</td>
<td>DI</td>
</tr>
<tr>
<td>CLK</td>
<td>CI</td>
</tr>
<tr>
<td>CS</td>
<td>LI</td>
</tr>
<tr>
<td>AUX</td>
<td>EI</td>
</tr>
<tr>
<td>5volts</td>
<td>V+</td>
</tr>
<tr>
<td>Vpullup</td>
<td>V+</td>
</tr>
<tr>
<td>GND</td>
<td>GND</td>
</tr>
</tbody>
</table>
<p>We used our <a href="http://www.buspirate.com">Bus Pirate universal serial interface</a> to demonstrate the ShiftBrite, but the command sequences will be the same for any microcontroller. We connected the Bus Pirate to the ShiftBrite as shown in the table above.</p>
<p>We setup the Bus Pirate for raw3wire mode (M, 8), and chose open drain outputs (Hi-Z) so we can interface the ShiftBrite at 5volts. The Bus Pirate can&#8217;t output 5volts directly, so we enabled the bus pull-up resistors (menu &#8216;p&#8217; in v2) and attached the pull-up resistor voltage input pin to the 5volt supply. Finally, we enabled the on-board power supply (capital ‘W’).</p>
<p><em>Interfacing</em></p>
<p>The LED driver output is only active when the  enable pin (EI) is held low.</p>
<blockquote><p>RAW3WIRE&gt;A <strong>&lt;&#8211; capital &#8216;A&#8217;, EI pin high, output disabled</strong><br />
AUX HIGH<br />
RAW3WIRE&gt;a <strong>&lt;&#8211; small &#8216;a&#8217;, EI pin low, output active</strong><br />
AUX LOW<br />
RAW3WIRE&gt;</p></blockquote>
<p>We used the Bus Pirate&#8217;s auxiliary pin to toggle the A6281&#8242;s enable pin, but you could also bypass this feature by wiring EI directly to ground. A small &#8216;a&#8217; in the Bus Pirate terminal takes the AUX/EI pin connection low, enabling the LED output.</p>
<p><img class="alignnone size-full wp-image-11998" title="A6281-IO.470" src="http://hackadaycom.files.wordpress.com/2009/06/a6281-io-470.png" alt="A6281-IO.470" width="470" height="95" /></p>
<p>Two commands update the A6281  settings. The configuration command controls dot correction and  clock settings. The LED pulse-width modulator (PWM) command updates the  three 10bit values that set the red, green, and blue channel brightness. Both commands are  32 bits (4 bytes) long, bit 30  selects the configuration or pulse-width modulator command.  Refer to the chart above, or datasheet page 7.</p>
<p>The interface protocol is like <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a>, but the master-input-slave-output pin is unused. Data is sent most significant bit first, starting with bit 31. Commands are sent by clocking 32 bits into the chip and then toggling the latch pin.</p>
<p>Before we can start mixing colors, we need to setup the A628a&#8217;s internal clock and write the dot correction values.</p>
<blockquote><p>RAW3WIRE&gt;0b01000111 0b11110001 0b11111100 0b01111111 ][<br />
WRITE: 0x47 <strong>&lt;--write 32bits of data</strong><br />
WRITE: 0xF1<br />
WRITE: 0xFC<br />
WRITE: 0x7F<br />
CS DISABLED <strong>&lt;--latch pin high</strong><br />
CS ENABLED <strong>&lt;--latch pin low</strong><br />
RAW3WIRE&gt;</p></blockquote>
<p>We wrote the values in binary so it's easy to follow along in the table above. Remember that bit 31 is sent first, so the order of bits shown here is opposite of what is shown in the table.</p>
<p>The complete setup command is 32 bits (4 bytes) long. Bit 30 sets this as a configuration command (1). Bit 7 and 8 configure the clock source, value 00 configures the 800KHz internal oscillator (datasheet page 7). Three 7bit 'dot correction' values fine tune the LED color channels if you want to correct a wonky pixel in a large array (see the register locations in the table above). We set all the dot correction values to full (1111111). Several bits trigger test functions or don't have a purpose, these should be entered as 0.</p>
<p>After entering 32 bits, toggle the A6281 latch pin (][) to lock the data into the register. Now that the chip is configured and the output enabled, we can finally play with the LED.</p>
<blockquote><p>RAW3WIRE&gt;0b00111111 0b11111111 0b11111111 0b11111111 ][<br />
WRITE: 0x3F<br />
WRITE: 0xFF<br />
WRITE: 0xFF<br />
WRITE: 0xFF<br />
CS DISABLED<br />
CS ENABLED<br />
RAW3WIRE&gt;</p></blockquote>
<p>First,  turn all the colors to full. Bit 31 (0) is ignored, bit 30 (0) indicates a LED pulse-width modulator update command, and the remaining bits set all three channels to 100%.  The three PWM values control the output intensity of each color as follows: blue (bits 29:20), red (bits 19:10), and green (bits 9:0). Raise and lower the latch pin (][) to end the command.</p>
<p>Next, test each each color individually.</p>
<blockquote><p>RAW3WIRE&gt;0b00111111 0b11110000 0b00000000 0b00000000 ][<br />
WRITE: 0x3F<br />
WRITE: 0xF0<br />
WRITE: 0x00<br />
WRITE: 0x00<br />
CS DISABLED<br />
CS ENABLED<br />
RAW3WIRE&gt;</p></blockquote>
<p>Bit 30 (0) signals an LED PWM  update command, followed by a 100% setting for the blue channel (1111111111) and 0% settings for the red and green channels. When we toggle the latch pin (][) the new values are saved and the LED color changes to blue.</p>
<blockquote><p>RAW3WIRE&gt;0b00000000 0b00001111 0b11111100 0b00000000 ][<br />
WRITE: 0x00<br />
WRITE: 0x0F<br />
WRITE: 0xFC<br />
WRITE: 0x00<br />
CS DISABLED<br />
CS ENABLED<br />
RAW3WIRE&gt;</p></blockquote>
<p>This time we'll set the LED to 100% red. Bit 30 (0) signals an LED PWM update command, followed by a 0% setting for the blue channel, a 100% setting for the red channel (1111111111), and a 0% setting for green.  When we toggle the latch pin (][)  the LED color changes to red.</p>
<blockquote><p>RAW3WIRE&gt;0b00000000 0b00000000 0b00000011 0b11111111 ][<br />
WRITE: 0x00<br />
WRITE: 0x00<br />
WRITE: 0x03<br />
WRITE: 0xFF<br />
CS DISABLED<br />
CS ENABLED<br />
RAW3WIRE&gt;</p></blockquote>
<p>Finally, we set the LED to 100% green. Bit 30 signals an LED PWM update, followed by 0% settings for the blue and red channels, and a 100% setting for the green channel (1111111111).  Toggle the latch pin (][)  and the LED color changes to green.</p>
<p>Like this post? Check out the <a href="http://hackaday.com/category/parts/">parts posts</a> you may have missed. Want to request a part post? Please leave your suggestions in the comments.</p>
<p><strong>Hack a Day review disclosure</strong>: Macetech gave us a couple free <a href="http://hackaday.com/2008/05/08/maker-faire-2008-shiftbright-rgb-led-module/">ShiftBrites at Maker Faire 2008</a>.</p>
<br />Posted in led hacks, misc hacks, parts  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/10589/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/10589/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/10589/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=10589&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/06/29/parts-shiftbrite-rgb-led-module-a6281/feed/</wfw:commentRss>
		<slash:comments>10</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/05/shiftbriteii.jpg" medium="image">
			<media:title type="html">shiftbriteii</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/05/shiftbrite-over.jpg" medium="image">
			<media:title type="html">shiftbrite-over</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/a6281-connect-470.png" medium="image">
			<media:title type="html">A6281-connect.470</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/06/a6281-io-470.png" medium="image">
			<media:title type="html">A6281-IO.470</media:title>
		</media:content>
	</item>
		<item>
		<title>Parts: LTC2631A I2C digital to analog converter</title>
		<link>http://hackaday.com/2009/02/09/parts-ltc2631a-i2c-digital-to-analog-converter/</link>
		<comments>http://hackaday.com/2009/02/09/parts-ltc2631a-i2c-digital-to-analog-converter/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 22:00:17 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[dac]]></category>
		<category><![CDATA[digital to analog converter]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[ltc2631a]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[voltage output]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=8232</guid>
		<description><![CDATA[Linear Technology&#8217;s LTC2631A-LZ8 is an 8bit digital to analog converter (DAC) with an I2C interface. This DAC can output 255 different voltages, spaced evenly between 0 and 2.5volts. We previously demonstrated the LTC2640 with a three-wire SPI interface, but this version is controlled with only two signal wires. Bus Pirate LTC2631A (pin #) DATA SDA [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=8232&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8066" title="ltc2640" src="http://hackadaycom.files.wordpress.com/2009/01/ltc2640.jpg" alt="ltc2640" width="450" height="354" /></p>
<p>Linear Technology&#8217;s <a href="http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1155,C1005,C1156,P85698">LTC2631A-LZ8</a> is an 8bit <a href="http://en.wikipedia.org/wiki/Digital-to-analog_converter">digital to analog converter</a> (DAC) with an <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C</a> interface. This DAC can output 255 different voltages, spaced evenly between 0 and 2.5volts. We previously demonstrated the <a href="http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/">LTC2640</a> with a three-wire <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a> interface, but this version is controlled with only two signal wires.</p>
<p><span id="more-8232"></span></p>
<table border="0">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>LTC2631A (pin #)</strong></td>
</tr>
<tr>
<td>DATA</td>
<td>SDA (3)</td>
</tr>
<tr>
<td>CLOCK</td>
<td>SCL (2)</td>
</tr>
<tr>
<td>ADC</td>
<td>VOUT (7)</td>
</tr>
<tr>
<td>&#8211;</td>
<td>CA0/Address 0 (1)</td>
</tr>
<tr>
<td>+5volts</td>
<td>CA1/Address 1 (8)</td>
</tr>
<tr>
<td>+5volts</td>
<td>VDD (5)</td>
</tr>
<tr>
<td>GND</td>
<td>GND (4)</td>
</tr>
<tr>
<td>&#8211;</td>
<td>REF (6)</td>
</tr>
</tbody>
</table>
<p>We used the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Bus Pirate universal serial interface tool</a> to work with the DAC, but the same basic principals apply to any custom implementation. The connections between the Bus pirate and the LTC2631A are outlined in the table. We powered the chip from the Bus Pirate&#8217;s 5volt supply, but it would also work fine at 3.3volts.</p>
<p>The I2C bus requires <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up resistors</a> on both bus wires. 5volts is supplied to the pull-up resistors by connecting a wire from the 5volt supply to the pull-up resistor input terminal. Close the jumpers on the clock and data lines to supply the external voltage to the pull-up resistors.</p>
<p>Now, setup the Bus Pirate for I2C mode and activate the on-board power supply.</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 />
&#8230;<br />
9. PC AT KEYBOARD<br />
MODE&gt;4<strong>&lt;&#8211;I2C mode</strong><br />
900 MODE SET<br />
202 I2C READY<br />
I2C&gt;p<strong>&lt;&#8211;setup power supply</strong><br />
W/w toggles 3.3volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;1<strong>&lt;&#8211;don&#8217;t use 3.3volts</strong><br />
W/w toggles 5volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;2<strong>&lt;&#8211;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 />
I2C&gt;W<strong>&lt;&#8211;capital &#8216;W&#8217; activates the supply</strong><br />
9xx 5VOLT SUPPLY ON<br />
I2C&gt;v<strong>&lt;&#8211;check the voltage levels</strong><br />
9xx VOLTAGE MONITOR: 5V: 4.9 | 3.3V: 0.0 | VPULLUP: 5.0 |<strong>&lt;&#8211;supply on</strong><br />
I2C&gt;</p></blockquote>
<p>After configuring the Bus Pirate, the voltage monitor shows that the 5volt supply is active (4.9volts). Additionally, the monitor shows that 5volts is connected to the pull-up resistor supply terminal (VPULLUP).</p>
<blockquote><p>I2C&gt;(0)<strong>&lt;&#8211;list available macros</strong><br />
0.Macro menu<br />
1.7bit address search<br />
I2C&gt;(1)<strong>&lt;&#8211;search for I2C devices</strong><br />
xxx Searching 7bit I2C address space.<br />
Found devices at:<br />
0&#215;40 0xE6<strong>&lt;&#8211;got reply from these addresses</strong><br />
I2C&gt;</p></blockquote>
<p>The state of pin 1 and 8 determine the LTC2631A I2C address, according to the table on page 22 of the datasheet. Instead of looking up the address in the datasheet, we used the Bus Pirate&#8217;s I2C address search macro to scan the entire I2C address range. The DAC responds to the set address (0X40) and a global address (0xE6). The global address is useful for controlling multiple DACs simultaneously over the same I2C bus.</p>
<blockquote><p>I2C&gt;d [0x40 0b00110000 0xff 0] d<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;output</strong> <strong>is 0volts</strong><br />
210 I2C START CONDITION<strong>&lt;&#8211;start transaction</strong><br />
220 I2C WRITE: 0&#215;40 GOT ACK: YES<strong>&lt;&#8211;DAC address</strong><br />
220 I2C WRITE: 0&#215;30 GOT ACK: YES<strong>&lt;&#8211;set DAC output command</strong><br />
220 I2C WRITE: 0xFF GOT ACK: YES<strong>&lt;&#8211;set DAC to full (255)</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<strong>&lt;&#8211;don&#8217;t care, extra byte</strong><br />
240 I2C STOP CONDITION<strong>&lt;&#8211;end transaction</strong><br />
9xx VOLTAGE PROBE: 2.5VOLTS<strong>&lt;&#8211;output at full</strong><br />
I2C&gt;</p></blockquote>
<p>Now we&#8217;re ready to interface the DAC. An initial voltage measurement (d) shows that the DAC is currently outputting 0volts.</p>
<p>An I2C start condition ([) alerts connected I2C devices to listen for their address. The first byte is the address (0x40) that identifies the device we want to access. The next byte is the LTC2631A command to update the DAC output (0x30 or 0b00110000), followed by the output setting (0xff or 255, 100% output). The final byte doesn't matter for the 8bit DAC we're using, but carries additional data bits for higher resolution versions of the DAC. The transaction is completed by sending the I2C stop condition (]).</p>
<p>After updating the DAC to 100%, a voltage measurement (d) shows that the output is 2.5volts.</p>
<blockquote><p>I2C&gt;d [0x40 0x30 0 0] d<br />
9xx VOLTAGE PROBE: 2.5VOLTS<strong>&lt;&#8211;DAC at 100%</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0&#215;40 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;30 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<strong>&lt;&#8211;set DAC to 0</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<br />
240 I2C STOP CONDITION<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;DAC at 0%</strong><br />
I2C&gt;</p></blockquote>
<p>A similar command sequence sets the DAC output back to 0. A voltage measurement confirms that the DAC output is now 0volts.</p>
<p>For a complete list of DAC features and command codes, see the in-depth discussion of the LTC2640 SPI DAC at the end of the <a href="http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface">Bus Pirate version 1 how-to</a>.</p>
<p>Are there any chips you&#8217;d like us to interface in future <a href="http://hackaday.com/category/parts/">parts</a> posts?</p>
<br />Posted in parts, tool hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/8232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/8232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/8232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=8232&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/02/09/parts-ltc2631a-i2c-digital-to-analog-converter/feed/</wfw:commentRss>
		<slash:comments>8</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/ltc2640.jpg" medium="image">
			<media:title type="html">ltc2640</media:title>
		</media:content>
	</item>
		<item>
		<title>Parts: 1K 1-Wire EEPROM (DS2431)</title>
		<link>http://hackaday.com/2008/12/24/parts-1k-1-wire-eeprom-ds2431/</link>
		<comments>http://hackaday.com/2008/12/24/parts-1k-1-wire-eeprom-ds2431/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 14:00:01 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[1-wire]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[eeprom]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[interfacing]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[serial interface]]></category>
		<category><![CDATA[to-92]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=6785</guid>
		<description><![CDATA[The Maxim DS2431 1K EEPROM is 1-Wire device that adds storage to a project using a single microcontroller pin. We previously interfaced a 1-wire thermometer, but this EEPROM is slightly different because it draws power directly from the 1-Wire bus. Grab the datasheet (PDF) and follow along while we read and write this simple 1-Wire [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6785&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-7182" title="1keeprom-450" src="http://hackadaycom.files.wordpress.com/2008/12/1keeprom-450.jpg" alt="1keeprom-450" width="450" height="335" /></p>
<p>The Maxim <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4272">DS2431 1K EEPROM</a> is <a href="http://en.wikipedia.org/wiki/1-Wire">1-Wire</a> device that adds storage to a project using a single microcontroller pin. We previously interfaced a <a href="http://hackaday.com/2008/12/10/parts-1-wire-temperature-sensor-ds1822/">1-wire thermometer</a>, but this EEPROM is slightly different because it draws power directly from the 1-Wire bus. Grab the <a href="http://www.maxim-ic.com/getds.cfm/qv_pk/4272">datasheet</a> (PDF) and follow along while we read and write this simple 1-Wire memory.</p>
<p><span id="more-6785"></span></p>
<p><strong><a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4272">DS2431</a> 1-Wire 1K EEPROM (Digikey #<a href="http://www.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=DS2431%2B-ND">DS2431+-ND</a>, $1.67)</strong></p>
<p>We used our <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">Bus Pirate universal serial interface</a> to demonstrate the DS2431 EEPROM, we covered the proper connections and configuration options in <a href="http://hackaday.com/2008/12/10/parts-1-wire-temperature-sensor-ds1822/">our previous 1-wire post</a>. The DS2431 requires just two connections: ground (pin 1) and 1-Wire/power (pin 2).  Pin 3 remains unconnected. Like last time, we used a 2K pull-up resistor with the 1-Wire bus.</p>
<p>First, we use the Bus Pirate&#8217;s SEARCH ROM command to identify connected 1-Wire devices.</p>
<blockquote><p>1-WIRE&gt;(240) <strong>&lt;&#8211;SEARCH ROM command macro</strong><br />
1WIRE ROM COMMAND: SEARCH (0xF0)<br />
Found devices at:<br />
Macro     1-WIRE address<br />
1.0x2D 0&#215;54 0xD2 0xEF 0&#215;00 0&#215;00 0&#215;00 0x2B <strong>&lt;&#8211;address</strong><br />
*DS2431 1K EEPROM <strong>&lt;&#8211; type</strong><br />
2.0x2D 0xFE 0x8D 0&#215;43 0&#215;01 0&#215;00 0&#215;00 0&#215;52<br />
*DS2431 1K EEPROM<br />
3.0x2D 0x2B 0xED 0xEF 0&#215;00 0&#215;00 0&#215;00 0x7C<br />
*DS2431 1K EEPROM<br />
Found 0&#215;03 devices.<br />
The first 10 device IDs are available by MACRO, see (0).<br />
1-WIRE&gt;</p></blockquote>
<p>The SEARCH ROM command reveals that there are 3 EEPROMs connected to the 1-Wire bus. The Bus Pirate stores the 64bit 1-wire addresses in macros so we don&#8217;t have to type it every time. We&#8217;ll work with the first device, identified by macro (1).</p>
<p>Writing to the DS2431 takes three steps:</p>
<ul>
<li>Write data to DS2431&#8242;s 8byte &#8216;scratch pad&#8217; EEPROM buffer</li>
<li>Verify the scratch pad contents and get the write access key</li>
<li>Copy data from the scratch pad to the EEPROM for permanent storage.</li>
</ul>
<p>Command 0x0f writes to the scratch pad. The scratch pad is an 8byte buffer that holds data prior to saving it permanently in the EEPROM.</p>
<blockquote><p>1-WIRE&gt;(85)(1) 0x0f 0&#215;00 0&#215;00 0 1 2 3 4 5 6 7 <strong>&lt;&#8211;command</strong><br />
1WIRE BUS RESET OK<br />
1WIRE WRITE ROM COMMAND: MATCH (0&#215;55) *follow with 64bit address<br />
1WIRE ADDRESS MACRO 1: 0x2D 0&#215;54 0xD2 0xEF 0&#215;00 0&#215;00 0&#215;00 0x2B<br />
1WIRE WRITE: 0x0F <strong>&lt;&#8211;write to scratch pad</strong><br />
1WIRE WRITE: 0&#215;00 <strong>&lt;&#8211;begin address byte 1</strong><br />
1WIRE WRITE: 0&#215;00 <strong>&lt;&#8211;begin address byte 2</strong><br />
1WIRE WRITE: 0&#215;00 <strong>&lt;&#8211;data</strong><br />
1WIRE WRITE: 0&#215;01<br />
1WIRE WRITE: 0&#215;02<br />
1WIRE WRITE: 0&#215;03<br />
1WIRE WRITE: 0&#215;04<br />
1WIRE WRITE: 0&#215;05<br />
1WIRE WRITE: 0&#215;06<br />
1WIRE WRITE: 0&#215;07<br />
1-WIRE&gt;</p></blockquote>
<p>The MATCH ROM macro, (85), isolates the the first device, (1). 0x0f is the command to write to the scratch pad, followed by the start address, 0 0. Finally, we send eight bytes of data to save in the scratch pad. The scratch pad is eight bytes long, and all eight bytes will be copied from the scratch pad to the EEPROM at once.</p>
<blockquote><p>1-WIRE&gt;(85)(1) 0xaa r:3 r:8 r:2 r:2 <strong>&lt;&#8211;command</strong><br />
1WIRE BUS RESET OK<br />
1WIRE WRITE ROM COMMAND: MATCH (0&#215;55) *follow with 64bit address<br />
1WIRE ADDRESS MACRO 1: 0x2D 0&#215;54 0xD2 0xEF 0&#215;00 0&#215;00 0&#215;00 0x2B<br />
1WIRE WRITE: 0xAA <strong>&lt;&#8211;read scratch pad</strong><br />
1WIRE BULK READ, 0&#215;03 BYTES: <strong>&lt;&#8211;access code</strong><br />
0&#215;00 0&#215;00 0&#215;07<br />
1WIRE BULK READ, 0&#215;08 BYTES:<strong>&lt;&#8211;verify our data</strong><br />
0&#215;00 0&#215;01 0&#215;02 0&#215;03 0&#215;04 0&#215;05 0&#215;06 0&#215;07<br />
1WIRE BULK READ, 0&#215;02 BYTES:<strong>&lt;&#8211;inverse CRC</strong><br />
0&#215;44 0&#215;67<br />
1WIRE BULK READ, 0&#215;02 BYTES:<strong>&lt;&#8211;all 1s from here</strong><br />
0xFF 0xFF<br />
1-WIRE&gt;</p></blockquote>
<p>To copy data from the scratch pad to the EEPROM, we must first retrieve a three byte access code from the scratch pad with the command 0xaa.  The first three bytes are the access code (0&#215;00 0&#215;00 0&#215;07), followed by the data contained in the scratch pad.</p>
<blockquote><p>1-WIRE&gt;(85)(1) 0&#215;55 0&#215;00 0&#215;00 0&#215;07<br />
1WIRE BUS RESET OK<br />
1WIRE WRITE ROM COMMAND: MATCH (0&#215;55) *follow with 64bit address<br />
1WIRE ADDRESS MACRO 1: 0x2D 0&#215;54 0xD2 0xEF 0&#215;00 0&#215;00 0&#215;00 0x2B<br />
1WIRE WRITE: 0&#215;55 <strong>&lt;&#8211;copy to EEPROM command</strong><br />
1WIRE WRITE: 0&#215;00<strong>&lt;&#8211;access code (3 bytes)</strong><br />
1WIRE WRITE: 0&#215;00<br />
1WIRE WRITE: 0&#215;07<br />
1-WIRE&gt;!!!! <strong>&lt;&#8211;read bits</strong><br />
1WIRE READ BIT: 0<br />
1WIRE READ BIT: 1 <strong>&lt;&#8211;bits alternate, done</strong><br />
1WIRE READ BIT: 0<br />
1WIRE READ BIT: 1<br />
1-WIRE&gt;</p></blockquote>
<p>Command 0&#215;55 with the correct access code will copy the scratch pad to the data EEPROM. Bit reads (!!!!) alternate between 0 and 1 when the copy completes.</p>
<blockquote><p>1-WIRE&gt;(85)(1) 0xf0 0&#215;00 0&#215;00 r:8 r:8<br />
1WIRE BUS RESET OK<br />
1WIRE WRITE ROM COMMAND: MATCH (0&#215;55) *follow with 64bit address<br />
1WIRE ADDRESS MACRO 1: 0x2D 0&#215;54 0xD2 0xEF 0&#215;00 0&#215;00 0&#215;00 0x2B<br />
1WIRE WRITE: 0xF0 <strong>&lt;&#8211;read memory</strong><br />
1WIRE WRITE: 0&#215;00 <strong>&lt;&#8211;start address (2 bytes)</strong><br />
1WIRE WRITE: 0&#215;00<br />
1WIRE BULK READ, 0&#215;08 BYTES: <strong>&lt;&#8211;read back data</strong><br />
0&#215;00 0&#215;01 0&#215;02 0&#215;03 0&#215;04 0&#215;05 0&#215;06 0&#215;07<br />
1WIRE BULK READ, 0&#215;08 BYTES: <strong>&lt;&#8211;read beyond our data</strong><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 />
1-WIRE&gt;</p></blockquote>
<p>Command 0xf0 followed by a two byte memory address (0&#215;00 0&#215;00) begins the data read process. The first eight bytes (r:8) are the values we wrote earlier. Reads don&#8217;t involve the scratch pad and don&#8217;t have an 8byte limit, so further reads continue to the end of the memory.</p>
<p>Don&#8217;t forget to catch up on any <a href="http://hackaday.com/category/parts/">parts posts</a> you may have missed.</p>
<br />Posted in parts, tool hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/6785/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/6785/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/6785/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6785&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/12/24/parts-1k-1-wire-eeprom-ds2431/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://hackadaycom.files.wordpress.com/2008/12/1keeprom-450.jpg" medium="image">
			<media:title type="html">1keeprom-450</media:title>
		</media:content>
	</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&amp;blog=4779443&amp;post=6059&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-6091" title="overview" src="http://hackadaycom.files.wordpress.com/2008/11/overview.jpg" 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 &#8217;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">&#8217;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" 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" 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" 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 0x4B 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 />
0x7B 0&#215;14 0xAE 0&#215;47 0xE1 0x7A 0&#215;94 0x3F<br />
0x4C 0&#215;46 0xC6 0x3B 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 0x6F 0x6D 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, 0x0A 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]&#8216;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 0x4B 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>0x7B 0&#215;14 0xAE 0&#215;47 0xE1 0x7A 0&#215;94 0x3F <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. 0x3f947ae147ae147b=$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>
<br />Posted in how-to, misc hacks, tool hacks  <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/gofacebook/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/6059/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/6059/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/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&amp;blog=4779443&amp;post=6059&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/11/25/how-to-read-a-fedex-kinkos-smart-card-sle4442/feed/</wfw:commentRss>
		<slash:comments>24</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>
	</channel>
</rss>
