How to get rid of your prototype board

[Image]
The ATmega328 microcontroller, just removed from the Arduino board, ready to start living on its own.

When you started discovering microcontrollers, you probably bought some kind of evaluation or prototype board. The microcontroller chip itself is placed in a nice socket on a PCB, surrounded by power circuit, some I/O, and RS232 or USB connector for programming. But after a while you want to remove the chip from the board and place it in your first own application. What do you need to get the chip running?

Microcontrollers always require at least three things:

  1. power;
  2. clock signal;
  3. reset circuit.

Sometimes option 2 and/or 3 are internally managed and can therefore be skipped. To find out what your microcontroller requires, first download the corresponding datasheet and find out what options are applicable to your project. Down here I will discuss each of these requirements and provide some example solutions.

Power

Every microcontroller needs power. Most require 5 Volt, some 3.3 Volt. Check your datasheet to find out.

There are many ways to achieve this voltage. In most cases the microcontroller is just a part in a larger circuit, so there will be DC power available already, maybe 9 or 12 Volt. Using a voltage regulator will provide you the appropriate voltage for your microcontroller. Whatever your power source is, the power should be very stable and clean, so some way of voltage regulation is mandatory. Interesting 5 Volt regulators are the classic LM7805, its smaller brother 78L05 (TO-92 case) and the MAX604 (low voltage drop). For 3.3 Volt you may consider the LM7833 (a.k.a. UA78M33) and MAX603. Low drop regulators are especially interesting when using battery power, e.g. 4 AA(A) batteries making 6 Volts.

Whatever your power source is, it is always good practice to place a capacitor (100 nF ~ 1 uF) close to the power pin of the chip to filter out glitches caused by other parts of your circuit or interfering signals.

Clock signal

Every processor needs a clock signal, so does the processor in your microcontroller. Most have multiple options to get a clock signal:

  1. full internal oscillator;
  2. internal oscillator which requires some external parts to get running;
  3. external oscillator.

The full internal oscillator (option 1) is useful when size matters; each external component requires space. Since this oscillator is typically of the RC type, it is not very stable and runs on a rather low frequency.

If you want to run your chip on a higher frequency, or your application requires a stable clock, you probably prefer option 2 or 3. Option 2 is the most popular one, where you normally add a crystal and some small capacitors to get your clock running.

When you have more logic in your circuit that requires a clock signal, you probably share a single oscillator, probably an XO. In that case you want to provide an external clock signal to your microcontroller.

When power is very limited (e.g. you want a long battery runtime, or your circuit is powered using a small solar panel) you may consider a very low oscillator frequency. Most microcontrollers support a low power option, using a 32, 100 or 455 kHz resonator for the oscillator. Again, check your datasheet to see what options you have.

Reset circuit

When powering up your circuit, all kind of undefined I/O may occur in the first microseconds. To ensure this does not affect your microcontroller, a power-on-reset (POR) is often applied to ensure a defined initial state when booting. Most modern microcontrollers have an internal POR. Some models however require a 10 kΩ resistor to 5 Volts to enable this POR, others require an external reset signal by pulling the RESET pin to ground or 5 Volts for a moment. To create this external reset, you can place a small capacitor (100 nF ~10 uF) between this pin and ground, and a resistor (10 kΩ) from the pin to the power (3.3 or 5 Volt). If a non-inverted reset is required, just swap the resistor and capacitor.

Other considerations

When the onboard A/D-converter is used for precise measurements, most controllers allow you to supply an external reference voltage, resulting in a less noisy A/D conversion.

Examples

In the examples below the given pin numbers always refer to the DIL version of the microcontroller. Be sure to check the correct pin numbers in the datasheet unless you like the smell of burning silicium.

Example 1: ATmega328 (Arduino Uno)

[Image]
Minimal circuit for the ATmega328 microcontroller with crystal oscillator.

The Arduino boards are immense popular, and thus the most asked board from which people want to transfer the chip to a breadboard or PCB. Most boards have a DIL version in a socket, however there are also versions with a SMD version of the chip soldered directly on the board. The DIL version is of course the most easy one to transfer.

To run without the Arduino board, the microcontroller requires a 5 Volt power supply and some components to complete the onboard oscillator: a 16 MHz crystal and two 22 pF capacitors. No external parts are required for reset, POR is fully handled internally.

Power:

  1. Attach 5 Volt DC power to pin 7 (VCC), and attach pins 8 (GND) and 22 (GND) to ground.
  2. Place a 100 nF capacitor between pin 7 (VCC) and ground.

Oscillator:

  1. Attach the crystal to pins 9 (XTAL1) and 10 (XTAL2).
  2. Place a 22 pF capacitor between pin 9 (XTAL1) and ground.
  3. Place another 22 pF capacitor between pin 10 (XTAL2) and ground.

Example 2: PIC 16F627A, 16F628A

The PIC 16F627A and 16F628A are the most commonly used PIC processors nowadays. In this example we use the internal clock oscillator, and therefore we do not require external components, except a single 4k7 resistor to activate the POR function.

  1. Attach 5 Volt DC power to pin 14 (VDD), and attach pin 5 (VSS) to ground.
  2. Place a 100 nF capacitor between pin 14 (VDD) and ground.
  3. Place a 4k7 resistor between pin 4 (/MCLR) and 5 Volt.

If we want to use a crystal oscillator instead, we have to apply these additional steps:

  1. Attach the crystal to pins 15 (OSC2) and 16 (OSC1). The oscillation frequency depends on the application, typical values are 4, 16 and 20 MHz.
  2. Place a 22 pF capacitor between pin 15 (OSC2) and ground.
  3. Place another 22 pF capacitor between pin 16 (OSC1) and ground.

Example 3: PIC 16F84A

[Image]
Basis circuit to get the 16F84A running on its own.

The 16F84A is a bit outdated nowadays, but has been one of the most popular PIC microcontrollers and is used in many homebrew projects and kits. Therefore I decided to include an example hookup in this article. The controller runs on 5 Volt, has no internal oscillator and a poor internal POR. Therefore we need to add a bunch of components to ensure stable application.

Power:

  1. Attach 5 Volt DC power to pin 14 (VDD), and attach pin 5 (VSS) to ground.
  2. Place a 100 nF capacitor between pin 14 (VDD) and ground.

Oscillator:

  1. Attach the crystal to pins 15 (OSC2) and 16 (OSC1). The oscillation frequency depends on the application, in most cases 4 MHz is used.
  2. Place a 22 pF capacitor between pin 15 (OSC2) and ground.
  3. Place another 22 pF capacitor between pin 16 (OSC1) and ground.

Power-On Reset:

  1. Place a 10 kΩ resistor between pin 4 (/MCLR) and 5 Volt.
  2. Place a 100 nF capacitor between pin 4 (/MCLR) and ground.

Please note that the formal reset circuit is a bit more complicated (see datasheet), however the circuit given here does its job and is proven to work by lots of applications.


This article was also published in:

Leave a Reply

Your email address will not be published. Required fields are marked *