I have been programming my ATmega328 with OPTIBOOT Bootloader chips on a breadboard for the last 6 months and I always dreaded the moment when I had to pry the chip out of the breadboard because I was afraid some pins might get bent so I went online to look for a ZIFF socket and found this. The price was so cheap I couldn't resist . When I received it and looked at the pins I realized that they wouldn't fit in a breadboard and that in order to use it I would have to build a custom protoboard. After I started building it , it occurred to me that it would be nice to add an ATtiny85 programming circuit to the same protoboard. I already have a Kickstarter ATtinyISP but for those who don't have one you can use this.
The schematic for the ATtiny85 programming circuit is here (schematic attached) and the schematic for the ATmega328 programming circuit is here.. By combining the two circuits on a protoboard with an LM7805 regulator mounted on a beefy heatsink, you wind up with a board that you can use to program both chips. You can take the
DIPMICRO ATmega328 right out of the tube , drop it in the 28-pin ZIFF socket, use the onboard off the shelf FTDI module like this or this cp2102 TTL-UART Module. to upload your sketches from your computer. You just need to install the proper driver on your computer. I chose the second one, the CP2102 TTL-USB Module. Either one will work. The FTDI driver for the FT232 module can be found on the FTDI website. A photo of the finished board is attached.
A few things to make note of:
1- Make sure to cross the RX , TX from the ATmega328 with RX, TX from the FTDI module
(RX --> tx, TX ---> RX), otherwise it won't work.
2- Make SURE to GROUND the CTS signal from the FTDI module (or TTL-UART Module)
One thing to be aware of here: the CTS signal on the FTDI is clearly visable (with a magnifying glass , on the second pin from the right , just to the left of the GND pin. However, the cp2102 has extra pins on it that the FTDI doesn't have and the CTS pin is not located on the 6 pin male header at the end of the board like it is with the FTDI. Instead it is located on one of the pins on the side. Those pins are clearly labeled on the bottom and easy to read. The CTS pin MUST be connect to GND or the module won't send anything. Why ? Because CTS stands for CLEAR TO SEND. It floats HIGH, so if left unconnected to anything the board will assume it is NOT clear to send (CTS). This is an ACTIVE LOW
signal so to be TRUE, it must be LOW (GROUNDED).
3- The ATtiny85 RESET pin (pin 1 of the chip ) MUST be connected to pin-10 of the ATmega328. It CANNOT be connected to the ATmega328 RESET pin.
4- The most well known source for instructions on how to program an ATtiny85 is the MIT HighLow_Tech tutorial. You can also use the Instructable Programming the ATtiny85 using an UNO
5- Don't try to use an LM7805 without the heatsink, especially if you input voltage is 12Vdc , like mine. It will overheat and shutdown after a few minutes. I learned that 3 years ago. That's why I have such a beefy heatsink on my board. this is the heatsink I used.
6- Intall RESET circuits for both the ATmega328 and the ATtiny85 by connecting a 10 k ohm resistor from the reset pin to +5V , and a tactile push button to GND. This keeps the reset pin HIGH
until you press the button and short it to GND.
7- Make sure to add three LEDs,
a- Power led, on when +5v is present
b- led to D13 , (called PB5 on ATmega328 Datasheet. It is pin-19 of the 28 pin chip.
DO NOT connect the LED directly to the pin ! Connect a 470 ohm resistor to the pin and connect the LED from the resistor to GND, (CATHODE to GND) (CATHODE IS THE SHORTER PIN).
c- LED to ATtiny85-pin-5 (called PB0 on the ATtiny85 datasheet of the ATtiny85.
Again , DO NOT CONNECT THE LED TO THE pin. Connect a 470 ohm resistor to the pin and the led from the resistor to GND, (cathode to GND).
8- Make SURE to connect a 0.01 uF cap from the DTR SIGNAL of the FTDI (or the TTL-UART Module) to the RESET pin of the ATmega328. (in series, NOT to GND). The DTR signal does NOT connect directly to the ATmeag328 chip. It connects to one side of the 0.01 uF cap and the other side of the cap connects to the ATmega328 RESET pin.
9- Put 10 uF electrolytic filter caps on the input and output of the LM7805 , to GND.
10- Print this (ATmega328 Pin Mapping)
11- If for any reason you decide to add an ICSP 6-pin Male header to your board, DO NOT connect the RESET pin on that header to the reset pin on the ATtiny85 !
12- Add an ON/OFF switch (SPST) in series with the INPUT power of the LM7805 voltage regulator so that when that switch is OFF, there is NO power anywhere on the board.
13- You can print out all the relevant schematics I linked, but when you start wiring the board, print a SECOND copy of EACH, and get a yellow , fine tip felt marker and after EACH wire you connect, HIGHLIGHT the connection you just made. If you follow this procedure RELIGIOUSLY , you can be interrupted from your work a hundred times and when you come back you will always know EXACTLY where you left off.
14- When you complete the board , you must install the ATtiny85 CORES in your Arduino folder in My Documents. This is going to be in a folder named Hardware. There should only be two folders in the My Documents folder, one is "Libraries" {where all the user installed libraries are located} , the other is "Hardware " {where the ATtiny85 CORES are located.
15- To program the ATtiny85 you need to load "File\Examples\ArduinoISP".
THEN, you need to CHANGE the "Tools/Board" " to ATtiny85 (1 Mhz (Internal Oscillator, BOD disabled)
THEN you need to change "Tools/Programmer" to "Arduino as ISP"
THEN and ONLY THEN, can you load a sketch to the ATtiny85. (remember, the pin names are different . This is a useful tutorial on ATtiny85 pin names.
ENJOY !
Note- Attached is a sketch for the ATtiny85 that blinks the led at 1 second..
To use ATtiny85s at 8 and 16 Mhz, read this post
NOTE: The 8 Mhz and 16 Mhz board configurations work with IDE Version 1.0.5 (just tested it).
I do not know what OTHER versions it works with (besides V 1.0.5) If you find out please post here to let others know.
If you load the attached sketch "Blink_t85_ok" with the board 1 Mhz selected the led will blink at 1 second. If you change the board file to 8 Mhz WITHOUT burning BOOTLOADER , the led will blink 8 times longer (8 seconds) because the fuses have not been set for 8 Mhz.) If you then Burn Bootloader to set the fuses , the led will blink the correct duration of 1 second. This is the method I use to verify that the 8 Mhz board file configuration is working. (if it were not, the led would blink 1 second with the 8 Mhz board selected. Once you have verified that the board file is working using the above method you can then burn bootloader to set the fuses. (the same process works for the 16 Mhz configuration. Knowing this will tell you in the future if you have forgotten to "Burn Bootloader".
Blink_t85_ok.ino (754 Bytes)