In the past two weeks, I discussed the prerequisits for starting your first application and the issues surrounding PICMicro programmers and what to look for. With this background, I am now ready to present what I think is a good first application for somebody learning about the PICMicro. This circuit is not as simple as what I started with in βProgramming and Customizing the PIC Microcontrollerβ, but can be used in the same way to experiment with different ideas and trying out new concepts.
The application itself consists of the 16F84 PICMicro (with power, reset and clocking βcoreβ) with two LEDs and a button. One of the LEDs is lit by the PICMicro while the other is lit when the button is pressed.
Bill of Materials |
|
Part Number R1 R2-R3 C1 C2 U1 U2 CR1-CR2 SW1 β β β Y1 |
Value/Comments 4.7K 0.25 Watt Resistor 220 Ohm 0.25 Watt Resistor 10 uF 25 Volt Electrolytic Capacitor 0.1 uF 16 Volt Tantalum Capacitor 78L05 Voltage Regulator PIC16F84 Microcontroller 5 mm Red LEDs βMomentary Onβ SPST Pushbutton Prototype Card Wiring Power Supply (> 6 Volts if Voltage Regulator used) 4MHz Ceramic Resonator (With Internal Capacitors) |
When I built the circuit, I put it on a spring loaded βBreadboardβ as is shown at the top of the article. I was able to put on the Voltage regulator at one end of the breadboard with the βredβ commoning bar as positive voltage and the blue bar as ground. I used a +12 Volt βWall Wartβ for powering my prototype, but this circuit could be powered by a 9 Volt Alkaline radio battery. As I pointed out in the earlier articles, three βAAβ 1.5 Volt Alkaline batteries could be wired in series to provide power as well.
For my prototype, I used a 4 MHz βCeramic Resonatorβ for clocking. For this circuit, the operating frequency is not important. If you havenβt used a Ceramic Resonator before, I highly recommend that you look into them because they are a) easier to wire than a crystal and a couple of capacitors and b) are much more robust than a crystal, which means that you will be able to abuse them more and not loose your investment.
The LEDs are lit when the Microcontroller pins that they are connected to are pulled to ground. This is traditional in Microcontroller applications because in most devices, the β0β can βsinkβ more current than the β1β can βsourceβ. The PICmicro is capable of sourcing enough current to drive an LED, but I prefer using the sink feature because this is the only way that the 8051 can light LEDs directly and this eliminates the need for me to convert mentally how applications work for different devices.
The button connection probably seems unreasonably simple because I have not provided a βpull upβ for the switch to pull down. In the interests of keeping the circuit simple, I rely on the internal pull ups in βPORTBβ of the PICMicro to provide this function for me. A 4.7K Resistor connected between Vdd and the PICMicroβs I/O pin could also be used if the internal pull ups are not used.
There is one point to make about the layout that you should always keep in mind when developing a circuit with a microcontroller or other programmable device; you should always design the circuit in such a way that the chip can be pulled easily. This means that there should be space at either end for prying the chip up out of its socket or, as I like to do, slide a small screwdriver underneath the PICMicro and βpopβ it up simply by twisting it. I know a lot of people that end up cursing themselves because theyβve forgotten to remember this basic operation. In keeping with this theme, when using a βbreadboardβ, I like to put in a connection between the row of holes above the Microcontroller. This allows me to pull the part without having to figure out where it goes back each time.
For more detail: PICMicro Project using PIC16F84 Microcontroller