I want to control some parts of my laser cutter with an atmega1284p. Besides the laser cutter I also wanted to control 3 220V devices. An exhaust fan, a water pump and a compressor with relay’s. Everything worked fine until I connected the 3 220V devices. If I switch off one of the devices the microcontroller reset’s itself 40% of the times. This is only when I connect the 220V devices. Also, I’m catching an unintended interrupt on a pin if a 220V device is switched on (interrupt pin is connected to a switch and pulled down with the internal pull down.)
Without them the microcontroller the relay’s work as expected. So, since the 220V devices are not electrically connected to the microcontroller board, I expect there’s some massive noise generated on the 220V line when switching on and off. So, what can I do to fix this? I’ve already “fixed” the noise on the interrupt by ignoring interrupts when switching the relay. But the resetting of the microcontroller can’t be fixed in software… Do the “Single Phase EMI Filters” work for this kind of problem? And how should I implement them. If I put one between the relay’s and the external device, do they filter only noise to the device, or also noise coming from the device?
I presume that the coils are driven by a DC voltage. That DC voltage may be somehow connected to the Arduino's 5V supply - maybe it is the 5V supply, or maybe it's something like a 12V supply from which the Arduino's 5V is derived. A schematic would be very helpful for a diagnosis.
If any of that is so, you'll need a suppression diode on each of the relay coils. The diode is connected directly across the coil, with the cathode connected to the positive terminal. When the coil is energized, the diode is reverse-biased, and doesn't conduct. When the coil is released, the diode conducts and dissipates the coil's inductive kick. Maybe you have those already; I can't tell from your post.
I also note that all of your 220V loads are motors. A motor load draws much more current when starting than it does running. High starting current can cause voltage dips that persist for longer than you might think. Aside from that, there's a possibility that the motor manufacturer wasn't thinking about sensitive electronics on the line when he designed his motor, so those motors may not be particularly kind to the power line when they start, or when they operate. To address those issues, consider DrAzzy's advice, above. You might consider using two filter capacitors - a "bulk" device of several microfarads, or even tens or hundreds of microfarads, and a ceramic disk in the neighborhood of 0.1 microfarads. The small capacitor has a low internal resistance, and filters spikes, while the bulk capacitor delivers current to the circuit when the power circuit struggles to keep up.
Don't think the power supply is the problem. I’ve tried a lab power supply on a different group, still got resets.
Also the grounded metal box is a bit of a problem since I already designed and made the pcb.
Anyhow, I think I solved the problem! I’ve found some ferrite cores and thought it wouldn’t hurt trying them out.
And it worked! Didn’t expect it would work, but wow, amazing. I "relayed" the hell out of it and haven’t got a single reset or error. So, is this a reliable solution?
Hi guys, if your relay board is opto-isolated and you pull the output pin low to energize the relay, you probably don't need a GND wire from the relay board to the Arduino, you just need the VCC from the Arduino 5V pin and 1 wire for each relay input pin IN1,IN2 etc. eliminating the ground wire can eliminate a lot of noise pickup. You will need a separate power supply for the relay board though, which you should have anyway.
tmd3:
I presume that the coils are driven by a DC voltage. That DC voltage may be somehow connected to the Arduino's 5V supply - maybe it is the 5V supply, or maybe it's something like a 12V supply from which the Arduino's 5V is derived. A schematic would be very helpful for a diagnosis.
If any of that is so, you'll need a suppression diode on each of the relay coils. The diode is connected directly across the coil, with the cathode connected to the positive terminal. When the coil is energized, the diode is reverse-biased, and doesn't conduct. When the coil is released, the diode conducts and dissipates the coil's inductive kick. Maybe you have those already; I can't tell from your post.
Flyback diodes fix a different problem, not this one.
satoer:
Anyhow, I think I solved the problem! I’ve found some ferrite cores and thought it wouldn’t hurt trying them out.
It'd help if you told us what those wires were. The control signals? The load?
leonardojc:
I use a RC filter in series with relay contacts.
R=100ohm
C=100nf
All your loads have electric motors - which take a very large inrush ie startup current. This can cause interference as you found. The amount depends upon when exactly in the mains cycle the relay contacts close - unpredictable. Hence it wouldn't cause your reset problem every time.The same applies to turning off, with the extra problem of suddenly open-circuitiing an inductor - the motor. This can give a large voltage spike.
Adding a series inductor - your ferrites - slows down both these pulses, and reduces interference. A good solution
The various 'snubber' suggestions would reduce interference ( and sparking at the contacts) when the relay contacts opened . May also be worth doing to extend the contact life.
A revived thread, but very informative. I agree with allanhurst ... a good solution.
I also think there's still room for improvement. My thoughts on a perfect relay board would be:
Configured by default to use opto isolation.
Flyback protection (diode + zener) on coil to improve turn-off time as opposed to diode only solution. This reduces turn-off bounce time and contact arcing.
Ferrite core in series with relay COM terminal to slow the rise/fall of voltage spikes across the contacts.
RC snubber designed to handle inductive load at only up to 50% of the relay's VA capacity.
Large MOV, sized to help protect and work with the snubber, further reducing contact arcing by clamping/limiting any remaining high energy spikes.
Good PCB design and component quality meeting all safety approval regulations.
Hmm, somehow I seem to have over looked cost as a consideration.
Jiggy-Ninja:
Flyback diodes fix a different problem, not this one.It'd help if you told us what those wires were. The control signals? The load?That filter is not in series with the contacts.
I tried the serial RC out in parallel to the inductive load and also works.