Just got my PIC16F628A in the mail today. This will be my first time using a chip other than the 16F887. I found the datasheet here PIC 16F628 and started looking over the features. Internal Oscillator, 16 I/O ports, comparator, PWM, and a couple timers. YAY!
PIC16F628A Pinout |
The first project I am going to be doing with it is a digital tachometer. A signal will be generated by a hall effect sensor and magnet, translated by the PIC into RPM, then displayed on a four 7-segment displays. Use it for a bike or maybe find a way to hook it up to my car.
I started by getting the pinout and hooking up power (Vdd) and ground (Vss). Then looked up how I was going to connect the oscillator. I want pretty good accuracy and the internal oscillator is effected by temperature so I decided to use a 4 MHZ crystal connected between osc1 and osc2, along with two 68pf caps to ground. Also put a 10uf cap from +5 to ground near the supply and a .1uf cap across Vdd and Vss close to the chip. After that, I hooked up the PICKIT to power and ground, and connected the PGD (data) and PGC (clock) to the chip. Loaded up MPLab and it recognized it right away! After that I hooked up my 7-segment pcb. The individual segment LEDs are controlled by PORTB, (a=0, b=1, c=2 etc..) while the digits are turned on in off with the lower nibble of port a. (digit 0 = 0, digit 1 =1, etc) Works great but take note that I used PNP transisotors for current supplement to the LEDs, so the logic is reversed. (A 0 on the port turns the LED on, while a 1 on the port turns it off)
Wiring is kinda messy. 7 Segment is a custom PCB I designed and printed out. It has 8 wires for the segments and 4 wires for Digit select. Plus one 5V power wire. |