Interfacing Arduino to single coil latching relay

I am looking to interface my Arduino with an existing device. This device is for turning on/off a bulb: it plugs into a bulb socket, and accepts a bulb on the other end. It has a cord connected to it with two wires. Those wires apparently connect to a single coil, latching relay inside the device. It's intended to be connected to a motion detector, and when activated the detector sends 2V down for just a moment to switch the relay to ON. Then, after a timeout, it sends 2V, but with polarity reversed, to turn the light OFF.

I want to control the light via the Arduino. The simplest plan would seem to be connecting the two wires to two Arduino pins, keep them LOW, then set one HIGH briefly to turn the light on. Set the other HIGH briefly to turn the light off. That would seem to work logically, but I understand that there are issues with connecting Arduino pins directly to things like coils. Back EMF is the danger, and there are all sorts of proper ways to deal with this, H-bridges and the like.

I've measured the resistance of the coil at 250 ohms, and the current draw appears to be 12 mA when I connect the relay to a 3V battery pack. At least Ohm's law still seems to apply. :slight_smile:

Is there some simple circuitry I can build to protect the Arduino? Are these numbers small enough that I don't have to worry?

If it is right then you can directly connect it to the arduino pins providing you use protection diodes. On each pin connect a diode from the pin, anode to pin cathode to +ve and another one cathode to pin anode to ground.
However it seems like a very low current tome for a latching relay.

Thanks, Mike. I thought the current was low as well (though I have no experience to base that on), but I was reassured that 0.012 * 250 = 3. Also, all I have is a multimeter, not a scope, so I can't "see" any transient spikes or waves.

Do the diodes then just provide a preferred path for a back emf spike, so the current wouldn't go through the uC? I received one other piece of advice to have 2 diodes, in series but opposite directions, across the coil. Would that be somehow equivalent? If not equivalent, do you think it would work?

Would that be somehow equivalent?

No. How can any current ever get through the relay like this.

D'oh! Sorry, Zener diodes. What type are you proposing?

I've used a low coil current 5 VDC single coil latching relay as a auto power shutoff feature in a couple of my projects. I did not do anything to try and prevent back emf coil spikes, and so far after a couple of years have seen no failures. However you could wire two back to back 5.1 volt zener diodes across the coil terminals if you felt the need to add that protection. Latching relays are cool for some uses, I like them.

http://img25.imageshack.us/img25/563/08miq7.jpg

Lefty

tastewar:
What type are you proposing?

Normal diodes.

Thanks, folks!

I think there is a disconnect here, the latching device requires a +2V signal to turn it on... and a -2V signal to turn it off. 2 pins from the Arduino and 2 diodes aren't going to do this, I sure would like the circuit for that in a pulse too. There might be an easy way with a port pin and a cap and 2 resistors, 1uF for a start and a pair of 10 K resistors, one tied high the other end goes to the relay coil which connects to one end of the cap and one end of the other 10 K resistor, the other end of which is grounded the remaining connection is the open end of the cap and it connects to the port pin used to "Latch" and "Unlatch" the relay. The cap might have to go as high as 4R7uF, just big enough to reliably control the relay.

Doc

2 pins from the Arduino and 2 diodes aren't going to do this,

Two diodes on each pin I said.

Yes it will do it because you can have one high and the other low, to turn it on and the other way round to get the negative current.
You don't need any capacitors or resistors.

So, the device will turn on with +5V on the control pin and turn off when the control pin is at 0 volts... I don't see a negative supply or reference point from which to measure a negative voltage.
I only see a logic 1 or a logic 0... not a logic 1/2.

Doc

So, the device will turn on with +5V on the control pin and turn off when the control pin is at 0 volts

No.
Consider the coil is connected one end to pin 3 and the other end to pin 4.
With pin 3 low and pin 4 high current flows from pin 4 to pin 3 through the coil producing a magnetic field, let's say a north pole the relay latches.
THEN
With pin 3 low and pin 4 low there is no current, no magnetic field but the relay is still latched due to the mechanics of it.
NOW
With pin 3 high and pin 4 low current flows from pin 3 to pin 4 through the coil, this time it is flowing in the opposite direction and so the magnetic field that it produces is the opposite, south, thus tripping the latching relay the other way.

Docedison:
So, the device will turn on with +5V on the control pin and turn off when the control pin is at 0 volts... I don't see a negative supply or reference point from which to measure a negative voltage.
I only see a logic 1 or a logic 0... not a logic 1/2.

Doc

A single coil latching relay doesn't have a 'control pin', just a single coil winding attached to two terminals. The direction of current determines which direction the relay latches to, as it's a current operated device not a voltage operated device. As Mike explained if the latching 5vdc relay coil is wired to two independent output pins then a truth table is setup.

PinX PinY relay state
0 0 No change, remain in last state commanded, no coil current is consumed
0 1 Set the relay, coil current draw will be continuous
1 0 Reset the relay, coil current draw will be continuous
1 1 No change, remain in last state commanded, no coil current is consumed

Also one of the stated 'disadvantages' of using latching relays, not knowing it's state when starting up a device, can be solved by using a DPDT latching relay and using one set of the contacts as feedback information to digital input pins that can be read at power up.

Lefty

I got it about 10 minutes after I posted my... mistaken message, I had assumed that one end of the relay was grounded (required ground) and that was my mistake. Sorry that it took so long to get back and aplolgize. I do see where it could be done that way...

Doc

Wow! I step away for a few hours, thinking we're done here, and there's a whole lotta discussion when I get back! Interesting!

Anyway, I can't tell you much more than I have, other than to say that my intent is to use this to make my porch light flicker on Halloween. I was looking for something like the PowerSwitch Tail but for a bulb socket. Never really expected to find something purpose-built, but this is pretty close. It's made to be connected to a PIR motion sensor as an add-on to allow it to control a second bulb, like if you were retrofitting a motion detector to a pair of floodlights.

Here's the device:

And here's the sensor it's designed to be connected to:

So it turns out that it provides a pretty uC friendly interface. Now to find some zener diodes...