Computing stuff tied to the physical world

Latching relays

In Hardware on Jun 22, 2011 at 00:01

The traditional relay looks like this (thank you Wikipedia):


A spring pulls on the vertical lever on the right (above its pivot), keeping the contact pushed agains the “NC” contact – hence the name: normally closed.

An electromagnet can pull the (iron) lever towards the left, against the “NO” contact – i.e. normally open, but closed once the electromagnet is powered.

Great invention. Perhaps the first example of electric amplification: using a small amount of electricity to switch a potentially much larger voltage or current.

For ultra-low power devices, ordinary relays have a drawback: you have to keep them energized as long as you want to keep the “NO” contact closed. With the Relay Plug, things are no different – the latest relays used on it have a coil resistance of about 125 Ω, and each of the two requires 40 mA @ 5V to stay “on”:

Dsc 2591

That amount of current consumption is not so convenient with batteries – when turned on, they wouldn’t last more than a day or two on a bunch of AA batteries.

Fortunately there’s an alternative, called a “bi-stable” or latching relay. It uses two coils to move that lever back and forth, with weak magnets in the relay set up in such a way that they’ll stay in place without using a spring as counter-force.

The benefit is that latching relays don’t need any power to stay in their current state (be it open or closed), you only need to give them a pulse to change their state from ON to OFF or from OFF to ON.

There are actually two types of latching relays:

  • dual coil, usually with a common pin which should be tied to ground
  • single coil, where changing the state is done by applying reverse voltages

Most dual coil latching relays can also be used in single-coil mode, by simply leaving that common pin floating.

In principle, the circuitry for a dual-coil latching relay is simple: you just need two relay drivers and then turn one or the other on briefly to make the relay change its state. The point being that you only need to pulse them very briefly, 10..100 msec should be enough.

Unfortunately, the Relay Plug isn’t usable for bi-stable relays, because it assumes a common PWR pin, not GND. It turns out that these relays are polarized. Thinking about this a bit more, this is actually quite logical: the force of the little latching magnet(s) need to be overcome with a magnetic field with a specific opposite orientation.

But there’s a surprising way out…

With single-coil plugs, the trick is to let current flow in different directions to set or reset the relay. IOW, either connect one pin to PWR and the other to GND (briefly), or vice versa. Hm, that sounds awfully like running an electric motor forwards or backward…

Now here’s the trick: instead of a Relay Plug, use the DC Motor Plug!

Dsc 2310 Large

It contains two H-Bridges which are intended to control two small DC motors (or one stepper motor), allowing them to run in either direction.

You even get 4 additional general-purpose I/O pins thrown in…

Now, instead of hooking up a motor, just hook up a relay, and only pulse the power briefly (by making both sides GND or PWR the rest of the time). With as added benefit that the DC Motor Plug will support two latching relays, and being an I2C device, it’ll also allow daisy-chaining with other I2C plugs.

Note that the chips used on the DC Motor Plug require at least 4.5V to operate, according to the data sheet. Maybe a slightly lower voltage will work – I haven’t tried it.

Update – DC Motor Plug is confirmed to work. The 5V relays I was testing this with appear to switch reliably with pulses down to 4 ms, using this test code (modified from the dcmotor_demo.pde) sketch:

Screen Shot 2011 06 22 at 16.33.58

  1. I too love latching relays, low power, and am miserly with pins.

    Check out my solution to the problem:

    You might be able to use a tri-state pin, if the coil current requirement is low enough.

    Have tested, works great.


    • Neat idea – have you got it working?

    • I’ve tried this, but I can’t get enough voltage out of the cap, even with 1000 µF (and I can’t use this as is to switch a higher voltage, i.e. 5V with a 3.3V logic I/O pin). Also, you have to be careful with “shoot-through”, i.e. both transistors briefly conducting at the same time. And lastly, the current out of the I/O pin isn’t limited in the schematic you present – a resistor before the base will probably help.

  2. I tried it a while back.. pretty much as drawn IIRC.. My coils require 30ma to flip, so you have to size the cap and check the various voltages and resistances to match.. In the drawing keep in mind that the resistor and inductor together represent the coil, and are not intended to be part of the circuit :)

    I was under the impression that the ‘totem pole’ arrangement was a standard solution to the push/pull problem and didn’t have an issue with shoot-through, but i can’t seem to verify that.

    You are correct about the resistor on the gate, that’s a good idea :)

    What do you mean ‘enough voltage’ out of the cap.. you mean current?

    I’ll breadboard it and re-verify.

    Why can’t you switch a higher voltage with the totem pole arrangement? I’m no expert, but i’m pretty sure that one of the main features of transistors is to switch higher voltages with a lower voltage control source.

    If you want, we can move the discussion to the forums or email.. I’m ok having it here also though :)


    • I’m seeing a 2 Vpp pulse with a 3.3V supply, which isn’t enough to make my unit switch.

      The higher voltage is in principle feasible, but the I/O pin has to be able to switch the NPN “on”, which requires 0.7V above emitter. Oh, wait – maybe your push-pull setup would work better with the NPN and PNP transistors exchanged? That would change your circuit to a “half H-bridge”, see this link, for example.

      As for voltages: with 3.3V to drive the circuit, the output can never rise more than 3.3-0.7 = 2.6V, nor discharge the cap below 0.7V, I think. That’s why I was thinking that the exchanged setup might work better (it can drive both transistors in saturation).

      Anyway, this discussion is probably better on the forum. Chances are better that some EE’s will read it there, I think.

  3. Thanks for this, both of you.

  4. You are correct. Reversing the PNP and NPN is the correct configuration. Will try tonight and confirm.

    What model/part of latching resistor are you using? I couldn’t find it in the specs

  5. s/resistor/relay

  6. to the forums –>

    Basically my circuit has too many drawbacks, but the thing that’s needed is a 1/2 H bridge :)

Comments are closed.