Relay switching causing voltage spike - Page 1
Forum section: electronics / projects

author: SethGI
author_rank: Regular Contributor
timestamp: July 14, 2017, 04:46:26 pm
content: Hi,I'm building a robot which uses a large automotive relay to control power to motors. (https://www.digikey.com/product-detail/en/te-connectivity-potter-brumfield-relays/V23720A0001A001/PB1985-ND/5215141). Every time we switch the relay, it causes a voltage spike across the system. This has killed two raspberry Pis. I have a flyback diode (1n4007) across the coil in reverse parallel. This did not seem to help at all. The spikes range from about .5 volts to about 4 volts (measured on a scope). Any ideas of how to deal with this? One thought was to use a transient voltage suppressor, but I have no clue if that's right.Thanks,Seth

author: MK14
author_rank: Super Contributor
timestamp: July 14, 2017, 04:54:42 pm
content: The 1N4007 is a very slow (recovery time) diode. Have you tried a much faster diode ?

author: Benta
author_rank: Super Contributor
timestamp: July 14, 2017, 05:03:07 pm
content: It says coil resistance 4 ohms, meaning it's pulling 3 A.That a lot of noise on your power lines, and a bit much for a 1N4007.I think you need to look at your power distribution, separating electronics and power completely, and seriously consider optoisolation between power and logic.

author: MK14
author_rank: Super Contributor
timestamp: July 14, 2017, 05:08:18 pm
content: Quote from: Benta on July 14, 2017, 05:03:07 pmI second that. Using opto-isolators, is a very good idea.I did not realize it was a 3 amp coil relay. I should have looked at the link.Motors can be very (electrically) noisy. So it is a bad idea, for them to share the same supply rails, as the rest of the circuitry. I.e. The MCU.

author: floobydust
author_rank: Super Contributor
timestamp: July 14, 2017, 05:14:32 pm
content: Many things can be causing your trouble.That big relay/contactor (450VDC, 250A) 3A coil current, switching that alone can damage things.The diode must be located close to the relay coil wiring, and the MOSFET grounded away from the Rpi and a gate resistor there too. Isolated I/O there is best. If you post pics or your schematic that makes it easier.The contactor usually arcs and makes a burst of EMI during switching, and large back-EMF voltae spike from the motor too. If the RPi is physically close it will probably crash. I would have an RC snubber across the contacts. Not sure what the motor voltage is.In all likelyhood it is the RPi power supply getting damaged by the huge motor currents getting switched on/off. I would have a filter and transient supressor on the PSU input.If this is a big motor and can kill people, then you need a decent emergency stop switch that overrides the Rpi and its hardware. Forklifts use this, in series with the contactor coil, or a second (safety) contactor altogether.

author: MK14
author_rank: Super Contributor
timestamp: July 14, 2017, 05:30:29 pm
content: It probably would have helped if you had provided some more details about your robot.Assuming it is the one you already posted about.So it apparently already has a kill switch (but its design maybe is dubious) and needs to be water proof, for going underwater, etc etc.EDIT:The details above, can be important. Because having interference and back-emf effects, messing up circuit operation, in something which can be dangerous, to people. Is a very bad idea.E.g. your killswitch should be an effective 100% power off/isolator, rather than something which may not always work correctly (if I understand the other thread, where you seem to be criticized about it).

author: SethGI
author_rank: Regular Contributor
timestamp: July 15, 2017, 02:44:08 pm
content: Ok here's an update that should cover everything.For the sake of testing, I completely disconnected the coil from everything else. I'm till seeing the voltage spike on the completely disconnected coil. I'm powering the relay off a bench supply. I'm still seeing the voltage spikes. This means it must be caused by the magnetism. How would you recommend dealing with the spikes? We only have a few days to get this worked out.

