Problem with Up/Down Counter?

Thread Starter

hazim

Joined Jan 3, 2008
435
Dear all.

I want to make a PIC based 2 digit Up/Down counter with two switchs, and I found the circuit below, on this web page.



As you see in the picture, both 7-segment displays are connected in parallel, so they will display the same number. It will count like this: 11, 22, 33.... or so.

I don't know if this is what they meant by 2-digit! and I can't figure if the PIC's program is wrote according for this output, i.e. for one digit actually.

I rarely work with programming and I really forgot what I've learned in my uC course.. due to the lack of practice.
I thought IC 74191 would work for me but it's a 4-bit counter meaning it's maximum counting number is 16, while I need a higher number, 8-bit counter is fine / any number in tens is fine...

Any Idea? or please suggest for me another circuit if possible.

Regards,
Hazim
 
Last edited:

bance

Joined Aug 11, 2012
315
The digits are multiplexed, only one is on at a time (relying on persistance of vision). It appears to the eye that both are on and are different when that is the required output.

That circuit/programme will do what you ask!
 

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
i have done this use 7447 it will save data wires..
for two digit binary to int conversion...
if(sw1==1){
count++;
}

count=count%10; // for unit only dispalying 0-9
count=count%100/10; // for ten....
 

Dodgydave

Joined Jun 22, 2012
11,285
The displays are switched (Multiplexed) on and off one at a time so they each have a seperate value in the display, thats what the two Npn transistors are for, or port A,0 and A,1.

multiplexing
 

elec_mech

Joined Nov 12, 2008
1,500
If you use a microcontroller (uC), you'll save parts and board space but you'll have to program. You can take a look at one of MMcLaren's projects for an example on how to program a multiplex display.

If you don't want to program and aren't terribly concerned about board space or parts count, I've done a few of these using a CD40110. Here is one I helped another member with recently. This may be bigger and have more options than you want, but you can easily use a smaller display with less parts and features.
 

tracecom

Joined Apr 16, 2010
3,944
The diagram you posted is not from the link you listed; the diagram is from talkingelectronics.com and uses a 16F628, but the link you posted is to a similar project that uses a 16F877A. You may be able to use either one, but don't try to mix them together. :)
 
they are multiplexed; for example, if you want to show any number with this circuit lets say "40" the uC will send a "4" to both displays tru portB, but it will set ra1 to saturate transistor connected to the right display in order to activate it (the left one is OFF), then the uC will clear ra1 and will send a "0" to both displays again, but this time it will set ra0 to saturate the second transistor in order to activate the second display, and this process repeats very quickly you'll see both numbers correctly showed, however both numbers are never showed at the same time just one by one but very very fast
 

Thread Starter

hazim

Joined Jan 3, 2008
435
Thanks all for your great help. tracecom, I've corrected the link :).
Any general propose NPN would work right? ex. 2N2222 or 2N3904... etc.

Regards and thank you again.
Hazim
 

Thread Starter

hazim

Joined Jan 3, 2008
435
Hi again.

I implemented the circuit on a bread board for testing it, and of course I programmed the PIC using the available hex file. I used common cathode 7-segment displays.
The problem now is that nothing is displayed. I tested the voltage on the PIC, it's 5V. I tested the switches and they are working fine. No output voltage on RA0 and RA1 if I pressed the switches or didn't, I think the voltage there should measure around 3V as it's a digital signal output...
I think the problem would be with the configuration of the IC.
Any advice or help??

Regards,
Hazim

 

Attachments

bance

Joined Aug 11, 2012
315
From the look of your breadboard I imagine you have a short somewhere...

It's not a good idea to use uninsulated wires like that:eek:
 

tracecom

Joined Apr 16, 2010
3,944
I can't see anything wrong with your breadboard wiring. What transistors did you use? It looks like if they are 2N2222 or 2N3904, the wiring is correct, but if they are something else (BC547 e.g.,) recheck the pinout.

And of course we can't see the code since it is a hex file, but I bet there is something wrong with the configuration bits.
 

tracecom

Joined Apr 16, 2010
3,944
Looking at the original code, it seems that he has low voltage programming turned off. What are you using for a programmer?
 

Thread Starter

hazim

Joined Jan 3, 2008
435
Ofcourse I programmed the chip :)
I used 2N2222 transistors. I'm using "TOP2007" USB programmer.

I think the problem would be with the configuration bits as you said, but I don't know how should I set them exactly.
 

Thread Starter

hazim

Joined Jan 3, 2008
435
It looks like your configuration bits should be 0b11110111010101. Try that And report back...
Where and how to do that? In the programmer's software there is a tab for the buffer and another tab for the configuration, there I set the configuration of the PIC (pwrte, cp1, cp2, wdt, mclre.. etc), as clear for the software I should set each one alone by choosing what I want.
 

absf

Joined Dec 29, 2010
1,968
Where and how to do that? In the programmer's software there is a tab for the buffer and another tab for the configuration, there I set the configuration of the PIC (pwrte, cp1, cp2, wdt, mclre.. etc), as clear for the software I should set each one alone by choosing what I want.
Yes, use configuration to set the above bit pattern. The result should look like "3DD5" after setting the bits.

See the attached picture.....

Allen
 

Attachments

Last edited:
Top