How to set a 4040 ripple counter with a 12 position DIP switch

Discussion in 'The Projects Forum' started by SouthernAtHeart, Jan 10, 2011.

  1. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Working on my coffee water timer, but I didn't want to clutter that thread anymore. And since this question is singularly specific I'll just ask it here:

    I need to be able to use a CD4040 ripple counter to get a count that is end user customizable by dip switches. Is there a way to have just 1 set of DIP switches, 1 on each Q1-Q12 to select the desired number? I've tried putting inverters on each Q1-12, and jumpers in front of and after the inverter, but this is making a huge nightmare on my pc board. I'm just wondering if there's a simpler way to do this???
  2. Bill_Marsden

    Bill_Marsden Moderator Staff Member

    Joined:
    Mar 24, 2008
    Messages:
    19,079
    Location:
    Dallas, TX (GMT-5 w/ DST)
    Yes. The DIP switch will connect the 4040 to a really large AND gate. You can easily make good AND gates with one diode per input and one resistor. Need an illustration?
  3. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Yes, a diagram would be great. All I can visualize is that the dip switches will cut the Q's from the 4040 off the AND gate... So does that leave it high or low or ? ...if it is just disconnected.
    thanks,
  4. thatoneguy

    thatoneguy AAC Fanatic!

    Joined:
    Feb 19, 2009
    Messages:
    6,356
    Location:
    Midwest USA
    Would you need all 12, or could you use a combination of 8, leaving out the 2-3 least significant and the most significant bit to get enough of a span for times? It would be a simpler interface as well, not to mention DIP Switches typically come in banks of 2, 4, or 8.
  5. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    I thought about that. Q1-8 would be enough.
    thanks.
  6. Bill_Marsden

    Bill_Marsden Moderator Staff Member

    Joined:
    Mar 24, 2008
    Messages:
    19,079
    Location:
    Dallas, TX (GMT-5 w/ DST)
    If you haven't seen diode gates before this may not be obvious. An open input is assumed high. It is a real 12 input AND gate though.

    [​IMG]

    Since the 4040 counts up the gate will go high with all the selected digits go high. If the counter stops then it is done, if the counter keeps going it will go high several more times as the selected outputs go high. It doesn't respond to the open switches, since they are open.

    Attached Files:

    SouthernAtHeart likes this.
  7. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Thanks! Yes, I see how this works. The R1 would be connected to Vcc, correct. Giving the output a high valve, except if any of the the selected Q's are low, that will sink the high pulse and keep it low.
    Could I use 14448 diodes for the gate? Or what would you recommend?
    This is much simpler than I thought I'd be, which is usually how things work!
  8. Bill_Marsden

    Bill_Marsden Moderator Staff Member

    Joined:
    Mar 24, 2008
    Messages:
    19,079
    Location:
    Dallas, TX (GMT-5 w/ DST)
    Almost any diode will work. Something like the 1N914 or 1N4454 are signal diodes, which means they are fairly fast. Whatever junk box parts is good though.
    SouthernAtHeart likes this.
  9. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Sounds good.
  10. SgtWookie

    SgtWookie Expert

    Joined:
    Jul 17, 2007
    Messages:
    22,044
    Location:
    In the vast midwest of the USA; CST
    The 1N914 and 1N4148 are considered as equivalent. Your local Radio Shack store should have a 10-pack of them available.
  11. Bernard

    Bernard Senior Member

    Joined:
    Aug 7, 2008
    Messages:
    3,208
    Location:
    Tucson AZ USA
    Welcome back. I' drawn up amy interpitation of your requirement- at least something to throw knives at. As shown big AND gate uses jumper wires, but could easily use dip sws & still provide for necessary inversions by directly connecting U2 outputs 8- 512 to invertor inputs, outputs going to
    dip sw's. That is just one more 74C14 [ or other invertor ] for 2- 8 position dip sw's. Assuming not using 1,2.4,&2048. I would preffer moving diodes to U15 side of AND.
    Rather than inhibiting U2 input, U2 reset is held hi when ckt is off. The F-F is composed of U9 & U10. Pushbutton sw , SW1,starts water flow by setting F-F , U9-Q hi & removing reset from U2. When programed count is reached, U2 is reset & & U8 receives a count. U8 counts up, illuminating LED's in sucession, untill SW3 selection is reached, U8 clock enable goes hi stopping further counting; selected LED stays on, F-F is reset, valve closes, U2 held at reset. A manual reset is provided by SW2.

    Attached Files:

    SouthernAtHeart likes this.
  12. Audioguru

    Audioguru New Member

    Joined:
    Dec 20, 2007
    Messages:
    9,411
    Location:
    Ontario, Canada
    The CD4040 is a ripple counter, not a syncronous counter. Its ripple causes many extra glitch outputs that will probably clock the CD4017 wrongly.

    Maybe the timer circuit should be a simple CD4541 oscillator/timer IC instead of those hundreds of parts.
  13. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Doesn't the 4541 create it's own pulse/freq. rather than monitor the incoming pulses?
  14. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    I'm following most of this,
    I'll be drawing this up in PCB Artist! I'm not quite sure about the inverters, if/why I need them if I use DIP switches, but I'll post my drawing thus far when I get it done.
  15. Audioguru

    Audioguru New Member

    Joined:
    Dec 20, 2007
    Messages:
    9,411
    Location:
    Ontario, Canada
    The CD4541 has its own built-in oscillator but can also use an external oscillator. It is a timer that is programmable with DIP switches or other things.
  16. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    I am drawing up something now, with the ripple counter, and will post what I got tonight. If it seems better to use the 4541, I don't mind that. I tried finding some schematics with the 4541 in it so I'd better understand it, but anything I found, it was being used as an oscillator/timer like thing... If it's not hard to sketch a diagram or if you could point me to an example online somewhere, I'd like to see it.
  17. Bernard

    Bernard Senior Member

    Joined:
    Aug 7, 2008
    Messages:
    3,208
    Location:
    Tucson AZ USA
    I do not think ripple counter glitches are a problem, but threw in a glitch filter just in case. I do not see a way around using invertors to decode random number selection.

    Attached Files:

  18. Bernard

    Bernard Senior Member

    Joined:
    Aug 7, 2008
    Messages:
    3,208
    Location:
    Tucson AZ USA
    The CD 4541 does not look verry promising if I read it right- selects only 4 divisions??
  19. Audioguru

    Audioguru New Member

    Joined:
    Dec 20, 2007
    Messages:
    9,411
    Location:
    Ontario, Canada
    Then use a CD4536 oscillator/timer IC. It has 24 binary counter stages. Its first 8 stages can be bypassed with one-bit and its last 16 stages can be decoded with 4-bits.
  20. SouthernAtHeart

    SouthernAtHeart Thread Starter Member

    Joined:
    Jan 2, 2011
    Messages:
    97
    Here's a .pdf of what I've got so far. I didn't put in the inverters, but I will if you say I need them. I thought that if any of the dip switches were open, then that leg would just read high? I must not be following the logic quite right here.

    Note that I've added a 3 digit display to give a readout of the cups as the water fills up. If I decode the pulses into 10th's of a cup (1/10 of 6 oz to be exact) then the display will count to the 10th's decimal place! That should be pretty nice.

    Oh, I see a mistake already. The output going on the the cup counter is counting 10th's of a cup, not cups. I guess I need to put another devide by 10 (4017) in there, unless I find some kind of smaller chip with fewer pins.

    Can someone also confirm that the BC548 transitor is a good choice to gate the water solenoid-I don't quite follow the PNP/NPN thing.


    I'll now work on adding the glitz remover components you just mentioned...

    Attached Files:

Similar Threads: 4040 ripple
Forum Title Date
The Projects Forum Too much ripple May 21, 2014
The Projects Forum High ripple on boost regulator Mar 30, 2014
The Projects Forum Practical Ripple Measurements Mar 3, 2014
The Projects Forum binary ripple counter(as RNG) Sep 5, 2013
The Projects Forum LM2623 - voltage ripple Apr 25, 2013

Share This Page