Help adapting a discrete toggle latch circuit - Page 1
Forum section: electronics / projects

author: Analog Kid
author_rank: Super Contributor
timestamp: May 28, 2025, 04:06:40 am
content: Just breadboarded this and got it to work:(It's one of Ray Marston's concoctions from hisBipolar Transistor Cookbook, fromthis page)The thing I don't like is that I had to use two power supplies, one +12 for Vcc, the other -12 for the negative-going trigger.I'm wondering if someone can come up with a clever way to trigger this from the positive supply. I couldn't figure out any way to do that.If you're wondering what my purpose is here, forget about it: this is just another discrete utility circuit that I want to add to my collection for possible future use.(BTW, it works, but very erratically because of switch bounce; obviously needs some signal conditioning if the trigger is a pushbutton.)

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 28, 2025, 08:33:15 am
content: Add a capacitor to the trigger input and charge it to the +9V rails (12V huh?)With a 10uF capacitor it 500x bigger then C1 parallel to C2.If your trigger input pulses are very long, you may have to add a circuit to prevent discharge of this capacitor.But C1 and C2 already provide AC coupling only into the rest of the circuit, so you can also just connect R7 to the positive supply rails.

author: David Hess
author_rank: Super Contributor
timestamp: May 28, 2025, 09:09:17 am
content: Quote from: Analog Kid on May 28, 2025, 04:06:40 amConnect R7 to the positive supply. Now the trigger input sits at the positive supply, and pulling it to ground triggers the flip-flop.

author: Analog Kid
author_rank: Super Contributor
timestamp: May 29, 2025, 02:40:12 am
content: Thanks. That did the trick.I even added a power-on reset so the thing comes up in a known state.I admit that I tried a really naive thing, replacing the transistors with PNPs and trying to use a positive pulse. Didn't work, of course.

author: Zero999
author_rank: Super Contributor
timestamp: May 30, 2025, 09:49:06 pm
content: I simulated the circuit. I couldn't get it to simulate with your start-up circuit, but making the base resistors widely different worked. Of course, simulators use ideal models, so don't do well at this.It's getting late here. I'll post more tomorrow.

author: Analog Kid
author_rank: Super Contributor
timestamp: May 30, 2025, 10:25:07 pm
content: Thanks for that. All I can say is that my power-on reset does work.Here's another thing I'd like for this: a very simple switch debouncer.I'd like to do it with just a single BJT if possible, maybe with just a cap and resistor to generate a pulse.Think that's possible?

author: Zero999
author_rank: Super Contributor
timestamp: May 31, 2025, 10:50:20 am
content: Quote from: Analog Kid on May 30, 2025, 10:25:07 pmThe problem I had with the simulator is the power on reset worked, but then it wouldn't trigger properly. Yes, it probably works in real life. It's possible I could've got it to work. I didn't play with it too much.Have you tried making R3 and R4 different?QuoteJust increase the capacitor values?I've simulated a switch bounce and increasing the capacitors to 1µF makes it ignore it. You might have to use even larger capacitors in real life.The circuit is also very hard on the transistors, which are subject to negative base pulses near the supply voltage, and BJTs can be damaged by negative voltages below -5V. Adding diodes in series with the bases would help.

author: Analog Kid
author_rank: Super Contributor
timestamp: May 31, 2025, 08:40:48 pm
content: Further development: now we're in switch-debouncing territory. I came up with this:which kinda-sorta works, but switch operation is still flaky. Obviously I'm missing something basic here, but what?The idea is to pull the junction of the two caps low to trigger the flip-flop. i thought the RC circuit would extend the pulse to get rid of the bouncies. Tried both small (0.1μF) and larger (10μF) caps, with a small resistor (470Ω).A DSO would sure help here; my trusty old Tektronix 475 probably won't do much good ...So diodes in series w/the bases: between D1/D2 & base in your sim? And with anode towards the base?

author: Analog Kid
author_rank: Super Contributor
timestamp: May 31, 2025, 10:22:13 pm
content: Well, whaddya know: a pair of 10μF caps makes it work just fine. No additional debouncing stuff needed.Time constant to the rescue!Now about those base-protection diodes ...

author: Analog Kid
author_rank: Super Contributor
timestamp: June 01, 2025, 06:18:21 am
content: @Zero999, if you don't mind, a Spice question (I'm using LTspice):I'm having trouble implementing the switch. The only switch I can find is one that takes an external voltage input to operate, unlike the one I see on your simulation:And when I run it I get the error "Can't find definition of model "SW". Select "OK" to continue the simulation with the default model or Cancel to quit now".When I click "OK" it runs, but I get a window showing data, apparently in error; not sure what the "default model" does or if it's actually using it.How do you implement your switch?(There are actually other switches underunder Components, including a SPST, but I have no idea how to operate it.)Also, I'm curious why you used two different values for the cross-coupled resistors: is that intentional?

