Monday 7 January 2013

A Low Cost Serial Programmer for AVRs


The Serial Programmer for AVR

A hardware device is required to load your program (in the form of Hex file!) into the Flash memory of the Micro-controller, after which it performs according to the program instructions inside it. The device is called a Programmer. The above circuit is of a serial programmer for AVR micro-controllers which is easy to build at a low cost in home. Most of the PC's and Laptops have a serial port, so it can be used in both with ease.

[N.B. This programmer will not work with USB-SERIAL converters. It only works with native Serial Port.]

In-System Programming 

In-System-Programming is a feature which allows programming and reprogramming of any AVR micro-controller at the end system. Simply put, if you have a micro-controller which lists that it is “In-System-Programmable” then you will be able to program it on site. Which is unlike older MCU’s which would have to be removed from the main target system and then put into a separate hardware programmer to burn their flash (loading the firmware into the flash memory). For example lets say, you need to upgrade the software version in your Android phone (i.e. if you want to install the latest Android Os.), then you don’t need to take your phone to a service centre! You can just download it and upgrade your software version right from your phone. This would be possible because the phone’s processor is “In-System-Programmable”.
"In-System Programming eliminates the physical removal of the chips from the system. This saves time, and money, both during development in the lab, and when updating the software and parameters in the field", 

The Serial Programmer
Here is the PCB etch diagram which is pretty simple and can be etched easily by toner transfer or any other method of PCB etching. Or you can even try to solder the components on a pointed vero board according to the PCB layout.
PCB layout for Etching.


You can connect your serial programmer to an Atmega 8 as shown in the following figure. [Image courtesy : electronics-diy.com]

You can also build a simple socket board for programming your Atmel AVR 8 (you can also have an ISP connector for your development board according to the programmer ISP layout and then you can directly plug in the programmer to your board) as shown in the following picture. [Image courtesy : electronics-diy.com]

Socket PCB for an AVR Atmega 8

Extra bit (For Advanced Readers)

Most AVR devices have a facility known as SPI which stands for Serial Programming Interface. This is the functionality that allows us to program (load the firmware in the flash memory of the MCU) the micro-controller.
The SPI is a pretty simple programming interface (the hardware philosophy behind loading the flash memory with the firmware) which incorporates only three wires. The serial programming interface (SPI) consists of three wires: The MISO (Master Input-Slave Output) line, MOSI (Master Output-Slave Input) line and the SCK (System Clock) line.
Here in this serial programmer we have used these three SPI lines along with the Ground, VCC and Reset pin.
While programming the AVR, the in system programmer always operates as the Master mode, and the target system always operates as a Slave mode.
The In-System Programmer (Master) provides the clock for the communication on the SCK Line. Each pulse on the SCK Line transfers one bit from the Programmer (Master) to the Target (Slave) on the Master Out – Slave In (MOSI) line. Simultaneously, each pulse on the SCK Line transfers one bit from the target (Slave) to the Programmer (Master) on the Master In – Slave Out (MISO) line.
The programmer is quite simple and it is based on the SI-Prog from the author of PonyProg software. The Zener diodes D2, D3 with the resistors R1, R3 reduce the voltage from the ouput pins DTR, RTS on the serial port to around 5V which is suitable for microcontroller (MOSI, SCK). MISO signal is connected directly to the input CTS pin. The Zener diode D1 with the resistor R2 drive the NPN transistor T1, which controls the RESET signal. The AVR microcontrollers are in reset when the signal has low level. The resistor R5 works as a pull-up for reset signal. 

Software 

PonyProg software is required to program using this serial device. Its an open source software hosted by http://www.lancos.com/prog.html

Click here to download the Eagle files for the Schematic and the PCB layout. [This link will soon be available- check this space!]



1 comment:

  1. Please provide link to Eagle files or send a mail with link
    Thank you

    ReplyDelete