Tap into the sum of all human knowledge and get your questions answered here!
From software algorithms to material selection, Mr. Roboto strives to meet you
where you are — and what more would you expect from a complex service droid?

by

Dennis Clark

Q. Our club is making a robot based on the Atmel
ATMEGA168. About half of the members use
either Mac OSX or Linux, not Windows. What can
we use to program our robots that isn’t Windows only?

A. Many fellow robot makers out there know that I am
a Mac fan and go out of my way to do just what you
are asking about. Sometimes there is no choice and
for that I have a Windows laptop. BUT, in this case you do
indeed have an option: avr-gcc. Avr-gcc is gcc, the open
source C and C++ compiler of choice for many environments,
customized for AVR programming. This environment can be
used on Windows (usually Winavr), Linux, and the Mac OS. In
this column, I’m going to detail where to find the parts, how
to install them, and how to configure it all to program your
robots. These packages usually want OSX 10. 3. 9 minimum;
I recommend 10. 4 (Tiger) to play in (mostly because that is
what I used — that and Leopard — so I know that it works).

Now that we have our context set up again, here is the
second part of this rather involved answer! In Part 1, we
got the avr-gcc compiler installed, the Eclipse IDE installed,
and the AVR plug-in installed that tied them all together.
In this installment, we’ll investigate compiling, setting the
fuses, and downloading the code to the AVR device. You’ll
be ready to go after this!

Setting up a Mac to Program
AVR Microcontrollers (Part 2)

There are three more pieces to the AVR development
puzzle that need to be solved. They are:

1) You’ll need to understand avrdude — the AVR programmer
that comes with the AVRMacPack install package. All that
you need is already there; we’ll see how to use it shortly.

2) You’ll need a programmer. There are a variety of DIY projects
out there for this, but because the Atmel programmers are
so inexpensive, it really isn’t worth your time to do anything
but buy one. My favorite is an AVRISP 2 clone made by

Pololu which be bought for about $28. It is hard to beat.

3) You need to understand how to program a device, which
means you need to read the datasheets and have some
understanding of what they mean.

Setting up an AVR programmer board

We’ll start here; it will make the rest of the discussion
easier to understand if we have some example hardware to
work with. As I mentioned above, an inexpensive and useful
programmer is an AVRISP 2 from Pololu. (Find it at www.
pololu.com/catalog/product/740.) You need to add your
own USB cable, however, if you have a digital camera chances
are you have the cable you need already. The programmer
board can also be used as a USB-to-serial converter by
moving a jumper, which might come in handy sometime.
Figure 1 shows what the programmer board looks like.

To test this entire process, we’re going to need an AVR
Tiny26 that we can program. I have a robot controller that I
made for a class that I taught at a local community college
a few years ago that had what I needed on it. Figure 2
shows the schematic for this board. The “Hello World”
program of the embedded world is blinking LEDs; that is
what the example program I created for this article does.