author: Zero999
author_rank: Super Contributor
timestamp: June 01, 2025, 11:23:49 am
content: Quote from: Analog Kid on June 01, 2025, 06:18:21 amAlways post the .asc file.One of the terminals on the input to your switch isn't connected, so it can't work and note the polarity.You haven't defined a model and the simulation won't run without one. A blank definition works. I believe the default threshold voltage is 0V, on resistance is 1Ω and off resistance 1TΩ.Vswitch demo.asc(1.17 kB - downloaded 26 times.)I used a current controlled switch in my simulation. Open the .asc file to see how I implemented it.Click on Help, LTSpice Help, Circuit Elements, Current Controlled or Voltage Controlled Switch, for more information.The switches underare analogue switch ICs, similar to the CD4066 and 74HC4052. They are not the same as a mechanical switch. Incidentally, the SPICE switch models are ideal i.e. they don't model bounce. You have to pulse the input to do that.I found the circuit simulates better and always starts in the same state, if different values are used for R3 and R4. Have you tried that in real life, rather than adding a capacitor and resistors?

author: Ian.M
author_rank: Super Contributor
timestamp: June 01, 2025, 11:28:58 am
content: The SPST you found under  and any others there that aren't ADG... or MAX... analog switch IC part numbers are non-standard 3rd party components, *NOT* supplied as part of the Analog Devices LTspice distribution or updates. Without knowing where you got them from its difficult to say how they are meant to be used.You'll find a sample circuit for 'sw' (voltage controlled switch) here: Educational\Vswitch.ascUse the menu File=>Open Examples... to get there.I've also got a similar (unofficial) example for 'csw' (current controlled switch), attached.For both you need to read up on the S or W circuit elements in the help to understand the parameters of the switch .model statement.A third alternative for simple switches that operate once (or at least very few times) is to use a time dependent resistor but pretty it up by using the 'csw' switch symbol. To do this place a 'csw' (which you will find in the root of the standard library), and right click it too open the Component Attribute Editor. Change the Prefix from W to R to make it a resistor and make the Value some suitable time dependent expression, e.g:Code:R=if(time>1 & time<2, 1m, 1G)which gives a switch that's on between 1 and 2 seconds as simulation time passes, with an on resistance of 1 milliohm and an off resistance of 1 gigaohm.

author: Zero999
author_rank: Super Contributor
timestamp: June 01, 2025, 01:56:10 pm
content: The current controlled switch is handy for making a rough relay model.Here's an example of a small 5V relay, with normally closed and normally open, break before make contacts. I drew a line on the switch symbol for the normally closed contact, to make a normally closed symbol.

author: Analog Kid
author_rank: Super Contributor
timestamp: June 01, 2025, 05:26:18 pm
content: Thanks to all.My .asc file is attached.@Zero999, I like your simple switch setup but don't understand how it works:How is switch W1 activated by V2? I don't see any connection between them.

author: Ian.M
author_rank: Super Contributor
timestamp: June 01, 2025, 06:53:54 pm
content: Zero999's switches are sensing the current through K1. However that is undocumented and unofficial behaviour extending the classic SPICE3 syntax, as the help states that the W circuit element senses the current through a namedvoltage source, which can of course have a value of 0, i.e. a typical SPICE current probe, where the voltage source has no effect on the circuit except as somewhere to measure a current used to control other parts.

author: Zero999
author_rank: Super Contributor
timestamp: June 01, 2025, 07:10:28 pm
content: Quote from: Analog Kid on June 01, 2025, 05:26:18 pmAs I said. You didn't define a model for the switch, so it can't work. The polarity of the capacitors is also wrong. It doesn't matter in SPICE, but it does in real life. Here's the simplest model which will work in your circuit.Bipolar latch.asc(3.02 kB - downloaded 19 times.)By the way, why make the labels so darn small?QuoteLook at the other schematic I posted of the bistable, which also included a current controlled switch.And here's another example, which conforms to SPICE3.iswitch example.asc(0.87 kB - downloaded 22 times.)Note SPICE doesn't need schematics. Everything is converted to a net list, which is then sent to the SPICE engine.

author: Analog Kid
author_rank: Super Contributor
timestamp: June 01, 2025, 09:14:24 pm
content: OK, gotcha. Ran yours and it works fine.About the negative base spikes: they go down to about -6 - -8V in the simulation, but they look very, very short: do you still think this is a problem? And where would I put those diodes you mentioned?(I think I'll test this at 5V and see if it works; if it does, that should limit the reverse base voltage to a safe level, yes?)About the cap polarity: are you sure about that? My breadboard sim works fine the way it is. Seems like the polarity should be positive on the side toward the base, judging by the diode polarity. I wonder how important the polarity really is, since it looks like current actually flows in both directions there. (?)Hmm; just checked the sim, and it definitely shows current flowing the way you indicated, so I stand (sit) corrected on this point. (However, it shows 0mA current, so again, important?)BTW, this is fun ...About the labels:do you mean the one output node, or the component labels? They're the same size in your sim, and they look OK to me. Not sure what you're seeing or how to change them.(After seeing what my .asc looks like at your end: that sucks ...)

author: Zero999
author_rank: Super Contributor
timestamp: June 01, 2025, 09:34:48 pm
content: Here's what your .asc file looks like. This might not be your fault. I've seen this before. Sometimes the font size gets set to a very small size for some reason.EDIT:Quote from: Analog Kid on June 01, 2025, 09:14:24 pmI very much doubt it. I've viewed the file on three different machines: two Windows 10 and one under WINE and they all display your .asc file as per my attachment. They all have the latest version of LTSpice installed.

author: Analog Kid
author_rank: Super Contributor
timestamp: June 02, 2025, 05:46:29 pm
content: The latch works fine at 5 volts.Caps need to be 10μF for proper debouncing.Thanks for everyone's help.