Basic Circuit Of PIC16F877A
Power
Supply
To
start up your PIC16F877A, there are 7 pins you should connect correctly. Likes
others electronic component, the supply pin is the most important. The ideal
voltage for PIC16F877A is 5V (Direct Current). It should not be higher then
5.5V because it going to blow up. It also should not be less then 2V because it
not going to be operate. You will have various type of supply such as battery
and DC adapter. The problem is, if you use battery, it hard to fine normal
battery in 5V. Yes you can use 3 normal 1.5V battery that connected in series.
But I don’t think it will be efficient enough. So how if I use 9V battery? Yes
I can use it but I need to step it down to 5V. How? You can use voltage
regulator. LM7805 the part number of the voltage regulator that I used. The two
number at the end of the part number is 05 which is mean it will step down the
larger input voltage to 5V. Let say if use LM7809 it will step down the higher
voltage then 9V to 9V. Here is the datasheet. This is the basic
connection to step down 9V to 5V by using LM7805.
Using
LM7805 is not only limited to battery supply source. But you can also use it at
your rectifier circuit. Picture below show how the connection from the output
of rectifier to the LM7805 and to PIC16F877.
Reset
Pin
So,
how to give power supply to PIC is already covered. As I said before, there are
7 pins should be connect in order to let your PIC operate. 4 pins is already
connected which is 2 pins for 5V and 2 pin for ground (negative). It 3 more
pins left. The other important pin is Reset pin (MCLR - Master Clear Reset at
Pin number 1). If PIC read 0V at MCLR pin, it will reset the program, so if you
not connect the MCLR pin with 5V, PIC will remain reset and your program will
not execute. You can directly connect the MCLR with 5V (series with resistor
likes picture below) but you will unable to reset if your system goes wrong.
If
you want to use the reset function, you need to create logic condition which is
1 and 0 to the reset pin. 1 is mean the reset pin get 5V. If the reset pin
logic is 1, then the program in your PIC will execute, but if the reset pin
logic condition is 0 (which is 0V) then your PIC will not execute the program.
Logic Condition
|
Voltage
|
Program Status
|
0
|
0V
|
Not Execute
|
1
|
5V
|
Execute
|
So,
how you can get this condition? The answer is simple, you just need a switch.
But you cannot simply add a switch between the 5V and the reset pin. You will
need the Pull Up Resistor. What is that thing? See the picture below, that is
the correct way how to add up a switch in order to create the logic condition.
When
the switch is not pushed, current will flow trough 10K resistor and MCLR Pin.
As a result, MCLR Pin receive 5V and PIC read it as logic 1. But when switch is
push, current will flow through 10K resistor, switch and directly to ground.
There is no voltage will receive at MCLR Pin. This give 0 logic at MCLR Pin.
The
Oscillator
Five
from seven of important pins already covered, now there are only 2 pin left
which is pin number 13 and 14. Those pin was named as OSC1 and OSC2. You can
connect the crystal osillator from various frequency. Pulse generated from the
oscillator will some time have the noise. To reduce the noise, two capacitors
in piko farad value is needed. The value of capacitor is depend on the speed of
oscillator that you use. Here is the way how to connect the the crstal
oscillator and capacitor value table.
VCC (+5V)
|
GND
|
PIN 11
|
PIN 12
|
PIN 32
|
PIN 31
|