Set/Reset DPDT Latching relay

Hey Arduino buds, Here is my situation:

I am using a single coil DPDT latching relay to switch between 2 audio signals. I would like to control the relay with a momentary switch that sends a quick pulse to the relay coil. This tutorial:

http://www.electroschematics.com/8975/arduino-control-relay/

has helped me clarify how to operate a single coil relay with an Arduino but with a quick glance at the schematic, it shows that current will only flow in one direction with the rectifier diode shown. (Or so I understand). So with this orientation I cannot reset the relay. Here is the data sheet for the AL-5WN-K relay that I am using:

http://www.fujitsu.com/downloads/MICRO/fcai/relays/a.pdf

Instead of using a rectifier diode across the coils, I propose using two 5.1V Zener diodes with the anodes connected and the cathodes connected to the coil pins on the relay to prevent back flow. Much like this schematic:

http://monomonster.files.wordpress.com/2014/02/schematic.png

The ultimate goal is to program an ATtiny85 to switch the relay, but for now I am using an Arduino Uno. I understand that I need a transistor network to increase the current from the pulse to switch the relay because like the Arduino Uno, the ATtiny85 has a max current output of only 20mA per pin. The relay needs a minimum of around 30mA at 5V to switch. I have been using a 2n3904 transistor and have had luck switching the relay one way, but not no luck switching it back.

Any help or input would be greatly appreciated! Thank you!

Here is the code I am using provided by electroschematics.com:

int pinButton = 8;
int Relay = 2;
int stateRelay = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 500;
int stayON = 5000; //stay on for 5000 ms

void setup() {
  pinMode(pinButton, INPUT);
  pinMode(Relay, OUTPUT);
}

void loop() {
  stateButton = digitalRead(pinButton);  
  if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
    if(stateRelay == HIGH){
      digitalWrite(Relay, LOW);
    } else {
       digitalWrite(Relay, HIGH);
       delay(stayON);
       digitalWrite(Relay, LOW);
    }
    time = millis();
  }
  previous == stateButton;
}

That latching relay has two coils so you treat each coil like a separate relay. Use a transistor for each coil and just pulse the coil you want to have switched through.

If you insist on driving it differentially you will need a H-bridge to do the switching but there is no point in that.

Hey Grumpy_Mike,

Thanks for the reply. If you see on page 6 of the data sheet I am using a single coil latching type of relay. My part number is

AL-5WN-K

not

ALD - 5WN - K

which is the double coil latching type you mentioned.

OK so you need a H-bridge circuit to switch this.
You need four diodes for this if they are not built into the H-bridge circuit.
See the fourth diagram on this page:-
http://www.thebox.myzen.co.uk/Workshop/Motors_2.html

Excellent. Thanks Grumpy_Mike!

I looked into H-Bridges a little further and found this helpful set of pages.

http://www.robotroom.com/BipolarHBridge.html

So, with the H-Bridge being able to switch current flow, how would I manipulate the code to switch current flow with the momentary switch is pressed. Another member mentioned on a previous thread that a case statement code may be more efficient considering that current only needs to flow for a couple mS to generate the switch and then 'sleep' (no current flow).

A H-bridge has two inputs. If these are both high the current flows round one way, if both are low it flows the other way. If the are both the same there is no flow. So code it like this.

Why is a H-drive needed? The AL-5WN-K is indeed a single coil latching type so wire it to two digital outputs as shown on the schematic he posted. The relay draws 20 ma and has back to back zener protection. output 1 & 0 to set, 0 & 1 to reset, and either 00 or 11 to eliminate coil current draw while latched in the desired state.

Quite right, I hadn't spotted the current rating. You will still need those four diodes though.

Grumpy_Mike: Quite right, I hadn't spotted the current rating. You will still need those four diodes though.

Which four diodes? In which drawing? Two back to back zeners wired across the single coil should work OK for back emf protection.

Which four diodes? In which drawing?

See reply #3

Grumpy_Mike:

Which four diodes? In which drawing?

See reply #3

Don't see that being required in this case, the back to back zeners across the coil protects the arduino pins as shown in his posted schematic: http://monomonster.files.wordpress.com/2014/02/schematic.png

Well I would not do it that way because zenners do not have that sharp a knee and start to go before the stated voltage.

Grumpy_Mike: Well I would not do it that way because zenners do not have that sharp a knee and start to go before the stated voltage.

Shouldn't be a problem, coil will activate at less then full 5vdc. In fact I would lower the zener values to 4.3 as Vf of opposite zener will give closer to 5.0 clamping value.

If my calculations are correct the relay needs around 28mA at 5V to switch. The ATtiny85 max output current per pin is 20mA. For security purposes I think the H-bridge is a good idea not only for current flow but for increasing current. What I really need help with this the coding portion.

So I have it working with a simple blink code, changing the current direction back and forth.

I am having trouble writing the code for my push button. I am very new to Arduino but I understand this is what has to happen. Could you help me write this out? My digital in on pin 8 (the switch) and my relay pins are on pin 2 and 3. Here is what I need to happen:

Switch is press (pin 8 reads a signal)

Pin 2 == High Pin 3 == Low

this only needs to be a short pulse then

Pin 2 == Low Pin 3 == Low

Until the button is pressed again THEN

Pin 2 == LOW Pin 3 == HIGH

again, this only needs to be a small pulse.

cterjesen:
If my calculations are correct the relay needs around 28mA at 5V to switch. The ATtiny85 max output current per pin is 20mA. For security purposes I think the H-bridge is a good idea not only for current flow but for increasing current. What I really need help with this the coding portion.

The datasheet you posted shows the 5 volt relay coils as having 250 ohms, I think you will find that equates to 20 MA not 28 MA.

The datasheet you posted shows the 5 volt relay coils as having 250 ohms, I think you will find that equates to 20 MA not 28 MA.

RetroLefty, your totally right duder. I don't know why I had that number in my head.