Hello UAV world

My UAV project has taken its first steps. I got the Atmega16 microcontroller last week, and set about doing the hardware equivalent of “hello, world”, 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.

Mental note: Must buy a bench power supply. I’m fed up building LM7805-based battery-driven power supplies every time I do anything electronic.

Further note: LM7805’s don’t immediately blow up if you plug them into back-to-front.

Final note: Neither do electrolytic capacitors, as far as I can make them, despite dire warnings about their explosive tendencies. They mostly die quietly.

The Atmega16 chip is supported by gcc, and Gentoo linux makes it easy to get this all set up. You just “emerge crossdev” then run “crossdev -target avr”. 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.

Next, I need to get programmer software working so I could download my program onto the chip. I tried PonyProg 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 avrdude which is much better (more configurable and better error messages) but still had no success. I kept getting “Verify error – unable to read hfuse properly” 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 …

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 – 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’m not into the whole “compiler, burn, test” cycle … ocaml/ruby/lisp has spoiled me too much.