{"id":133,"date":"2006-02-07T22:49:06","date_gmt":"2006-02-07T21:49:06","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/?p=133"},"modified":"2006-02-07T22:49:33","modified_gmt":"2006-02-07T21:49:33","slug":"hello-uav-world","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2006\/02\/07\/hello-uav-world\/","title":{"rendered":"Hello UAV world"},"content":{"rendered":"<p>My <a href=\"http:\/\/www.nobugs.org\/blog\/archives\/2006\/01\/30\/the-plane-that-flies-itself\/\">UAV project<\/a> has taken its first steps.  I got the Atmega16 microcontroller last week, and set about doing the hardware equivalent of &#8220;hello, world&#8221;, which involves flashing an LED off and on.  I breadboarded a circuit with 5v and an LED on the first output line.  I had expected that the chips memory was blank and would require some initial programming, and so was pleasantly surprised when I powered it up and saw the LED blinking all by itself.  The chip must come with a rather useful default program!  A good start.<\/p>\n<p>Mental note: Must buy a bench power supply.  I&#8217;m fed up building <a href=\"http:\/\/www.national.com\/pf\/LM\/LM78L05.html\">LM7805<\/a>-based battery-driven power supplies every time I do anything electronic.<\/p>\n<p>Further note: LM7805&#8217;s don&#8217;t immediately blow up if you plug them into back-to-front.<\/p>\n<p>Final note: Neither do electrolytic capacitors, as far as I can make them, despite dire warnings about their explosive tendencies.  They mostly die quietly.<\/p>\n<p>The Atmega16 chip is supported by gcc, and Gentoo linux makes it easy to get this all set up.  You just &#8220;emerge crossdev&#8221; then run &#8220;crossdev -target avr&#8221;.  This produces avr-gcc (and libs\/headers in \/usr\/avr).  Finally, you run avr-gcc -mmcu=atmega16 and it generates appropriate code for the chip.  The avr-objcopy converts from ELF format to HEX format used by most programmers.<\/p>\n<p>Next, I need to get programmer software working so I could download my program onto the chip.  I tried <a href=\"http:\/\/www.lancos.com\/prog.html\">PonyProg<\/a> first.  It could read the chip memory fine, but failed to write.  I spent hours trying different delay values, checking and rechecking the connections to no avail.  Next, I tried <a href=\"http:\/\/www.bsdhome.com\/avrdude\/\">avrdude<\/a> which is much better (more configurable and better error messages) but still had no success.  I kept getting &#8220;Verify error &#8211; unable to read hfuse properly&#8221; errors, which suggested that the cable from the PC to the Atmega board was flaky and unreliable.  After many more frustrating hours, I tried using a avrdude on a different PC and it worked first time.  Perhaps I cooked the parallel port on my desktop last time I did hardware &#8230;<\/p>\n<p>Next step is to get my PC and the Atmega chip talking over a serial link, which just requires a MAX232 chip to convert the voltage levels &#8211; the Atmega16 has a builtin USART.  Then I can see about getting a forth interpreter running on the chip to allow me to do interactive experiments.  I&#8217;m not into the whole &#8220;compiler, burn, test&#8221; cycle &#8230; ocaml\/ruby\/lisp has spoiled me too much.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My UAV project has taken its first steps. I got the Atmega16 microcontroller last week, and set about doing the hardware equivalent of &#8220;hello, world&#8221;, which involves flashing an LED off and on. I breadboarded a circuit with 5v and an LED on the first output line. I had expected that the chips memory was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-uav"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}