AVR Drivers: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
===Drivers===
===Drivers===


[[File:Avrisp.jpg|thumb|200px|SOIC 8 clip attached to flashlight driver board for AVR ISP programming]]
Of course you will need a flashlight driver circuit board first. There are several NANJG drivers available that include an Atmel TINY13A chip that can be programmed. These chips can also be locked down so they can't be changed, but so far none seem to be. However, some variants of NANJG drivers use a PIC chip that can not be programmed with AVR tools. See [[Popular drivers]] to see some of the drivers people have been using. Most of these use current regulators to limit the current delivered to the LED while the Atmel chip itself turns the power on and off very quickly, leaving it on for full power, or flashing on and off quickly to simulate a lower mode. As the percentage of off time increases, the light gets dimmer. By setting the on-off cycles to a high frequency, the eye just sees this as a lower mode even when the LED is barely lit. This is called Pulse Width Modulation (PWM). By slowing the flashing more, you get a visible strobe mode or SOS modes. So essentially the Atmel chip is just a computer-controlled on-off switch.
Of course you will need a flashlight driver circuit board first. There are several NANJG drivers available that include an Atmel TINY13A chip that can be programmed. These chips can also be locked down so they can't be changed, but so far none seem to be. However, some variants of NANJG drivers use a PIC chip that can not be programmed with AVR tools. See [[Popular drivers]] to see some of the drivers people have been using. Most of these use current regulators to limit the current delivered to the LED while the Atmel chip itself turns the power on and off very quickly, leaving it on for full power, or flashing on and off quickly to simulate a lower mode. As the percentage of off time increases, the light gets dimmer. By setting the on-off cycles to a high frequency, the eye just sees this as a lower mode even when the LED is barely lit. This is called Pulse Width Modulation (PWM). By slowing the flashing more, you get a visible strobe mode or SOS modes. So essentially the Atmel chip is just a computer-controlled on-off switch.


Line 14: Line 15:


You will need two pieces of hardware: an AVR ISP programmer that attaches to your computer's USB port and a clip to attach to the Atmel chip which is already soldered in place.  
You will need two pieces of hardware: an AVR ISP programmer that attaches to your computer's USB port and a clip to attach to the Atmel chip which is already soldered in place.  
[[File:Usbisp.jpg|center|thumb|400px|USB ISP programmer]]


There are a number of ISP programmers available, including one called USBTinyISP that you can build yourself from a kit. Ironically, it uses an Atmel chip as well which must be programmed before it can be used as a programmer. There are also a number of cheap drivers available on eBay if you search for USBASP. These all look similar with an exposed blue circuit board and cost about $12, usually including a ribbon cable, which you probably won't need.
There are a number of ISP programmers available, including one called USBTinyISP that you can build yourself from a kit. Ironically, it uses an Atmel chip as well which must be programmed before it can be used as a programmer. There are also a number of cheap drivers available on eBay if you search for USBASP. These all look similar with an exposed blue circuit board and cost about $12, usually including a ribbon cable, which you probably won't need.


The other piece of hardware is a SOIC 8 clip to attach to the pins of the Atmel chip on the flashlight driver. There are cheap ones on eBay that have been problematic, but will generally work. They cost about $12 as well. It is best to get one with a ribbon cable that attaches to pins coming out of the clip. The individual wires of the ribbon cable can be moved to the correct pins for the ISP programmer. See below for the proper configuration.
 
[[File:Soic8clip.jpg|thumb|200px|SOIC 8 clip with wires rearranged]]The other piece of hardware is a SOIC 8 clip to attach to the pins of the Atmel chip on the flashlight driver. There are cheap ones on eBay that have been problematic, but will generally work. They cost about $12 as well. It is best to get one with a ribbon cable that attaches to pins coming out of the clip. The individual wires of the ribbon cable can be moved to the correct pins for the ISP programmer. See below for the proper configuration.


===Software===
===Software===
Line 79: Line 83:
|}
|}


So Wire 1 (MOSI) of the ribbon cable from the programmer must attach to Pin 5 of the Atmel. Make sure you mark which side of the clip attaches to the top of the Atmel or everything will be misaligned next time you use it. Line up RST and SCK with their appropriate wires. But notice that MISO on the programmer is Wire number 9 and the ribbon only has 8 wires. You will need to disassemble the end of the ribbon cable at the controller end and move wire 8 over to the 9 position so that MISO lines up correctly.
 
[[File:Ribbon.jpg|thumb|The ribbon port at the end is disassembled and wire 8 is moved over to the 9th position]]So Wire 1 (MOSI) of the ribbon cable from the programmer must attach to Pin 5 of the Atmel. Make sure you mark which side of the clip attaches to the top of the Atmel or everything will be misaligned next time you use it. Line up RST and SCK with their appropriate wires. But notice that MISO on the programmer is Wire number 9 and the ribbon only has 8 wires. You will need to disassemble the end of the ribbon cable at the controller end and move wire 8 over to the 9 position so that MISO lines up correctly.


Communication with the Atmel chip is via Serial Peripheral Interface (SPI, see [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Wikipedia article]) with the ISP programmer a Master and the Atmel on the driver board a Slave. SCK is Serial Clock so they are in sync. The ISP programmer talks on the MOSI line (Master Ouput, Slave Input) while the Atmel talk back on the MISO (Master Input, Slave Output) line. RST is reset.
Communication with the Atmel chip is via Serial Peripheral Interface (SPI, see [http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus Wikipedia article]) with the ISP programmer a Master and the Atmel on the driver board a Slave. SCK is Serial Clock so they are in sync. The ISP programmer talks on the MOSI line (Master Ouput, Slave Input) while the Atmel talk back on the MISO (Master Input, Slave Output) line. RST is reset.