AVR Drivers: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Some drivers have an Atmel microprocessor on board to control different modes. Atmel processors are programmable therefore the same driver can be loaded with different settings to give different numbers of modes, different output levels, as well as flashing modes like strobe or SOS, along with features like mode memory. This page will summarize some of the things you will need if you want to program your own drivers. This is based on a [http://budgetlightforum.cz.cc/node/799 Budget Light Forum discussion thread] where you can go for help or to get answers to your questions. This whole thing was started by a BLF member Tido.
Some drivers have an Atmel microprocessor on board to control different modes. This microprocessor controls the number of modes, the brightness of the modes, the different flashing modes (strobe, SOS, etc.), mode memory, and low battery warnings. Atmel processors are programmable therefore the same driver can be loaded with different settings to customize the light with whatever features you want. This page will summarize some of the things you will need if you want to program your own drivers. This is based on a [http://budgetlightforum.cz.cc/node/799 Budget Light Forum discussion thread] where you can go for help or to get answers to your questions. This whole thing was started by a BLF member, Tido.


All of this is based on AVR tools developed for Atmel chips, which is mostly open source (free). [http://en.wikipedia.org/wiki/Atmel_AVR Wikipedia article]. ISP means "In Sytem Programming," in other words, the chip can be reprogrammed while still soldered in place.
All of this is based on AVR tools developed for Atmel chips, which is mostly open source (free). [http://en.wikipedia.org/wiki/Atmel_AVR Wikipedia article]. ISP means "In Sytem Programming," in other words, the chip can be reprogrammed while still soldered in place.
Line 7: Line 7:
===Drivers===
===Drivers===


Of course you will need a driver 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. This is called Pulse Width Modulation (PWM). By slowing the flashing more, you get strobe modes 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.


The Atmel ATTiny13A has an 8-bit processor with 1 kb of flash memory, 64 bits of RAM, and 64 bits of EEPROM that can be written several thousand times. There are also settings called "fuses" which can be set or cleared.  
The Atmel ATTiny13A has an 8-bit processor with 1 kb of flash memory, 64 bits of RAM, and 64 bits of EEPROM that can be written several thousand times. There are also settings called "fuses" which can be set or cleared.  
Line 23: Line 23:
You need some kind of software to interface with the USB programmer and read or load programs into the Atmel chip.
You need some kind of software to interface with the USB programmer and read or load programs into the Atmel chip.


You will at least need AVRDUDE (AVR Downloader UploaDEr) to upload and download files to the Atmel chip. It is a command line interface (DOS). If you use Tido's programs then you don't need to compile anything. Those programs are ready to be loaded.
You will at least need AVRDUDE (AVR Downloader UploaDEr) to upload and download files to the Atmel chip. It is a command line interface (DOS). If you use Tido's programs then you don't need to compile anything: those programs are ready to be loaded.


If you want to customize the programs or write your own, you will need a compiler. The programs can be written in assembly language or C. Assembly can give more compact programs, but C is easier to write and understand, so that is what is being used so far. AVR Studio is available from Atmel to allow you to write and compile programs and load them. [http://winavr.sourceforge.net/ WinAVR] is a collection of all the software you need as well as a graphical user interface (GUI) to edit, compile, and load programs. Eclipse is another package that can be used to develop programming and is what Tido uses.
If you want to customize the programs or write your own, you will need a compiler. The programs can be written in assembly language or C. Assembly can give more compact programs, but C is easier to write and understand, so that is what is being used so far. AVR Studio is available free from Atmel to allow you to write and compile programs and load them. [http://winavr.sourceforge.net/ WinAVR] is a free collection of all the software you need as well as a graphical user interface (GUI) to edit, compile, and load programs. Eclipse is another free GUI that can be used to develop programming and is what Tido uses.


===BLF-VLD===
===BLF-VLD===
Line 79: Line 79:
|}
|}


So Wire 1 (MOSI) of the ribbon cable from the programmer must attach to Pin 5 of the Atmel. Make sure you mark which end 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.
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.


==Download settings==
==Download settings==