Confused about Latch Circuit - Page 1
Forum section: electronics / beginners

author: LoveLaika
author_rank: Frequent Contributor
timestamp: August 27, 2021, 10:11:39 pm
content: I came across this post below, and I'm having trouble understanding how the circuit works. I'm analyzing the second circuit in the accepted solution, the one with just BJTs, resistors, the LED, and the switch. Not understanding much about latches, I came across this tutorial in the second link and quickly learned that latches essentially hold state regardless of input until reset by turning the power off/on again. Thus, I expected the solution circuit to behave in a similar manner; however, I'm kind of stuck trying to simulate it.So, R1 and R2 as a voltage divider give 12 volts at the base of Q1, assuming Q2 is off initially. This would turn off Q1, so the collector of Q1 is essentially close to 0 volts. R3 and R4 form another voltage divider, so the base of Q2 has a tiny voltage, but not enough to turn it on. Thus it stays 'off'. When the switch is pressed, 12 volts go to the collector of Q1, which, thanks to R3 and R4, turn on Q2. This in turn pulls the base of Q1 to ground (or at least lower than 12 volts previously), and that would 'turn on' Q1. So, when the switch is de-pressed, The collector of Q1 stays at a high voltage keeping everything on until the circuit is reset.Is this logic correct? I tried simulating it with a 2N3904 and a 2N3906 in LTspice, but it seems to stay on all the time before the switch is depressed.https://electronics.stackexchange.com/questions/326164/why-doesnt-my-latch-work-schematic-attached?rq=1http://www.learningaboutelectronics.com/Articles/Latch-circuit-with-transistors.php

author: Ian.M
author_rank: Super Contributor
timestamp: August 27, 2021, 11:22:31 pm
content: Sims fine here. As you didn't post your .asc sim file, and crystal balls are on 60 week backorder, only %DEITY% knows what's wrong with your version!

author: Manul
author_rank: Super Contributor
timestamp: August 27, 2021, 11:31:49 pm
content: Part of problem is in simulation, part is in the schematic. With a little bit of simplification:1. In simulation, if you use zero impedance voltage source, then basically after starting the simulation it produces infinitely fast transient (step) into your circuit which obviously contains infinitly high frequencies.2. Transistors have parasitic capacitances. For example, we could say that transistor Q1 base goes through 5.6K resistor and transistor Q1 CE capacitance to ground. Also transistor Q2 base goes through 56K resistor and Q1 CE capacitance to +12.3. 2N3904 and 2N3906 are quite fast transistors and circuit like this is very fast acting, because it does not have much frequency response limitting, except RC networks formed by resistors and natural, parasitic capacitances (which is not much).If we take all above into consideration we can see how a fast power supply transient couples to Q1 and Q2 bases and manages to latch the circuit ON.So, your simulation will likely work correct if you add a few Ohms of series resistance to +12V source and also some decoupling capacitor, so the power supply voltage rises more slowly. Or if you add small capacitor between Q1 base and emitter (so it forms RC filter together with R1 lowering frequency response). Maybe also for Q2. You may graph base voltages and analyze yourself.In practice you would have some bulk capacitance and power supply rise time will likely not be fast enough to latch such circuit. Yet, lowering the frequency responce would still be a good idea so the circuit is more transient proof.

author: Ian.M
author_rank: Super Contributor
timestamp: August 27, 2021, 11:42:51 pm
content: ... or just use the .transtartupoption, as I did, which ramps the supply (and all other DC voltage sources) from 0 to its specified value in the first 20us of the sim run, thus avoiding the infinite transient current and dV/dT problem thatUICwith an ideal source and a load with any capacitance would give, and if you use neither, the possibility the operating point analysis used to solve for the initial conditions will prefer the latch on state.Note: I got very odd results when I used time-conditional behavioral resistors as the switch elements, as their resistance wasn't differentiable at their transitions which caused the LTspice solver to glitch. Everything started working nicely when I substituted controlled switches using a model that transitions smoothly between on and off states.

author: Manul
author_rank: Super Contributor
timestamp: August 28, 2021, 12:21:25 am
content: For beginners I would really recommend practicing building simulations using non-ideal models. That is a good way to learn (or don't forget) that real circuits contain lots of invisible elements. For example, make voltage sources with realistic non-zero impedance, capacitors with real world ESR values, add parasitic inductances, etc.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: August 31, 2021, 04:48:10 pm
content: Thanks for replying. Sorry for not replying sooner. Thanks as well for your schematic. Sorry, I forgot to post mine.Judging by other posts, my logic seems to be correct in how the latch works. At least that way, I have gained a rough comprehension of how a latch works. If I may, I wanted to ask some questions about your circuit.From what it seems like, it uses current-controlled switches. Before any switch turns on, Q1 and Q2 seemed to be in reverse active mode (or open, if you think of it as a switch). SW1 closes first, bringing the output to 12 volts which turns on Q2 to be fwd active (or perhaps saturation) which pulls the base of Q1 a bit lower to cause it to go into forward active mode. That way, even after SW1 is open again, the output would still remain high. SW2 acts as a 'reset switch', resetting everything and causing the output to be 0 again.Why did you use current controlled switches? Personal preference? I tried using voltage controlled switches to accomplish the same thing, but my output rises to ~1 volt before the switch closes, whereas yours starts at 0 volts.

author: Ian.M
author_rank: Super Contributor
timestamp: August 31, 2021, 05:25:06 pm
content: Current controlled switches avoid Voltage controlled switches' need for extraneous wires on the schematic to connect their control signals and IMHO result in a less cluttered schematic when all you need is a time-sequenced switch. Each is bound to the current through a voltage source, which I also use as the sequencing source. I give it unit negative internal resistance so its control expression gives +1V=+1A (into the source) when its shorted.N.B. as the control source is shorted you cant plot its voltage. You can however plot its current.OTOH when you are switching as the result of expressions or logic, voltage controlled switches are far more convenient.The reason why you are getting 1V when off is your crappy switch:.model MYSW SW(Ron=1Roff=1MegVt=1.5 Vh=.4)as 1Meg is a really low insulation resistance for the switch off state, and forms a potential divider with R3+R4. They total 89K, and 12V*89/1089=0.98V. You'd think the LED will drag it down a little but at under 1V, it only draws picoamps.I used:.model CSW CSW(Ron=1 Roff=1G It=.5 Ih=-.3)which has an off resistance three orders of magnitude higher than yours so at most you'll see 1mV when its off. Also note the negative 'hysteresis' which sweeps the switch resistance between on an off over the 'hysteresis' range rather than switching sharply at its limits. This behavior is not representative of the real world, unless you are modelling a conductive (carbon loaded) elastomer switch, but with only 1us rise/fall times is near enough to reality, but makes it significantly easier and quicker for the LTspice solver to handle the transition accurately. That's not really an issue in this sim, but if your switch is operated hundreds or even thousands of times per sim run, it becomes important to optimize such things.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: August 31, 2021, 06:29:26 pm
content: That explains so much. I didn't think about the switch being the problem. I feel reassured now.Also, thank you for your explanation of your circuit. I found it helpful and insightful for future simulations where switches are needed.