Latching toggle swithc with 555 or CD4013 - Page 1
Forum section: electronics / projects

author: hafrse
author_rank: Regular Contributor
timestamp: December 23, 2021, 04:02:00 pm
content: Hello,I am looking for a working design for a Latching toggle switch with 555 or CD4013 to light a 20mA lamp when the push button is pressed and realeased (shorted when pressed) , pressing again should switch of the lamp. I tried a couple of designs found on the net but did not work properly (attached in this post) .The one with 555, works but not all the time., I need to press many times to execute the low or the high state. The one with 4013 does not work.Thanks

author: Leo Bodnar
author_rank: Frequent Contributor
timestamp: December 23, 2021, 04:55:57 pm
content: Can't be tempted?https://www.analog.com/media/en/technical-documentation/data-sheets/295012fd.pdfLeo

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 23, 2021, 05:30:46 pm
content: First - schematics with pin names instead of pin numbers are much easier to read. Having to check the pinout just to figure out the whole thing is annoying.As to the 4013 version: I think the issue is that this design doesn't comply with the requirements for the clock input.There is a max rise and fall time for the clock input - in the order of a few µs, depending on Vdd - at 12 V, that should be about 8 µs *max*. Due to the way the clock input is driven here, the rise time will essentially be defined by the mechanical characteristics of the pushbutton, and the fall time will be several tens of ms due to the RC (that's probably supposed to mitigate contact bouncing). So it can't meet the specs for the clock input.Note that TI's datasheet for the CD4013B exactly shows how to do it properly in "8.2 Typical Application", using a schmitt-trigger buffer between the button circuitry and the 4013.For the NE555 one, I didn't check.

author: themadhippy
author_rank: Super Contributor
timestamp: December 23, 2021, 05:31:47 pm
content: QuoteI built several based on the 4013,although much stripped down compared to the version posted,that worked flawlessly for many years.From memory the switch went from +v to the clock,with a 10k from clock to negative,Q bar linked to D and output on Q .Cant remember if i used a transistor on the output (doubt it) .

author: jfiresto
author_rank: Frequent Contributor
timestamp: December 23, 2021, 06:16:15 pm
content: The attached alternate action push button circuit works quite well. I recently adapted it to toggle a pair of goose neck lamps on and off. I substituted a 4093 NAND schmitt trigger and added an RC pair to keep things off at power up. I chose and adjusted the component values to ignore up to ~1/2 s power drop outs and to account for the 4093's hysteresis.

author: hafrse
author_rank: Regular Contributor
timestamp: December 24, 2021, 07:44:20 am
content: Quote from: themadhippy on December 23, 2021, 05:31:47 pmThanks for the information, probably the CD4013 is faulty, when I press the Q output goes high, when I release, the Q output goes low it does not latch.I will replace the CD4013 with a new one. I think I found the simple schemtics

author: Buriedcode
author_rank: Super Contributor
timestamp: December 24, 2021, 04:29:00 pm
content: Remeber the cap across the switch. Switches "bounce" so a single press will likely be several transitions that will toggle a flip flop several times, which can mean the final state its it is almost random.Often button signals are cleaned up with a combination of RC and a schmitt trigger input (like a schmitt trigger input NOT or NAND gate), or "debounced" in software.

author: hafrse
author_rank: Regular Contributor
timestamp: December 25, 2021, 11:07:29 am
content: Quote from: Buriedcode on December 24, 2021, 04:29:00 pmthanke, I will replace the suspected 4013 and test again.

author: Ian.M
author_rank: Super Contributor
timestamp: December 25, 2021, 01:54:38 pm
content: That circuit is no good, and simply putting a capacitor across the switch wont fix it. A CMOS 4013 dual flipflop typically does not have Schmitt trigger inputs, so the clock can still glitch as the charging capacitor voltage passes through the input transition zone, and if you directly short the capacitor with a switch with metal contacts, a very high transient current can flow which can glitch other nearby logic.Essential reading:'A Guide to Debouncing, or, How to Debounce a Contact in Two Easy Pages', by Jack GanssleOnce you've read that, (especially part 2), if you *MUST* use a 4013, rather than the vastly preferable two inverter toggle latch suggested by Jfiresto, consider the attached circuits. The top one is a little tricky - it uses half of a 4013 with input to PRE (Set) and CLR (Reset) tied low, as a non-inverting buffer, and adds positive feedback (R3, R4) for 10% hysteresis. Also you must choose the value of C1 to get an appropriate time constant with R2 (button pressed) or R1 (button released) to cover the maximum expected contact bounce time. It draws negligible current when the button is not pressed so is suitable for battery powered applications.The lower circuit is much simpler and 100% reliable with no further thought required, however it requires a SPDT (changeover) button and draws current via R6 when the button is not pressed, so is not suitable for battery powered applications. Its good as a general debounced button circuit when experimenting with logic circuits.Edit: In spite of the note on the schematic, the bottom circuit is a debounced clock pulse generator. Its output should NOT be connected direct to a power switching transistor as it does not hold its state when the switch is released. *IF* you want to use it as a power switch, you'll need to use it to clock a toggle flipflop e.g. like the right half of the top circuit.

