Dear All,
I am trying to built an ESP32 controlled PLC.
The connection is:
ESP32 —> 16 channels 74HC595 shift register —> opto isolated 5VDC relay modules —> 240 VAC load
Without the AC load, the switching performed as programmed. However when the AC load is connected to the relay output, even the slightest AC load such as electrical test pen, will cause occational glitches.
Please advise the cause and the solution.
Best regards,
Herman
Hi.
Can you be more specific? What kind of glitches?
What exactly happens?
Regards.
Sara
This sounds like an issue with the pcb layout or system wiring coupling noise into the cpu. Do you have an experienced EE available to dig into this?
I am 100% certain the problem is not software related.
Hi Herman,
Details on kick back diodes for DC and MOV’s for AC:
Today
Relays and kick back diodes 240 V. A.C.? detail kick back diodes
Relays are electromagnetic switches often used to control high-power circuits, and they can generate voltage spikes when the current through their coils is suddenly interrupted. These spikes, known as “inductive kickback,” can damage other components in the circuit.
For DC circuits, a flyback diode (also called a kickback diode) is commonly placed across the relay coil to suppress these spikes. The diode provides a path for the current to dissipate safely when the relay is turned off, protecting the circuit. However, in AC circuits like 240 V AC, the situation is different. Since the current alternates direction, a single diode isn’t effective. Instead, other methods like snubber circuits (a combination of resistors and capacitors) or MOVs (Metal Oxide Varistors) are used to suppress voltage spikes.
–from Microsoft’s Copilot
Regards,
William
Hi Herman!
Please note that it is not enough to use an opto isolated 5VDC relay module to protect the electronics against glitches. It is mandatory to have …
– a flyback diode connected in the blocking direction in parallel to the coil of the relay
– a galvanic separated DC 5V supply for the relay module
– some mechanical distance between your CPU board and the mains power circuit
First mentioned is required to avoid the voltage pulse due to self-induction when switching off. Possibly a flyback diode is already part of the relay circuit, otherwise there is a high risk to damage the electronics when you switch off the relay.
Second mentioned is required to avoid transmission of noise or glitches to the electronics. Please note that for optic isolation it is mandatory to have absolutely no connection from the Plus or the Ground of the separate DC5V supply to the powersupply of the CPU!
Third mentioned shall help to reduce EMC, which may be responsible for extra clock pulses that lead to shifting the switch-on bits to a wrong position.
Regards,
Manfred