Author Topic: Help adapting a discrete toggle latch circuit  (Read 4863 times)

0 Members and 1 Guest are viewing this topic.

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Help adapting a discrete toggle latch circuit
« on: May 28, 2025, 04:06:40 am »
Just breadboarded this and got it to work:



(It's one of Ray Marston's concoctions from his Bipolar Transistor Cookbook, from this 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.)
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5384
  • Country: nl
Re: Help adapting a discrete toggle latch circuit
« Reply #1 on: May 28, 2025, 08:33:15 am »
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.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 19247
  • Country: us
  • DavidH
Re: Help adapting a discrete toggle latch circuit
« Reply #2 on: May 28, 2025, 09:09:17 am »
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.

Connect R7 to the positive supply.  Now the trigger input sits at the positive supply, and pulling it to ground triggers the flip-flop.
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #3 on: May 29, 2025, 02:40:12 am »
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.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #4 on: May 30, 2025, 09:49:06 pm »
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.
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #5 on: May 30, 2025, 10:25:07 pm »
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?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #6 on: May 31, 2025, 10:50:20 am »
Thanks for that. All I can say is that my power-on reset does work.
The 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?

Quote
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?
Just 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.
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #7 on: May 31, 2025, 08:40:48 pm »
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?
« Last Edit: May 31, 2025, 09:06:35 pm by Analog Kid »
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #8 on: May 31, 2025, 10:22:13 pm »
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 ...
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #9 on: June 01, 2025, 06:18:21 am »
@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 under [Switches] under 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?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #10 on: June 01, 2025, 11:23:49 am »
@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:

(Attachment Link)

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 under [Switches] under 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?
Always 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 54 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 under [Switches] are 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?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: Help adapting a discrete toggle latch circuit
« Reply #11 on: June 01, 2025, 11:28:58 am »
The  SPST  you found under [Switches]  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.asc 
Use 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: [Select]
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.
« Last Edit: June 01, 2025, 11:32:11 am by Ian.M »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #12 on: June 01, 2025, 01:56:10 pm »
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.

 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #13 on: June 01, 2025, 05:26:18 pm »
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.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14132
Re: Help adapting a discrete toggle latch circuit
« Reply #14 on: June 01, 2025, 06:53:54 pm »
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 named voltage 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. 
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #15 on: June 01, 2025, 07:10:28 pm »
Thanks to all.
My .asc file is attached.
As 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 56 times.)
By the way, why make the labels so darn small?


Quote
@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.
Look 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 55 times.)

Note SPICE doesn't need schematics. Everything is converted to a net list, which is then sent to the SPICE engine.
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #16 on: June 01, 2025, 09:14:24 pm »
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 ...)
« Last Edit: June 01, 2025, 09:46:04 pm by Analog Kid »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22473
  • Country: gb
  • 0999
Re: Help adapting a discrete toggle latch circuit
« Reply #17 on: June 01, 2025, 09:34:48 pm »
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:
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 ...)
I 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.
« Last Edit: June 02, 2025, 11:20:51 am by Zero999 »
 

Offline Analog KidTopic starter

  • Super Contributor
  • ***
  • Posts: 5053
  • Country: us
  • DANDY fan (Discretes Are Not Dead Yet)
Re: Help adapting a discrete toggle latch circuit
« Reply #18 on: June 02, 2025, 05:46:29 pm »
The latch works fine at 5 volts.
Caps need to be 10μF for proper debouncing.
Thanks for everyone's help.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->