<?xml version="1.0" encoding="windows-1252"?>
<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>The Blogging Protagonist &#187; Microcontrollers</title>
	<atom:link href="http://www.SWHarden.com/blog/category/microcontrollers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.SWHarden.com/blog</link>
	<description>A collection of thoughts in technological degradation</description>
	<lastBuildDate>Wed, 12 Oct 2011 02:20:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>High School Students&#8217; High Altitude Balloon #2</title>
		<link>http://www.SWHarden.com/blog/2011-08-14-high-school-students-high-altitude-balloon-2/</link>
		<comments>http://www.SWHarden.com/blog/2011-08-14-high-school-students-high-altitude-balloon-2/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 23:36:12 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Radio]]></category>
		<category><![CDATA[high altitude balloon]]></category>

		<guid isPermaLink="false">http://www.SWHarden.com/blog/?p=3104</guid>
		<description><![CDATA[Last year a group of high school students, in collaboration with a seminar course on Space Systems sponsored by the University of Florida&#8217;s Student Science Training Program (SSTP), gained some real-world experience planning, building, and launching a research payload to the edge of space – all in a couple weeks!  Last year&#8217;s high altitude [...]]]></description>
			<content:encoded><![CDATA[<p><b>Last year a group of high school students,</b> in collaboration with a seminar course on Space Systems sponsored by the University of Florida&#8217;s <a href="http://www.cpet.ufl.edu/sstp/default.html" onclick="javascript:urchinTracker ('/outbound/article/www.cpet.ufl.edu');">Student Science Training Program (SSTP)</a>, gained some real-world experience planning, building, and launching a research payload to the edge of space – all in a couple weeks!  Last year&#8217;s high altitude balloon launch was <a href="http://www.swharden.com/blog/2010-07-14-high-altitude-balloon-transmitter/" >covered on my website</a>, and the radio transmitter I built for it was featured on <a href="http://hackaday.com/2010/07/27/200-mile-rf-transmitter-and-high-altitude-balloon/" onclick="javascript:urchinTracker ('/outbound/article/hackaday.com');">this Hack-A-Day post</a>. Unlike last year&#8217;s payload, whose only homebrew device was the radio transmitter, this year&#8217;s payload had equipment we assembled ourselves, and instead of launching from NASA we launched from the UF football stadium! There were a couple problems along the way, and the payload hasn&#8217;t been recovered (yet), but it was a fun project and we all learned a lot along the way!<br />
<iframe src="http://player.vimeo.com/video/27447092?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0"></iframe>
<p><a href="http://vimeo.com/27447092" onclick="javascript:urchinTracker ('/outbound/article/vimeo.com');">Untitled</a> from <a href="http://vimeo.com/user2105187" onclick="javascript:urchinTracker ('/outbound/article/vimeo.com');">DJ Meyers</a> on <a href="http://vimeo.com" onclick="javascript:urchinTracker ('/outbound/article/vimeo.com');">Vimeo</a>.</p>
<p><a href="http://www.SWHarden.com/blog/images/group.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/group-525x193.jpg" alt="group" title="group" width="525" height="193" class="alignnone size-medium wp-image-3105" /></a></p>
<p>Below is a panoramic photo right before the launch &#8211; see our balloon on the right? So cool!<br />
<a href="http://www.SWHarden.com/blog/images/pan.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/pan-525x118.jpg" alt="pan" title="pan" width="525" height="118" class="alignnone size-medium wp-image-3118" /></a></p>
<p><b>Our goal was to take photos from the edge of space, and log temperature, pressure, humidity, and GPS coordinates along the way.</b> On-board were a radio transmitter, an Arduino with a GPS shield, and an Android phone to take pictures every few seconds.</p>
<p><b>Android details:</b> Most of the Android development was handled by UF student Richard along with high school students Benji, Tyler, Michael, and Kevin. Their GitHub project is here:<a href="https://github.com/rich90usa/AndroidSensorLogger" onclick="javascript:urchinTracker ('/outbound/article/github.com');">https://github.com/rich90usa/AndroidSensorLogger</a>. Also note that the automatic photo capture utilized <a href="http://www.appbrain.com/app/photo-log-lite/com.keepknocking.PhotoLogLite" onclick="javascript:urchinTracker ('/outbound/article/www.appbrain.com');">Photo Log Lite</a>. We also used <a href=http://mendhak.github.com/gpslogger/">GPSLogger</a> to handle logging GPS to SD. <i>&#8220;Both of these programs were chosen for their ability to run in the background &#8211; and do so reliably by using the &#8216;correct&#8217; Android supported methods of doing so.&#8221; &#8212; Richard</i></p>
<p><table><tr><td style="text-indent: 25px; background-color: #E5E5E5; padding: 10px; border-top-width: 1px; border-bottom-width: 1px; border-left-width: 7px;border-top-style: solid; border-right-style: solid;border-bottom-style: solid;border-left-style: solid;border-top-color: #B5B5B5; border-right-color: #B5B5B5;border-bottom-color: #B5B5B5; border-left-color: #B5B5B5;border-right-width: 1px;background-image: url(http://www.swharden.com/graphics/layout_2006_08_12/quotes.jpg); background-position: left top; background-repeat: no-repeat;">Our code used the phone&#8217;s text-to-speech engine to speak out an encoded version of every 90th new GPS coordinate. The data was encoded by connecting every number (0-9) to a word the <a href="http://en.wikipedia.org/wiki/NATO_phonetic_alphabet" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">NATO phonetic alphabet</a>. The code also used text-to-speech to have the phone speak out the phone&#8217;s altitude data.<br />
&#8211;Benji</td></tr></table></p>
<p><a href="http://www.SWHarden.com/blog/images/DSC_6013.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6013-525x790.jpg" alt="DSC_6013" title="DSC_6013" width="525" height="790" class="alignnone size-medium wp-image-3106" /></a></p>
<p><b>The device consisted of 4 main components:</b> <a href="http://www.SWHarden.com/blog/images/IMG_2095.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/IMG_2095-51x150.jpg" alt="IMG_2095" title="IMG_2095" width="51" height="150" class="alignright size-thumbnail wp-image-3108" /></a>a payload (the styrofoam box in which all of the electrical equipment was housed), a radar reflector (hanging off the bottom of the payload, to help make this object visible to aircraft), a parachute (at the top, made of bio-degradable plastic), and the balloon itself which measured about 6 feet wide when inflated at ground level (supposedly it reaches approximately 30 feet wide at high altitudes before it bursts).  Once the balloon bursts, the parachute fills with air and the device floats back to earth.<br />
<a href="http://www.SWHarden.com/blog/images/DSC_6009.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6009-525x348.jpg" alt="DSC_6009" title="DSC_6009" width="525" height="348" class="alignnone size-medium wp-image-3107" /></a></p>
<p><b>Kunal demonstrates the</b> effectiveness of our parachute with a scientific &#8220;run test&#8221;!<br />
<a href="http://www.SWHarden.com/blog/images/DSC_6015.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6015-525x348.jpg" alt="DSC_6015" title="DSC_6015" width="525" height="348" class="alignnone size-medium wp-image-3109" /></a></p>
<p><b>The radio communication system we used this year</b> were a little more commercial than last year. Due to my limited time availability (I had an oral surgery rotation all week the week before launch), I chose to get something pre-packaged. My intent was to use FRS (those little 500mW family radio service radios) to send GPS data back to earth, but I later (after launch) did a little more research and realized that it probably wasn&#8217;t the most legal way to do it. However, it was extremely cost effective (amateur radio transmitters and RF transmitter modules are quite pricey). For about the cost of a pizza, we were able to interface a FRS radio to the android phone, and the phone ran a program which polled its GPS, turned coordinates into NATO letter abbreviations, and spoke them through the speaker line. The FRS radio with VOX (voice operated transmit) sensed audio and transmitted accordingly. Although it worked very well, I later learned that this may not have been legal in the US because, although FRS doesn&#8217;t require a user license and is legal to use anywhere as long as you use its stock antenna, I violated the rule that it cannot be operated above a certain height (20m I think?). Note that this should not be replicated, and probably shouldn&#8217;t have been done in the first place. I know I&#8217;ll take a lot of heat over this, but it&#8217;s in the past now and will be done differently in the future.</p>
<p><a href="http://www.SWHarden.com/blog/images/DSC_6016.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6016-150x99.jpg" alt="DSC_6016" title="DSC_6016" width="150" height="99" class="alignnone size-thumbnail wp-image-3111" /></a> <a href="http://www.SWHarden.com/blog/images/DSC_6042.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6042-150x99.jpg" alt="DSC_6042" title="DSC_6042" width="150" height="99" class="alignnone size-thumbnail wp-image-3112" /></a> <a href="http://www.SWHarden.com/blog/images/DSC_6049.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6049-150x99.jpg" alt="DSC_6049" title="DSC_6049" width="150" height="99" class="alignnone size-thumbnail wp-image-3113" /></a> <a href="http://www.SWHarden.com/blog/images/DSC_6071.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6071-150x99.jpg" alt="DSC_6071" title="DSC_6071" width="150" height="99" class="alignnone size-thumbnail wp-image-3114" /></a></p>
<p><b>Here are some photos right before the launch.</b> It was a sunny day at the UF football stadium! The Android phone is taped the the outside of the box and takes pictures every few seconds, storing them on a micro SD card. Inside the box is an Arduino with GPS shield, and the FRS radio transmitter.<br />
<a href="http://www.SWHarden.com/blog/images/DSC_6079.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6079-525x348.jpg" alt="DSC_6079" title="DSC_6079" width="525" height="348" class="alignnone size-medium wp-image-3115" /></a></p>
<p><b>The balloon is ready to be inflated!</b><br />
<a href="http://www.SWHarden.com/blog/images/DSC_6119.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6119-525x348.jpg" alt="DSC_6119" title="DSC_6119" width="525" height="348" class="alignnone size-medium wp-image-3116" /></a></p>
<p><b>The balloon is about 75% inflated at this point.</b><br />
<a href="http://www.SWHarden.com/blog/images/DSC_6132.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6132-525x348.jpg" alt="DSC_6132" title="DSC_6132" width="525" height="348" class="alignnone size-medium wp-image-3117" /></a></p>
<p><b>Richard looking all serious as he finishes inflating the balloon.</b></p>
<p><a href="http://www.SWHarden.com/blog/images/pan.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/pan-525x118.jpg" alt="pan" title="pan" width="525" height="118" class="alignnone size-medium wp-image-3118" /></a></p>
<p>&#8230;panoramic above, zoomed below&#8230;</p>
<p><a href="http://www.SWHarden.com/blog/images/panZoomed.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/panZoomed-525x354.jpg" alt="panZoomed" title="panZoomed" width="525" height="354" class="alignnone size-medium wp-image-3119" /></a></p>
<p><b>What a cool photo!</b> It needs no words to describe!<br />
<a href="http://www.SWHarden.com/blog/images/DSC_6145.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6145-525x348.jpg" alt="DSC_6145" title="DSC_6145" width="525" height="348" class="alignnone size-medium wp-image-3120" /></a></p>
<p><b>The balloon is way up there!</b></p>
<p><iframe width="640" height="390" src="http://www.youtube.com/embed/BozzCpdTJUk" frameborder="0" allowfullscreen></iframe></p>
<p><b>After launch the balloon ascended at a rate of about 500ft/min.</b> It spat out GPS data often, and altitude (not encoded with NATO abbreviations) was the easiest to hear as I walked from the UF football stadium to the UF <a href="http://gatorradio.org" onclick="javascript:urchinTracker ('/outbound/article/gatorradio.org');">Gator Amateur Radio Club</a> to use their equipment (namely an AZEL-rotor-controlled 70cm yagi antenna attached to an I-Com 706) to listen in as the balloon ascended&#8230; but not before a group photo!<br />
<a href="http://www.SWHarden.com/blog/images/DSC_6151.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSC_6151-525x348.jpg" alt="DSC_6151" title="DSC_6151" width="525" height="348" class="alignnone size-medium wp-image-3121" /></a></p>
<p><b>Here we are in the station&#8230; let&#8217;s get to work!</b></p>
<p><iframe width="640" height="390" src="http://www.youtube.com/embed/98SHxyvsGB4" frameborder="0" allowfullscreen></iframe><br />
.<br />
<a href="http://www.SWHarden.com/blog/images/IMG_2118.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/IMG_2118-525x350.jpg" alt="IMG_2118" title="IMG_2118" width="525" height="350" class="alignnone size-medium wp-image-3122" /></a></p>
<p><b>The results were a bit disappointing,</b> as we believe the Android phone froze/crashed about 10,000 feet in the air! Since that was the device which generated the audio fed into the transmitter, when that phone died, the transmitter stopped transmitting, and we didn&#8217;t hear anything else from the transmitter ever again!  We included contact information in the payload and it&#8217;s possible it will be found one day and we will be contacted about it. If this is the case, we&#8217;ll view the SD cards and see the full GPS log and pictures from the edge of space! Until then, we can only cross our fingers and hope for the best. Either way we had a blast, and learned a lot along the way. Next time we can be better prepared for a solid recovery!</p>
<p><b>Here&#8217;s audio of the device&#8217;s last words when it was about 10,000 feet in the air:</b><br />
DOWNLOAD <a href='http://www.SWHarden.com/blog/images/lastwords.mp3'>lastwords.mp3</a></p>
<p><b>Overall we had an awesome time!</b> I&#8217;d like to thank everyone who helped with this project, especially UF students Richard, Kunal, Dante, and all of the SSTP high school students!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.SWHarden.com/blog/2011-08-14-high-school-students-high-altitude-balloon-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://www.SWHarden.com/blog/images/lastwords.mp3" length="877296" type="audio/mpeg" />
		</item>
		<item>
		<title>I before E except after Hellschreiber</title>
		<link>http://www.SWHarden.com/blog/2011-08-05-i-before-e-except-after-hellschreiber/</link>
		<comments>http://www.SWHarden.com/blog/2011-08-05-i-before-e-except-after-hellschreiber/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 23:52:40 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Circuitry]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Radio]]></category>
		<category><![CDATA[high altitude balloon]]></category>

		<guid isPermaLink="false">http://www.SWHarden.com/blog/?p=3055</guid>
		<description><![CDATA[This post describes a project I designed which transmits strings of data from a microcontroller to a PC&#8217;s screen using audio beeping in a special mode called Hellschreiber. Although these days it&#8217;s almost exclusively used by amateur radio operators, I thought it would make a cool microcontroller project! The result can be accomplished with a [...]]]></description>
			<content:encoded><![CDATA[<p><table><tr><td style="text-indent: 25px; background-color: #E5E5E5; padding: 10px; border-top-width: 1px; border-bottom-width: 1px; border-left-width: 7px;border-top-style: solid; border-right-style: solid;border-bottom-style: solid;border-left-style: solid;border-top-color: #B5B5B5; border-right-color: #B5B5B5;border-bottom-color: #B5B5B5; border-left-color: #B5B5B5;border-right-width: 1px;background-image: url(http://www.swharden.com/graphics/layout_2006_08_12/quotes.jpg); background-position: left top; background-repeat: no-repeat;">This post describes a project I designed which transmits strings of data from a microcontroller to a PC&#8217;s screen using audio beeping in a special mode called <a href="http://en.wikipedia.org/wiki/Hellschreiber" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">Hellschreiber</a>. Although these days it&#8217;s almost exclusively used by amateur radio operators, I thought it would make a cool microcontroller project! The result can be accomplished with a microcontroller and a speaker as a transmitter and a PC with a microphone as a receiver and decoder, or with actual radio equipment (even toy walkie talkies) by transmitting the tones over modulated radio frequencies for long distance communication! <a href="http://www.amazon.com/Midland-GXT760VP4-36-Mile-42-Channel-Two-Way/dp/B0039YON6Q/ref=sr_1_1?ie=UTF8&#038;qid=1312588647&#038;sr=8-1" onclick="javascript:urchinTracker ('/outbound/article/www.amazon.com');">Ideas anyone?</a></p>
<p><i><b>SPECIAL THANKS:</b> I&#8217;d like to think <a href="http://www.mikeseese.com" onclick="javascript:urchinTracker ('/outbound/article/www.mikeseese.com');">Mike Seese</a> for his brainstorming help in making this project a reality.  <a href="http://www.mikeseese.com" onclick="javascript:urchinTracker ('/outbound/article/www.mikeseese.com');">Mike</a> and I are working on a high altitude balloon project together, and a creative inexpensive radio link is one of our goals. Thanks <a href="http://www.mikeseese.com" onclick="javascript:urchinTracker ('/outbound/article/www.mikeseese.com');">Mike</a>!</i><br />
</td></tr></table></p>
<p><b>As a professional dental student by day and amateur electrical/RF engineer by night, I&#8217;m having a very strange summer.</b> I&#8217;m developing rapidly in my experience and skills in both arenas. I finally feel like I have a working knowledge of most fundamental electrical and radio frequency concepts, and I&#8217;m starting to see patients and do procedures on humans (no more mannequins) in the student dental clinic. For legal and ethical reasons I do not write specifics about what I do with my patients, but I certainly make up for it by documenting the electronic projects I work on! My goals of doing this are to (a) inspire potential electronics tinkerers to come up with new ideas and attack new projects, and (b) receive feedback and insight from those more experienced than me to help me grow in my knowledge. My eye caught <a href="http://www.swharden.com/blog/2011-07-24-frequency-counter-gen2/comment-page-1/#comment-16485" >a comment</a> a few posts ago that made me smile: <i>You have been blessed with talent and the drive to attempt things not been tried before, keep it up, great job. &#8211;David S</i>  While I can&#8217;t claim that everything I do is truly novel or never tried before, I appreciate the encouraging words. Thank you David S!</p>
<p><b>Today&#8217;s project is a fun one involving vintage wartime radio equipment, amateur radio computer software, and a healthy dose of microcontrollers!</b> My goal is to design a single chip Hellschreiber (technically Feldhellschreiber) transmitter. &#8220;Hellschreiber&#8221; translates into English as &#8220;Light Writer&#8221; and is a pun on the name of its inventor, Rudolf Hell, who built the first device in 1920. It was intended to allow messages to be transferred over poor radio links too noisy for intelligible voice or <a href="http://en.wikipedia.org/wiki/Radioteletype" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">radioteletype (RTTY)</a> communication. Its cool factor is upped by the fact that it was sometimes used by the German military in conjunction with the <a href="http://en.wikipedia.org/wiki/Enigma_machine" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">Enigma encryption system</a> during World War 2! [As an aside, RTTY is still pretty sweet and dates back to the mid 1800s! Check out hardware receivers in <a href="http://www.youtube.com/watch?v=mN8pkJoDDfI" onclick="javascript:urchinTracker ('/outbound/article/www.youtube.com');">video 1</a> and <a href="http://www.youtube.com/watch?v=Ml00ngVwrcU" onclick="javascript:urchinTracker ('/outbound/article/www.youtube.com');">video 2</a>]<br />
<iframe width="525" height="393" src="http://www.youtube.com/embed/nXLPUbGYDp4" frameborder="0" allowfullscreen></iframe></p>
<p><b>Seeing a battlefield-ready Hellschreiber receiver gives you a good idea of how it works.</b> (The video isn&#8217;t mine, I found it on youtube.) The concept is relatively simple (shown above), and the receiver has only 2 moving parts. A spinning corkscrew presses a ticker tape into ink when it receives a radio signal. As the radio signal beeps on and off, the corkscrew contacts at different positions at different times, and letters are written on the ticker tape! <a href="http://www.SWHarden.com/blog/images/anaglyph-hell-GL-11.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/anaglyph-hell-GL-11.jpg" alt="anaglyph-hell-GL-11" title="anaglyph-hell-GL-11" width="300" height="250" class="alignright size-thumbnail wp-image-3074" /></a>The <a href="http://www.nonstopsystems.com/radio/hellschreiber-fonts.htm" onclick="javascript:urchinTracker ('/outbound/article/www.nonstopsystems.com');">designers of these things were extraordinarily creative</a>! The picture on the right shows a Hellschreiber transmitter &#8211; basically a typewriter with mechanical wizardry that turns key presses into a series of radio tones corresponding to the pixelated shape of a character.</p>
<p><b>Almost a century later, people are still sending messages around the world using Hellschreiber!</b> With an <a href="http://en.wikipedia.org/wiki/Amateur_radio" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">amateur radio license</a> and an amateur radio transceiver you can tune around special <a href="http://www.nonstopsystems.com/radio/frank-radio-dig-mode-freqs.htm" onclick="javascript:urchinTracker ('/outbound/article/www.nonstopsystems.com');">Hellschreiber calling frequencies</a> and engage in conversations with other people who enjoy using this unique mode. Computers have modernized the process, allowing you to send Hellschreiber text by typing on your keyboard and receive it by just looking at your screen. My favorite program (free) to do this is Digital Master 780, part of <a href="http://www.ham-radio-deluxe.com/Downloads.aspx" onclick="javascript:urchinTracker ('/outbound/article/www.ham-radio-deluxe.com');">Ham Radio Deluxe</a>.</p>
<p><iframe width="525" height="393" src="http://www.youtube.com/embed/_MJYwXvwTvY" frameborder="0" allowfullscreen></iframe></p>
<p><b>This is the project I just completed.</b> It takes strings of text stored (or dynamically generated) in an array on a microcontroller (I&#8217;m using an ATMega48, but the code is almost identical for any ATMEL AVR microcontroller, and easy adapted for other architectures) and turns it into an audio tone using PWM. This audio tone could be fed into a speaker and a microphone across the room could receive it and use the software to show the received data, or the audio could be fed into a radio transmitter and a PC hooked to the receiver could decode the audio.  Either way, the text in the microcontroller is converted to Hellschreiber audio tones ready to be used however you see fit!  Although I designed it as a resilient way to transmit GPS/altitude data from a high altitude balloon using a small, cheap, low-power radio transmitter, this project is just the foundation of a plethora of potential projects!<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1663.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1663-525x393.jpg" alt="DSCN1663" title="DSCN1663" width="525" height="393" class="alignnone size-medium wp-image-3080" /></a></p>
<p><b>Here&#8217;s the circuit I&#8217;m using.</b> It&#8217;s actually less complicated than shown &#8211; all those yellow wires are going to my AVR programmer! The chip just receives +5V and GND, and the audio is generated automatically and output on the OC0A pin, which happens to be pin 12 on my ATMega48. The output (audio level square waves) is fed to a crystal oscillator <a href="http://www.taydaelectronics.com/servlet/the-709/OSC-dsh-40M-dsh-MEC-dsh-LF-CRYSTAL-OSCILLATOR-40.00/Detail" onclick="javascript:urchinTracker ('/outbound/article/www.taydaelectronics.com');">like this one</a>, which generates square waves with an amplitude equal that to the input. Thus, by audio-frequency AC from the microchip, decoupled through a series capacitor, added to the power supply of the oscillator (provided by the 5V rail through a 1.8k resistor), we effectively produce an amplitude modulated (AM) radio signal!<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1667.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1667-525x393.jpg" alt="DSCN1667" title="DSCN1667" width="525" height="393" class="alignnone size-medium wp-image-3081" /></a></p>
<p><b>This is the receiver I&#8217;m using.</b> I&#8217;m lucky enough to have an all-mode, general-coverage, 100W amateur radio transceiver! It&#8217;s a <a href="http://www.eham.net/reviews/detail/3046" onclick="javascript:urchinTracker ('/outbound/article/www.eham.net');">Yaesu 857-D</a> and I&#8217;m completely in love with it. It&#8217;s quite pricey though! You can find wide coverage receive-only radios called <a href="http://en.wikipedia.org/wiki/Scanner_(radio)" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">radio scanners</a> (or police scanners), often for $20 or so on eBay which would do just as good a job of receiving all sorts of radio signals! Whatever you use, after tuning into the audio with the ham radio delux software, you&#8217;ll be able to decode Hellschreiber like this:<br />
<a href="http://www.SWHarden.com/blog/images/hell.PNG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/hell-525x380.PNG" alt="hell" title="hell" width="525" height="380" class="alignnone size-medium wp-image-3062" /></a></p>
<p><b>A few notes about the code:</b> Each letter is sent twice vertically and I don&#8217;t think I should have done that. It&#8217;s easy enough to correct by eliminating the second FOR loop in the sendChar() function, and doubling the height of the pixels transmitted by changing on(1) and off(1) to on(2) and off(2). Then again, I could be mistaken &#8211; I don&#8217;t use this mode much.  Also, horizontal width of characters (increase this and horizontally compress the received image to reduce the effects of noise) is controlled by a single variable, dynamically adjustable in software. Characters are created from a 3&#215;5 grid (15 bits) and stored as an integer (16 bits, 2 bytes in AVR-GCC). Custom characters are certainly possible! This program takes 16.1% of program space (658 bytes) and 25.4% of data space (130 bytes) and certainly leaves room for optimization.</p>
<pre class="prettyprint c">
// designed for and tested with ATMega48
#include &lt;avr/io.h&gt;
#define F_CPU 8000000UL
#include &lt;avr/delay.h&gt;
#include &lt;avr/interrupt.h&gt;

/*
character format (3x5):
	KFA
	LGB
	MHC
	NID
	OJE

variable format:
	2-byte, 16-bit int 0b0ABCDEFGHIJKLMNO
	(note that the most significant bit is not used)
*/
#define A 	0b0111111010011111
#define B 	0b0010101010111111
#define C	0b0100011000101110
#define D	0b0011101000111111
#define E	0b0100011010111111
#define F	0b0100001010011111
#define G 	0b0100111000101110
#define H	0b0111110010011111
#define I	0b0100011111110001
#define J	0b0111110000100011
#define K	0b0110110010011111
#define L	0b0000010000111111
#define M	0b0111110110011111
#define N	0b0011111000001111
#define O	0b0011101000101110
#define P	0b0010001010011111
#define Q	0b0111011001011110
#define R	0b0010111010011111
#define S	0b0100101010101001
#define T	0b0100001111110000
#define U	0b0111110000111111
#define V	0b0111100000111110
#define W	0b0111110001111111
#define X	0b0110110010011011
#define Y	0b0110000011111000
#define Z	0b0110011010110011
#define n0	0b0111111000111111
#define n1	0b0000011111101001
#define n2	0b0111011010110111
#define n3	0b0111111010110001
#define n4	0b0111110010011100
#define n5	0b0101111010111101
#define n6	0b0101111010111111
#define n7	0b0110001011110000
#define n8	0b0111111010111111
#define n9	0b0111111010111101
#define SP	0b0000000000000000
#define BK	0b0111111111111111
#define SQ	0b0001000111000100
#define PR	0b0000110001100011
#define AR	0b0001000111011111

volatile char width=1; // width of characters, widen to slow speed

#define spd 8300 // synchronization, incr to make it slant upward

void rest(char times){while (times){times--;_delay_us(spd);}}

void on(char restfor){OCR0A=110;rest(restfor);}
void off(char restfor){OCR0A=0;rest(restfor);}

void sendChar(int tosend){
	char w;
	char bit;
	for(w=0;w&lt;width*2;w++){ // left column
		off(1);
		for (bit=0;bit&lt;5;bit++){
				if ((tosend&gt;&gt;bit)&#038;1) {on(1);}
				else {off(1);}
			}
		off(1);
		}
	for(w=0;w&lt;width*2;w++){ // middle column
		off(1);
		for (bit=5;bit&lt;10;bit++){
				if ((tosend&gt;&gt;bit)&#038;1) {on(1);}
				else {off(1);}
			}
		off(1);
		}
	for(w=0;w&lt;width*2;w++){ // right column
		off(1);
		for (bit=10;bit&lt;15;bit++){
				if ((tosend&gt;&gt;bit)&#038;1) {on(1);}
				else {off(1);}
			}
		off(1);
		}
	off(14); // letter space (1 column)
}

// CUSTOMIZE THE MESSAGE, OR GENERATE IT DYNAMICALLY!
int message[]={AR,AR,AR,S,W,H,A,R,D,E,N,PR,C,O,M,SP,R,O,C,K,S,
	SP,AR,AR,AR,SP,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,
	V,W,X,Y,Z,n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,BK,SP};

void sendMessage(){
	char i;
	for(i=0;i&lt;sizeof(message)/2;i++){
		sendChar(message[i]);
	}
}

int main(){ // ### PROGRAM STARTS HERE ###

	// this sets up CPWM in CTC mode,
	// it may be slightly different for other chips
	DDRD|=255; // OC0A is now an output
	TCCR0A=0b01000010; // toggle on match, CTC mode
	TCCR0B=0B00000011; // set prescalar

	for(;;){
		width=1; // fast mode
		sendMessage();
		width=3; // slow mode
		sendMessage();
	}

	return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.SWHarden.com/blog/2011-08-05-i-before-e-except-after-hellschreiber/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PC/microcontroller &#8220;wireless&#8221; data transfer (part 1)</title>
		<link>http://www.SWHarden.com/blog/2011-07-26-pcmicrocontroller-wireless-data-transfer/</link>
		<comments>http://www.SWHarden.com/blog/2011-07-26-pcmicrocontroller-wireless-data-transfer/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 03:35:16 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Circuitry]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.SWHarden.com/blog/?p=2992</guid>
		<description><![CDATA[UPDATE! >>> [FINISHED PROJECT HERE]
Several days ago I had a crazy idea. I was driving to Orlando to pick my wife up from the airport and it was dark and stormy on the highway and I was thinking about the backlash I got from my Sound Card Microcontroller/PC Communication project, where I used an embarrassingly [...]]]></description>
			<content:encoded><![CDATA[<p><code>UPDATE!</code> >>> <b><a href="http://www.swharden.com/blog/2011-07-31-pcmicrocontroller-wireless-data-transfer-part-2/" >[FINISHED PROJECT HERE]</a></b></p>
<p><b>Several days ago I had a crazy idea.</b> I was driving to Orlando to pick my wife up from the airport and it was dark and stormy on the highway and I was thinking about the backlash I got from my <a href="http://www.swharden.com/blog/2011-07-09-sound-card-microcontrollerpc-communication/" >Sound Card Microcontroller/PC Communication</a> project, where I used an embarrassingly simple hardware to accomplish the simple task of exchanging a few bytes of data between a PC and microcontroller (in the face of many people who adamantly prefer more complicated &#8220;traditional standard&#8221; methods). The car in front of me drove with his emergency flashers on, and at times all I could see were his lights. At that moment the crazy idea popped in my head &#8211; I wonder if I could use a PC monitor and phototransistors to send data to a microchip? I can&#8217;t think of any immediate uses for this capability, but perhaps if I make a working prototype I&#8217;ll stumble upon some. Either way, it sounds like a fun project!<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1652.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1652-525x393.jpg" alt="DSCN1652" title="DSCN1652" width="525" height="393" class="size-medium wp-image-3021" /></a></p>
<p><b>The circuit is as simple as it gets.</b> <a href="http://www.SWHarden.com/blog/images/PHOTOTRANSISTOR-MICROCONTROLLER-CIRCUIT.png" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/PHOTOTRANSISTOR-MICROCONTROLLER-CIRCUIT.png" alt="PHOTOTRANSISTOR MICROCONTROLLER CIRCUIT" title="PHOTOTRANSISTOR MICROCONTROLLER CIRCUIT" width="141" height="233" class="alignright size-full wp-image-2993" /></a>A phototransistor is exactly what it says, a photo (light-triggered) transistor (uses small current to trigger a large current). It&#8217;s a <a href="http://en.wikipedia.org/wiki/Photodiode" onclick="javascript:urchinTracker ('/outbound/article/en.wikipedia.org');">photodiode</a> with a small transistor circuit built in. Make sure you give it right polarity when you plug it in! For some reason (likely known to electrical engineers, not dental students) the larger metal piece in the plastic part, which I normally associate as negative for LEDs, should be plugged in the +5V for my photodiode. Again, make sure you hook yours up right. I purchased mine from eBay quite cheaply, but I&#8217;ll bet you can find some in RadioShack.  Note that the value of the 22k resistor is important, and that your needed value may differ from mine. The resistor relates to sensitivity, the larger the value the more sensitive the device is to light. If it&#8217;s too sensitive, it will sense light even when aimed at a black portion of the screen.<br />
<a href="http://www.SWHarden.com/blog/images/hardcode.jpg" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/hardcode-525x104.jpg" alt="hardcode" title="hardcode" width="525" height="104" class="size-medium wp-image-3020" /></a></p>
<p><b>Initial tests were done</b> using the pins as digital inputs. This was difficult to achieve because, even as transistorized photo-diodes, it took a large difference in light to go from 5V to 0V (even past the 2.5V threshold). After a few minutes of frustration, I decided to use ADC to measure the light intensity. I use only the most significant 8 bits (ADCH). I found that in ambient light the readings are 255, and that white monitor light is around 200. Therefore my threshold is 250 (4.88V?) and I use this for logic decisions. Here&#8217;s my setup showing the ADC value of each phototransistor translated into a 1 and 0 for clock (C) and data (D). Both are aimed toward the lamp, so both show a logical 1:<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1651.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1651-525x393.jpg" alt="DSCN1651" title="DSCN1651" width="525" height="393" class="size-medium wp-image-3022" /></a></p>
<p><b>My first test</b> involved reading the data from the image above. The clock is on the bottom line, data is on the top. Every time the clock transitions from black to white, the value of the data at that point is read (white=1, black=0) and the number is placed on a screen.  Here&#8217;s what it looks like in action:<br />
<iframe width="480" height="390" src="http://www.youtube.com/embed/lvVjsMMCx0U" frameborder="0" allowfullscreen></iframe></p>
<p><b>Hopefully soon we can get a JavaScript interface going!</b> Rather than swiping I&#8217;d like to just point this at the screen and let JS flash some squares for my device to read. This will allow virtually unlimited amounts of data to be transferred, albeit slowly, to the micro-controller. Here&#8217;s a preliminary sketch of how to send strings.<br />
<a href="http://www.SWHarden.com/blog/images/string.png" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/string-525x228.png" alt="string" title="string" width="525" height="228" class="size-medium wp-image-3024" /></a></p>
<p><b>Remember now we&#8217;re using a time domain, not a 2d barcode.</b> I really stink at writing JavaScript, I&#8217;m going to have to pull in some help on this one!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.SWHarden.com/blog/2011-07-26-pcmicrocontroller-wireless-data-transfer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Frequency Counter Gen2</title>
		<link>http://www.SWHarden.com/blog/2011-07-24-frequency-counter-gen2/</link>
		<comments>http://www.SWHarden.com/blog/2011-07-24-frequency-counter-gen2/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 22:07:24 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Circuitry]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Radio]]></category>

		<guid isPermaLink="false">http://www.SWHarden.com/blog/?p=3001</guid>
		<description><![CDATA[I&#8217;m working to further simplify my frequency counter design. This one is simpler than my previous design both in hardware and software! Here&#8217;s a video to demonstrate the device in its current state:

I utilize the ATMega48&#8217;s hardware counter which is synchronous with the system clock, so it can only measure frequency less than half of [...]]]></description>
			<content:encoded><![CDATA[<p><b>I&#8217;m working to further simplify my frequency counter design.</b> This one is simpler than <a href="http://www.swharden.com/blog/2011-03-14-frequency-counter-finished/" >my previous design</a> both in hardware and software! Here&#8217;s a video to demonstrate the device in its current state:<br />
<iframe width="480" height="390" src="http://www.youtube.com/embed/FUdxwntNh1c" frameborder="0" allowfullscreen></iframe></p>
<p>I utilize the ATMega48&#8217;s hardware counter which is synchronous with the system clock, so it can only measure frequency less than half of its clock speed. I solve this issue by dividing the input frequency by 8 and clocking the chip at 12mhz. This allows me to measure frequencies up to about 48MHz, but can be easily adapted to measure over 700MHz (really?) by dividing the input by 128. Division occurs by a 74HC590 8-bit counter (not a 74HC595 as I accidentally said in the video, which is actually a common shift register), allowing easy selection of input divided by 1, 2, 4, 8, 16, 32, 64, or 128. The following image shows the o-scope showing the original signal (bottom) and the divided-by-8 result (top)<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1630.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1630-525x393.jpg" alt="DSCN1630" title="DSCN1630" width="525" height="393" class="alignright size-medium wp-image-3002" /></a></p>
<p><b>The device outputs</b> graphically to a LCD simply enough. That LCD is from eBay and is only $3.88 shipped! I&#8217;m considering buying a big box of them and implementing them in many more of my projects. They&#8217;re convenient and sure do look nice!<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1634.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1634-525x393.jpg" alt="DSCN1634" title="DSCN1634" width="525" height="393" class="alignright size-medium wp-image-3003" /></a></p>
<p><b>The signal I test with</b> comes from an oscillator I built several months ago.  It&#8217;s actually a SA612 style receiver whose oscillator is tapped, amplified, and output through a wire. It&#8217;s tunable over almost all of 40m with a varactor diode configuration. It was the start of a transceiver, but I got so much good use out of it as a function generator that I decided to leave it like it is!<br />
<a href="http://www.SWHarden.com/blog/images/DSCN1637.JPG" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/DSCN1637-525x393.jpg" alt="DSCN1637" title="DSCN1637" width="525" height="393" class="alignright size-medium wp-image-3004" /></a></p>
<p><b>THIS IS HOW THE PROGRAM WORKS:</b> I don&#8217;t supply a schematic because it&#8217;s simple as could be. Divide the input frequency to something relatively slow, &lt;1MHz at least.  Configure the 16-bit counter to accept an external pin as the counter source (not a prescaled clock, as I often use in other applications). Then set the timer value to 0, _delay_ms() a certainly amount of time (1/10th second), and read the counter value. Multiply it by 10 to account for the 1/10th second, then multiply it by 8 to account for the divider, and it&#8217;s done! It will update 10 times a second, with a resolution down to 10*8 = 80 Hz. It&#8217;s well within the range of amateur radio uses! If you&#8217;re considering replicating this, read up on how to use hardware counters with ATMEL AVR microcontrollers. That should be enough to get you started! Here&#8217;s the code I used&#8230;</p>
<p>For the LCD, this code requires <a href="http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html" onclick="javascript:urchinTracker ('/outbound/article/homepage.hispeed.ch');">LCD library</a>. </p>
<pre class="prettyprint python">
#include &lt;stdlib.h&gt;
#include &lt;avr/io.h&gt;
#include &lt;avr/pgmspace.h&gt;
#include &lt;util/delay.h&gt;
#include "lcd.h"
#include "lcd.c"

int main(void)
{
	TCCR1B=0b00000111; // rising edge trigger
    char buffer[8];
	long toshow=0;
	char mhz=0;
	int khz=0;
	int hz=0;
    lcd_init(LCD_DISP_ON);
	for(;;){
    	lcd_clrscr();

    	lcd_gotoxy(0,0);
		itoa(mhz , buffer, 10);
		lcd_puts(buffer);
		lcd_puts(".");

		if (khz&lt;100){lcd_puts("0");}
		itoa(khz , buffer, 10);
		lcd_puts(buffer);

		itoa(hz/100 , buffer, 10);
		lcd_puts(buffer);

		lcd_puts(" MHz");

		TCNT1=0;
		_delay_ms(99);
		_delay_us(312);
		toshow=TCNT1;
		toshow=(long)toshow*16*10; // tenth second period
		mhz=toshow/1000000;
		toshow=toshow-mhz*1000000;
		khz=toshow/1000;
		toshow=toshow-khz*1000;
		hz=toshow;
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.SWHarden.com/blog/2011-07-24-frequency-counter-gen2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Half-Hearted DIY Logic Analyzer Works, a Little</title>
		<link>http://www.SWHarden.com/blog/2011-07-16-half-hearted-diy-logic-analyzer-works-a-little/</link>
		<comments>http://www.SWHarden.com/blog/2011-07-16-half-hearted-diy-logic-analyzer-works-a-little/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 03:52:17 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Circuitry]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.SWHarden.com/blog/?p=2968</guid>
		<description><![CDATA[While trying to attack the problem described in the previous entry, it became clear that a logic analyzer would be necessary.  I thought I&#8217;d try to build one, and my first attempt was so close to being successful, but not quite there.  It records 19 channels (the maximum pins available on the ATMega48 [...]]]></description>
			<content:encoded><![CDATA[<p><b>While trying to attack the problem described in the previous entry,</b> it became clear that a logic analyzer would be necessary.  I thought I&#8217;d try to build one, and my first attempt was so close to being successful, but not quite there.  It records 19 channels (the maximum pins available on the ATMega48 not being occupied by the status LED or USB connection pins) at a rate just under 1,000 samples per second. The USB connection to the PC is obvious, and it utilizes the V-USB project to bit-bang the USB protocol. I&#8217;m posting this in part because some of the comments to my entry two posts ago were disheartening, discouraging, and even down-right viscous!  I made a simple way to send numbers to a PC through the sound card, so what? Don&#8217;t be nasty about it!  Meh, internet people.  Anyway, here&#8217;s a marginally more proper way to send data to a PC with USB and an AVR (logging and interface designed in python), but I&#8217;ll probably still get yelled at for it.</p>
<p><iframe width="480" height="390" src="http://www.youtube.com/embed/TEHF6b5bqj8" frameborder="0" allowfullscreen></iframe></p>
<p><b>As you can see from the video</b>, it&#8217;s good but not good enough. If I could get samples at 2,000 per second I&#8217;d probably be OK, but it&#8217;s just not quite fast enough with it&#8217;s current, ultra-simplistic method of sample recording. I&#8217;ll figure out a fancier way to build a spectrum analyzer &#8211; it&#8217;s obvious the platform is there, it just needs some refinement.</p>
<p><iframe width="480" height="390" src="http://www.youtube.com/embed/chyJ3Fw0mPc" frameborder="0" allowfullscreen></iframe></p>
<p>A few stills:<br />
<a href="http://www.SWHarden.com/blog/images/diy-logic-analyzer-1.png" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/diy-logic-analyzer-1-525x237.png" alt="diy logic analyzer 1" title="diy logic analyzer 1" width="525" height="237" class="alignnone size-medium wp-image-2969" /></a><br />
<a href="http://www.SWHarden.com/blog/images/diy-logic-analyzer-2.png" onclick="javascript:urchinTracker ('/outbound/article/www.SWHarden.com');"><img src="http://www.SWHarden.com/blog/images/diy-logic-analyzer-2-525x239.png" alt="diy logic analyzer 2" title="diy logic analyzer 2" width="525" height="239" class="alignnone size-medium wp-image-2970" /></a></p>
<p><b>UPDATE!</b> The more I think about it, the more I think this might be just good enough to work!  Look at the stagger in those peaks near the top &#8211; that&#8217;s probably the lines telling which character to display. Data between the peaks indicates the value to be provided, and I should have enough time to accurately measure that&#8230; Maybe this is good enough after all? I&#8217;ll have to run some more tests tomorrow&#8230;</p>
<p><b>Where&#8217;s the code?</b> It kills me to do this, but I need to withhold the chip side code. I&#8217;m working on an idiot&#8217;s guide to USB connectivity with AVR microcontrollers, and I&#8217;d rather post the simplest-case code first, then share complicated stuff like this.  I&#8217;ll post the python scripts:</p>
<pre class="prettyprint python">
# LOGIC.PY - this script will log (or print) raw data from the USB device
from optparse import OptionParser
import time
import usb.core
import usb.util
import os

while True:
        print "\nTrying to communicate with the Gator Keyer ...",
        dev = usb.core.find(find_all=True, idVendor=0x16c0, idProduct=0x5dc)
        if len(dev)==0: print "FAIL"
        dev=dev[0]
        dev.set_configuration()
        print "there it is!"
        break

def readVals():
    x=dev.ctrl_transfer(0xC0, 2, 2, 3, 4).tolist()
    return x

def toBinary(desc):
	bits=[]
	for i in range(7,-1,-1):
		if (2**i&gt;desc):
			bits.append('0')
		else:
			bits.append('1')
			desc=desc-2**i
	return bits

def toStr(lists):
	raw=[]
	for port in lists: raw+=toBinary(port)
	return ''.join(raw)

### PROGRAM START ##################
live=False
#live=True
start=time.time()
if live==True:
	while True:
		a,b,c,d=readVals()
		if not a==123: continue #bad data
		elapsed=time.time()-start
		print "%.010f,%s"%(elapsed,toStr([b,c,d]))
else:
	times=0
	data=''
	f=open("out.txt",'a')
	while True:
		a,b,c,d=readVals()
		if not a==123: continue #bad data
		elapsed=time.time()-start
		data+="%.010f,%s\n"%(elapsed,toStr([b,c,d]))
		times+=1
		if times%1000==999:
			print "%d readings / %.02f = %.02f /sec"%(times,elapsed,times/elapsed)
			f.write(data)
			data=""
</pre>
<pre class="prettyprint python">
#logicGraph.py - this will show the data in a pretty way
import matplotlib.pyplot as plt
import numpy

c={
0:"",
1:"",
2:"blk sol",
3:"yel str",
4:"yel sol",
5:"pur sol",
6:"pur str",
7:"",
8:"",
9:"",
10:"blu sol",
11:"blu str",
12:"orn sol",
13:"orn str",
14:"pnk sol",
15:"pnk str",
16:"",
17:"",
18:"",
19:"",
20:"",
21:"",
22:"",
23:"",
24:"",
}

print "loading"
f=open("out.txt")
raw=f.readlines()
f.close()

print "crunching"
times=numpy.array([])
data=numpy.array([])
for line in raw:
	if len(line)&lt;10: continue
	line=line.replace("\n",'').split(',')
	times=numpy.append(times,float(line[0]))
	bits = []
	for bit in line[1]:
		if bit=="1":bits.append(1)
		else:bits.append(0)
	data=numpy.append(data,bits)

columns=24
rows=len(data)/columns
data=numpy.reshape(data,[rows,columns])
print "DONE processing",len(data),"lines\n\n"
print "plotting..."
plt.figure()
plt.grid()
for i in range(len(c.keys())):
	if c[i]=="": continue
	plt.plot(times,data[:,i]+i*1.1,'-',label=c[i])
plt.legend()
plt.show()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.SWHarden.com/blog/2011-07-16-half-hearted-diy-logic-analyzer-works-a-little/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

