Problem with Controlling Relays (Suspected Relay Contact EMI Issues) - Page 1
Forum section: electronics / projects

author: Grazing
author_rank: Newbie
timestamp: July 29, 2025, 06:02:43 pm
content: Problem with Controlling Relays (Suspected Relay Contact EMI Issues)Hello everyone, hope you are having a lovely day! I am having some problems with my project so any help would be much appreciated.BackgroundI am working on a project in which I need to switch many relays. The main components I am working with are:- Many wall switches (normally-open momentary push-button switches)- Many relays- A 12V switch mode power supply- An MCU board (ESP32 dev board)- Many serial in parallel out shift register ICs (74HC595) (for MCU output pin expansion)- Many parallel in serial out shift register ICs (74HC165) (for MCU input pin expansion)- Many darlington pair BJT ICs (ULN2803) (to drive the relays)- A buck converter board (MP1584EN) (for MCU voltage supply)Block DiagramI know the general structure is not the best, I am trying to improve a system that was already in place.SchematicsSIPO shift register and BJT driverOutput relaysPhysical RealizationsEach module is approximately 12 inches apart.The ProblemWhen the MCU tries to toggle any output, the output relays behave unpredictably. Sometimes the one that is sent the signal toggles and the others don't. Sometimes all 8 toggle. Sometimes they toggle twice quickly. The MCU reports the correct states but the physical situation doesn't match what the MCU is doing.Troubleshooting-The problem isn't the code:Everything works beautifully when I swap the relays with LEDs.-The problem isn't EMI ???:The incorrect behavior described above persists even when the digital electronics part is ~3 feet from the relays.-The problem IS EMI ???:Everything works beautifully when theload is disconnectedfrom the normally open output of the relay.-I don't even know anymore:The problem gets partially solved when I recreate the shift register-bjt driver circuit above on a breadboard but with the two ICs 1 inch apart.The breadboard circuit:ConclusionI am not sure what exactly is happening. I am not sure how to solve it. I would appreciate any and all help.Thank you in advance!Bonus Question!How can I make the whole thing better? I'm sure sending single ended digital signals over bare wire is not the best solution. I am open to suggestions. (everything before the input relays and after the output relays -including the relays in both cases- were already installed so I want to reuse them)

author: David Hess
author_rank: Super Contributor
timestamp: July 29, 2025, 07:09:28 pm
content: My guess is that sharing the ground between the 3.3 volt logic and 12 volt relay supplies is coupling noise from the relay side to the logic side.I do not see any local decoupling between the ULN2803 and +12 volt relay supply. There should at least be a bulk decoupling capacitor on each ULN2803.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 30, 2025, 01:14:22 am
content: Quote from: Grazing on July 29, 2025, 06:02:43 pmYes, this is a classic induced noise causing false clocking issue.Once you add the load to the relays, you now have very large dV/dT signals very close to everything else.It only takes femto-farads of coupling, for that to disturb the inductance of long cables, especially those carrying clocks.Multiprong approach can help mitigate this.Physically move everything to give lowest femto-farads between your mains and your controls. Never run the cables close or parallel. Shielding helps.PCB design and even relay selection can also lower the fFYou can also locally deglitch the clock: a bare HC595 can 'see' single-ns pulses, so you want to filter those.If your shift register has SCHMITT pins, this can be as simple as a RC circuit, otherwise add an external schmitt(s).This reduces your max shift clock, but for relays that's usually quite slow.Optocouplers are also commonly used, these slow everything down, and allow you have multiple barriers between the high dV/dT and your master MCUThere are also parts called optocoupler emulators eg CI-0611-500E, CI-063L-500E (dual) from Tokmas & ISOM8116 from TI etcYou can get 595+2803 in a single package. eg TLC6C598, TLC6C5912, TLC6C596, NPIC6C596D etc

author: Grazing
author_rank: Newbie
timestamp: July 30, 2025, 08:38:23 am
content: Quote from: David Hess on July 29, 2025, 07:09:28 pmThanks for replying!Putting a cap between the GND pin of ULN2803 and +12V is not going to be easy because I don't have +12V on the board. I will try your suggestion on the weekend and report back.

author: Grazing
author_rank: Newbie
timestamp: July 30, 2025, 10:55:17 am
content: Thanks for replying!Quote from: PCB.Wiz on July 30, 2025, 01:14:22 amI have been trying to keep wires carrying clock, latch, and data signals away from each other and the switched mains. The closest wire I have to the switched mains is the output wire of the ULN2803 connected to the relay coil.Quote from: PCB.Wiz on July 30, 2025, 01:14:22 amI have thought about differential signaling between the boards but I might try these first. Looks like I have lots of work ahead of myself with trying your suggestions and various filteringmethods etc.

author: David Hess
author_rank: Super Contributor
timestamp: July 30, 2025, 12:57:08 pm
content: Quote from: Grazing on July 30, 2025, 08:38:23 amThe idea is to reduce the loop area of the higher current load as much as possible.

author: Grazing
author_rank: Newbie
timestamp: July 30, 2025, 01:25:55 pm
content: Quote from: David Hess on July 30, 2025, 12:57:08 pmSo, we are thinking that the voltage change caused by the closing of contacts (+ some arcing maybe) induces noise on the +12V line. And because the ground of the +12V and +3.3V are the same, the noise effects the digital part of the system.Reading your reply again, assuming the higher current load you are talking about is the relay coil driving current, wouldn't the problem persist when the load is disconnected?

author: Sorama
author_rank: Frequent Contributor
timestamp: July 30, 2025, 01:50:33 pm
content: one of our automation controllers drive 32 relais 12V (230V contacts) with 4 (obsolete) UCN5801 latched drivers without any issue.Common of all power lines (12V and 5V) are all tied up.

author: David Hess
author_rank: Super Contributor
timestamp: July 30, 2025, 02:03:10 pm
content: Quote from: Grazing on July 30, 2025, 01:25:55 pmThere is still coupling between the coil and isolated relay pins.PCB.Wiz is correct also. The clock pins are very sensitive to noise. If the layout cannot be improved, then RC filters should be added close to the clock pins, and there the loop area between ground, supply, and the clock pin should be as small as possible.