Build the chip's programming board

Think of the circuit board as a ready application. This is actually your target circuit, the exact same thing you want to install somewhere after the chip is programmed.

Just, to this end-application circuit board, you add a 10 (or 6) pin male plug that connects with the ISP cable.

One key requirement of the circuit board is that it provides the AVR chip with power, also and particularly while programming the AVR chip. During programming, the ISP is also powered from this board.

board_and_isp.jpg This is the garden shack interpretation of an ISP cable and a programmer board. The board hosts an ATMEGA8 which is driven by a 4 MHz oscillator. The transistors on the right are driving an old train station clock.

Above you can see my first AVR application. That sticking out black-and-metal component on top with the hole in it is a 5 V voltage regulator. As long as the input voltage is above seven-something volt, it delivers a solid 5 V output voltage -- ideal for the AVR. I can plug in any DC power source and still have the correct voltage. A voltage regulator is not one of the most power efficient components, though.

The red components close to the voltage regulator are capacitors that filter out noise -- one on the input side, the other on the output side of the voltage regulator.

The silver rectangular box is a 4 MHz Quartz Crystal Oscillator, which is connected to time the AVR chip. ATMEGA chips come with an internal 1 MHz oscillator based on an RLC circuit -- not very precise, but useful for programming the chip. A Quartz is what you need for good timing.

Note that the newer type of Quartz comes in a smaller black case and draws less current than the metal case version. They are called CMOS.

All components to the right of the Quartz are specific to my application (you don't need them) -- they drive a classic old clock my father retrieved from a rubble heap at an old train station site.

This is actually a pretty boring task for a versatile chip like the ATMEGA.

Circuit diagram

Below is the circuit I use to program an ATMEGA AVR chip with my PC and the In-System Programmer (ISP) I built before.

Note that the Quartz is not needed for programming. It will only be used when the ATMEGA is running on its own.


Shopping list

Important design guidelines

Do not draw heavy current from the output pins. See the circuit picture above for an example of how to drive heavy current components: here a relay is switched using a transistor. A LED should always have a 1k = 1000 Ohm resistor in series, and LEDs must not share resistors if they are going to be on simultaneously.

Note that some of the output pins are used for programming the ATMEGA8: PB3..PB5 must be able to switch between 0V and 5V for communication with the computer. You can connect LEDs (with resistors) and watch the communication.

Token explanations

The 10 k resistor keeps RESET disabled at 5 volt until an explicit zero is sent to enable RESET for programming. The 47pF capacitor slightly stabilizes the RESET line, making it less sensitive to spikes or such.

The two capacitors around the 5V voltage regulator ("L78S05") stabilize the 5V, getting rid of any ripple the voltage regulator might receive or cause.

The quartz is a complete quartz oscillator. So the timing circuit examples seen on ATMEL's datasheets are spared. Those circuits use mere quartz crystals. (note the difference: quartz oscillator -- quartz crystal. A crystal still needs to be excited, where an oscillator swings on its own when powered up.)

For the relay circuit, you can use an ("old style") npn Binary Junction Transistor, or a ("new style") n-type MOSFET transistor. The MOSFET does basically the same as the npn: it can switch on and off stronger power according to a low power signal. The two main differences: the pins have other names and in the MOSFET there is no current flowing from the controlling signal into the transistor at all.

Transistor leg names

In the npn BJT (binary junction transistor):

In the n-type MOSFET (metal oxide field effect transistor):

basically, MOSFET = BJT:

but a MOSFET is much cooler than a BJT (draws no gate current).

[Next section]
login 2010-08-13 03:19