1

Okay, I'm at my wits end with this one. Having tried a dozen or so free/semi-free circuit simulators, I can't find any that include latching relays. This surprises me as they're one of the most common components I use.

Am I missing something obvious like another naming convention, or is there a decent simulator out there that does include them that I just haven't found yet?

I'm giving thought to coding one for Falstad's simulator, but can't do this in the office as I don't have the software...


The functionality I need is a single momentary switch latching the relay on, then latching it off again on the next press. I imagine I'm missing something fairly obvious in making this happen, so will keep playing, but felt it couldn't hurt to ask for an extra prod in the right direction please?

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393
J. Carter
  • 85
  • 1
  • 8
  • 1
    It should be fairly straightforward to bodge one, with a relay with an extra set of contacts to do the holding function, package it in a subcircuit. – Neil_UK Jun 26 '19 at 11:02
  • 3
    Add a D type flip flop to the relay driver circuit and tie the D input to logic 1. Use the clock input for latching the relay and the reset input for unlatching it. – Andy aka Jun 26 '19 at 11:03
  • 1
    Simulating a latching relay properly would require integrating mechanical simulation with circuit simulation. I can appreciate that you use latching relays frequently, but most circuit simulations don't need to simulate mechanical elements so there is little incentive to include it in a circuit simulator. You could try to translate the mechanical behavior to electrical equivalents and make your own model. – Elliot Alderson Jun 26 '19 at 11:40
  • @Neil_UK I'm open to bodging one if it's simple (I need about 9 in this model, so lots of components becomes a problem), but I've yet to work out the logic. Can you elaborate a little more how I could use extra contacts to simulate the latch? – J. Carter Jun 26 '19 at 12:16
  • @Andyaka Thanks for the tip! This seems to get me so close to what I need, with the exception of requiring two switches to control it. The functionality I need is a single momentary switch latching the relay on, then latching it off again on the next press. I imagine I'm missing something fairly obvious in making this happen, so will keep playing, but felt it couldn't hurt to ask for an extra prod in the right direction please? – J. Carter Jun 26 '19 at 12:18
  • @ElliotAlderson Thanks for your thoughts on this. As far as I can see there's little difference in simulating this 'mechanical' element than there is in simulating the spring in a momentary switch etc, but I appreciate the concept. I have been trying to translate that behaviour, with limited success. The only working model I've created involves using 3 relays, but I think is only working on the basis of the simulator not being 'real', and bugs out every few seconds :/ – J. Carter Jun 26 '19 at 12:20
  • Creating a "toggle" function using ordinary relays requires 3 of them. See my answer to [How to control a motor with only relays and push button?](https://electronics.stackexchange.com/q/361918/11683) for details. Note that getting such circuits to simulate properly in a modern circuit simulator may require extra effort. – Dave Tweed Jun 26 '19 at 13:23
  • But circuit simulators **do not** simulate the spring in a pushbutton switch. A simulated switch does not bounce, and the switch changes position much faster than a mechanical switch ever could. Maybe you need to clarify exactly what characteristics of the relay you wish to model. Do you care about the coil current and voltage? The time required for the relay to actually latch? – Elliot Alderson Jun 26 '19 at 13:38
  • @ElliotAlderson You're quite right. All I'm looking for is the latched state (so once current is removed from the driver circuit, the Relay remains in the state it was just switched to); the mechanics of the proposition are pretty irrelevant to my use case, as I imagine they are to most people modelling a latching relay really - perhaps I'm mistaken though. – J. Carter Jun 26 '19 at 13:43
  • You should ask yourself what you're using the simulator for, and why it's necessary to show the action of a latching relay in one. You might consider modeling individual subsystems to see if you're getting your design right. In other words, simulation is not an end to itself, and it rarely pays to generate an exact full version of a complex system. – Scott Seidman Jun 26 '19 at 15:22
  • @ScottSeidman I'm trying to test the interplay of a set of latching relays... I can't think of a better way to do it without actually wiring up the latching relays (which I'd rather not waste money on if I can't get the behaviour I want), or staring blankly at a drawing trying to visualise the cascading changes each time a switch is pressed, which doesn't feel particularly effective haha! – J. Carter Jun 26 '19 at 15:44
  • I'd go w/ something other than a circuit simulator for this. You seem much more interested in timing and logic than currents and voltages, or you wouldn't be asking for any old latching relay. I'd encourage you to look into something like Octave. – Scott Seidman Jun 26 '19 at 15:47
  • @ScottSeidman Thanks for the recommendation. The problem that I have is that the logic is incredibly easy to code but I cannot for the life of me translate that into build-able circuitry. You're quite right that currents+voltages are pretty irrelevant to me in this case; this side of the circuitry is really simple. It's only the switch logic that is presenting a challenge, despite how easy it is to code :/ – J. Carter Jun 27 '19 at 13:21

3 Answers3

4

@Andyaka Thanks for the tip! This seems to get me so close to what I need, with the exception of requiring two switches to control it. The functionality I need is a single momentary switch latching the relay on, then latching it off again on the next press. I imagine I'm missing something fairly obvious in making this happen, so will keep playing, but felt it couldn't hurt to ask for an extra prod in the right direction please?

OK, to make this work from a single switch, tie the D input to the inverted output of the D type flip-flop (Q bar) instead of tying it to logic 1. Now, each time the switch is pressed (i.e. a single press puts clock high and then returns it low when released), the output toggles state and remains latched until the next transition on clock: -

enter image description here

If you were to build it in hardware then a good trick is to incorporate contact debounce like this: -

enter image description here

Taken from this answer from 2013.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • That's absolutely perfect! Wow! I think I could have played with this for weeks without getting something that neat in execution! Thanks so much! – J. Carter Jun 26 '19 at 13:39
  • Small note for anyone finding this as a potential solution to the problem, it works really well in some circuit simulators (Falstad, for instance) for a single latching relay, but doesn't work in others (e.g. Everycircuit/Multisim), and exposes what I think is a bug in Falstad in that if you try to control the clock with a relay (or another D flip flop) it will register a signal even when the relay/flip flop is open. So close :/ – J. Carter Jun 27 '19 at 13:20
  • Of course it will work in all simulators. It’s a standard technique. If you couldn’t get it to work then that might be an implementation problem. – Andy aka Jun 28 '19 at 15:52
  • As noted, it does work, but fails to read anything but direct inputs in Falstad (the only simulator I've found a D flip-flop that registers the Q bar -> D connection) making it ineffective as a solution. Here's the simplest way I can demonstrate this... https://ibb.co/m6brxhf The input is registered despite that the relay is open and no connection is made. – J. Carter Jul 01 '19 at 09:43
  • The link doesn't show anything relevant in my browser and your words above don't make sense to me. – Andy aka Jul 01 '19 at 11:05
  • Assuming you can see the picture (if not, I'm not sure how else to show you it), the Green wires indicate wires that are in some way 'active'. In this case, you'll note the switch powering the relay is open, so the relay is also open. It should therefore not send a signal to the D flip-flop, but the green wire indicates that it does. Thus you can't toggle the D flip-flop electronically, as it registers all inputs except a manual switch as 'on' even when they are not. – J. Carter Jul 01 '19 at 13:10
  • Have you ever heard of using a pull-down resistor on a logic input when being activated by a switch or contact? Yes, I can see the picture now but your circuit implementation is flawed because the simulator (although I've never used Falstad) will likely "store" the initial voltage from the closed switch for the rest of time - it stores it as charge on the input capacitance and, of course, a pull-down (or discharge) resistor is needed to make it work properly (as you would do so in real life on a real circuit). – Andy aka Jul 01 '19 at 15:09
1

As an alternate solution, lots of people suggested creating a sub-circuit to 'latch' the relay. There was a lot of head-scratching in this, and it's far from neat/uses a lot of resources (in Falstad, at least), but in case it's of use to anyone finding this thread, here's a latching relay setup.

It requires two double pole relays; the first for logic, and the second to use one pole as part of the logic and the other as the actual toggle. So in terms of treating this as a single 'latching relay', the labelled Switch is your input signal (and can be replaced with a single pole relay if this needs to be electrically triggered), and the secondary pole of the labelled Output is what is actually toggled backwards and forwards with each press of the switch.

Latching Relay with Non-latching Relays

J. Carter
  • 85
  • 1
  • 8
  • This circuit won’t work in reality because it relies on putting two relay coils in series for it to work. A proper simulation tool that had decent models for parts would also fail this circuit. I might suggest that you change the decision to accept your own answer because it’s clearly the poorer answer for you and anyone reading it. – Andy aka Jun 28 '19 at 15:56
  • @Andyaka I can't see how - your answer doesn't work in the simulators I have access to, whereas this answer works in all of them. The idea here is not to create a working latching relay, but to provide the functionality in the simulator (since no one has been able to suggest a simulator that includes latching relays). The D flip-flop does not work. This does. – J. Carter Jul 01 '19 at 09:46
  • Then you are incorrectly implementing the flip flop circuit or breaking a rule such as not having a pull-up or pull-down resistor. Nobody will use this composite relay circuit for the reason I have mentioned and, for other reasons, they will use a flip-flop. – Andy aka Jul 01 '19 at 15:10
0

The functionality I need is a single momentary switch latching the relay on, then latching it off again on the next press.

There are ICs that provide this functionality. For example, U6032B.

It has three debounced inputs: ON, OFF and TOGGLE (one can be used for momentary switch) and a relay driver with Z-diode.

U6032B datasheet has an example circuit under "Figure 2-5 ON/OFF Function" section.

ololoid
  • 1
  • 2