author: rpiloverbd
author_rank: Regular Contributor
timestamp: December 26, 2021, 07:54:53 am
content: 5 years ago, I did this task with a CD4027 J-K flip-flop. Unfortunately, that circuit diagram is no longer with me.

author: hafrse
author_rank: Regular Contributor
timestamp: December 26, 2021, 10:59:01 am
content: Quote from: Ian.M on December 25, 2021, 01:54:38 pmThanks for the information, the reason is that I have 4013 but I will purchase the CD4093 and try that instead. Do I need to add things on the schemtic prposed by suggested by Jfiresto? thanks

author: hafrse
author_rank: Regular Contributor
timestamp: December 26, 2021, 11:00:53 am
content: Quote from: jfiresto on December 23, 2021, 06:16:15 pmThanks ! Will try itI will purchase some CD4093, hopfully I get them early nest week.

author: hafrse
author_rank: Regular Contributor
timestamp: December 26, 2021, 11:07:11 am
content: Quote from: jfiresto on December 23, 2021, 06:16:15 pmCan you please describe the RC pair you added for the state on power up ? I am using 13.5V , how can I adjust the components values to ~1/2 s ?

author: jfiresto
author_rank: Frequent Contributor
timestamp: December 26, 2021, 12:37:20 pm
content: I have attached one side of the circuit below; the other side using the two other 4093 NAND gates is the same. Q1 (and the other side's Q2), pick AZ6960, 12V 250mW relays, by pulling to ground.The RC pair at the left reset both sides at power up. Its RC time is a few 50hz cycles long to insure the voltage on pin 8 is still low when VDD starts powering the 4093. (This is being conservative and lazy so that I only need a few common component values.) I sized the power supply, bulk filter capacitor so that when both relays are on and the power goes off, VDD stays above half of nominal for at least a half second: to insure the RC pair does not reset the circuit should the power return before then.

author: Steffalompen
author_rank: Contributor
timestamp: January 04, 2022, 03:02:09 pm
content: Took me a while to find it, but if any 555 enthusiast insist on using it I've had no problem with OP's circuit, however with slightly different values. No idea if that matters, perhaps I should try yours.Disregard the diode, dunno what that was about. And R11 was in case of mosfet I think I remember, so disregard that too.I just tried it for hundreds of toggles. Seems rugged with both short and very long button press. At first I connected 6-2 floating by mistake, and it became super erratic, naturally.-Does your load interfere with VCC and thus threshold, perchance?(PS. I now see it's just 20mA, so no)C8 could conceivably keep 6-2 steady while button is pressed, and while VCC drops or there are transients, and thus throw off the threshold?

author: Steffalompen
author_rank: Contributor
timestamp: January 04, 2022, 06:54:49 pm
content: Ok so I tried the OP 555 values.Are you sure it's wise to dissipate 600mW through R4?Feedback should improve a bit as well with a higher value.

author: Ian.M
author_rank: Super Contributor
timestamp: January 04, 2022, 07:24:37 pm
content: It wont dissipate 600mW. The NE555 output cant drive higher than two Vbe drops below its supply, and there's another Vbe drop in the external transistor, so at 12V Vcc, there will be about 10V across and under 500mW dissipation in R4. Use a 1/2W resistor and it will run hot but within its ratings. That's the disadvantage of using an external BJT rather than a MOSFET.However the O.P's circuit and indeed your version still suck, due to the quiescent current when off. The internal reference divider chain is nominally 5K each section, so there's 15K across the supply internally, + the quiescent current of the rest of the chip, totaling typically 8mA at 12V, and the current through the external divider biassing threshold and trigger. Switching to a CMOS 555 would get that down to under half a mA, so a bit under 1mA total with the external divider. That's comparable to the typical equivalent self-discharge current of a 20AH SLA at room temperature, so unless you've got a *BIG* battery and are using a CMOS 555, the 555 based circuits are only suitable for switching the output of mains PSUs.

author: Steffalompen
author_rank: Contributor
timestamp: January 04, 2022, 09:09:29 pm
content: Quote from: hafrse on December 26, 2021, 11:07:11 amThat would bring us back above, Ian.M. Perhaps try and read a bit more and write a bit less.Quote from: Ian.M on January 04, 2022, 07:24:37 pmYesyes.I wrote "If any 555 enthusiast insists on using it"