Binary adder with 7-seg display

Discussion in 'The Projects Forum' started by pillyg, Sep 19, 2011.

  1. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Yup.

    There are a few ways we can prevent the final result from being displayed until the user is finished selecting the two input values. A toggle switch could work depending on how it is wired into the circuit.

    So far, so good.

    Personally, I'm not a fan of circuit simulations. You'll spend a lot of time looking for or configuring a chip to match a datasheet, then spend more time learning the nuances of the program, all to simulate something you're going to build and test anyway. Don't get me wrong, simulations have their place - if you're designing an extremely complex circuit and really want to make sure you're getting the right parts and that it will work as intended, then they are the way to go.

    For hobbyist circuits like these, I recommend drawing the schematic so you know what you're building and can document changes as you test it, then building it. For that, you can use MS Paint, Visio, ExpressPCB, or just draw it on paper. Drawing with a computer program will make it easier to document, save, make changes, and share if you choose to. Using ExpressPCB schematic capture is probably the quickest and simplest at this point. If it doesn't list the IC you're using, just pick a blank one with the same number of pins. You're aiming to draw the circuit, not simulate it (unless you choose to).


    Just remember to save often and save multiple versions. I start by making my basic circuit. Once done, everytime I add or change something, I choose Save As and save the modified version by that day's date. This helps me in case I make a goof somewhere and need to go back to an earlier design of the circuit.
     
  2. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    Do both inputs occur simultaneously? If not the circuit can be simplified even further by using one BCD counter to sum both inputs. Even if they do occur simultaneously there are ways to separate them into two separate pulses, and that would likely still be simpler then using a binary adder and then converting back to BCD.
     
  3. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Im not sure what you mean. My finished project is a 6-bit binary adder with the inputs and the output being displayed on 7-seg displays.

    Each input will be set separately if that's what you mean.
     
  4. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    By simultaneous I mean are two people inputting the numbers at the same time?
     
  5. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Ah no. I will set input A then set Input B. Are you suggesting I use 1 driver and switch its inputs from A to B? If so I want both inputs to be displayed at the same time.


    Can I connect 2 binary counters and to BCD counters to fit all 6 bits? I mean like a Cout to a Cin
     
    Last edited: Oct 7, 2011
  6. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    No, you still use two switches.

    But if both numbers are input at separate times then you can simply combine the two input pulses with an OR gate and connect the OR gate output to the input of a third 40110 BCD counter. This counter will then contain the sum of the A and B inputs. No adder or BCD conversion required.

    The 40110 is an Up/Down counter with separate clock up/down inputs so if you added separate subtract A and B buttons you could either add or subtract the input pulses.

    Edit: You can cascade as many counters as you like.

    Edit2: The counters have an output latch function so if you only want to display the sum only at the end of entering both inputs, you can do that also.
     
  7. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Ah. I understand now. That's a good idea. I will use momentary push button switches.

    I am still confused about the 40110s though. Do I only need 1 for 3 digits? or 1 for each digit or what. I see looking at the data sheet that it has a borrow and a carry. Are those like Cin and Cout? the 40110 is 4-bit so if I connected the borrow to the carry of one to another, could I have up to 8 bits? (Im only going to use 6)
     
  8. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    You need one 40110 for each decimal digit (4-bits) so cascading two will give you two digits (ones and tens) with 8 BCD bits (maximum count of 99).

    The borrow and carry are indeed for cascading the counters.
     
  9. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    For the inputs, the clock(push button) will be connected to the 1s place 40110 and it's carry will be connected to the borrow on the 10s place?

    Same with the output except the clock will be the output of the OR gate (inputs are the 2 push button inputs) and there will be 3 digits.

    I think I know what Im doing now! Thanks Elec and crutschow :)
     
  10. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    Almost right. If you look at Figure 15 in the CD40110 data sheet you will see how to cascade the counters. The BORROW goes to the CLK DN input and the CARRY goes to CLK UP input of the next stage.

    Be sure and debounce the switches (Google "switch debounce") or you will likely get more than one count per button push.

    Edit: Just to clarify, the push button and OR outputs go to the CLK UP (or DN for subtracting) input of the 1s counter.
     
  11. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    That, crutschow, is brilliant. My hat is off to you.

    William, I can help you with a deboucing circuit. Actually, just look at the circuit in the attachment I did earlier this year. It shows how to cascade two 40110s, has a 4-switch input debouncer, and the auto clocks for holding the buttons down that I mentioned earlier. You don't need the flashing circuit, toggle switch, any of the transistors, or the 3V regulator. If you're going to use standard 0.56" tall, 7-segment displays, I don't think you'll need the 2982s either. This should give you a good starting point.
     
  12. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Yeah I agree. Thanks crutschow!
    The diagram is a bit much for me lol. Would a debouncer like the one in the picture work? Do I need one for each switch? For the reset, should I have a master reset or a reset for each value (2 input and 1 output) I think I should have 1 for each so you can reset 1 part without doing the whole thing.

    Also, let me make sure Im right for the 40110s. I connect the carry to the clock up and the borrow to the clock down.
    Where can I find the circuit to keep the counter going when the button is pressed-the Auto count thing.

    William
     
  13. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Hey William,

    Look at the circuit I attached one piece at a time. Everything is in there - it is a bit much so I'll need to walk you through it a bit at a time.

    Let's start with the debouncer. Look at U7, the CD4093. This is a quad, 2-input NAND Schmitt trigger. What this means is it has 4 NAND gates with two inputs for each. The Schmitt trigger helps with debounce. In my circuit, I'm interfacing it to switches with a different voltage, so I had to add the transistors. You don't need them. You'll connect a switch between the input of the NAND and ground. This circuit is similar with less parts to the one you posted last.

    I'll be back later to explain more.
     
  14. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Ok. So the 1 NAND gate replaces the whole debouncer? I was gonna use logic gates to make the adder but that was way too much. What will the 2 NAND inputs be? The switch and what else?

    What resistors do I need for this? I know 330 for the 7 segments, but I don't know what to use for the rest. Do I even need them for the other components?


    I just checked the ICs on jameco and the displays and ICs are $20 alone. Is there any way I can use a CD4553? It is a 3 digit BCD counter. Could I use that on the output display at all? The 7 40110s are almost $10 so if I could use the 4553s that would be good.

    (I am in high school and I don't have any source of income so less money is better)
     
    Last edited: Oct 7, 2011
  15. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    You need one debounce circuit for each switch.

    You need to reset everything at once otherwise the sum value will be incorrect.
     
  16. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    You can't go from BCD to a 7-segment display directly. If you used the 4553 you will need also need a BCD to 7-segment converter chip such as the 4511 for each digit. Since the output of the 4553 is multiplexed you will need to generate the proper decoder signals to latch each output value into the appropriate 4511 chip. All-in-all a much more complicated circuit then just using 40110s. Futurlec has them for $1.10 each.
     
  17. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    Ok. I will use futurlec for some stuff. They are pretty cheap. I also need a breadboard and I will get 2 840 point breadboards.

    Also, can I use double displays http://www.futurlec.com/LED/7DR5621ES.shtml Instead of single ones (they are the same price but 2 displays)

    Do I need any other components besides the switches, ICs, and displays? (what resistors and other stuff do I need)

    Sorry if I ask too many questions :)

    William
     
  18. crutschow

    Expert

    Mar 14, 2008
    23,092
    6,850
    That double display should work fine.

    The only other components you might need are any resistors and capacitors for the debounce circuits, and current limit resistors for each LED segment (the resistor value depends upon the LED current you want,typically 10 to 20mA, depending upon the desired brightness, and your power supply voltage).

    What is your power supply?
     
  19. pillyg

    Thread Starter Member

    Sep 19, 2011
    52
    0
    I will probably us an AC to DC black box thing. Or maybe a transformer and a voltage regulator. I want 5v.
     
  20. elec_mech

    Senior Member

    Nov 12, 2008
    1,501
    196
    Ok, I've isolated a debouncer circuit based on the CD4093 with its maximum number of switch inputs - 4. If you don't need to debounce 4 switches, you can leave off the respective resistor and capacitor pair AND tie all unused INPUTS to ground. You can use any mechanical switch for SW1-SW4, typically normally open (N.O.) momentary switches. Whenever a N.O. switch is pressed, the output goes high and stays high for as long as the switch is pressed.

    I don't have much time this weekend, so I'll be back when I can to explain more about the auto-counting circuits.

    Before you buy anything, draw up a circuit. Spend time doing the best you can on the design first so you get all your parts figured out. Once we see your circuit, we can help you select resistor values, remind you to add bypass and de-coupling capacitors, find errors, etc. Then you'll have your complete parts list and we can help you find the best suppliers and prices. Otherwise you're going to order some parts, find out you're missing something, reorder parts, and spend extra money on multiple shipments.
     
    Last edited: Oct 8, 2011
Loading...