Monday, May 20, 2013

ATtinyShield: Arduino ATtiny85 Programmer Shield

INTRO…

Arduino projects are very popular but also big and expensive. There are many times that we don’t need so many input or output pins. As a matter of fact, most projects could be accomplished with only 2 or 3 inputs and outputs. Besides the size, using one Arduino board for each small project can be costly.

Image Hosted by ImageShack.us
Atmel's tiny... ATtiny85
     So the solution is given (again) by Atmel with the ATtiny microcontrollers. Especially the ATtiny85 chip, which has 8 Kb flash memory, 6 input/output pins, low power supply at 1.8-5.5V, small 8-pin packaging and costs only 2-3$.
 
Image Hosted by ImageShack.us
ATtinyShield - easy Arduino programming
     It is very easy to program the ATtiny85 using our own Arduino board based on the tutorial Arduino-based ATtiny programming (http://hlt.media.mit.edu/?p=1695) published by MIT’s High-Low Tech research group. So we have to connect the ATtiny85 (pins 1, 5, 6, 7) with 4 digital outputs of our Arduino (pins 10, 11, 12, 13), give 5V and Ground to pins 8 and 4 of the microcontroller and finally place a 10uF Electrolytic Capacitor between the Reset and Ground of the Arduino.

Image Hosted by ImageShack.us
Image Hosted by ImageShack.us     In my project I have added an indicator LED on pin 9 of the Arduino that shows that the programmer is running properly and a reset tact switch for the ATtiny85.
 
     So by creating a small shield with all these connections, it’s easy to plug it on our Arduino and worry only about the programming stuff. This is what ATtinyShield is doing for us.

If you want to buy this shield check, my EBay listing:

You will get:
  • The shield with printed and already etched PCB with color silkscreen on it, and of course the components soldered on it. It will be fully functionable ready to program.
  • An Attiny85 20PU chip for your first experiments.
  • A detailed printed (and pdf) guide (in color) for the connections and the whole programming procedure.
  • The RGB-Tiny board, a small PCB with RGB Led, controlled by an ATtiny85 for your first experiments. With code provided you will be able to fade the Led to all colours or any other programming you want.
 WHAT ELSE IS NEEDED…

Image Hosted by ImageShack.us     Before we start, let’s check what is needed:
     • An Arduino Uno board (Uno is a verified version that works fine).
     • An ATtinyShield (to be placed on the Arduino) with an ATtiny85 on it.
     • The Arduino IDE (the software) version 1.0.1 (also verified version that works fine).
     • Attiny.zip (https://github.com/damellis/attiny/), containing the necessary files for the software.
 
 SETTING UP THE HARDWARE…

Image Hosted by ImageShack.us     First attach the ATtiny85 on the shield (check the indicator) and the little jumper connection on the 5V selection (5V – SEL, just confirm it). We are ready to place it on the Arduino board.
     The connections are as following:
     • The 5 pins connector (DATA) of the ATtinyShield to pins 9 – 13 (DIGITAL) of the Arduino board.
Image Hosted by ImageShack.us     • The 4 pins connector (POWER) of the ATtinyShield to pins RS – 3.3 – 5V – GND (POWER) of the Arduino board.
     If everything went normally, you must have an easy fit. If not it might help tilting the pins a bit. 
 
 SETTING UP THE ARDUINO IDE…

     Now that the connections are done, we have to set the software of the Arduino IDE for the programming phase.
     As seen on the photos below, we have to follow some more steps:
     1: Open your Arduino IDE 1.0.1 version. Make sure you have the COM port and your Arduino board set correctly.
Image Hosted by ImageShack.us
      2: Go to FilePreferences.
Image Hosted by ImageShack.us
      3: Copy the Sketchbook location mentioned on this window.
Image Hosted by ImageShack.us
      4: Navigate to this folder and you’ll find a subfolder named Hardware in it – if not create it.
Image Hosted by ImageShack.us
      5: Download the necessary files for the ATtiny85 ATtiny (from https://github.com/damellis/attiny/) and extract it in this folder (Hardware). This step is only done once.
Image Hosted by ImageShack.us
      6: Restart the Arduino IDE and in the Board section you must have a lot of new choices. Do not change the board yet.
Image Hosted by ImageShack.us
      7: Select Arduino as ISP on the Programmer menu.
Image Hosted by ImageShack.us
      8: Now let’s run the script that will turn our Arduino into an ISP programmer. Go to FileExamplesArduinoISP
Image Hosted by ImageShack.us
      9: This sketch will also test our shield. The LED we have connected on pin 9 is the Heartbeat LED, that shows the programmer is running fine. Let’s upload it and see if it will light.
Image Hosted by ImageShack.us
      10: Now that the sketch is uploaded, the LED must light, like a heartbeat… If not, check the ATtiny85 installation on the DIP socket and rerun steps 5 to 9.
Image Hosted by ImageShack.us
      11: Go to Tools, change the Board and select the ATtiny85 with internal 1 MHz clock.
Image Hosted by ImageShack.us
      12: Now it’s time to upload the Blink (or any other) sketch to ATtiny85. Load it from the Examples menu.
Image Hosted by ImageShack.us
      13: Change the pin of the LED on line 10, from 13 to 0. Refer to the ATtiny85 pin-out image.
Image Hosted by ImageShack.us
      14: Finally upload it and ignore the 2 avrdude error messages (if errors appear). You are DONE.
Image Hosted by ImageShack.us
  
 TESTING…

Image Hosted by ImageShack.us     The small microcontroller is ready to be tested. You can leave it on the ATtinyShield and test it there, while it is powered by the Arduino. But let’s try it out on a breadboard and see if the Blink function is activated.
Image Hosted by ImageShack.us     Connect pin 4 of ATtiny85 to the Ground and pin 8 to 5 Volts. Then connect the pin 5 (that is referred as pin 0 on the pin-out schematic) to a LED (through a small 200 Ohm resistance). It must blink with a second of period.
 The programming worked!
 
 TROUBLESHOOTING…
 
     If something went wrong and the chip isn’t properly programmed these might be some reasons.
PROBLEM
REASONS
SOLUTIONS
1. When uploading the Arduino ISP, the Heartbeat LED doesn’t work and the IDE returns errors.
1.a. The software doesn’t have the necessary ATtiny files.
1.a. Check steps 2-5 again, so that the files are in the correct folder.
1.b. Sometimes the ISP must be uploaded without the ATtinyShield on the Arduino board.
1.b. Just remove the shield and re-upload the ISP sketch. Then – after uploaded – plug the shield.
2. When uploading a script the Arduino IDE returns errors.
2.a. The ISP isn’t properly uploaded.
2.a. Check Troubleshooting case 1.
2.b. The ATtiny board isn’t correctly selected.
2.b. In the board section select ATtiny85 with 1 MHz clock.
2.c. Some errors, like Avrdude type, may not cause any problem.
2.c. Try ignoring them if the script is uploaded despite the errors and test the chip.
3. When tested the LED connected on ATtiny85’s pin 5 doesn’t flash.
3.a. The ATtiny85 isn’t connected properly on the shield.
3.a. Check the DIP pin holder for the mark and match it with the chip.
3.b. The Input / Output pins of the ATtiny85 are 0-5.
3.b. In the Blink sketch, the pin must be changed from 13 to 0. 

1 comment:

  1. The only trouble that I had, was that with the shield connected, I couldn't upload the ArduinoISP sketch. With the shield removed, the sketch uploaded fine, and then after connecting the shield and selecting the right attiny board, everything went smoothly.

    This is a good quility Arduino shield. It is much easier than using jumper wires and breadboards if you want to program attiny chips.

    ReplyDelete