author: Benta
author_rank: Super Contributor
timestamp: July 15, 2017, 05:41:39 pm
content: Nobody ever doubted that it's from the coil, that was clear from the start.You get a double "kickback" effect, first from the coil inductance itself, and second from the mechanical movement of the actuator away from the coil.There are two options (or perhaps even a combination) for solving this.One isdivertingthe energy stored in the coil by sending it back on your supply line. That's what the reverse diode does.Second isdissipatingthe stored energy, this can only be done through heat in some resistive snubber.Diverting brings it own problems: as the coil voltage is limited to perhaps 1 V by the diode-to-supply during turnoff, the release time of the relay switch is prolonged and will probably cause contact arcing/burning.Dissipating can be done, but normally means you have to isolate the coil during turnoff, meaning you need both high-side and low-side switches for the coil, plus a diode/resistor/capacitor snubber to absorb the energy.There's no easy solution, especially with a contactor as large as this one (and probably a motor that's even bigger).My original suggestion of having separate supply circuits for control and power still stands, where you allow the power side to be "dirty" with spikes and sparks being kept somewhat in rein by a couple of fat MOVs or/and tranzorbs across the supply, and the control side having a quiet supply.Optoisolation on all signal lines between the two circuits, of course.But doing this in two days is probably not possible.Best I can do, sorry.

author: Zero999
author_rank: Super Contributor
timestamp: July 15, 2017, 06:03:09 pm
content: Quote from: Benta on July 15, 2017, 05:41:39 pmNot quite. No energy goes back to the supply line. The energy is dissipated in the coil's resistance and diode. The problem with that is, it takes while to decay, causing the contacts to open slowly, resulting in arcing.

author: Benta
author_rank: Super Contributor
timestamp: July 15, 2017, 07:24:26 pm
content: Hero, you're absolutely right, mea culpa.Which makes me think, that the sudden loss of 3 A current draw makes a voltage regulator somewhere act up...

author: Damianos
author_rank: Frequent Contributor
timestamp: July 15, 2017, 08:33:26 pm
content: Except of the (obvious?) separation of the control and high power circuits supplies:- Did you studied the data-sheet? I am not meaning looking at it from a distance!- Did you reduce the power (voltage/current) of the coil, after the activation? They provide also a circuit ...- What you expect from a diode to do, with this coil? It can destroy it in some cases!

author: tszaboo
author_rank: Super Contributor
timestamp: July 16, 2017, 12:02:53 pm
content: Quote from: MK14 on July 14, 2017, 05:08:18 pmRule of thumb is that the diode nominal current capability should be equal to the relay current. And as fast as possible.Another rule of thumb is 1000uF / 1 A for the capacitors. If you dont use low ESR caps.

author: MK14
author_rank: Super Contributor
timestamp: July 16, 2017, 07:21:36 pm
content: Quote from: MK14 on July 14, 2017, 04:54:42 pmCorrecting my own post.As long as it is not being driven by a PWM or other complicated output driving schemes. According to the following link, it should be fast enough. Because it is basically the forward bias switching time (which is not too bad), rather than the reverse recover time, which can be considerably longer with a 1N4000 series device (and many other diodes).https://www.scribd.com/document/40610418/Diode-Turn-On-and-Off-TimeThat still leaves other issues, such as the fact that 3 Amps is probably too much for a 1N4000 series diode (although they will take higher than 1 A, short duration pulses, but probably not a good idea, in this case).Quote

author: GoneTomorrow
author_rank: Regular Contributor
timestamp: July 18, 2017, 11:24:39 am
content: The Vf of a 1N4007 is ~1.5V at 10A. The back EMF from a 3A coil collapsing might be substantially higher than that. You might just be needing a beefier diode, perhaps an actual unidirectional TVS diode.

author: Zero999
author_rank: Super Contributor
timestamp: July 18, 2017, 12:23:46 pm
content: Quote from: GoneTomorrow on July 18, 2017, 11:24:39 amHow can the current due to the back EMF be any higher than that? It's not possible.The diode allows the current to continue to flow through the coil, after the power has been removed, so the maximum current through the diode will be equal to the coil current, no more.

author: Benta
author_rank: Super Contributor
timestamp: July 18, 2017, 12:54:47 pm
content: QuoteActually it can get higher, due to the mechanical movement of the plunger. Depends on the design of the contactor.

author: Kalvin
author_rank: Super Contributor
timestamp: July 18, 2017, 01:00:25 pm
content: Place a proper transient-voltage-suppression diode cross the power supply and place a fast schottky-diode across the coil.

author: Zero999
author_rank: Super Contributor
timestamp: July 18, 2017, 03:47:24 pm
content: Quote from: Benta on July 18, 2017, 12:54:47 pmHave you made any measurements or seen any actual data?The inductance will decrease slightly, when the spring returns the contacts to the off state but that won't be until the current has already decayed significantly and I don't see how any increase in current, would be above the initial state.

author: Benta
author_rank: Super Contributor
timestamp: July 18, 2017, 04:05:09 pm
content: QuoteI've seen it in solenoids. Don't know how this contactor is made, though.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 18, 2017, 04:15:34 pm
content: I think driving a large relay requires, first and foremost, layout design. Adding suppressors should be thought about after the layout is properly designed first.You should think about the route the current flows; also, you need to supply the current from somewhere - this means capacitors. If the capacitors are insufficient or in the wrong place, you end up driving peak currents out from the Rpi's onboard capacitors - and, worse, Rpi doesn't provide proper high-ESR dampening bypass cap, so it's sensitive for this kind of abuse, and can easily blow up due to voltage peaks from LC ringing simply caused by switching any external load.Once you fix the mistake of using a wrong (slow) type of diode in the wrong place (at the relay), you can arrive at a properly decoupled half bridge design; that's what a relay driver is! You should have the FET and the diode tightly coupled with enough low-inductance DC link capacitance at the bridge. This DC link capacitance should then include some ESR to snub parasitic ringing; typically it would be a combination of small MLCCs or film caps in the bridge, no more than a few mm away, and then some large electrolytics to provide the R for dampening the LC.If you STILL have voltage spike issue after this, in the DC link, adding the TVS can be considered.Driving a relay using a transistor from a simple microcontroller or computer IO pin is a big catch for young players; it appears utterly trivial, but actually requires much deeper understanding than most people ever realize.

author: SethGI
author_rank: Regular Contributor
timestamp: August 07, 2017, 02:43:19 am
content: I know it's been a while, but I figure I might as well post the conclusion we came to. Whether it's technically right or wrong can be argued about, but I'm 100% sure it works, because it did.Diagnosis: It was just a fucking massive relay. It was huge. Too big. Any relay which needs 3A to keep the coil switched is a bit absurd.Solution: Get a smaller relay. Limited total power draw by our motors, but whatever we never got close to the max anyways.Results: Worked great. Still got some voltage spikes upon powering up, but that makes sense because all the caps on the motor controllers had to be charged. Obviously circuitry could have been put in place to prevent the inrush current, but given time constraints we didn't have time to play around with that. Absolutely no spikes left on powering down.Extra safety measure: The only component in the electronics which was susceptible to the voltage spike was the raspberry pi. All of the 5 arduinos have protection, as does the main computer (desktop computer with intel i5 and GTX1060.) So, we added an external switch to turn off the raspberry pi before we turn on the relay. This worked great since we could still turn off the switch without causing damage, and just got a little extra piece of mind by always powering up with the raspberry pi off. We then just implemented some auto-run software to reconnect via ROS and launch all the required nodes, pick back up the I2C communication, and send a heartbeat to the main computer to confirm that all was working well. Near the end of the competition I started getting lazy and just turning the relay on and off without turning off the raspberry pi and we didn't cause any damage.Thanks to all for the suggestions! This worked fine for us though.

author: Damianos
author_rank: Frequent Contributor
timestamp: August 12, 2017, 06:29:12 am
content: Instead of blaming the relays you can start using them properly!The relay mentioned initially does not need 3A to stay activated. The steady 12V was wrong for its coil. The selected solution for suppressing the coil voltage was the worst...When you have time, visit the manufacturer website, they have data-sheets and some relative application notes. By studying you can learn some more things about these devices.There is not a need for exotic magic tricks, just a little study.

author: Circlotron
author_rank: Super Contributor
timestamp: August 12, 2017, 12:52:56 pm
content: I never use a diode across a relay coil. Whenever I drive a small relay I use a BC639 with 80V rating and a BZX79C75 zener from emitter to collector. This allows the relay to demagnetise much faster because with a 12V supply for example the coil inductance can empty into 63 volts instead of 0.6V. Also the armature separates from the pole piece much quicker so the contacts are less likely to stick. You can clearly hear the difference. If the sudden cessation of coil current is an issue then start off with a 1uF 63V cap from emitter to collector across the switching transistor to slow down the rate the current quits flowing in the coil.