Summary: A number of the device creation projects detailed on this website use the Atmel AVR microprocessor as the CPU or the ‘brains’ behind the device. However, before one can build any of these devices, one has to be able to get the firmware code on the AVR itself. There are a number of ways to achieve this and the method descibed here is probably not the most efficient way, but it does tend to be one of the less expensive ways of firmware loading and can also put to work some old equipment which you might have lying around earmarked for the trash heap.

 

Objective

Make a simple programming board to load firmware onto the Atmel AVR microprocessor.

 

Background

Having long ago established my set-up for loading code onto an AVR microprocessor, I tend to take for granted the ability to do so with relative ease and often forget that many an AVR beginner might not yet have the set-up for doing so. Since a number of the electronics projects on this website require the use of an AVR microprocessor, it seemed logical to document the building of a simple DIY programming board that anyone can make and that can be used as part of a system to get code onto the AVR. The method described is by no means the only or the best way to flash an AVR but it is a relatively inexpensive way of doing so and it is particularly useful if you have an old computer lying around that you would like to make use of beyond its paper-weight duties!

 

Methods

Computer & Software:

Image of an Atmel ATmega168 microprocessor

Atmel’s ATmega168

AVRs run on C code (with some additional libraries), and a computer is (obviously) needed to load this C code on to the AVR via a programmer. There are multiple ways of doing this, but if you have an old PC that is long past its expiry date, then you might be able to give it a new lease on life by re-tasking it to focus solely on AVR programming duties. To do so, it needs to be running Windows XP (other Windows versions might work but have not been tested with this set-up), and a couple of other bits of software should be added also. WinAVR is a software suite of commandline tools for prototyping on the AVR microprocessor and includes avrdude which is the actual AVR programming part of the software. In addition, Programmer’s Notepad is often recommended on top of WinAVR as it provides a graphical user interface for the AVR programming rather than just using only the commandline. One final requirement for the computer is for it to have a parallel port to connect to the AVR-PG2B programmer – other ports can be used instead but then the appropriate programmer, other than the AVR-PG2B programmer described here, needs to be chosen.

AVR-PG2B Programmer and Parallel Cable:

Image of a computer parallel cable

Parallel cable

Image of an Olimex AVR-PG2B programmer

AVR-PG2B programmer

As alluded to above, the programming board described here has been designed to work with the AVR-PG2B programmer which connects to the computer via an old-style parallel port. Impractically, the AVR-PG2B programmer comes with a very short ribbon cable between the parallel port connector and the pin header. Consequently, you almost certainly need some way of extending the connection from the computer to the programming board so that it remains within easy reach. This is important since the AVR microprocessor almost always goes back and forth between the programmer and the prototype circuit one is working as the firmware is tweaked to work optimally. In my case, I use a 2m parallel cable to provide the extension from the computer’s parallel port, and these days such cables are cheap to get online (if you don’t have already one forgotten about in an old drawer somewhere from computer days gone by).

Power Supply:

Image of a TENMA bench-top power supply unit

Benchtop Power Supply

The AVR needs a separate power source when being programmed (unfortunately this does not come from the parallel connection as it was never designed to power peripheral devices). There are a number of ways to accomplish this, but the easiest way is to use a standard bench-top laboratory-type power supply. Now you may wonder whether it is worth getting a power supply (if you don’t have one) just for AVR programming, but if you are in any way serious about electronic tinkering in any form (which you probably are if you are reading this!), then you will almost certainly want one anyway for prototyping. There are other less expensive ways to power the AVR programming board (such as using an appropriate wall-wart / AC-to-DC wall adapter with appropriate voltage) but extra power circuitry is needed to smooth out the voltage coming from these rudimentary power supplies and that is both for electronic prototyping as well as for AVR programming, so it’s worth investing in a bench-top power supply upfront.

PCB:

