# How to wire latching SPDT relay using proximity switches without relay hanging

I have a hydraulic-driven piston pump that I designed and built.

I need a way for the pump to automaticlly go up and down.

I wired it using a SPDT relay and a 3 wire PNP NC (normally closed) and PNP NO (normally open) proxy switches. The NO proxy powers the relay then the NC proxy latches the relay until the nc proxy sensor switches breaking the latching current which will kill the relay untill the NO proxy switches starting the proces again..

My problem:

The NC has too much current leak which causes the relay to hang.

How do i get around this?

Or is there a better way of doing it?

Thanks for any input. This has me stumped.

• Schematic? Links to datasheets? – Transistor Aug 13 '18 at 2:02
• are you talking about some type of hydraulic relays? ... you did say that the pump is driven by hydraulics – jsotola Aug 13 '18 at 2:34
• Pump is hydraulic driven... all electrical to controlled though – Sam burris Aug 13 '18 at 2:49
• Use a better proximity switch, with lower leakage, or just use mechanical limit switches. – R Drast Aug 13 '18 at 3:26
• Could in use a semi conductor in place of the relay.? – Sam burris Aug 13 '18 at 4:26

I wrote the original answer while feeling very ill and using EE.SE as a distraction. The answer was as garbled as my stomach and was inaccurate. I've deleted most of it and left what might be relevant.

Very often you need a little more understanding of what's inside a "black box" device especially if you want to use it in an unconventional manner as you are doing with the NC prox switch.

simulate this circuit – Schematic created using CircuitLab

Figure 1. The likely internals of your PNP switches. Note the protection diode D1.

simulate this circuit

Figure 2. The OP's schematic redrawn.

[I] forgot to mention this but, it does work for a while with a new NC proxy then stops working. When it stops working the NC proxy doesn't break the current enough.

That was important information. It sounds as though the switches are being destroyed by inductive kick from somewhere. Add in the diodes D1, D2 and D3 below.

simulate this circuit

Figure 3. Protection diodes.

Can you explain why diodes in that direction eliminates the induction kick?

When you change the current in an inductor a voltage is generated. This is shown by the formula $$V = L \frac {dI}{dt}$$ This is just saying that the voltage across an inductor is proportional to the rate of change of the current through it. If you change the current gradually you get a low induced voltage. If you switch it off in an instant then a very high voltage is generated. If you like, the inductor is doing this to try and generate enough voltage to keep the current going. You will often see this as a spark on a relay or switch.

simulate this circuit

Figure 4. (a) Switch closed, current flowing. (b) Switch opens, current continues to flow but high voltage is generated to cause the current to jump the gap. (c) Adding the snubber allows the current to circulate during switch-off. When the inductor / relay / solenoid is switched on the diode is reverse-biased and does not conduct.

Adding the diode allows the current to continue flowing but back through the diode. The current will decay to zero as the power is dissipated in the diode and in the inductor's resistance. The voltage across the coil is kept very low and so there is no sparking at the switch.

The snubber diode will delay the release of the relay or solenoid by a fraction of a second while the current decays.

• Sweet ill try this... forgot to mention this but, it does work for a while with a new nc proxy then stops working... when it stops working the nc proxy doesnt break the current enough... – Sam burris Aug 13 '18 at 23:30
• Shouldn't the nc pnp prox get current (v+) from the NO on the relay...? And the NC on the prox go to the coil.? – Sam burris Aug 13 '18 at 23:42
• Sorry, @Sam. See the edit. My brain wasn't working due to a very badly upset stomach. My drawings were non-sensical - although, in my defense, reading your drawing was hard work. I'll have another look later. – Transistor Aug 14 '18 at 11:05
• My bad about the lined paper its all i had at the time.... – Sam burris Aug 14 '18 at 15:52
• Question: what types of diodes do i use or are they all the same.? And on the diode symbol which way is current flow...? – Sam burris Aug 14 '18 at 15:56

You could try adding a resistor from the top of the relay coil to GND. This would bleed the leakage current from the NC proximity switch to GND so that it would not try to keep the partially energized.

You will also want to add a reversed biased (flyback) diode across the relay coil. Each time the relay coil becomes de-energized there will be a large voltage spike that can and will take out the solid state electronics in the proximity switches. It is even possible that the leakage you see from the NC proximity switch is because it is has already been damaged by this spike on the first few times you tried to operate the machine.

• The two-wire prox switches have a leakage current as they need to power the sensor even while the output is off. The three-wire sensors shouldn't suffer this problem. See my answer. – Transistor Aug 13 '18 at 9:44