Tuesday, October 22, 2013

Arduino ATtiny programmer circuit

In several small microcontroller projects there is a need for just a few pins and only a few KB of code. Atmels series of ATtiny microcontroller serves this purpose and can be programmed using the Arduino IDE.

An ATtiny such as the ATtiny85 can not be connected directly to a computer via a FTDI cable but needs an Arduino (i.e., a ATMega328) in between. I built this little circuit which connects the SCK, MISO, MOSI and RESET of a ATTiny to an ATMega using the latter as an ISP. This small prototyping unit also has some header pins and a small solderless breadboard for prototyping circuits for the ATtiny.

The prerequisite to run this board is that the ATmega328 is preloaded with the Arduino bootloader. You also need to prepare the Arduino ISP for ATtiny microcontrollers.
  1. Download the zip file from GitHub.
  2. Unzip the zip-file and place the attiny folder under a "hardware" folder in your Arduino sketchbook directory.
  3. You should now see the ATtiny entries under the board menu in the Arduino ISP.
  4. Connect the FTDI adapter (as this one from Sparkfun).
  5. Select the Arduino Uno from the board menu.
  6. Upload the ArduinoISP sketch from the examples menu (you only have to do this once).

After that, you are ready to program the ATtiny. Follow this procedure:
  1. Open the Blink sketch from the examples menu.
  2. Change the pin number for the LED from 13 to 0.
  3. Select the ATtiny85 from the tools > board menu.
  4. Select "Arduino as ISP" from the tools > programmer menu.
  5. Upload the sketch and watch the LED (you just connected at pin 0 on the ATtiny85) blink.
The circuit diagram for my ATtiny-programmer board is shown below.

Female headers are used to break out all the pins on the ATtiny. I also added a DIP switch (not in the diagram) do disconnect the ATMega328 from the ATtiny once it is programmed.

More information about ATtiny Arduino stuff can be found in the links below:

The board can also be used to bootload an ATMega328 by connecting the SCK, MISO, MOSI and RESET pins to the female headers as shown in the above picture. In this case the ATtiny must be removed. You must also add a 16MHz crystal and 22pF decoupling capacitors as well as a 10K pullup on the reset pin. The schematics for such a bootload circuit is shown here.

1 comment: