Monday, March 24, 2014

Microchiping - Mandatory Circuits

The PIC16F1938 can't be used without the following circuits:
  • stabilized power supply;
  • reset circuit;
  • oscillator;
  • ICSP (in circuit serial programming) connector.


Stabilized Power Supply

Usually the microcontroller circuits draw a limited amount of current from the power supply. That makes the linear regulators like 780x series or LM1117 series the logical choice for powering this applications.

The simplest fixed regulator configuration:

7805 Stabilized Power Supply
7805 Stabilized Power Supply

To the base configuration you can add protection circuits (overvoltage, reverse polarity) or visual indicators (like a LED). The next image displays the 7805 stabilized power supply with protection circuits and visual indicator.

7805 Stabilized Power Supply With Protection Circuits And Visual Indicator
7805 Stabilized Power Supply With Protection Circuits And Visual Indicator

Diode D1 is used as a reverse polarity protection. It is a Schottky diode with a rated forward current greater then the maximum current generated by the regulator. The forward voltage should be as low as possible to increase the efficiency of the supply.
D2 is a Zener diode used to protect the circuit from overvoltage. The rated voltage of the diode should be less then the maximum input voltage of the regulator circuit.
LED1 indicates that the circuit is powered. R1 resistor is used to limit the current trough the LED.

Note: All the protection circuits are the simplest possible. For more information check out the dedicated article.


Reset Circuit

All microcontrollers (or at least most of them) have a master clear reset pin. Microchip names this pin MCLR and usually uses inverted logic to drive it (to keep the uC in the reset state you should apply a logic '0' to this pin).

The recommended reset circuit is presented in the next picture:

Reset Circuit
Reset Circuit

R3 is a pull-up resistor that powers the pin. It's value is usually 10 kΩ for uC powered with 5V.
R2 protects the pin by limiting the current to a safe value (<25mA).
Capacitor C5 eliminates the transient voltages (voltage spikes). A value of 100 nF is commonly used.

A push-button can be used if you need a external reset. By pressing the button the pin is brought in a low state, resetting the uC.

Reset Circuit With Push-Button For External Reset
Reset Circuit With Push-Button For External Reset


Oscillator

Every microcontroller needs an oscillator to generate the device clock, required for the device to execute instructions and for peripherals to function.

Usually you can select a internal or external oscillator. The internal oscillator is cheaper and doesn't consume any space on the board, but it's less accurate and stable then the external ones. 

The most used external oscillator circuit is made out of a quartz crystal and two capacitors:

External Quartz Crystal Oscillator
External Quartz Crystal Oscillator

The two capacitors are used to increase the frequency stability. The values should be between 20 pF and 32 pF, and equal.

Some uC have internal oscillators with frequencies up to 32 MHz. The setup process of a internal oscillator is described into the dedicated article.


ICSP (in circuit serial programming) Connector

The standard connector for Microchip ICSP is the following:

ICSP
ICSP

This interface allows the user to upload the code (.hex file) from the PC to the uC using a programmer device like Pickit, MPLAB ICD or others.

MCLR connects to the uC's reset pin.
Vdd and Vss are are connected to the power and ground pins.
PGD stands for "Programming Data" and must be connected to the corespondent pin on the uC. It can also be named ICSPDAT.
The programming clock (PGC) can also be named ICSPCLK.
The PGD and PGC signals are preferably routed directly to the microcontroller pins, without using other circuit elements.

No comments:

Post a Comment