3. Configuring the Arduino Environment

The configuration instructions in this section explain how to alter the Arduino IDE so that it programs your Orangutan or 3pi robot using the correct settings, using either an AVR ISP programmer that supports the avrispv2 protocol (such as the Pololu USB AVR Programmer) or an Arduino bootloader.

  1. Go to http://www.arduino.cc/en/Main/Software and download the latest Arduino software for your platform (Arduino 1.0.1 as of this writing).
  2. Add the following to the end of the boards.txt file in the arduino-1.0.1/hardware/arduino directory:

      ##############################################################
      
      orangutan48pgm.name=Pololu Baby Orangutan B-48 via Programmer
      
      orangutan48pgm.upload.using=avrispv2
      orangutan48pgm.upload.maximum_size=4096
      
      orangutan48pgm.build.mcu=atmega48
      orangutan48pgm.build.f_cpu=20000000L
      orangutan48pgm.build.core=arduino
      orangutan48pgm.build.variant=standard
      
      ##############################################################
      
      orangutan168pgm.name=Pololu Orangutan or 3pi robot w/ ATmega168 via Programmer
      
      orangutan168pgm.upload.using=avrispv2
      orangutan168pgm.upload.maximum_size=16384
      
      orangutan168pgm.build.mcu=atmega168
      orangutan168pgm.build.f_cpu=20000000L
      orangutan168pgm.build.core=arduino
      orangutan168pgm.build.variant=standard
      
      ##############################################################
      
      orangutan328pgm.name=Pololu Orangutan or 3pi robot w/ ATmega328P via Programmer
      
      orangutan328pgm.upload.using=avrispv2
      orangutan328pgm.upload.maximum_size=32768
      
      orangutan328pgm.build.mcu=atmega328p
      orangutan328pgm.build.f_cpu=20000000L
      orangutan328pgm.build.core=arduino
      orangutan328pgm.build.variant=standard

    This will add three options to the Tools > Board menu of the Arduino IDE.

    If you would rather use a different programmer that does not support the avrispv2 protocol, then change the upload.using lines to match the name of your programmer/protocol, and skip Step 3 (if your programmer is already defined by the Arduino environment) or add the corresponding entry for your programmer in programmers.txt.

    These next two entries are optional, but allow you to use an Arduino bootloader instead of an external programmer:

      ##############################################################
      
      orangutan168.name=Pololu Orangutan or 3pi robot w/ ATmega168 via Bootloader
      
      orangutan168.upload.protocol=arduino
      orangutan168.upload.maximum_size=15872
      orangutan168.upload.speed=144000
      
      orangutan168.bootloader.low_fuses=0xF6
      orangutan168.bootloader.high_fuses=0xDD
      orangutan168.bootloader.extended_fuses=0x04
      orangutan168.bootloader.path=optiboot
      orangutan168.bootloader.file=optiboot_atmega168.hex
      orangutan168.bootloader.unlock_bits=0x3F
      orangutan168.bootloader.lock_bits=0x0F
      
      orangutan168.build.mcu=atmega168
      orangutan168.build.f_cpu=20000000L
      orangutan168.build.core=arduino
      orangutan168.build.variant=standard
      
      ##############################################################
      
      orangutan328.name=Pololu Orangutan or 3pi robot w/ ATmega328P via Bootloader
      
      orangutan328.upload.protocol=arduino
      orangutan328.upload.maximum_size=32256
      orangutan328.upload.speed=144000
      
      orangutan328.bootloader.low_fuses=0xF6
      orangutan328.bootloader.high_fuses=0xDE
      orangutan328.bootloader.extended_fuses=0x05
      orangutan328.bootloader.path=optiboot
      orangutan328.bootloader.file=optiboot_atmega328.hex
      orangutan328.bootloader.unlock_bits=0x3F
      orangutan328.bootloader.lock_bits=0x0F
      
      orangutan328.build.mcu=atmega328p
      orangutan328.build.f_cpu=20000000L
      orangutan328.build.core=arduino
      orangutan328.build.variant=standard

    If you want to use the bootloader, you will still need to use an AVR programmer to initially load the bootloader onto your Orangutan or 3pi, and you will also need to obtain a USB-to-serial adapter or RS-232-to-TTL serial adapter through which the Arduino software can talk to the Arduino bootloader on your device. The Pololu USB AVR Programmer can serve as your AVR ISP programmer and USB-to-serial adapter.

    Note that you will have to either reset the Orangutan/3pi manually when programming it with the bootloader or modify the hardware to allow the DTR control signal to auto-reset the microcontroller.

    Be aware that the Baby Orangutan B-48 has an ATmega48 microcontroller, which lacks a bootloader section, meaning the B-48 version can only be programmed using an ICSP.

  3. If you are using an AVR ISP programmer such as our USB AVR Programmer, add the following to the end of the programmers.txt file in the arduino-1.0.1/hardware/arduino directory:

      avrispv2.name=AVR ISP v2
      avrispv2.communication=serial
      avrispv2.protocol=avrispv2

    This will allow the Arduino IDE to program with the avrispv2 protocol used by our USB AVR Programmer.