Image of a photo-etched printed circuit board for the AVR microchip-programming deviceThe PCB for the programming board was made using UV-light sensitive copper board according to the PCB photo-etching technique (picture right).  Since my AVR of choice in projects is most often the 28-legged ATmega168, the AVR programming board described here is fitted with a 28-legged position to accept this size of microprocessor. A Zero-Insertion-Force or ZIF socket is used to connect the AVR to the board so that the microprocessors can be inserted into and removed from the Schematic of the printed circuit board for the AVR microchip-programming deviceBoard layout of the printed circuit board for the AVR microchip-programming deviceprogrammer with ease – something that is important when prototyping, especially when different versions of the AVR code often have to be loaded in rapid succession. Header pins are used in places where connections to components, which are housed within the enclosure walls, are made (see below). A 15 MHz Crystal and two 15pF ceramic capacitors provide a clock signal for the AVR if its fuses have been set to use an external signal as opposed to its default internal oscillator. Finally, an LED was included as part of the design to provide a visual indication of when the AVR programming board was powered up.

Enclosure:

Image of the 3D model of the enclosure for the AVR microprocessor-programming device (lower part only)Image of the 3D model of the enclosure for the AVR microprocessor-programming deviceTo give the programming board a bit more of a polished look, an enclosure was designed around it and the components that need to be accessed or visible from the outside (such as the LED, switch and power supply connections) have been relocated to the surface of

Image of the PCB and the lower part of the 3D-printed enclosure for the AVR microprocessor-programming device

3D printed enclosure base

the enclosure. The enclosure was designed in Blender (www.blender.org) and is made up of 3 parts. The bottom half of the enclosure is pretty straightforward with the PCB itself attached using size 4 x 3/8″ pan-head screws, while the top half of the enclosure was designed as two separate parts so that it could be easily printed out on a basic 3D printer (in this case, the Velleman K8200) without the need for extensive amounts of support material. The two top parts of the enclosure are secured to the base with M3 machine screws – 20mm in length for the larger of the two enclosure parts, and 12mm for the smaller – and standard M3 nuts. Note the machine screws have a diameter head of …, which can vary between different screw manufacturers. An LED holder was used to hold the LED in place in the enclosure wall, while M2.5 machine screws and M2.5 nuts were needed to hold the power supply connector the the enclosure. The power switch is just a standard small rocker switch which it snaps into place on the enclosure. All the enclosure-attached components had wires soldered onto their connecting legs and standard crimp pins / crimp housings were used on the other ends of the wires to connect the components to the appropriate header pins on the PCB. One final note about the enclosure are the two semi-circular protrusions each side of the enclosure which were integrated into the design so that the whole unit could be secured to a table or similar with 3.5mm (countersunk) wood screws if the user desired.

Image of the programming device for the Atmel AVR microprocessor

File Downloads

Resource Links

 

Materials

TypeComponent Quantity
Resistors:330 Ω330ohms
1
Capacitors: (ceramic)15 pFceramic15pF
2
Rapid
Diodes1N4001Diode1N4001
1
Rapid
Header Pins1 & 2 pins (straight)1and2pins
6
2 x 5 pin header2x5header
1
ZIF Socket28-way28WayZIF2
1
Photo Etch PCB Kitkit
1
LEDs3mm3mmLED2
1
LED Holders3mm LED Holder3mmLEDHolder1
1
ebay
Switchsingle pole single throw (SPST) small_rocker_switch
1
Crystal15 MHz15MHzCystal
1
Farnell
Banana Plug SocketBananaSocket1
1
ebay
Pan-head Screw4 x 3/8"4xthreeEighthPanHead3
4
toolstation
Machine ScrewsM3 x 12mmM3x12machineScrew2
4
M3 x 20mmM3x20machineScrew2
4
M2.5 x 20mm
2
Rapid
Hexagon NutM3 M3 nut1
8
M2.5
2
Rapid
Accessories
AVR ProgrammerAVR-PG2BPG2B programmer
1
Olimex
Parallel CableMale-to-Female DB25parallel cable
1