<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Micah&#039;s Bloggy Widget</title>
	<atom:link href="http://micah.navi.cx/feed/" rel="self" type="application/rss+xml" />
	<link>http://micah.navi.cx</link>
	<description></description>
	<lastBuildDate>Mon, 26 Jul 2010 05:34:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Propeller Bluetooth Stack Demo</title>
		<link>http://micah.navi.cx/2010/07/propeller-bluetooth-stack-demo/</link>
		<comments>http://micah.navi.cx/2010/07/propeller-bluetooth-stack-demo/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 04:29:35 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Propeller]]></category>
		<category><![CDATA[bit-banging]]></category>
		<category><![CDATA[propeller]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=1198</guid>
		<description><![CDATA[After going months without a lot of time for working on my hobby projects, I finally had a few free days to work on debugging my embedded Bluetooth stack for the Propeller. I got it working well enough to demo a Serial Port Profile device, implemented using only a Propeller Demo Board and a $2 [...]]]></description>
			<content:encoded><![CDATA[<p>After going months without a lot of time for working on my hobby projects, I finally had a few free days to work on debugging my <a href="http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/">embedded Bluetooth stack for the Propeller</a>. I got it working well enough to demo a Serial Port Profile device, implemented using only a Propeller Demo Board and a $2 USB Bluetooth dongle:</p>
<p><object width="570" height="452"><param name="movie" value="http://www.youtube.com/v/xlXfVVQT6KM&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xlXfVVQT6KM&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="570" height="452"></embed></object></p>
<p>(<a href="http://www.youtube.com/watch?v=xlXfVVQT6KM">Embedded video</a>)</p>
<ul>
<li><a href="http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/">Original blog post</a></li>
<li><a href="http://micah.navi.cx/2010/04/its-alive-bit-banging-full-speed-usb-host-for-the-propeller/">More about the bit-banging USB host</a></li>
<li><a href="http://forums.parallax.com/forums/default.aspx?f=25&amp;m=440787">Forum thread</a></li>
<li><a href="http://svn.navi.cx/misc/trunk/propeller/usb-host/">Source code</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/07/propeller-bluetooth-stack-demo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AVRFID 1.1 Firmware</title>
		<link>http://micah.navi.cx/2010/06/avrfid-1-1-firmware/</link>
		<comments>http://micah.navi.cx/2010/06/avrfid-1-1-firmware/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 08:02:23 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[RFID]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[firmware]]></category>
		<category><![CDATA[old-project]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=1192</guid>
		<description><![CDATA[I don&#8217;t normally write bloggy posts on every version of every source file I check in, but every so often an older project sees some more activity, and I love the opportunity to revisit software I wrote years ago. Sometimes I wonder why I wrote such-and-such thing that way and oh my god what an [...]]]></description>
			<content:encoded><![CDATA[<p><a class="flickr-image alignright" title="AVRFID Tag Prototype" href="http://www.flickr.com/photos/micahdowty/4702756196/"><img style="margin: 5px; border: 1px solid black;" src="http://farm5.static.flickr.com/4054/4702756196_34c1cc3d79_m.jpg" alt="AVRFID Tag Prototype" width="240" height="180" /></a>I don&#8217;t normally write bloggy posts on every version of every source file I check in, but every so often an older project sees some more activity, and I love the opportunity to revisit software I wrote years ago. Sometimes I wonder why I wrote such-and-such thing that way and oh my god what an ugly hack. But usually it&#8217;s just refreshing to think about a problem I haven&#8217;t thought about in a while.</p>
<p>The <a href="http://micah.navi.cx/2008/09/using-an-avr-as-an-rfid-tag/">AVRFID</a> was a quick but rather unique project, back from when I was on a bit of a 125 kHz RFID binge culminating in the design, construction, and installation of a proxcard reader for my garage door. While I was fidgeting around with such things, it occurred to me that you could (using a whole host of dirty tricks) convince a general-purpose 8-bit microcontroller like the AVR to function as a passive RFID tag.</p>
<p>Since then, I received a couple patches:</p>
<ul>
<li>Luke Koops improved the FSK modulation for HID tags, so that the resulting waveform is much more regular.</li>
<li>Cesar Fernandez described the HID card format in more detail, and implemented a parity calculation. The 45-bit code is actually composed of four distinct fields:
<ul>
<li>A 20-bit manufacturer code or header, constant for all HID cards.</li>
<li>An 8-bit site code, unique to the particular security installation.</li>
<li>A 16-bit unique ID. These are often printed in decimal on the back of the card, and they seem roughly sequential.</li>
<li>An odd parity bit, covering the other 44 bits.</li>
</ul>
</li>
</ul>
<p>I didn&#8217;t have my RFID gear handy, so Cesar was kind enough to verify it with his official HID reader. So I stamped a new version number on it. If you&#8217;re interested in building your own HID card emulator, there is now a much better chance it will actually work with your reader <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<ul>
<li>Grab the latest <a href="http://svn.navi.cx/misc/trunk/avrfid/">source code</a> from Subversion.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/06/avrfid-1-1-firmware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed Antenna Design 101</title>
		<link>http://micah.navi.cx/2010/04/failed-antenna-design-101/</link>
		<comments>http://micah.navi.cx/2010/04/failed-antenna-design-101/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 02:18:17 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[teardown]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=1016</guid>
		<description><![CDATA[I just got some more Bluetooth dongles in from DealExtreme. This one advertises extended range and EDR support, for $5. The package looks convincing enough, nevermind the engrish: So I cracked it open, naturally. (Hey, I was planning on using it for that crazy project.) And I was shocked to find this:]]></description>
			<content:encoded><![CDATA[<p>I just got some more Bluetooth dongles in from DealExtreme. <a href="http://www.dealextreme.com/details.dx/sku.7">This one</a> advertises extended range and EDR support, for $5. The package looks convincing enough, nevermind the engrish:</p>
<p style="text-align: left;"><a class="flickr-image aligncenter" title="Bluetooth Fail" href="http://www.flickr.com/photos/micahdowty/4544265707/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4030/4544265707_96871c513b.jpg" alt="Bluetooth Fail" width="375" height="500" /></a></p>
<p style="text-align: left;">So I cracked it open, naturally. (Hey, I was planning on using it for <a href="http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/">that crazy project</a>.) And I was shocked to find this:</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" style="text-decoration: none;" title="Bluetooth Fail" href="http://www.flickr.com/photos/micahdowty/4544268637/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4046/4544268637_6d9891256b.jpg" alt="Bluetooth Fail" width="500" height="375" /></a></p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="Bluetooth Fail" href="http://www.flickr.com/photos/micahdowty/4544268769/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4049/4544268769_5653e85aa1.jpg" alt="Bluetooth Fail" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/04/failed-antenna-design-101/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Embedded Bluetooth for $2</title>
		<link>http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/</link>
		<comments>http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 03:49:30 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Propeller]]></category>
		<category><![CDATA[Wireless Sensors]]></category>
		<category><![CDATA[bit-banging]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[propeller]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=1009</guid>
		<description><![CDATA[This is a continuation of my experiments in bit-banging full-speed USB on the Propeller. I have the basic host controller working reasonably well now, so I started trying to do something a bit more &#8220;useful&#8221; with it by implementing a simple Bluetooth stack on top of it. Bluetooth and USB are both quite complicated, and [...]]]></description>
			<content:encoded><![CDATA[<p>This is a continuation of my experiments in <a href="http://micah.navi.cx/2010/04/its-alive-bit-banging-full-speed-usb-host-for-the-propeller/">bit-banging full-speed USB on the Propeller</a>. I have the basic host controller working reasonably well now, so I started trying to do something a bit more &#8220;useful&#8221; with it by implementing a simple Bluetooth stack on top of it.</p>
<p>Bluetooth and USB are both quite complicated, and this project is implementing only tiny fractions of each specification. But I think it&#8217;s enough to show that the functionality you actually <em>need</em> in a simple embedded application isn&#8217;t that complex- and a lot of the cheap consumer electronics you can get nowadays might actually be more hobbyist-accessable than they appear.</p>
<p><a href="http://hannoware.com/">Hanno</a> on the <a href="http://forums.parallax.com/forums/default.aspx?f=25&amp;m=440787">forums</a> found some great <a href="http://www.dealextreme.com/details.dx/sku.11866">$2 Bluetooth dongles</a> on DealExtreme. So I just had to order a few of these and try them out with my work-in-progress software stack. The result:</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="Propeller USB Bluetooth Test 1" href="http://www.flickr.com/photos/micahdowty/4536394355/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4065/4536394355_8c3004717d.jpg" alt="Propeller USB Bluetooth Test 1" width="500" height="375" /></a></p>
<p style="text-align: left;">That&#8217;s a Propeller demo board, the $2 dongle (stripped down and attached to a 4-pin header, for convenience) and no other components. The demo here is just scanning for nearby devices, but I also have some basic L2CAP support and I&#8217;m working on the SDP server. Currently the stack uses 4 cogs (3 for USB, 1 for Bluetooth) and 12 kB of RAM, but I&#8217;m hoping to optimize it.</p>
<p style="text-align: left;">(Of course, this is only possible because the Bluetooth dongle itself has significantly more RAM and ROM than the Propeller has. Oh, the economies of scale!)</p>
<p style="text-align: left;">The software is very much a work-in-progress, but <a href="http://svn.navi.cx/misc/trunk/propeller/usb-host/">you can find it in the Subversion repository</a>, with an MIT-style license.</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/04/embedded-bluetooth-for-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>It&#8217;s Alive: Bit-banging full-speed USB Host for the Propeller</title>
		<link>http://micah.navi.cx/2010/04/its-alive-bit-banging-full-speed-usb-host-for-the-propeller/</link>
		<comments>http://micah.navi.cx/2010/04/its-alive-bit-banging-full-speed-usb-host-for-the-propeller/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 04:37:00 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Propeller]]></category>
		<category><![CDATA[bit-banging]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=1006</guid>
		<description><![CDATA[I&#8217;d like to make a more detailed post about this once the project is a bit further along&#8230; but for now just a brief description and a couple teaser photos This is one of those things that people have said was impossible, and I&#8217;ve wanted to try it for a while. I finally found an [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to make a more detailed post about this once the project is a bit further along&#8230; but for now just a brief description and a couple teaser photos <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is one of those things that people have said was impossible, and I&#8217;ve wanted to try it for a while. I finally found an excuse. I wanted a way to build more cheap wireless networked devices. You can get <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=582">bluetooth</a> and <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9290">wifi</a> adapters that are microcontroller-friendly, but it&#8217;s a niche market so you&#8217;ll pay a lot. I wanted a way to use the $2 bluetooth dongles and $10 wifi adapters you can easily find online or at your local electronics shop. But these devices are all USB, and USB host controllers aren&#8217;t yet common on small hobbyist-friendly microcontrollers like the <a href="http://www.arduino.cc/">Arduino</a> and <a href="http://www.parallax.com/tabid/407/Default.aspx">Propeller</a>. So, I decided I&#8217;d see if it was possible to implement a USB host controller entirely in software on the Parallax Propeller microcontroller.</p>
<p>Turns out that it is. This still needs more development before it&#8217;s generally useful, but it&#8217;s already showing potential. Of course there&#8217;s a long list of caveats on something that pushes the limits of both the Propeller and the USB spec, but none of them should be deal-breakers for most applications.</p>
<p>If you&#8217;re interested in helping with or following the project&#8217;s development, there&#8217;s <a href="http://forums.parallax.com/forums/default.aspx?f=25&amp;m=440787">a thread on the Parallax forums</a>. The latest source code is in my <a href="http://svn.navi.cx/misc/trunk/propeller/usb-host/">usb-host Subversion repo</a>.</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="IMG_1131" href="http://www.flickr.com/photos/micahdowty/4483469646/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4034/4483469646_e705b874e4.jpg" alt="IMG_1131" width="500" height="375" /></a></p>
<p style="text-align: center;"><a title="Screen shot 2010-04-01 at 9.24.40 PM by Micah Dowty, on Flickr" href="http://www.flickr.com/photos/micahdowty/4483478772/"><img class="aligncenter" src="http://farm3.static.flickr.com/2790/4483478772_0f23df2088_o.png" alt="Screen shot 2010-04-01 at 9.24.40 PM" width="539" height="552" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/04/its-alive-bit-banging-full-speed-usb-host-for-the-propeller/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Baking success</title>
		<link>http://micah.navi.cx/2010/02/baking-success/</link>
		<comments>http://micah.navi.cx/2010/02/baking-success/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 23:22:09 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Food]]></category>
		<category><![CDATA[baking]]></category>
		<category><![CDATA[bread]]></category>
		<category><![CDATA[cookies]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=998</guid>
		<description><![CDATA[My boyfriend&#8217;s dad and I made some delicious french bread, and some dangerously tasty white chocolate and milk chocolate cookies!]]></description>
			<content:encoded><![CDATA[<p>My boyfriend&#8217;s dad and I made some delicious french bread, and some dangerously tasty white chocolate and milk chocolate cookies!</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="French bread and cookies" href="http://www.flickr.com/photos/micahdowty/4357044299/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4072/4357044299_f80638d7ae.jpg" alt="French bread and cookies" width="500" height="375" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/02/baking-success/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More laser projector photos</title>
		<link>http://micah.navi.cx/2010/02/more-laser-projector-photos/</link>
		<comments>http://micah.navi.cx/2010/02/more-laser-projector-photos/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 09:31:51 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Laser Projector]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[scott]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=996</guid>
		<description><![CDATA[I brought my old hard disk laser projector to work today, since it was the most interesting portable project I had to show off to some friends and new acquaintances at a geek get-together. Scott being himself, he naturally always has a fantastic camera with him. So we got some better pictures of its output:]]></description>
			<content:encoded><![CDATA[<p>I brought <a href="http://micah.navi.cx/2008/07/hard-disk-laser-scanner-at-ilda-4k/">my old hard disk laser projector</a> to work today, since it was the most interesting portable project I had to show off to some friends and new acquaintances at a geek get-together. <a href="http://numist.net/">Scott</a> being himself, he naturally always has a fantastic camera with him. So we got some <a href="http://www.flickr.com/photos/numist/sets/72157623356009586/detail/">better pictures</a> of its output:</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/numist/sets/72157623356009586/detail/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4047/4331540657_3e3702776e.jpg" alt="" width="500" height="333" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/02/more-laser-projector-photos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple Optical Microphone/Pickup</title>
		<link>http://micah.navi.cx/2010/02/simple-optical-microphonepickup/</link>
		<comments>http://micah.navi.cx/2010/02/simple-optical-microphonepickup/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 10:31:07 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Random Hacks]]></category>
		<category><![CDATA[analog]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[mini-project]]></category>
		<category><![CDATA[optics]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=979</guid>
		<description><![CDATA[This is another mini-project that began, like so many have, in a discussion with Scott over some beer. We wanted to build a new kind of speaker amplifier, which used mechanical closed-loop feedback to position the speaker cone exactly where the audio signal says it should be. We figured that, if done right, this could [...]]]></description>
			<content:encoded><![CDATA[<p>This is another mini-project that began, like so many have, in a discussion with <a href="http://numist.net/">Scott</a> over some beer. We wanted to build a new kind of speaker amplifier, which used mechanical closed-loop feedback to position the speaker cone exactly where the audio signal says it should be. We figured that, if done right, this could yield higher audio quality from cheaper speakers.</p>
<p>So, that idea is pretty crazy, but it seemed just <em>barely</em> plausible enough that I had been thinking about the component parts of such an amplifier. The most important seemed to be a sensor that could accurately supply feedback on the speaker cone position without loading the speaker or distorting the cone. The first method we considered was a capacitive pickup. Paint the back of the speaker cone with conductive paint, then position two copper plates behind the cone, just barely not touching when the speaker is at its maximum throw. This acts like two capacitors in series, and gives you a capacitance that varies along with the audio frequency, without any mechanical connection to the speaker cone.</p>
<p>We also considered magnetic feedback, using something like an <a href="http://en.wikipedia.org/wiki/LVDT">LVDT</a>, but where one coil is the voice coil itself. This would involve modulating some kind of high-frequency carrier into the speaker drive signal, then placing another fixed coil around or behind the voice coil to pick up that signal.</p>
<p>The next method, and I guess the simplest, is optical. This would work a lot like a <a href="http://en.wikipedia.org/wiki/Microphone#Fiber_optic_microphone">fiber optic microphone</a> or an <a href="http://www.lightwave-systems.com/">optical guitar pickup</a>. You can measure vibration by detecting changes in light intensity caused by changes in distance or angle of some reflective thing that&#8217;s vibrating.</p>
<p>Whereas the capacitive and LVDT ideas require a high-frequency modulated signal, that&#8217;s optional with the optical method. You can measure absolute intensity, or you can modulate your LED with a high-frequency carrier that can be detected on the receiving end. This modulation can help reject ambient light (including hum from fluorescent lights) but it isn&#8217;t required.</p>
<p>So, to see if this project has even a tiny chance of working, I thought I&#8217;d prototype the optical sensor by building an optical microphone. The end results were rather mediocre. I&#8217;m posting it here only because:</p>
<ul>
<li>I was honestly surprised that it worked at all</li>
<li>It could be useful for other applications, like a drum or bass guitar pickup</li>
<li>Maybe one of my readers has hints on making it more sensitive and lower noise? <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<h1>The Circuit</h1>
<p>This is a really simple back-of-the-envelope sort of transimpedance amplifier, high-pass filter, and gain stage. Disclaimer: I hate doing math for analog circuits when it&#8217;s just a quick hobby project, so I did no math in designing this. Take it with a few shakes of salt. My breadboard was humming pretty badly due to incoming EMI, so I built it dead-bug style in a mini Altoids tin. If you build this, definitely use a suitable amount of shielding.</p>
<ul>
<li>Power supply range is about 3-6v, but it seems to work best at 5-6v. (If you listen to the op-amp data sheet, max voltage is 5.5v.)</li>
<li>The op-amp should be a low-offset, rail-to-rail, high-bandwidth type. I used the OPA2350 because that&#8217;s what I had handy.</li>
<li>The IR LED I used is pretty generic. I&#8217;m operating it at fairly high current, because I wanted a strong light source. You might consider using multiple LEDs, though, to make it easier to position the pickup properly.</li>
<li>The photodiode should be a PIN diode with an IR filter. I used an SFH229.</li>
<li>Keep the leads short, especially power and photodiode.</li>
<li>They aren&#8217;t on the schematic, but remember some decoupling capacitors. (I used 0.1uF and 22uF)</li>
<li>I put a bit of black heat shrink tubing around the photodiode as a baffle. This seemed to help.</li>
<li>I used a stereo 1/8&#8243; audio jack for ground, audio out, and power in. It would be neat to build one with a built-in battery, but this tin was a bit small for that, and the IR LED is kind of power hungry.</li>
<li>Make sure to ground the Altoids tin! These smaller tins are harder to solder to than the larger tins, but it can be done. Just use a hot setting if your iron has adjustable temperature, and be patient.</li>
</ul>
<p style="text-align: center;"><a class="flickr-image alignnone" title="opticalmic-schematic" href="http://www.flickr.com/photos/micahdowty/4327610082/"><img class="aligncenter" style="border: 1px solid #ccc;" src="http://farm5.static.flickr.com/4061/4327610082_67fe862d28.jpg" alt="opticalmic-schematic" width="500" height="268" /></a></p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="IMG_1081" href="http://www.flickr.com/photos/micahdowty/4326877601/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4034/4326877601_07dd265674.jpg" alt="IMG_1081" width="500" height="375" /></a></p>
<h1>Rubber Band Pickup</h1>
<p>The first successful test I had of this pickup was with a rubber band. I&#8217;d like to try this with a guitar string, but I don&#8217;t play <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s actually pretty forgiving about the positioning of the pickup relative to the rubber band, and it&#8217;s very sensitive even when the rubber band is a few inches away. This circuit can pick up very low-frequency vibrations well, so you hear very deep bass notes that you don&#8217;t normally notice in a rubber band pluck.</p>
<ul>
<li><a href="http://micah.navi.cx/wp-content/uploads/2010/02/opticalmic-rubberband-test.mp3">Optical Microphone: Rubber band test (MP3)</a></li>
</ul>
<p style="text-align: center;"><a class="flickr-image alignnone" title="IMG_1085" href="http://www.flickr.com/photos/micahdowty/4326877691/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4057/4326877691_a2708d7b69.jpg" alt="IMG_1085" width="500" height="375" /></a></p>
<h1>Speaker Surface Pickup</h1>
<p>This is the application I originally hoped the optical microphone would work for: picking up sound off the front or back surface of a loudspeaker cone. If I could do this really well, the closed-loop amplifier might have a chance. The results certainly weren&#8217;t hi-fi, but I guess I was still surprised it worked at all.</p>
<p>Unlike the rubber band, this test was extremely finicky. I had to position the pickup just right, and I used some Kapton tape to make the surface of the speaker more reflective to IR light. I also had trouble getting a good reflection off the curved surface of the cone, so I stretched a flat section of tape between the center dome and the middle of the cone. This gave good signal strength, but the tape itself also acted as a mechanical filter, giving kind of an odd frequency response to the whole system.</p>
<ul>
<li><a href="http://micah.navi.cx/wp-content/uploads/2010/02/opticalmic-music-test.mp3">Optical Microphone: Music test (MP3)</a></li>
</ul>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="IMG_1078" href="http://www.flickr.com/photos/micahdowty/4327609816/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm3.static.flickr.com/2677/4327609816_73fbedb681.jpg" alt="IMG_1078" width="500" height="375" /></a></p>
<h1>And that is all.</h1>
<p>Hopefully this will allow me to have some closure on a completely mediocre mini-project that was nonetheless interesting enough that I couldn&#8217;t just forget about it without sharing. <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If anyone reading is a <em>real</em> electrical engineer, I&#8217;d be interested in hearing about what I did wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/02/simple-optical-microphonepickup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hacking a Digital Bathroom Scale</title>
		<link>http://micah.navi.cx/2010/01/hacking-a-digital-bathroom-scale/</link>
		<comments>http://micah.navi.cx/2010/01/hacking-a-digital-bathroom-scale/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 23:05:41 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Random Hacks]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[input devices]]></category>
		<category><![CDATA[propeller]]></category>
		<category><![CDATA[scale]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=971</guid>
		<description><![CDATA[People all around the internet have been doing cool things with the Wii peripherals lately, including the Wii Fit balance board. Things like controlling robots or playing World of Warcraft. But what if you just want one weight sensor, not four? The balance board starts to look kind of pricey, and who wants to deal [...]]]></description>
			<content:encoded><![CDATA[<p>People all around the internet have been doing cool things with the Wii peripherals lately, including the Wii Fit balance board. Things like <a href="http://someoneknows.wordpress.com/2009/01/12/arduino-powered-robotic-labyrinth-game/">controlling robots</a> or <a href="http://hackaday.com/2008/06/13/wii-fit-world-of-warcraft/">playing World of Warcraft</a>.</p>
<p>But what if you just want one weight sensor, not four? The balance board starts to look kind of pricey, and who wants to deal with Bluetooth if you don&#8217;t have to?</p>
<p>I&#8217;ve had a couple ideas for problems that could be solved by a cheap interface to the weight sensor in a common digital bathroom scale. The kind you can get for $15 or so at the local big-box store. For example, I&#8217;ve pondered using a grid of bathroom scales as an input device. You could use it to emulate a DDR pad, and there might be new applications that could benefit from analog weight readouts on each square of the pad.</p>
<p>The other idea is really <a href="http://numist.net/">Scott</a>&#8216;s doing. He has a <a href="http://en.wikipedia.org/wiki/Kegerator">kegerator</a>, and naturally we&#8217;ve been plotting to fill it full of all manner of sensors, actuators, and <a href="http://micah.navi.cx/2008/08/simplest-rfid-reader/">RFID readers</a>. We&#8217;d like to have a continuous measurement of the keg&#8217;s weight, both to have some advance warning that it&#8217;s getting low, and to detect when an individual glass of beer has been dispensed. It seemed like if we could use the sensor from a digital bathroom scale, the filtered output would probably be accurate enough to detect the difference in weight from just one beer.</p>
<p>I&#8217;ve seen other projects to hack a digital scale. For example, this <a href="http://code.google.com/p/casainho-projects/wiki/SdCardBathroomScale">SD Card Bathroom Scale</a> project uses a microcontroller to &#8216;read&#8217; the LCD by decoding the signals used to drive it. This was a great idea, and he pulled it off quite well. But it requires a lot of wiring, and you&#8217;re still limited to the resolution and functionality of the original scale. I wanted to see if there was a simpler and lower-level way to hack a typical bathroom scale. And, for my particular scale at least, there is.</p>
<h1>How a digital scale works</h1>
<p>Old-skool analog scales (you know, with the needle that <em>moved</em>) were based on some clever gears and levers that converted pressure on the scale into compression of a big spring, then the spring&#8217;s compression into rotational motion that could drive a dial. But digital scales don&#8217;t really have any moving parts. They are mechanically designed to distribute your weight evenly to a bar or collection of bars which bend very very slightly under the pressure. Those bars are bonded to an electrical element that also flexes very very slightly, changing its electrical resistance. This is a <a href="http://en.wikipedia.org/wiki/Strain_gauge">strain gauge</a>.</p>
<p>Inside the scale I hacked, you can see the two load-bearing bars. Each bar has two strain gauge sensors bonded to it. Measuring the difference in strain between the two sensors can tell you how much the bar is flexing.</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Inside the modified scale" href="http://www.flickr.com/photos/micahdowty/4317059038/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4062/4317059038_0be240bab2.jpg" alt="Inside the modified scale" width="500" height="375" /></a></p>
<p style="text-align: left;">There are a lot of notable parts here:</p>
<ul>
<li>There are two buttons mounted on the scale&#8217;s feet. These are connected in parallel. If either one is pressed, the scale will power on.</li>
<li>The vertical bars on the left and right are load cells, the mechanical parts that are designed to bend slightly. Each one has a tiny PCB with two strain gauge sensors. The two sensors share one common wire, so there are three wires going to each load cell.</li>
<li>The clip in the bottom-center originally held a lithium coin cell battery.</li>
</ul>
<p>And on the main PCB:</p>
<ul>
<li>A numeric LCD module, bonded to the PCB.</li>
<li>A microcontroller or ASIC of unknown variety. This is the digital chip that runs the scale- it&#8217;s a chip-on-board module which is soldered to the back of the main PCB.</li>
<li>Analog front-end. This consists of an <a href="http://www.national.com/ds/LM/LMV321.pdf">LMV321</a> quad op-amp, a few transistors, and a heaping spoonful of passives. This amplifies and conditions the signal from the strain gauge sensors. I&#8217;ll talk about this more below.</li>
<li>Power switching. The analog front-end is very low-power, but to preserve battery life even more, the microcontroller uses a transistor to turn it off entirely when the scale is sleeping.</li>
<li>Hidden features! There&#8217;s a &#8220;CAL&#8221; header. If you short this header, wake up the scale, then un-short it, the scale will go into a factory calibration mode. The LCD displays some kind of raw reading in this mode, and it continuously updates.</li>
</ul>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Unmodified PCB" href="http://www.flickr.com/photos/micahdowty/4316324631/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4007/4316324631_a0da8de469.jpg" alt="Unmodified PCB" width="500" height="375" /></a></p>
<p style="text-align: left;">This is the only scale I&#8217;ve disassembled, so your mileage may vary. If your scale puts everything on a single IC, there may not be a way to hack it without building your own analog front-end. But if you get lucky (older scales may be more likely to use discrete parts) you may see something like this in the scale you disassemble. The separation of functionality into discrete analog and digital circuits makes this model of scale quite fun and easy to hack!</p>
<h1>Reverse Engineering</h1>
<p style="text-align: left;">This section will explain the process I used to figure out how this scale works. You might be able to use some of the same procedures on other types of digital scales.</p>
<ul>
<li>Visual inspection: Noticed the op-amp chip, arrangement of the passives, how the strain gauges were connected, power switching.</li>
<li>Looked up a data sheet for the op-amp chip. Noted the power and output pins.</li>
<li>Used an oscilloscope to probe each of the four op-amp outputs, looking for a signal that seemed plausible for a microcontroller to measure. This would have to be either a fairly high-amplitude DC analog voltage, or some kind of variable-frequency signal.</li>
<li>Found this signal. Output D on pin 14 had three different kinds of waveforms: low when the scale is off, high when the scale is on but not actively measuring weight (microcontroller is doing calculations or updating the LCD?). When weighing, this pin is a pulse train whose duty cycle seems proportional to weight.</li>
<li>Traced this signal back to a pin on the microcontroller.</li>
<li>At this point, it might have been sufficient to interface to the scale by snooping this signal. But the pulse train is not present all of the time, so I&#8217;d have to have extra code to ignore the idle periods. And you&#8217;d have to simulate button presses to keep the scale awake. So, I wanted to figure out how to keep the scale in measurement mode all the time.</li>
<li>First step: Keep the analog front-end powered on. I traced the V+ pin on the op-amp back to a transistor that the microcontroller uses to power on all analog circuitry. I soldered a shorting jumper across this transistor.</li>
<li>Now when the microcontroller is off, the op-amp output is high rather than low. This means there must be some other signal that the microcontroller is outputting in order to put the analog frontend into measurement mode, or otherwise generate that pulse train.</li>
<li>Probed around the microcontroller with my oscilloscope, looking for interesting signals on the pins nearby where the op-amp signal enters.</li>
<li>Found another pulse train which was active only when the scale was in weighing mode. This signal seemed to be at the same frequency as the op-amp output signal. This one is normally low, but has brief high pulses.</li>
<li>At this point, I thought I had enough information to guess how the circuit worked. Traced where this signal goes, to verify. It is an output from the microcontroller which heads to a transistor in the analog front-end. I didn&#8217;t fully reverse engineer this, but I suspect it&#8217;s discharging a capacitor that&#8217;s used for integrating the analog weight signal.</li>
<li>Made the modifications discribed below, and hooked the analog front-end input and output up to a Propeller microcontroller. Verified my guesses by performing some experiments with the microcontroller.</li>
</ul>
<h1>Analog Front-end</h1>
<p>This documents my understanding of how the analog front-end works in this digital scale. I didn&#8217;t reverse engineer the circuit itself, so this is really just a &#8220;black box&#8221; description based on observing how the circuit behaves.</p>
<p>The circuit&#8217;s input is a tiny resistance from four strain gauges. They are arranged as two independent load cells, each with two sensors that act as a differential pair. The front-end amplifies these tiny differences in resistance, and sums them into a single analog signal. For example, if the strain gauges were labeled L1, L2, R1, and R2 (two sensors each for left and right load cells), the analog summation would be:</p>
<blockquote><p>Total = L1 &#8211; L2 + R1 &#8211; R2</p></blockquote>
<p>This total is still an analog signal, and it&#8217;s fairly noisy. There would be a lot of different ways to convert this to a digital signal: a standard successive-approximation A/D converter, a voltage to frequency converter, an RC oscillator&#8230; This scale uses an approach that&#8217;s simple, cheap, and pretty accurate for situations where you&#8217;d like to dynamically make tradeoffs between sample rate and accuracy. It uses an integrator and comparator.</p>
<p>In this approach, there is a capacitor which can charge or discharge depending on the state of a signal from the microcontroller. I&#8217;ve been calling this the &#8220;Reset&#8221; signal. When Reset is low, the capacitor slowly charges at a rate which depends on the analog Total above. This is an analog integrator. When Reset is high, the capacitor discharges quickly. This voltage across the capacitor is fed to a comparator, where it&#8217;s compared to a reference threshold. If it&#8217;s larger than this threshold, you get a logic &#8220;1&#8243; out, if it&#8217;s smaller you get a logic &#8220;0&#8243;.</p>
<p>This starts to look a lot like a closed-loop feedback system. In fact, you can even think of it as an electronic equivalent to the old mechanical balance. Instead of balancing two physical weights on a lever, you&#8217;re balancing two electric currents which are trying to charge or discharge the integration capacitor. If the capacitor voltage is too high, you need to drain it a bit. If it&#8217;s too low, you need to let if fill up. If you keep the capacitor voltage oscillating right around the comparator threshold, it&#8217;s just like you&#8217;ve balanced a mechanical scale. Now you know how heavy the object you&#8217;re weighing is, because you know how much time you need to spend discharging the capacitor to keep it balanced.</p>
<p>I find this symmetry between the mechanical and electrical scale pretty elegant. It&#8217;s also practical- your accuracy is limited by electrical or mechanical noise in the circuit, and by your microcontroller&#8217;s timing resolution. But you can always integrate over longer periods of time in order to trade sample rate for accuracy. If you keep the capacitor balanced for a whole second, and add up how much time you spent discharging the capacitor over that second, you&#8217;ve just calculated the average weight with much more precision than you&#8217;d have if you measured the length of a single discharge pulse.</p>
<h1>Modding the Scale</h1>
<p>After figuring out the analog front-end, I really just wanted a way to use that by itself without worrying about the built-in microcontroller or LCD. This turned out to be really easy:</p>
<ul>
<li>Remove the lithium battery and holder</li>
<li>Solder a jumper wire across the transistor that normally powers off the analog front-end. (This is visible in the photo below, near the red and black power wires.)</li>
<li>Cut three traces near the microcontroller: Reset signal out, comparator signal in, and button signal in. This separates the microcontroller from the analog circuitry, and it also prevents the microcontroller from waking up. It will stay turned off.</li>
<li>Solder a 5-pin ribbon cable to the board: Ground, Power (+3v), Buttons (optional), Reset out, Comparator in.</li>
</ul>
<p>The wires on the left are power and ground. It&#8217;s hard to see here, but the traces corresponding to the three wires on the right were cut, between the wires and the chip-on-board assembly. From top to bottom, those wires are comparator, button, and reset. And that&#8217;s it! With that simple mod, the scale is ready to connect directly to any 3.3v microcontroller with two free I/O pins. I used a Propeller, but an AVR should work great for this too. If you&#8217;re using a 5V microcontroller, you&#8217;ll still want a 3v or 3.3v power supply for the scale. You may also want to limit the voltage on the reset output signal too, though I suspect this isn&#8217;t actually necessary.</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Modified PCB" href="http://www.flickr.com/photos/micahdowty/4316321043/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4011/4316321043_90e94865ea.jpg" alt="Modified PCB" width="500" height="375" /></a></p>
<h1>Software</h1>
<p>I tested this mod using a <a href="http://elmicro.com/en/proprpm.html">PropRPM</a> board and some jumper wires. All of the other stuff on the PropRPM board is unrelated to this project- no external components are necessary to talk to the scale, just two 3.3v I/O pins.</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="Testing the modified scale" href="http://www.flickr.com/photos/micahdowty/4317056668/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm3.static.flickr.com/2706/4317056668_d5bbc86544.jpg" alt="Testing the modified scale" width="500" height="375" /></a></p>
<p style="text-align: left;">The software is pretty simple. To measure weight, you need to toggle the &#8220;Reset&#8221; output on and off in order to keep the integration capacitor balanced around a comparator threshold. Pulling Reset high will quickly drain the capacitor, pulling it low lets the capacitor charge at a rate which depends on the total weight on the scale. You can take more accurate measurements by repeating this for more cycles, or take quicker measurements by repeating it for fewer cycles. On the Propeller, I use the system clock to measure the total amount of time that I spend letting the capacitor charge. Here&#8217;s a complete program that prints scale measurements to the serial port:</p>
<pre>CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  PIN_SCALE_OUTPUT = 3    ' Pulse high to discharge
  PIN_SCALE_INPUT = 4     ' Output from integrator

OBJ
  term : "Parallax Serial Terminal"

PUB main
  term.start(115200)
  repeat
    term.Str(String(term#NL))
    term.Dec(measure_raw(500))

PRI measure_raw(period) : raw_weight | timeref
  raw_weight := 0
  repeat period

    ' Reset, and wait for input to go high. This is its idle state.
    OUTA[PIN_SCALE_OUTPUT]~
    DIRA[PIN_SCALE_OUTPUT]~~
    waitpne(0, constant(|&lt; PIN_SCALE_INPUT), INA)

    ' Turn off the 'reset' output. This starts integrating
    ' the pressure. When the analog integrator reaches a threshold,
    ' our input pin goes high. Time this.
    timeref := cnt
    OUTA[PIN_SCALE_OUTPUT]~~
    waitpeq(0, constant(|&lt; PIN_SCALE_INPUT), INA)
    raw_weight += cnt - timeref</pre>
<p>And that&#8217;s all it takes! I&#8217;m looking forward to trying this with a larger grid of scales. A powerful microcontroller like the Propeller should be able to simultaneously sample and filter measurements from several scales. This proof-of-concept looks pretty promising for the kegerator project, too. With an integration time of a second or so, it can easily measure weight accurately enough to count glasses of beer <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>P.S.  I&#8217;m pretty sure I just spent more time writing this blog entry than I spent on the hack itself. How silly is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/01/hacking-a-digital-bathroom-scale/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>DIY Sewing Machine Retrofit</title>
		<link>http://micah.navi.cx/2010/01/diy-sewing-machine-retrofit/</link>
		<comments>http://micah.navi.cx/2010/01/diy-sewing-machine-retrofit/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 08:45:22 +0000</pubDate>
		<dc:creator>Beth</dc:creator>
				<category><![CDATA[Arts & Crafts]]></category>
		<category><![CDATA[Propeller]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[motors]]></category>
		<category><![CDATA[propeller]]></category>
		<category><![CDATA[retrofit]]></category>
		<category><![CDATA[sewing]]></category>

		<guid isPermaLink="false">http://micah.navi.cx/?p=934</guid>
		<description><![CDATA[The story behind this project is a bit overcomplicated. That&#8217;s all below, if you&#8217;re interested. I made a video to explain the final product: Back Story This all started when I bought a sewing machine for making fabric RFID tags a little over a year ago, and started using it to make cute plushy objects. [...]]]></description>
			<content:encoded><![CDATA[<p>The story behind this project is a bit overcomplicated. That&#8217;s all below, if you&#8217;re interested. I made <a href="http://www.youtube.com/watch?v=C7bGt_BZk7Y">a video</a> to explain the final product:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="570" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/C7bGt_BZk7Y&amp;hl=en_US&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="570" height="345" src="http://www.youtube-nocookie.com/v/C7bGt_BZk7Y&amp;hl=en_US&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2>Back Story</h2>
<p>This all started when I <a href="http://micah.navi.cx/2008/10/long-winding-descent-into-plushy-cuddliness/">bought a sewing machine for making fabric RFID tags</a> a little over a year ago, and started using it to make cute plushy objects. Well, as much as I like making plushy objects, I haven&#8217;t actually made <a href="http://www.flickr.com/photos/micahdowty/sets/72157608324093591/">very many of them</a> since buying the machine. So, my boyfriend has been guilting me into making him a few as gifts for Christmas, birthday, valentine&#8217;s day. Naturally, being the great partner I am, this gets me thinking about ways to soup up my sewing machine first <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The original machine did bug me in many ways when working on fine detail work. I&#8217;m lazy and uncoordinated with a needle, so I tend to sew almost everything by machine, even when the individual stitches all have to be lined up just right. In fact, when sewing the face parts on my meat and crab plushies, I found myself sewing individual stitches by turning the flywheel by hand.</p>
<p>I don&#8217;t know whether more expensive sewing machines are any better, but on my cheap <a href="http://www.amazon.com/Singer-R-Inspiration-4210/dp/B000PVDSO4">Singer Inspiration 4210</a> the stock motor is nearly unusable at slow speeds. It stalls easily, makes an awful buzzing noise, maintains an uneven speed, and delivers very little torque.</p>
<h2>Sensors</h2>
<p>My first experiments were to instrument the sewing machine with sensors that I could use to estimate the speed and angle of the main shaft.  I needed some kind of absolute angle reference, plus some way of counting how far the shaft has traveled. For the angle reference, I found a really handy place to mount a photo-interrupter sensor. This cam is part of the mechanism that advances the machine&#8217;s feed dogs. It conveniently moves this metal bar back and forth once per revolution of the shaft.</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="Photo-interrupter mounted" href="http://www.flickr.com/photos/micahdowty/4277776529/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4033/4277776529_4426e83b53.jpg" alt="Photo-interrupter mounted" width="500" height="375" /></a></p>
<p style="text-align: left;">For sensing the shaft speed accurately, my preferred solution would have been a high-resolution <a href="http://en.wikipedia.org/wiki/Rotary_encoder">encoder wheel</a> attached to the motor or the main shaft. But that would, at the very least, involve making a rotary encoder disc and attaching it somehow to one of the sewing machine&#8217;s moving parts. I wanted to avoid messing with the machine&#8217;s moving parts as much as possible, so I looked for non-contact solutions. I noticed that, with a little signal conditioning, an IR reflection sensor works pretty well for counting teeth on the machine&#8217;s drive belt. After switching motors, I modified this to sense teeth on the motor&#8217;s sprocket instead, but the same signal conditioning circuit works in either case. The signal conditioner is an dual op-amp configured as an amplifier, bandpass filter, and comparator with hysteresis.</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Optical tachometer" href="http://www.flickr.com/photos/micahdowty/4244262162/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm3.static.flickr.com/2754/4244262162_772918c86c.jpg" alt="Optical tachometer" width="500" height="375" /></a></p>
<p>Lastly, there&#8217;s the most important sensor: the foot pedal! I wanted to keep the original foot pedal feel, but use it as a generic input device for the microcontroller. So, I removed all electronic parts other than the variable resistor itself, and connected that to a 1/8&#8243; jack. With a little modification, the jack fit into the same hole that was originally used for the mains cord.</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Pedal after modification" href="http://www.flickr.com/photos/micahdowty/4278524232/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4060/4278524232_e9eafde946.jpg" alt="Pedal after modification" width="500" height="375" /></a></p>
<h2>Induction Motors Suck</h2>
<p>This is where the project got a bit out of hand and I started making wrong turns. At first, I was hoping it would be possible to implement smooth closed-loop control by using the original motor and a simple <a href="http://en.wikipedia.org/wiki/TRIAC">triac</a>-based speed controller for the motor. This seemed straightforward enough. But I didn&#8217;t have all of the parts on hand to do a normal optotriac + triac based driver circuit. So I went shopping at <a href="http://www.halted.com/">HSC</a>. No optotriac, but there were some solid state relays. Alas, after I got them home and looked up the data sheets, it turns out they are the zero-crossing switching variety. Useless for speed control. So, back to the drawing board. No optotriacs on hand. Well, I could move the opto-isolation, putting the microcontroller on a line-powered circuit, and opto-isolating the serial port instead. But that sounded really annoying to debug safely, especially for me without an isolation transformer or variac. But that would require a low-voltage power supply on the mains  side of the optoisolator anyway, and if I had to go to that trouble I might as well just use a transistor to switch on the triac&#8230;</p>
<p>So I started rummaging through my junk bins again, and I found an old X10 lamp module. This must have a triac in it, I thought. It won&#8217;t have an optoisolator, since X10&#8242;s cheap circuits never bother with mains isolation. But it might have a power supply and zero-crossing circuit I could use. So I find a handy <a href="http://www.nysaes.cornell.edu/cc/staff/pool/homeauto/lm465.html">LM465 schematic</a> online, and I start paring down the circuit into just a bare-bones triac driver, zero crossing detector, and +15V power supply. I got pretty far along on this triac-based speed controller before I switched tactics:</p>
<p style="text-align: center;"><a class="flickr-image alignnone" title="Old triac-based controller (closeup)" href="http://www.flickr.com/photos/micahdowty/4291955885/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4005/4291955885_92c3820102.jpg" alt="Old triac-based controller (closeup)" width="500" height="375" /></a></p>
<p style="text-align: left;">I was experimenting with closed-loop servo control using this triac controller, but the results were pretty uninspiring. With a triac, you can only change speeds as fast as twice your AC power frequency. And a 120 Hz control loop just isn&#8217;t tight enough to keep the sewing machine operating smoothly at low speeds. The motor&#8217;s lousy torque at these speeds certainly doesn&#8217;t help.</p>
<p style="text-align: left;">I also had lots of trouble with EMI in this design. With all the parts strewn about my desk and electrically isolated but not RF shielded, my microcontroller would randomly reset after the motor ran for a few seconds or so. I first saw this with my trusty <a href="http://en.wikipedia.org/wiki/Parallax_Propeller">Propeller</a>. I tried switching to an <a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146">AVR Butterfly</a>, half to try and avoid the EMI, half to have its LCD and joystick as a user interface. But, no luck.</p>
<p style="text-align: left;">I was curious how they solve this problem in industry. Servo motors are pretty common in industrial automation, and surely you must need a fancier way to control the speed of a large motor in order to build a heavy-duty servo. Well, it seems that there are two solutions:</p>
<ul>
<li>Just use a DC motor instead of AC. This is more expensive, but it&#8217;s simple and until recently it was the only option.</li>
<li><a href="http://en.wikipedia.org/wiki/Variable-frequency_drive">Variable-frequency drive</a>. You still use an AC motor, but now you use an AC-to-DC power supply plus a DC-to-AC inverter to control the frequency of the motor&#8217;s power supply. With an induction motor, this controls the speed.</li>
</ul>
<p>VFD seems quite cool, and I was really close to attempting to build a simple VFD controller using parts from a dead UPS. But then my better senses caught up with me&#8230;</p>
<p style="text-align: justify;">So, I was about to settle for this mediocrity and finish off my triac-based controller with some buttons and mounting hardware from HSC, when I randomly happened upon <a href="http://halted.com/commerce/ccp22296-12vdc-100w-dc-drive-motor-by-unitemotor-my6812a-21688.htm">the perfect DC motor</a>. I didn&#8217;t know it was perfect at the time, but I had a hunch. As soon as I got it home and sat it next to the original motor, I knew.</p>
<p style="text-align: center;"><a class="flickr-image aligncenter" title="New motor, old motor" href="http://www.flickr.com/photos/micahdowty/4278525888/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4047/4278525888_8c3dc1aa9c.jpg" alt="New motor, old motor" width="500" height="375" /></a></p>
<p style="text-align: left;">I was pretty lucky. The speed range was good, the sprocket had the same pitch, and it had plenty of torque at low speeds. The only problem: It&#8217;s just barely too large to fit inside the sewing machine cabinet. So, I had to improvise the mounting a bit. I ended up slicing off the bottom panel of the sewing machine, bolting its frame to some scrap pressboard, and mounting the motor using a hacky arrangement of pressboard scraps, screws, and zip ties.</p>
<p style="text-align: left;">I started out building a simple MOSFET speed controller for the motor, since I&#8217;d never used a MOSFET to control an inductive load before. But after spending an hour or two trying to squash transients and convince my FETs to switch at a high enough frequency, I figured I&#8217;d had enough pain for one week. I had a spare <a href="http://www.national.com/mpf/LM/LMD18200.html">LMD18200</a> chip with this project&#8217;s name on it.</p>
<p style="text-align: left;">The LMD18200 is an amazingly versatile and robust little chip. I used it for my <a href="http://micah.navi.cx/category/projects/laser-projector/">laser projector</a> project a while back. It was really overkill for that, but it&#8217;s about right for this sewing machine&#8217;s beefy new motor. I needed a pretty heavy duty motor drive capacitor too, so I ended up mounting the LMD18200, capacitor, and DC-DC converter in a small metal box for safety reasons. If the capacitor fails, I&#8217;d prefer not to have burning hot electrolyte and shrapnel all over my face.</p>
<p style="text-align: center;"><a class="flickr-image alignnone" style="text-decoration: none;" title="Motor drive and power supply box" href="http://www.flickr.com/photos/micahdowty/4282421804/"><img class="aligncenter" style="border: 1px solid black;" src="http://farm5.static.flickr.com/4060/4282421804_1833670a81.jpg" alt="Motor drive and power supply box" width="500" height="375" /></a></p>
<h2>Future work?</h2>
<p style="text-align: left;">Enough rambling for now. And I guess I should stop hacking my sewing machine, and start sewing cute things <img src='http://micah.navi.cx/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: left;">I did leave plenty of room in this build for later expansion. I&#8217;d like to add some kind of user interface for switching sewing modes. Right now I&#8217;m using the USB port for that, but a little LCD with a rotary encoder knob would be just swell. I&#8217;ve also thought of other ways to automate the sewing machine to make common tasks easier. For example, it would be useful to have a mode that automatically lifts the presser foot between stitches in single-stitch mode. I already found a good place to mount an RC servo motor for that.</p>
<p style="text-align: left;">And then there&#8217;s the idea of building a CNC embroidery machine around this, using Lego Mindstorms to make the cartesian robot&#8230;</p>
<h2>Links</h2>
<ul>
<li><a href="http://www.flickr.com/photos/micahdowty/sets/72157623135480898/">More pictures</a></li>
<li>Ugly hand-drawn schematics: <a href="http://www.flickr.com/photos/micahdowty/4283632625/in/set-72157623135480898/">main board</a>, <a href="http://www.flickr.com/photos/micahdowty/4284376538/in/set-72157623135480898/">wiring harness</a>, <a href="http://www.flickr.com/photos/micahdowty/4284376406/in/set-72157623135480898/">power box</a></li>
<li><a href="http://svn.navi.cx/misc/trunk/propeller/sewing/">Source code</a> for the Parallax Propeller firmware</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://micah.navi.cx/2010/01/diy-sewing-machine-retrofit/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
