<?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; interfacing</title>
	<atom:link href="http://hackaday.com/tag/interfacing/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Sun, 12 Feb 2012 08:27:59 +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; interfacing</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: AT keyboard</title>
		<link>http://hackaday.com/2009/01/26/parts-at-keyboard/</link>
		<comments>http://hackaday.com/2009/01/26/parts-at-keyboard/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 17:38:33 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></category>
		<category><![CDATA[peripherals hacks]]></category>
		<category><![CDATA[at keyboard]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[interfacing]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[parts monday]]></category>
		<category><![CDATA[scancode]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=8058</guid>
		<description><![CDATA[Last week we introduced a new version of the Bus Pirate universal serial interface tool. The last firmware update included an AT keyboard decoder library for both hardware versions. There&#8217;s a ton of old AT keyboards making their way to the landfill. We&#8217;ll show you how to recycle one as an input device for your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=8058&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8200" title="atkeyboard" src="http://hackadaycom.files.wordpress.com/2009/01/atkeyboard.jpg" alt="atkeyboard" width="450" height="336" /></p>
<p>Last week we introduced <a href="http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/">a new version</a> of the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Bus Pirate universal serial interface tool</a>. The last firmware update included an AT keyboard decoder library for both hardware versions.</p>
<p>There&#8217;s a ton of old AT keyboards making their way to the landfill. We&#8217;ll show you how to recycle one as an input device for your next project.</p>
<p><span id="more-8058"></span><strong>Connection</strong></p>
<table border="0">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>PC AT keyboard (pin #)</strong></td>
</tr>
<tr>
<td>SDA</td>
<td>KBD Data (3)</td>
</tr>
<tr>
<td>SCL</td>
<td>KBD Clock (1)</td>
</tr>
<tr>
<td>+5volts</td>
<td>VDD (5)</td>
</tr>
<tr>
<td>GND</td>
<td>GND (2)</td>
</tr>
</tbody>
</table>
<p>AT keyboards communicate over a bidirectional two-wire interface. The bus is <a href="http://en.wikipedia.org/wiki/Open_collector">open collector</a>, but keyboards already have internal <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up resistors</a>. The PC AT keyboard protocol is described <a href="http://www.beyondlogic.org/keyboard/keybrd.htm">here</a>. We used our Bus Pirate tool to demonstrate the keyboard protocol, but the same basic principals apply to any microcontroller.</p>
<p>We connected the Bus Pirate to the keyboard as outlined in the table. We believe that <a href="http://www.mouser.com/Search/ProductDetail.aspx?R=161-2306virtualkey11180000virtualkey161-2306">this</a> is a through-hole female AT keyboard jack, but we haven&#8217;t tested it. Do you know of a source for new sockets?</p>
<p><strong>Protocol</strong></p>
<p>The keyboard provides the clock signal for <em>all</em> data transfers; the PC side resembles a slave device. None of the existing Bus Pirate interface libraries work with an external clock, so we wrote a simple AT keyboard decoder library. The library depends on the keyboard&#8217;s clock signal, and it&#8217;ll hang if the keyboard fails or isn&#8217;t connected. If you use our library in your own project, consider adding a timeout delay in the readbit() and writebit() functions.</p>
<p><em>PC to keyboard command codes</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Code</strong></td>
<td><strong>Command</strong></td>
</tr>
<tr>
<td>0xed</td>
<td>Set status LEDs</td>
</tr>
<tr>
<td>0xee</td>
<td>Echo 0xee</td>
</tr>
<tr>
<td>0xf0</td>
<td>Set scancode type</td>
</tr>
<tr>
<td>0xf3</td>
<td>Set repeat rate</td>
</tr>
<tr>
<td>0xf4</td>
<td>Keyboard enable</td>
</tr>
<tr>
<td>0xf5</td>
<td>Keyboard disable</td>
</tr>
<tr>
<td>0xfe</td>
<td>Resend last byte</td>
</tr>
<tr>
<td>0xff</td>
<td>Reset keyboard</td>
</tr>
</tbody>
</table>
<p>A PC uses these commands to control various functions of an AT keyboard. The keyboard responds to commands with an acknowledge byte (oxfa). In our experience, the keyboard will reset if the response byte is not read shortly after the command is sent.</p>
<p><em>Keyboard to PC response codes</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Code</strong></td>
<td><strong>Response</strong></td>
</tr>
<tr>
<td>0xfa</td>
<td>Acknowledge</td>
</tr>
<tr>
<td>0xaa</td>
<td>Self test passed</td>
</tr>
<tr>
<td>0xee</td>
<td>Echo response</td>
</tr>
<tr>
<td>0xfe</td>
<td>Resend last byte</td>
</tr>
<tr>
<td>0&#215;00 or 0xff</td>
<td>Error or buffer overflow</td>
</tr>
</tbody>
</table>
<p>The keyboard has a number of single byte response codes.  Most PC commands are acknowledged with 0xfa. 0xaa is sent after a keyboard reset.</p>
<p><strong>Setup the Bus Pirate</strong><em><br />
</em></p>
<blockquote><p>HiZ&gt;m<br />
1. HiZ<br />
&#8230;<br />
9. PC AT KEYBOARD<br />
MODE&gt;9<strong> &lt;&#8211;set mode</strong><br />
900 MODE SET<br />
X02 PC AT KB DECODER READY<br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>First, we setup the the Bus Pirate for AT keyboard mode, option 9.</p>
<blockquote><p>PC AT KEYBOARD&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;1<strong> &lt;&#8211;no 3.3volt supply</strong><br />
W/w toggles 5volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;2<strong> &lt;&#8211;use the 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 />
PC AT KEYBOARD&gt;W <strong>&lt;&#8211;capital &#8216;W&#8217;, turn supply on</strong><br />
9xx 5VOLT SUPPLY ON<br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>Next, we configure the Bus Pirate&#8217;s power supply to provide 5volts for the AT keyboard.</p>
<blockquote><p>PC AT KEYBOARD&gt;r<strong> &lt;&#8211;read byte from keyboard</strong><br />
x30 PCATKB READ:  NONE<strong> &lt;&#8211;no data available</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>The AT keyboard library follows the standard Bus Pirate syntax. Numeric values are sent to the keyboard as bytes, &#8216;r&#8217; reads a byte from the keyboard. The protocol is clocked by the keyboard so bitwise operations are disabled.  If no data is available, the read will return &#8216;NONE&#8217;.</p>
<p><strong>Setup the keyboard<br />
</strong></p>
<blockquote><p>PC AT KEYBOARD&gt;0xee r <strong>&lt;&#8211;send 0xee, read one byte</strong><br />
X20 PCATKB WRITE: 0xEE GOT ACK <strong>&lt;&#8211;write oxee, got ack bit</strong><br />
x30 PCATKB READ: 0xEE <strong>&lt;&#8211;read 0xee, echo was successful</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>We can test the connection to the AT keyboard using the echo command, 0xee. The keyboard will respond 0xee if our connections are correct.</p>
<p>The keyboard responds to commands with an ACK bit at the protocol level, and then again with an ACK byte. We found that our test keyboards reset automatically if the ACK byte wasn&#8217;t read immediately after sending the command.</p>
<blockquote><p>PC AT KEYBOARD&gt;0xee<strong> &lt;&#8211;echo command</strong><br />
X20 PCATKB WRITE: 0xEE GOT ACK <strong>&lt;&#8211;wrote echo, got ACK</strong><br />
PC AT KEYBOARD&gt;r <strong>&lt;&#8211;read one byte</strong><br />
x30 PCATKB READ: 0xAA<strong> &lt;&#8211;read 0xaa, reset indicator</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>Here, we tried to send the echo command and then read the reply later. The keyboard reset automatically and replies 0xaa, self-test passed.</p>
<blockquote><p>PC AT KEYBOARD&gt;0xff r r <strong>&lt;&#8211;reset command, read two bytes</strong><br />
X20 PCATKB WRITE: 0xFF GOT ACK<strong> &lt;&#8211;write reset command, got ACK</strong><br />
x30 PCATKB READ: 0xFA<strong> &lt;&#8211;command ACK byte</strong><br />
x30 PCATKB READ:  NONE<strong> &lt;&#8211;read once more to reset</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>The keyboard is reset by writing the command 0xff, and reading two bytes. The Keyboard won&#8217;t reset until the second byte is read.</p>
<blockquote><p>PC AT KEYBOARD&gt;r<strong> &lt;&#8211;read a byte</strong><br />
x30 PCATKB READ: 0xAA<strong> &lt;&#8211;reset success</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>A short period after reset we can read the power on self test (POST) results, 0xaa indicates POST success.</p>
<blockquote><p>PC AT KEYBOARD&gt;0xf5 r <strong>&lt;&#8211;disable the keyboard</strong><br />
X20 PCATKB WRITE: 0xF5 GOT ACK <strong>&lt;&#8211;wrote command</strong><br />
x30 PCATKB READ: 0xFA<strong> &lt;&#8211;read ACK byte</strong><br />
PC AT KEYBOARD&gt;0xf4 r<strong> &lt;&#8211;enable keyboard</strong><br />
X20 PCATKB WRITE: 0xF4 GOT ACK<strong> &lt;&#8211;wrote command</strong><br />
x30 PCATKB READ: 0xFA<strong> &lt;&#8211;read ACK byte</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>0xf5 disables keyboard input. 0xf4 enables the keyboard and clears the buffer.</p>
<blockquote><p>PC AT KEYBOARD&gt;0xed r 0b111 r <strong>&lt;&#8211;set indicator LEDs</strong><br />
X20 PCATKB WRITE: 0xED GOT ACK <strong>&lt;&#8211;set LED command</strong><br />
x30 PCATKB READ: 0xFA<strong> &lt;&#8211;command acknowledged</strong><br />
X20 PCATKB WRITE: 0&#215;07 GOT ACK <strong>&lt;&#8211;send LED value</strong><br />
x30 PCATKB READ: 0xFA<strong> &lt;&#8211;value acknowledged</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>The num, caps, and scroll lock LEDs are controlled by the 0xed command. The last three bits of a second byte (ob111) indicate which LEDs to light. It&#8217;s very important to perform all four byte operations within the keyboard timeout period, or the keyboard will reset.</p>
<blockquote><p>PC AT KEYBOARD&gt;0xee r<strong> &lt;&#8211;echo test command</strong><br />
X20 PCATKB WRITE: 0xEE GOT ACK<br />
x30 PCATKB READ: 0xEE<br />
PC AT KEYBOARD&gt;0xfe r<strong> &lt;&#8211;repeat last byte command</strong><br />
X20 PCATKB WRITE: 0xFE GOT ACK<strong> &lt;&#8211;write repeat command</strong><br />
x30 PCATKB READ: 0xEE<strong> &lt;&#8211;previous byte is repeated</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>The last interesting keyboard command is the repeat byte command. 0xfe causes the keyboard to send the last byte again. This is a useful command if there was a error in the previous transmission.</p>
<p><strong>Read key presses<br />
</strong></p>
<p>Key presses are buffered by the keyboard until we read them.</p>
<blockquote><p>PC AT KEYBOARD&gt;r<strong> &lt;&#8211;read byte</strong><br />
x30 PCATKB READ: 0&#215;29<strong> &lt;&#8211;space scancode</strong><br />
PC AT KEYBOARD&gt;r<strong> &lt;&#8211;read byte</strong><br />
x30 PCATKB READ: 0xF0<strong> &lt;&#8211;key release scancode</strong><br />
PC AT KEYBOARD&gt;r <strong>&lt;&#8211;read byte</strong><br />
x30 PCATKB READ: 0&#215;29<strong>&lt;&#8211;space scancode</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>A key press sends <a href="http://www.barcodeman.com/altek/mule/scandoc.php">scancodes</a>, multi-byte sequences that represent the key presses. In the example, we pressed space which has the scancode 0&#215;29. When a key is released, the keyboard sends 0xf0 and the scancode for the key (0&#215;29). Each key press results in a similar three part sequence.</p>
<blockquote><p>PC AT KEYBOARD&gt;r:4 <strong>&lt;&#8211;read 4 bytes</strong><br />
x31 PCATKB BULK READ, 0&#215;04 BYTES:<br />
0&#215;29  0xF0  0&#215;29   NONE<strong> &lt;&#8211;space scancode</strong><br />
PC AT KEYBOARD&gt;</p></blockquote>
<p>This is just a simplified version of the previous example. Rather than read three bytes individually, we used the bulk read command. Again, we get the space scancode sequence. Our attempt to read a non-existant fourth byte fails.</p>
<br />Posted in parts, peripherals hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/8058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/8058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/8058/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=8058&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/01/26/parts-at-keyboard/feed/</wfw:commentRss>
		<slash:comments>15</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/atkeyboard.jpg" medium="image">
			<media:title type="html">atkeyboard</media:title>
		</media:content>
	</item>
		<item>
		<title>Parts: Precision humidity and temperature sensor (SHT1x/7x)</title>
		<link>http://hackaday.com/2008/12/29/parts-precision-humidity-and-temperature-sensor-sht1x7x/</link>
		<comments>http://hackaday.com/2008/12/29/parts-precision-humidity-and-temperature-sensor-sht1x7x/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 18:03:14 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[2 wire interface]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[interfacing]]></category>
		<category><![CDATA[monday parts]]></category>
		<category><![CDATA[sensirion]]></category>
		<category><![CDATA[sht11]]></category>
		<category><![CDATA[sht1x]]></category>
		<category><![CDATA[sht71]]></category>
		<category><![CDATA[sht7x]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=7279</guid>
		<description><![CDATA[Sensirion&#8217;s SHTxx is a digitally interfaced humidity and temperature sensor. Accurate humidity measurements usually require careful analog design, but the SHTxx moves all that complicated stuff into a single chip. Through-hole (SHT7x) and surface mount (SHT1x) versions are available, we used the surface mount SHT11 with +/-3% accuracy. We&#8217;ll show you how to use the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=7279&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-7334" title="sht11" src="http://hackadaycom.files.wordpress.com/2008/12/sht11.jpg" alt="sht11" width="450" height="322" /></p>
<p>Sensirion&#8217;s <a href="http://www.sensirion.com/en/01_humidity_sensors/00_humidity_sensors.htm">SHTxx</a> is a digitally interfaced humidity and temperature sensor. Accurate humidity measurements usually require careful analog design, but the SHTxx moves all that complicated stuff into a single chip. Through-hole (SHT7x) and surface mount (SHT1x) versions are available, we used the surface mount SHT11 with +/-3% accuracy. We&#8217;ll show you how to use the SHTxx below.</p>
<p><span id="more-7279"></span></p>
<p><strong>Sensirion SHT1x/SHT7x precision humidity and temperature sensor (<a href="http://octopart.com/search?q=sht*">Octopart search</a>, starting at $25).</strong></p>
<p>This isn&#8217;t a cheap sensor. Octopart lists <a href="http://octopart.com/search?q=sht*">a few places to buy it</a>. Several smaller hobby electronics stores carry it; Hobby Engineering has it for $29 (#<a href="http://www.hobbyengineering.com/H1509.html">H01509-01C</a>). We found compatible PCB footprints in <em>sht10_11_15.lbr</em> and <em>sht11.lbr</em> on the <a href="http://www.cadsoftusa.com/cgi-bin/download.pl?page=/home/cadsoft/html_public/download.htm.en&amp;dir=eagle/userfiles/libraries">Cadsoft library download page</a>. Pin connections for the different package types are in the datasheet: <a href="http://www.sensirion.com/en/pdf/product_information/Datasheet-humidity-sensor-SHT1x.pdf">SHT1x</a> (PDF), <a href="http://www.sensirion.com/en/pdf/product_information/Datasheet-humidity-sensor-SHT7x.pdf">SHT7x</a> (PDF).</p>
<p><img class="alignnone size-full wp-image-7314" title="sht11" src="http://hackadaycom.files.wordpress.com/2008/12/cct1.png" alt="sht11" width="452" height="337" /></p>
<p>The SHTxx has a two-wire serial interface that requires pull-up resistors (R1,2), values between 2K and 10K should work. Sensirion recommends a decoupling capacitor (C1) only if the sensor is powered over a length of wire, but we think it&#8217;s always a good idea to include one.</p>
<p>We&#8217;ll demonstrate the SHTxx using the <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">Bus Pirate universal serial interface</a> in raw2wire mode with Hi-Z outputs. The SHTxx is powered from the Bus Pirate&#8217;s 3.3volt supply. The Bus Pirate&#8217;s on-board pull-up resistors hold the bus high, eliminating the need for external resistors R1 and R2.</p>
<p><strong>Interface</strong></p>
<p>The SHTxx communicates over two wires using a simple serial protocol. The protocol isn&#8217;t compatible with I2C, but a single SHTxx can exist on a bus with I2C peripherals.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Command</strong></td>
<td><strong>Code</strong></td>
</tr>
<tr>
<td>Measure Temperature</td>
<td><em>000</em>00011</td>
</tr>
<tr>
<td>Measure Relative Humidity</td>
<td><em>000</em>00101</td>
</tr>
<tr>
<td>Read Status Register</td>
<td><em>000</em>00111</td>
</tr>
<tr>
<td>Write Status Register</td>
<td><em>000</em>00110</td>
</tr>
<tr>
<td>Soft reset</td>
<td><em>000</em>11110</td>
</tr>
</tbody>
</table>
<p>Five commands control the SHTxx, these are outlined in the table. The first 3 bits are the address (always 000), the remaining 5 bits are a unique command code.</p>
<p><strong>Reset</strong></p>
<p>Start a transaction by clearing any partial commands or data from a previous use. A minimum of nine clock ticks while data is high will clear the SHTxx interface. The Bus Pirate syntax to for this is <em>-^:9</em>; data high (-), 9 clock ticks (^:9).<strong><br />
</strong></p>
<p>Commands to the SHT11 begin with a unique start condition. Like an <a href="http://www.esacademy.com/faq/i2c/busevents/i2cstast.htm">I2C start condition</a>, this is the only time when the data signal changes with the clock signal high. This illegal condition causes the chip to prepare for a new command. The SHTxx start condition is different than I2C, allowing both types of devices to exist on the same bus.</p>
<p>The Bus Pirate code to generate an SHTxx style start condition is<em> -/_\/-\ </em>; data starts high (-), clock up (/), data goes low (_), clock low (\), clock high (/), data goes high (-), and a final clock low transition (\) ends the sequence.</p>
<p>A soft reset is a good idea because it puts the chip in a default state. Prior to the first temperature or humidity conversion, we send the soft reset command.</p>
<blockquote><p>RAW2WIRE&gt;-^:9 -/_\/-\ 0b00011110 !<strong>&lt;&#8211;command</strong><br />
4xx RAW2WIRE DATA OUTPUT, 1 <strong>&lt;&#8211;clear interface</strong><br />
4xx RAW2WIRE 0&#215;09 CLOCK TICKS<br />
4xx RAW2WIRE DATA OUTPUT, 1 <strong>&lt;&#8211;start condition</strong><br />
4xx RAW2WIRE CLOCK, 1<br />
4xx RAW2WIRE DATA OUTPUT, 0<br />
4xx RAW2WIRE CLOCK, 0<br />
4xx RAW2WIRE CLOCK, 1<br />
4xx RAW2WIRE DATA OUTPUT, 1<br />
4xx RAW2WIRE CLOCK, 0<br />
420 RAW2WIRE WRITE: 0x1E <strong>&lt;&#8211;soft reset code</strong><br />
4xx RAW2WIRE READ BIT: 0 <strong>&lt;&#8211;acknowledge</strong><strong> bit, OK</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>First, we clear the interface (-^:9), then send the start condition (<em>-/_\/-\). </em>The reset command (0b00011110=0x1E) follows. The SHTxx acknowledges (acks) commands by pulling the data line low for one bit after a command is transmitted. We read one bit (!) to get the acknowledgment status; 0 is success, 1 signals an error.</p>
<p><strong>Temperature</strong></p>
<p>Now we can read the temperature<strong>. </strong>This happens in two steps, with a delay for the temperature conversion.<strong><br />
</strong></p>
<blockquote><p>RAW2WIRE&gt;-^:9 -/_\/-\ 0b00000011 !<br />
4xx RAW2WIRE DATA OUTPUT, 1  <strong>&lt;&#8211;clear interface</strong><br />
4xx RAW2WIRE 0&#215;09 CLOCK TICKS<br />
4xx RAW2WIRE DATA OUTPUT, 1 <strong>&lt;&#8211;start condition</strong><br />
&#8230;<br />
4xx RAW2WIRE CLOCK, 0<br />
420 RAW2WIRE WRITE: 0&#215;03 <strong>&lt;&#8211;start temperature conversion</strong><br />
4xx RAW2WIRE READ BIT: 0 <strong>&lt;&#8211;ack bit, OK</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>First, we send a start condition and the temperature conversion command (00000011=0&#215;03). The SHTxx replies to a successful command by pulling the data line low for one bit (ack). After the ack bit, the data line goes high until the conversion finishes.</p>
<blockquote><p>RAW2WIRE&gt;.<br />
4xx RAW2WIRE DATA INPUT, STATE: 0 <strong>&lt;&#8211;data low when done</strong><br />
RAW2WIRE&gt;</p></blockquote>
<p>When the data line goes low, the temperature conversion is finished. &#8216;.&#8217; is the Bus Pirate command to read the data state without a clock tick. Now we can grab the result.</p>
<blockquote><p>RAW2WIRE&gt;r_^ r_^ r_^<br />
430 RAW2WIRE READ: 0&#215;17 <strong>&lt;&#8211;data byte 1</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0 <strong>&lt;&#8211;data low</strong><br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS <strong>&lt;&#8211;send ack bit</strong><br />
430 RAW2WIRE READ: 0xCC <strong>&lt;&#8211;data byte 2</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0<br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS<br />
430 RAW2WIRE READ: 0x0C <strong>&lt;&#8211;crc</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0<br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS<br />
RAW2WIRE&gt;</p></blockquote>
<p>Each byte read (r) requires an I2C style acknowledgment bit with the data low. We do this with the _^ sequence; data low (_), one clock tick (^).</p>
<p>The first two bytes are the temperature reading (0x17cc), followed by a CRC (0x0c). The raw value (0x17cc=6092) is converted to degrees Celsius using the equation and coefficients on page 9 of the datasheet. Temperature readings are 14bits by default:</p>
<p style="padding-left:30px;">T = -39.7 + 0.01*<em>X</em></p>
<p style="padding-left:30px;"><span style="text-decoration:underline;">21.22C</span> = -39.7 + (0.01*<em>6092</em>)</p>
<p><strong>Humidity</strong></p>
<p>Humidity conversions are started with code 00000101 (0&#215;05 hex).<strong><br />
</strong></p>
<blockquote><p>RAW2WIRE&gt;-^:9 -/_\/-\ 0b00000101 ! <strong>&lt;&#8211;command</strong><br />
4xx RAW2WIRE DATA OUTPUT, 1 <strong>&lt;&#8211;clear interface</strong><br />
4xx RAW2WIRE 0&#215;09 CLOCK TICKS<br />
4xx RAW2WIRE DATA OUTPUT, 1 <strong>&lt;&#8211;start condition</strong><br />
&#8230;<br />
4xx RAW2WIRE CLOCK, 0<br />
420 RAW2WIRE WRITE: 0&#215;05 <strong>&lt;&#8211;start humidity conversion</strong><br />
4xx RAW2WIRE READ BIT: 0<strong>&lt;&#8211;ack bit, OK</strong></p></blockquote>
<p>As before, a ninth acknowledgment bit is low if the SHTxx processed the command.</p>
<blockquote><p>RAW2WIRE&gt;.<br />
4xx RAW2WIRE DATA INPUT, STATE: 0 <strong>&lt;&#8211;data low when done</strong></p></blockquote>
<p>The data line goes high and then returns low when the humidity conversion is done.</p>
<blockquote><p>RAW2WIRE&gt;r_^ r_^ r_^<br />
430 RAW2WIRE READ: 0&#215;05 <strong>&lt;&#8211;data byte 1</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0 <strong>&lt;&#8211;data low</strong><br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS <strong>&lt;&#8211;ack bit</strong><br />
430 RAW2WIRE READ: 0&#215;80 <strong>&lt;&#8211;data byte 2</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0<br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS<br />
430 RAW2WIRE READ: 0&#215;46 <strong>&lt;&#8211;crc</strong><br />
4xx RAW2WIRE DATA OUTPUT, 0<br />
4xx RAW2WIRE 0&#215;01 CLOCK TICKS<br />
RAW2WIRE&gt;</p></blockquote>
<p>A complete conversion generates a three byte response. The first two bytes are the raw humidity reading (0&#215;0580=1408), the final byte is a CRC (0&#215;46) that can be used to verify data integrity.</p>
<p>Humidity readings have 12bits of resolution by default, convert to humidity using this equation:</p>
<p style="padding-left:30px;">RH = -2.0468 + 0.0367(<em>X</em>) + (-0.0000015955*(<em>X</em>^2))</p>
<p style="padding-left:30px;"><span style="text-decoration:underline;">46.46%RH</span> = -2.0468 + 0.0367(<em>1408</em>) + (-0.0000015955*(<em>1408</em>^2))</p>
<p><strong>Conclusion</strong></p>
<p>This isn&#8217;t a cheap sensor, but it doesn&#8217;t require careful analog design like the <a href="http://content.honeywell.com/sensing/prodinfo/humiditymoisture/">Honeywell HIH series</a>. Have you worked with a humidity sensor?</p>
<p>Like this post? Check out the <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/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/7279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/7279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/7279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=7279&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/12/29/parts-precision-humidity-and-temperature-sensor-sht1x7x/feed/</wfw:commentRss>
		<slash:comments>19</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/sht11.jpg" medium="image">
			<media:title type="html">sht11</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/12/cct1.png" medium="image">
			<media:title type="html">sht11</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>Parts: 133MHz-16.2kHz programmable oscillator (DS1077)</title>
		<link>http://hackaday.com/2008/11/28/parts-133mhz-162khz-programmable-oscillator-ds1077/</link>
		<comments>http://hackaday.com/2008/11/28/parts-133mhz-162khz-programmable-oscillator-ds1077/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 18:39:06 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[parts]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[chips]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[frequency dividers]]></category>
		<category><![CDATA[ics]]></category>
		<category><![CDATA[interfacing]]></category>
		<category><![CDATA[maxim]]></category>
		<category><![CDATA[oscillator]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=6359</guid>
		<description><![CDATA[The DS1077 is a 5volt, 133MHz to 16kHz programmable clock source. The internal frequency divider is configured over a simple I2C interface, and the chip requires no external parts. Not bad for under $2. We used the Bus Pirate to test this chip before using it in a project. Grab the datasheet (PDF) and follow [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6359&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-6371" title="cover" src="http://hackadaycom.files.wordpress.com/2008/11/cover.jpg" alt="cover" width="450" height="287" /></p>
<p>The <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3359">DS1077</a> is a 5volt, 133MHz to 16kHz programmable clock source. The internal frequency divider is configured over a simple I2C interface, and the chip requires no external parts. Not bad for under $2. We used <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface">the Bus Pirate</a> to test this chip before using it in a project. Grab the <a href="http://datasheets.maxim-ic.com/en/ds/DS1077.pdf">datasheet</a> (PDF) and follow along.<span id="more-6359"></span></p>
<p><strong><a href="https://shop.maxim-ic.com/storefront/priceavailable.do?Partnumber=DS1077Z-133%2B&amp;event=PartSearch&amp;menuitem=PriceAndAvailability">DS1077</a>, $1.69 direct from Maxim + $10 shipping.</strong></p>
<p>This chip isn&#8217;t available at any major distributors yet, but Maxim has them for under $2/each with a flat $10 shipping charge. This is an 8pin SOIC surface mount chip, so we made a small breakout board for testing.</p>
<p><em>Test circuit</em></p>
<p><img class="alignnone size-full wp-image-6360" title="schematic-450" src="http://hackadaycom.files.wordpress.com/2008/11/schematic-450.png" alt="schematic-450" width="453" height="212" /></p>
<p><em>Pin connections</em></p>
<table style="height:111px;" border="0" width="240">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>DS1077 (pin)<br />
</strong></td>
</tr>
<tr>
<td>SCL</td>
<td>SCL (8)</td>
</tr>
<tr>
<td>SDA</td>
<td>SDA(7)</td>
</tr>
<tr>
<td>AUX</td>
<td>OUT1 (1)</td>
</tr>
<tr>
<td>+5volts</td>
<td>Vcc (3)</td>
</tr>
<tr>
<td>GND</td>
<td>GND, CTRL (4,5,6)</td>
</tr>
</tbody>
</table>
<p>We powered the DS1077 from the Bus Pirate&#8217;s 5volt power supply. Two resistors, R1 and R2, <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up</a> the I2C bus to 5volts when it&#8217;s not in use. Capacitor C1 is 0.01uF and C2 is 0.1uF, as recommended by the datasheet. Control pins provide some additional functions, but we bypassed them to ground during our test. Output1 is the primary clock signal pin.</p>
<p><em>Interfacing</em></p>
<table border="0">
<tbody>
<tr>
<td><strong>Address</strong></td>
<td><strong>Purpose</strong></td>
</tr>
<tr>
<td>0b10110000</td>
<td>Default base address (0xB0)</td>
</tr>
<tr>
<td>0xB0</td>
<td>Write address</td>
</tr>
<tr>
<td>0xB1</td>
<td>Read address</td>
</tr>
</tbody>
</table>
<p>We put the Bus Pirate into I2C mode (M, options: I2C, 100kHz). The external pull-up resistors hold the bus at 5volts, so it&#8217;s important to leave the on-board 3.3volt pull-up resistors off (default).</p>
<blockquote><p>I2C&gt;{0b10110000} <strong>&lt;&#8211; DS1077 write address</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES <strong>&lt;&#8211; got ACK</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>First, we broadcast the DS1077&#8242;s address and see if it acknowledges. The address of the DS1077 is 1011, plus three programmable bits (000 by default), and the read (1) or write (0) bit. We got an ACK, so we know that the circuit is working and our connections are good.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Address</strong></td>
<td><strong>Bytes</strong></td>
<td><strong>Register</strong></td>
</tr>
<tr>
<td>0&#215;01</td>
<td>2</td>
<td>10 bit clock divider, n+2 (DIV)</td>
</tr>
<tr>
<td>0&#215;02</td>
<td>2</td>
<td>Prescaler, CTRL pin functions. (MUX)</td>
</tr>
<tr>
<td>0x0D</td>
<td>1</td>
<td>Address select, EEPROM write control. (BUS)</td>
</tr>
<tr>
<td>0x3F</td>
<td>0</td>
<td>Save settings to EEPROM (E2)</td>
</tr>
</tbody>
</table>
<p>The DS1077 is controlled by writing values to the locations shown in the table.</p>
<blockquote><p>I2C&gt;{0xb0 0x0d 0b00001000} , <strong>&lt;&#8211;write to BUS register</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES <strong>&lt;&#8211;DS1077 write address</strong><br />
220 I2C WRITE: 0x0D GOT ACK: YES <strong>&lt;&#8211; BUS register</strong><br />
220 I2C WRITE: 0&#215;08 GOT ACK: YES <strong>&lt;&#8211; BUS register setting</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>By default, the DS1077 saves all changes to the EEPROM. We don&#8217;t need this during testing, so we disable it by setting bit 3 (0b1000) of the BUS register (0x0d). The first four bits must be left as 0, the last three bits select the address to accommodate multiple DS1077s on the same I2C bus. See datasheet page 7.</p>
<blockquote><p>I2C&gt;{0xb0 0&#215;02 0b00011000 0b00000000} <strong>&lt;&#8211;set the 16bit MUX value</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES <strong>&lt;&#8211;DS1077 write address</strong><br />
220 I2C WRITE: 0&#215;02 GOT ACK: YES <strong>&lt;&#8211;MUX register </strong><br />
220 I2C WRITE: 0&#215;18 GOT ACK: YES <strong>&lt;&#8211;data byte 1</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES <strong>&lt;&#8211;data byte 2</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>The MUX register controls the prescalers, CTRL pin functions, and frequency divider.  We disable the prescaler and CTRL pins, and enable the 10bit frequency divider.  The MUX register is explained on page 5 of the datasheet.</p>
<p>Specific frequencies are generated by dividing the 133MHz reference frequency through the prescalers and a 10bit (1025 level) programmable divider.  The clock is divided by the amount specified in the DIV register, <em>plus two</em>. When DIV=0, the output is 133MHz/2=66MHz.</p>
<p><img class="alignnone size-full wp-image-6361" title="graph" src="http://hackadaycom.files.wordpress.com/2008/11/graph.png" alt="graph" width="208" height="251" /></p>
<p>This scheme gives the best frequency resolution in low ranges, and no steps between 133MHz and 66MHz.</p>
<blockquote><p>I2C&gt;{0xb0 1 0b11111111 0b11000000} <strong>&lt;&#8211;DIV=1025</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xB0 GOT ACK: YES <strong>&lt;&#8211;DS1077 write address</strong><br />
220 I2C WRITE: 0&#215;01 GOT ACK: YES <strong>&lt;&#8211; DIV register</strong><br />
220 I2C WRITE: 0xFF GOT ACK: YES <strong>&lt;&#8211; bits 9:2</strong><br />
220 I2C WRITE: 0xC0 GOT ACK: YES <strong>&lt;&#8211; bits 1:0</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;f  <strong>&lt;&#8211;do a frequency count</strong><br />
9xx FREQ COUNT ON AUX: 16128Hz (16kHz) <strong>&lt;&#8211; DS1077 frequency</strong><br />
I2C&gt;</p></blockquote>
<p>We set all the bits in the DIV register to 1 for maximum frequency division. &#8216;F&#8217; measures the frequency on the AUX pin, which is connected to the DS1077 clock output. With DIV=1025, the frequency is about 16kHz.</p>
<blockquote><p>I2C&gt;{0xb0 1 0 0} <strong>&lt;&#8211; DIV=0, 133MHz divide by 2</strong><br />
&#8230;<br />
9xx FREQ COUNT ON AUX: 0Hz <strong>&lt;&#8211;66MHz, too fast to count</strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;-<br />
</strong></p>
<p>I2C&gt;{0xb0 1 0 0b10000000} <strong>&lt;&#8211; DIV=2</strong><br />
&#8230;<br />
9xx FREQ COUNT ON AUX: 3339696Hz (33MHz) <strong>&lt;&#8211;133MHz/4</strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;-<br />
</strong></p>
<p>I2C&gt;{0xb0 1 0b00000001 0b00000000} <strong>&lt;&#8211;DIV=4</strong><br />
&#8230;<br />
9xx FREQ COUNT ON AUX: 22192384Hz (22MHz) <strong>&lt;&#8211;133MHz/6</strong></p></blockquote>
<p>We can play with the divider and generate a range of frequencies. The output is always equal to the reference frequency (133MHz) divided by DIV+2. The Bus Pirate&#8217;s input pin is only capable of measuring about 50MHz, so the highest speeds don&#8217;t register. A future version of the Bus Pirate should include a gigahertz prescaler for high frequency measurement.</p>
<blockquote><p>I2C&gt;{0xb0 0x3f} <strong>&lt;&#8211;write E2 register</strong></p></blockquote>
<p>Finally, we can write the E2 register (0x3f) to save these setting in the EEPROM. The DS1077 will now return to these settings at power-on.</p>
<p><strong>Conclusion</strong></p>
<p>The DS1077 simplifies complex clock sources by moving a programmable oscillator and frequency divider into a single chip. It isn&#8217;t available from distributors, but you can buy it directly from Maxim. If you need better control of high frequencies, check out the <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3491">DS1085</a> with 10kHz steps from 133MHz to 8kHz. The DS1085L is a 3.3volt, 66MHz version <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=DS1085LZ-25%2B-ND">available at Digikey</a>.</p>
<p><img class="alignnone size-full wp-image-6367" title="bread-450" src="http://hackadaycom.files.wordpress.com/2008/11/bread-450.jpg" alt="bread-450" width="450" height="405" /></p>
<br />Posted in misc hacks, parts  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/6359/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/6359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/6359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6359&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/11/28/parts-133mhz-162khz-programmable-oscillator-ds1077/feed/</wfw:commentRss>
		<slash:comments>18</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/cover.jpg" medium="image">
			<media:title type="html">cover</media:title>
		</media:content>

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

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

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