2 digit Up Down Counter

Discussion in 'The Projects Forum' started by Christian Tadeo, Sep 10, 2013.

  1. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    For the switches, when you press and hold either up and down, the LEDs are both counting up/down. But when you press any of the counter switches just once and didn't hold, where LEDs are at number 00, switches are not counting up/down. So basically, switches should be N.C. to count up/down the LEDs.

    For the Segment G, yes you are right for displaying number 3 it is backwards "c". I will test and post the result of voltmeter later for showing other numbers.

    For all number for LEDs, segment G is all absent.

    Up and Down switches are counting continously when you press and hold down one of those two (which is now normally close) but reset back to 00 when you stop holding it (back to normally open). Thus, toggle switches doesn't work out. The main problem now is, what circuit should be change to hold up the numbers, like you are using toggle switch and when you press once, count up/down should work. I think there is something missing in the circuit

    Maybe there should be something down int the 4093 IC to hold one number when you once count down or up the switch.
     
    Last edited by a moderator: Sep 29, 2013
  2. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    I don't know how you're coming to that conclusion. The fact that the digits go up or down when you press and hold the up or down switch indicates the CD4093 and 555's are all working properly.


    Are the values for C10, C11, R16-R19 you used the same as the schematic? If so, you have two choices:
    1. Press the up and down button for 1-2 seconds - just long enough to increment or decrement the display by one. Instead of simply pressing the up or down buttons quickly and releasing, you'll need to figure out how long to hold and release each one to increment or decrement by one.
    2. The 555's control how fast the display will change when a button is pressed once and when it is held down. You can play with the timing by changing the values for C10, R16, R18 for the up count and values C11, R17, R19 for the down count. Since it sounds like everything is a bit slow, you might try using smaller values for C10 and C11 first. You can also try using smaller values for R16-R19 as well.
    I suspect because you are using N.C. switches for everything now, the reset is now always on so whenever you release the up or down buttons, the circuit is going to reset. You can verify this by using a volt meter and put the black probe on GND and the red probe on pin 11 of the CD4093. If it high (+12V) when the switch is NOT pressed, that is the problem. Pull the reset switch off the bread board and repeat. Is the output on pin 11 still high? Replace the reset switch with a N.O. switch and repeat. Is the output on pin 11 high?

    If I understood your comments earlier, N.O. switches worked when you held them down for the up and down counting, just not when you quickly pressed and released them. Use N.O. switches for everything and try suggestions a and/or 2 above.
     
  3. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    Ok, so I run down again the circuit, connections are all clear and the components are all good.

    Now, when I supplied 12V to the circuit, the LEDs is flashing while showing 00 for both digits.
    Question 1: Why it is flashing when you turned on the circuit?

    While the LEDs are flashing when showing 00 digits, I tried to press one of the switches once but still didn't affect the LEDs and it is still flashing and showing 00 digits.
    Question 2: Why are the switches does not affect the LEDs even if the 555 timers are working?

    While LEDs are flashing, it seem to be counting down/up very fast (this is just a thought). But, still the Segment G is not lighting up or showing output in any random number. I tested the voltage outputs in the pins of 2981 ICs while the circuit is on and here is the result (note: the LEDs are showing 00 digits so I can't test it with other numbers):

    *For 1st Digit:
    pin 18 = 0-1V
    pin 17 = 4-5V
    pin 16 = 4-5V
    pin 15 = 10-11V
    pin 14 = 8-9V
    pin 13 = 4V
    pin 12 = 3-4V

    *For 2nd Digit:
    pin 18 = 9-10V
    pin 17 = 9-10V
    pin 16 = 10-11V
    pin 15 = 8-9V
    pin 14 = 11V
    pin 13 = 10-11V
    pin 12 = 7-8V

    These results has variation in the range given, means when i connect it to the tester, the output is either fall upon an X voltage while the LEDs are flashing
    Question 3: Why this is happening to the circuit?

    I still can't do the options that you suggested me to do, because I think it will not solve any. But later I will try to change the Capacitor and Resistor values and give you a report.
     
  4. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Something doesn't jive. Are the cathodes of the LEDs still connected directly to GND or have you added the flashing circuit (Q1, U6, U8)?

    It will be harder to troubleshoot this until you determine and solve the cause of the flashing.

    Are you using N.O. or N.C. switches?

    Does holding down the up or down switch cause the display to change?

    Connect black probe of volt meter to GND and red probe to pin 5 of U2 then U3. What is the voltage on pin 5 of U2 and U3? If it is not 0VDC, then that is why the display is stuck on "00". Based on limited information, this could be caused by using a N.C. switch, a bad CD4093, or a bad connection.

    Sooo, is the display counting up/down or only showing "00"?

    If the display is flashing, it will be next to impossible to take measurements on the LEDs - unless the flash is very, very slow, the measurements will change fast making them next to useless. We can't do much until the flashing is stopped.
     
  5. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    The LEDs are connected to the resistors and then to the GND, just like what is in the circuit. As I mentioned before, I removed the flashing circuit including Q1, U6, U8. So you can clearly imagine how's the schematic is going on.

    I am using N.O. switches, here is the image
    images.jpg

    Holding down any switch will cause the flashing stop, but pressing any switch once doesn't affect the LEDs

    I don't really know because it is really hard to measure the output voltages because it is flashing. It is just flashing so fast, like blinking Christmas lights.

    I guess I have to figure out how to stop the flashing, I will give a hand to it later. It is already my deadline of this project and my prof gave me another week so I have to finish this one soon.
     
  6. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Ah, the joys of troubleshooting. When you originally started this topic, I thought this was for a personal project. It appears it is a school project and I surmise you have not built many circuits. This is not a criticism, but knowing your objective and background might have helped. This is something I should have thought to ask at the beginning.

    Based on the problems you're having, I think it is safe to say the original circuit is a bit complex - it was in response to an inquiry in Nuts & Volts and, as tends to happen on many projects I work on, I over-engineered it. While the layman's saying is "If it ain't broke, don't fix it", the engineer's creed is "If it ain't broke, it doesn't have enough features".

    With this in mind, it's best to eliminate variables. Since the flashing circuit is removed but you're still seeing a flash, I'm led to believe the output of one of the 555 circuits is going somewhere it shouldn't.

    Let's simplify the counter circuit by eliminating the auto count feature and simply have it count up or down one digit at a time per button press.

    Can you build the circuit shown below and tell us how it performs?

    Also, I referred to the wrong connection regarding segment g. Look at the LEDs connected to pin 17 of UDN2981 and at the connection between pin 2 of both UDN2981 and CD40110.
     
  7. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    Sorry if I didn't inform you that it was a school project, but anyway I thank you for all the help you've made. I am not that good at building circuits but I made DIY circuits before and working just fine. In this circuit, I just don't know how the component operates that is why I am not sure of troubleshooting any part of it. Sorry for my part but I can always learn things my way.

    You said I should try the circuit you gave to me last night, and now got some results.

    I observed that you manage to remove the 555 timers in the circuit. So I tried to work things out and it seems that the flashing of the LEDs were gone. Well, that solved the flashing problem. On my first try to do the circuit (555 timers removed) the switch for Count Down works and also the RESET and Count Up. But the problem is that these 3 switches works only to Count Down the LEDs. Furthermore, while continuously pressing down one swithc, LEDs are counting down form 99-70(not sure but it never go down below 60s) and then reset to 00 again.

    I tried to reassemble again the circuit bringing back the 555 timers, and then the LEDs are back to flashing again. On my second and last attempt to do the circuit (555 timer removed) the LEDs are not flashing but now the all the switches are not working anymore.

    Both of my first and second attempts have common problems in the LEDs and that is the Segment G still not showing outputs.

    Troubleshooting burns my time today and I tried to play around with the circuit. Base on my observations, the circuit around 4093 is the main key to make the switches work in its respective purpose. Because, base on the previous versions of the original circuit, connection of the pins are different from other version compared to other version. I don't know how does 4093 operates as I don't have any data sheet but that is just my instinct.

    Well, I will try my luck to observe and again try another attempt to the previous suggested circuit.

    By the way, do you have any circuit simulator software that I can use to test this circuit? You know it takes a lot of time to troubleshoot even just a little changes in the circuit and I have other things to do in school. Maybe it will be easy to make changes on the actual circuit when it works fine the simulated circuit.
     
  8. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    No fault or harm. I'm just chiding myself for not thinking to ask more about your goals from the start which may have resulted in a simpler solution from the start. In any event, we're all here to learn and help.

    I find the above statement conflicts with the next one:

    So if you press DOWN, UP, or RESET, the display always counts down by one digit?

    When you say "continuously pressing down one swtich" do mean repeatedly pressing one switch (press, release, repeat) or are you holding said switch down without releasing? Without the 555's, the latter should not be possible, but I want to make sure I understand what is happening.

    Try connecting segment a to g and vice versa. Does segment g now light up and segment a stay off? If yes, my first guess would be a bad CD40110 IC, but it could be a connection between the CD40110 and the UDN2981. If segment g (once connected to segment a's output) is still off, then I suspect one or more LEDs in segment g are reversed.

    There is a problem between the switches and the rest of the circuit, but I'm not sure where. The CD4093 is a Schmitt-trigger 2-input NAND gate. We hold one input high and the other is connected to a switch with a pull-up resistor and a capacitor. When the N.O. is not pressed, both inputs to the NAND gate are high resulting in a low output. When the switch is pressed, one input goes low and the output of the NAND gate goes high. This will give you a little more information, but this may be more enlightening still. Look up debounce and Schmitt triggering.

    I can't say I have much experience with simulator software. I did discover a boo-boo in my last schematic, corrected below. Pin 9 from U3 should go to pin 11 on U1 (CD4093), not pin 10. I also connected pin 9 directly to Vcc, but you can leave the resistor and capacitor connected if you so choose.

    If time allows, I'll attempt to rebuild this circuit and see if I missed something. Most of the problems you've described sound like connection problems, not schematic issues (but I'll be the first to admit I'm not perfect). If you're able to post pictures of the current set-up, we can be of more help in spotting issues.
     
  9. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Okay, I put together the last schematic I posted and it works. I also tried eliminating the CD4093 - can't guarantee bounce/jitter-free operation, but you might want to try the schematic below. This connects the switches directly to the CD40110 - one less variable.
     
  10. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    I tried the schematic you recently post which is working for you after you put them together. The good news is that it also works for me now though I am having some kind of counting problems. The switch for RESET seems to be working as Count Down for me and the switch for Count Down works as RESET. I don't know how it all works in you but can you post some actual pictures of the circuit so that I can compare them to mine as well. Another problem is that the LEDs are counting up from 00, 01, 02, 03, 04, 05, 99 when you are pressing the Count Up switch one at a time. Thus, he 06 - 98 are missing. Also, the LEDs are counting down from 99, 98, 97, 96, 95, 80. It never goes down after 80 instead it resets back to 00. In my observation, during the count up process, the output on each segments of the LEDs surge up in an instant which explains the . . . 04, 05, 99 outputs. I don't know what is happening in counting down procedures but I guess it is also the same as the counting up process giving a surge down in the LEDs resulting to 99, 98, 97, . . . 90 then reset back to 00. What do you think is the problem here? Am I missing something? Did the LEDs count up and down to its minimum and maximum ranges without missing any digits between 00 - 99 when you tried it? What will you recommend then?

    By the way, thank you for buying us some time to try it with yourself and glad to here it works fine to you but no luck for me though. Thank you for supporting me for this project and hoping that this will finish soon enough. :)
     
  11. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Based on your descriptions, it sounds like you're seeing mechanical bounce from the switches. I don't have time to explain it in detail right now, but refer to the links I posted earlier on switch debouncing. When you press the switch once, the IC may think it is seeing several button presses - this would explain why it appears to jump from one value to another. Now that you've gotten all your switches working, try adding the CD4093 circuit back in - this will take care of any mechanical bounce.

    I've taken a picture of my circuit with the CD4093 installed from several angles so you can see how everything is connected.

    Is your segment g working now?
     
  12. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    Thank you for posting your work, segment G is working now, I think the problem is just the connections through the LEDs because I used independent wires (not like rainbow wires that you use in your circuit) so its a little bet messy in my part. I will later rearrange my circuit and make it look like yours but I will also try to learn the mechanical bouncing that occurs in my last circuit.

    I just have one question, why are the resistors directly connected to the outputs of 2981?? Because in my circuit the process goes 2981 output>>>LED in segments>>>resistors>>>GND. Looks like in your circuit goes like 2981 outpute>>>resistors>>>LED in segements>>>GND if I am not mistaken.

    It's exam week so I am a little bit busy here, but I will surely try to buy some time about this project after a day or two so I will be late for giving you the results. But I am very thankful I found the right project and the right person. Thank you again for all your help!
     
  13. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    The resistors used here serve to limit the current going through the LEDs. If you think of each LED and resistor pair as a series circuit, there is only one path for the current to flow. In a series circuit, the current going through each component will be the same. The resistor still limits the current to the LED whether it is placed on the anode (+) side or on the cathode (-) side.

    I'm not sure where you are in your studies, but if you draw a circuit with a battery, a resistor, and an LED in series, you can "prove" this mathematically using Kirchhoff's laws.

    Hope this helps.
     
  14. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    So you were saying that either the LEDs or the resistors can be connected to the 2981 outputs?
     
  15. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Code ( (Unknown Language)):
    1. So you were saying that either the LEDs or the resistors can be connected to the 2981 outputs?
    Simply put, yes. Think of the 2981 outputs as the + connection of your power supply.
     
  16. Christian Tadeo

    Thread Starter New Member

    Jul 4, 2013
    28
    0
    Good news, it all work out now. Thank you for your support and help here. I will post the project when I am done. Thank you!
     
Loading...