Thursday 9 February 2012

Basic Circuit for PIC16F877A

There's no point in knowing the PIC16F877A without know how to start up it. There are 7 pin should be connect correctly. 

Power Supply Pin

Table 1: Power Supply Pin


In every single electronic component, the supply pin is the most important thing. Same goes to PIC16F877A. The ideal voltage for this microcontroller is 5V (DC). The current that supply to this microcontroller should not be higher that 5.5V and below then 2V. This is because, the higher current will burn the microcontroller and the microcontroller will not operate if the current is below than it required current. Usually, the supply come from either battery or dc adapter and it's hard to fine normal battery or dc adapter in 5V. This problem can be solve by using LM7805 (Datasheet) voltage regulator which will step down the larger input voltage to 5V. Below is the voltage regulating circuit to regulate a voltage from 7V-20V to a stable 5V by using LM7805:

Figure 3: Basic connection to step down to 5V

The circuit begins with J2 which is a 2 pins connector to connect to battery or ac adapter. Pin 1 is negative and pin 2 is positive. The first capacitor C1, cleans up the signal if any (ac) noise is present on this. It shorts this noise to ground and allows the pure DC signal into the regulator. The regulator regulates this voltage down to 5 volts. After it comes out of the regulator, the other capacitor C2, cleans up any high-frequency or ac noise that may come out, again to produce a clean DC signal. Now this DC voltage, clean and crisp, is ready to power the load. D1 is a 5V LED as power on/off indicator and R1 is a resistor to limit the current through the LED.

Reset Pin

As being mention before, there are 7 pins to connect in order to operate the microcontroller. 4 pins already connected, so there are 3 more pins left. The other important pin is the reset pin (MCLR-Master Clear Reset at Pin 1). If the PIC read 0V at the MCLR pin, it will reset the program and if the MCLR pin read 5V, the PIC will execute the program. The MCLR can be directly connect with 5V (series with resistor like picture below) but it will unable to reset if something goes wrong with the system.

Figure 4: 5V direct current connection to MCLR pin

To solve this problem, a switch and a pull up resistor can be added in between 5V and the reset pin so it can create logic condition which is 1 and 0 to reset the pin.

Figure 5: Reset connection with switch and pull up resistor

Table 2: Logic Condition for MCLR pin

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.

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. It can been connect  to 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. Below is the way how to connect the the cristal oscillator and capacitor value table.

Figure 6: Oscillator connection

Table 3: Capacitor value refer to the oscillator type

No comments:

Post a Comment