PIC Projects

  • Some of the various PICs from Microchip, 16F84, 16F627, 16F628, 16F876 and a 16F877.

  • So far, I have only played around with the PIC16F84 PIC chip, with exception to using a PIC16F876 with the HamHUD. I have found the most documentation is on the 16F84. I have also found the most homebrew programmers for this PIC. I am starting to use 16F877 PICS now for larger projects. I mainly have to write for these in another compiler other than Hi-Tech's because I do not have a full registered version ($850). Below, I have posted a pinout diagram I created in MS Paint. I usually get most of my PICs and ocillators from Digi-Key

  • Click here to go right to my projects.

    Click here for my PIC16F84 tutorial.


  • It's fun to make the PIC do simple things like making LEDs blinks and related projects, but I like to do more exciting things, like using an LCD. If programmed right, the 16F84 can be a very usefull in many different applications. Below is another pinout I created to show the 14 pin serial/power inputs for the LCD. It uses an industry standard chipset (Hitachi HD44780). Any LCD using this chipset can be used. A great source of cheap, high quality LCDs is Crystalfontz

  • Here is the basic wiring for an LCD to a PIC16F84. This is the most basic wiring diagram. This is a 4 bit interface. It uses PORT B pins 0-3 for the data input. Most engineers like to add a cap at pin 5 of the PIC and take the PIC side of the cap to ground. Also adding a 4.7K limiting resistor to pin 4 of the PIC can help from voltage jolts, I personally have not experienced this. This circuit has much design flexability and a lot can be added if wanted. Mosty protection components.

  • Programmers

  • Here is the programmer I use to program my PICs. It's called the P16PRO40. This was a cheap programmer kit that only cost me $25. The programmer itself was about $15 but I opted for the extra ZIF socket (Zero Insertion Force Socket) which cost about another $6 or so, plus shipping brought it up to about $25. It can be found at Amazon Electronics. It's under the Soldering Required Kits - Microcontrollers and Programmers. This programmer will program almost every PIC out there.

  • HI-Tech's C compiler

  • I have started to use a C compiler for PIC programming provided by www.htsoft.com. It's a demo or student version that is not limited to function as far as programming commands but it will only allow for code to be written for the 16F84 and 16C84 PICs.

  • So far I have not had much luck since this type of C programming is completely new to me. It is NOT C++, not even close if you ask me. HTLPIC sets up differently from other PIC C compilers. It requires more lines of set-up code at the top of the program file.

  • Such as, __CONFIG(x), this command tells the compiler what configuration to load for the particular processor. In this case we are talking about the 16F84, so __CONFIG(0xnnnn) is the configuration command required. This command is unique to the particular processor.

  • The CONFIG word determines what initial features are activated on the PIC, such as, Watchdog Timer, Code Protection, What type of occillator. The the configuration word is represented in HEX

  • The syntax is very basic: __CONFIG(0xnnnn); //nnnn being the HEX value

  • Some examples: __CONFIG(0x3FF1);

  • My Projects

    LED Chaser

  • This was my first sucessful project with a PIC chip. I used a 16F84 with a 10MHz resonator with built in caps.

  • Click here to view the source code to this project. The code is written in Hi-Tech C.
  • Click here to download the source code to this project. File has a ".c" extension.

  • Bi-color LED Project

  • Here is a neat PIC project that I created using the 16F84 chip and a neat little bi-color LED from Radio Shack. The LED can be red or green depending on the bias of the diode. By using two of the PORT B pins, I can control the bias of the LED. If the LED is on PORT B, Pin 0 and Pin 1, I can set Pin 0 HIGH and Pin 1 LOW, this would make the LED light red. If Pin 0 is set LOW and Pin 1 is set HIGH, the LED will light green. PORT B has 8 pins, so I was able to connect up to 4 LEDs and have full control of them all (as seen in the schematic).

  • Click here to view the source code to this project. The code is written in Hi-Tech C.
  • Click here to download the source code to this project. File has a ".c" extension.

  • Now that I have had some time to brush up on my C coding, I am starting to optimize the code a little better and add new routines.

  • Creating a Sine Wave with a PIC16F84

  • I have been working on creating AX.25 packet with a PIC chip and while researching how to do it, I came across somthing that Byon N6BG of www.byonics.com used to do this, he used a resistor ladder network to create sine waves. In the diagram/schematic below, you can see how the ladder is wired to the PIC. It's a 4 bit ladder network, using 4 resistor values, each one about twice the value of the last. With 4 different values, you can theoretically have 16 different voltage levels from 0 VDC to 5 VDC. Since the PIC can not produce negative voltage levels for the down side of the sine, the middle of the voltage range is used as the center voltage, being 2.5 VDC. So, the sine would go from 2.5 VDC up to 5 VDC, then back down to 2.5 VDC and then down to 0 VDC and repeat the pattern to create the sine wave. The final voltage out can be run through a small value capacitor to help smooth out the signal. It will still have somewhat of a stair step to it, but it will be smoothed out some by the cap.

  • Theoretically the voltages would range from 0 to 5, since we are using resistors in parallel, the value at any given point will never be higher than the smallest resistor in the ladder. So, we are left with a voltage range of 0 to 3.20 VDC. This can still form a sine wave, just not with the amplitude of the full +/- 5 VDC.

  • Click here to view the source code to this project. The code is written in Hi-Tech C.
  • Click here to download the source code to this project. File has a ".c" extension.

  • The table below shows the output voltage levels from each of the 16 possible resistor combinations. The right most bit represents Pin 6. The other pins go in sucession with the binary bits 2, 3 and 4. It also shows what angle of degree on the sine wave that the voltage level should fall. When I finish getting the voltages, I enter them into the table. The graph to the left of the table shows where the voltage levels would fall on the sine wave.

  • Voltage Out for BIT combinations
    Sine D AnglePins 9 8 7 6Vout
    258.75, 281.2510000.48
    247.50, 292.5001000.87
    236.25, 303.7511001.21
    225.00, 315.0000101.55
    213.75, 326.2510101.79
    202.50, 337.5001101.99
    191.25, 348.7511102.17
    11.25, 168.7500012.51
    22.50, 157.5010012.63
    33.75, 146.2501012.75
    45.00, 135.0011012.85
    56.25, 123.7500112.96
    67.50, 112.5010113.05
    78.75, 101.2501113.12

  • Since the center voltage falls in-between the 8th and 9th voltage levels, I did some quick math to show what the calculated center voltage of the sine should be: 2.51 - 2.17 = 0.34 Then 0.34 / 2 = 0.17 And Then 2.17 + 0.17 = 2.34 Leaving a center voltage of 2.34 VDC at 0, 180 and 360 degrees.

  • Emergency Vehical Flasher

  • This is pretty much just a spinoff of the original LED chaser above. It's based on the PIC16F84 clocked at 10MHz. I found that many "emergency personel" were looking for simple flashers that they could mount in their vehicals. I searched around and found many different ones, but many we're very pricey ($50 - $100). This is a basic model that can be adapted to many applications. I plan to make a new version using the water-clear LED's. They are much brighter and can be seen during the day better. I also have plans to add a SPDT switch to allow for changing between flashing modes. The code provided has two modes.

  • Mode 1: Columns 1 - 4 flash and then 5 - 8 flash and it repeats 10 times.

    Mode 2: A typical chasing mode, the columns light up one after another back and fourth 10 times.

  • Anyone with the free Hi-Tech compiler can take the code and change the repeat rates and/or add/delete routines.

  • Schematic Comming!

  • Below is the breadboarded version of the flasher.

  • Below are front and back shots of both boards. I used a extra IC socket for a header/connector for the two boards.

  • Here is the whole thing together and ready to go.

  • Another shot, but closer.

  • Click here to view the source code to this project. The code is written in Hi-Tech C.
  • Click here to download the source code to this project. File has a ".c" extension.

  • Other Projects

    The Pixie

  • Here is a link to a really neat PIC16F84 project called the PIXIE. This is a cool little circuit that allows a PIC16F84 to drive a 8x8 LED array and make it do lots of neat patterns and pictures.