Books > Learning the PIC micro-controller @ PCB Heaven - On line book discussion

3-Digit Decimal Counter


Hello Everyone. If somebody can help me out with my dilemma, I would greatly appreciate it. I've been working with two projects from the PIC Tutorial book, but with a slight variation to both projects. The two projects are as follows...

1. Interface a Single 7-Segment Display
2. 3-Digit Decimal Counter (000 to 255)

For both projects, the PIC Tutorial uses Common Cathode 7-Segment Displays. The variation I'm implementing uses Common Anode 7-Segment Displays. I have been successful in interfacing a Single Common Anode 7-Segment Display, which involved making adjustments to the MainLoop section of the associated Single 7_Seg.asm file. The adjustments that had to be made to accommodate a Common Anode 7-Segment Display involved reversing the binary values associated with each movlw command within the MainLoop. So for example; in order to display the number 0 on a Common Cathode 7-Segment Display, you would use movlw b'00111111' as the binary value. However, in order to display the number 0 on a Common Anode 7-Segment display, you would use movlw b'11000000' as the binary value. So basically; the binary values you would use to light up the numbers 0 through 9 on a Common Cathode 7-Segment display would be completely reversed for a Common Anode 7-Segment display. By doing this, you will be able to Interface a Single Common Anode 7-Segment Display, and produce a count of 0 through 9.

For the 3-Digit Decimal Counter (000 to 255) project, I have not been as successful. I replaced the PNP Transistors with NPN Transistors, connected the emitters to +5v, the collectors to the Common Anode pin of the 7-Segment Displays, and connected base to the RA0 through RA2 pins on the PIC16F88. The result here is that the counter will not display the numbers correctly.  I did change the binary values in the BinaryTo7_Seg section of the Three Digit Counter.asm file in the same fashion as I did in the Single 7_Seg.asm file for the Single 7-Segment Display project, but that did not seem to make a difference. My questions to the audience are these:

1. Can someone provide me some insight as to what else I may want to try to get Common Anode 7-Segment Displays to work with the 3-Digit Decimal Counter program?

2. Will a single package 3-Digit 7-Segment Display component work with the 3-Digit Decimal Counter program, or do I have to use three 1-Digit 7-Segment Displays?

Once again I would appreciate any help on this matter so I can get this project to work, and I thank everyone in advance for whatever help they can provide. Take care!

First of all i take as standard that your package of 3-seven segments is multiplexed (so you have 8+3 pins), In that case, make the same changes in the  code. Then, connect the collector of the NPN transistors to 5 volts and the emitter to the common inputs of your digits. For 5 volt supply it will cork. The 10K resistors must be changed to something like 2200 or 4700.


[0] Message Index

Go to full version