<?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; pcf8574</title>
	<atom:link href="http://hackaday.com/tag/pcf8574/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Fri, 10 Feb 2012 10:54:53 +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; pcf8574</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: 8bit IO Expander (PCF8574)</title>
		<link>http://hackaday.com/2008/12/27/parts-8bit-io-expander-pcf8574/</link>
		<comments>http://hackaday.com/2008/12/27/parts-8bit-io-expander-pcf8574/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 08:00:41 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[parts]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[io expander]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[pcf8574]]></category>
		<category><![CDATA[texas instruments]]></category>
		<category><![CDATA[ti]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=6784</guid>
		<description><![CDATA[Sometimes a project has more sensors, buttons, or LEDs than your microcontroller has pins. The PCF8574 is an easy way to add 8 low-speed input or output pins to a microcontroller. A configurable address lets multiple PCF8574s exist on the same bus, so two microcontroller pins can control dozens of IO pins. We&#8217;ll show you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6784&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-7250" title="pcf8574" src="http://hackadaycom.files.wordpress.com/2008/12/pcf8574.jpg" alt="pcf8574" width="450" height="299" /></p>
<p>Sometimes a project has more sensors, buttons, or LEDs than your microcontroller has pins. The <a href="http://focus.ti.com/docs/prod/folders/print/pcf8574.html">PCF8574</a> is an easy way to add 8 low-speed input or output pins to a microcontroller. A configurable address lets multiple PCF8574s exist on the same bus, so two microcontroller pins can control dozens of IO pins. We&#8217;ll show you how to use this chip below.</p>
<p><span id="more-6784"></span></p>
<p><img class="alignnone size-full wp-image-7242" title="pcf8574" src="http://hackadaycom.files.wordpress.com/2008/12/pcf8574.png" alt="pcf8574" width="452" height="279" /></p>
<p><strong><a href="http://focus.ti.com/docs/prod/folders/print/pcf8574.html">TI PCF8574</a> I2C 8bit IO expander (Mouser #<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=L5CvrNUdZirGmsfmc3baKQ%3d%3d">595-PCF8574N</a>, $1.86)</strong></p>
<p>We found PCB footprints for this chip in <em>i2c.lbr</em> and <em>micro-phillips.lbr</em> on the Cadsoft Eagle <a href="http://www.cadsoft.de/cgi-bin/download.pl?page=/home/cadsoft/html_public/download.htm.en&amp;dir=eagle/userfiles/libraries">library download page</a>. The PCF8574 is controlled with the 2 wire <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C protocol</a>, so 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 this chip. The same basic operations will apply to any microcontroller.</p>
<p>The schematic shows our simple test circuit for the PCF8574, here&#8217;s the <a href="http://www.ti.com/lit/gpn/pcf8574">datasheet</a> (PDF). We powered the chip with 5volts, and used a 0.1uF decoupling capacitor (C1) between the power and ground pins. R1  and R2 hold the I2C clock and data bus at 5volts. We&#8217;ll use an LED to test the chip&#8217;s output features; P0 is connected to LED1 through current limiting resistor R3 (330+ ohms). P6 and P7 are tied to known states so we can easily test the chip&#8217;s input capabilities.</p>
<p>The PCF8574&#8242;s I2C address is 0100xxxy, with three bits (x) determined by the state of the address pins A2-0, and a final bit (y) that sets the read (1) or write (0) mode. Many PFC8574s can share an I2C bus by using different address pin settings. Since we tied the address pins to ground, the write address is 01000000 (0&#215;40).</p>
<p><strong>Output</strong></p>
<p>The LED on P0 is controlled by writing a 1 (on) or 0 (off) to bit 0 of the byte following the write address.</p>
<blockquote><p>I2C&gt;{0&#215;40 0b00000001}<strong> &lt;&#8211;command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0&#215;40 GOT ACK: YES<strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;01 GOT ACK: YES<strong>&lt;&#8211;output value</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p><em>{</em> issues an I2C start condition, followed by the write address, 0&#215;40. The output value, 0b00000001, sets P0 high and the remaining bits low.  } sends the I2C bus stop condition, ending the transaction. When the corresponding bit is set high, the LED turns on.</p>
<p>To turn the LED off, repeat the sequence with the corresponding output bit set to 0.</p>
<blockquote><p>I2C&gt;{0&#215;40 0b00000000}<strong>&lt;&#8211;command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0&#215;40 GOT ACK: YES<strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<strong>&lt;&#8211;output value</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>With P0 now set to ground, the LED turns off.</p>
<p><strong>Input</strong></p>
<p>Pins set to output high can also be used as inputs (datasheet page 1).  In the example, P6 is held high (+5 volts) and P7 is held low (ground), but these could also be buttons, sensors, or other digital logic. The other pins are left floating and don&#8217;t represent valid data.</p>
<blockquote><p>I2C&gt;{0&#215;40 0b11000000}<strong>&lt;&#8211;command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0&#215;40 GOT ACK: YES<strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0xC0 GOT ACK: YES<strong>&lt;&#8211;output value</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>First, we set the desired input pins to output high by writing 1 to the corresponding bits in the output value. Bits 6 and 7 set P6 and P7 to output high.</p>
<p>Now, we can read the pin.  We did this operation with the Bus Pirate&#8217;s output set to binary mode so that the pin values are immediately obvious.</p>
<blockquote><p>I2C&gt;{0&#215;41 r}<strong>&lt;&#8211;command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0b01000001 GOT ACK: YES<strong>&lt;&#8211;address</strong><br />
230 I2C READ: 0b01000000<strong>&lt;&#8211;pin state</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>{ issues an I2C start condition, 0&#215;41 is the read address, and r reads one byte from the device. } sends the I2C bus stop condition, ending the transaction.</p>
<p>The reply, 01000000, represents the state of the input pins. The most significant bit is 0 because P7 is tied to ground. The next bit is 1 because P6 is held high The other bits (0) are garbage data.</p>
<p>This is far from the only IO expander IC. Have you used another chip?</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/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/6784/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/6784/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/6784/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=6784&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/12/27/parts-8bit-io-expander-pcf8574/feed/</wfw:commentRss>
		<slash:comments>26</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/pcf8574.jpg" medium="image">
			<media:title type="html">pcf8574</media:title>
		</media:content>

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