I've this relay (5V) with 1N4148 as flyback diode across the relay's coil but there's still noise problem. When I switch on/off the relay, the PIC MCU will occasionally reset and false triggered the interrupt-on-change pin (a switch with pull-up resistor) all the time. The problem doesn't happens when the load (an electric lock) is not connected to the relay.

So my question is:

  1. What is the cause of the problem?, I have a flyback diode but the problem still exists. Did I do something wrong?
  2. Does position of the flyback diode in PCB layout matters and where should I place it.
  • 4
    \$\begingroup\$ My glass ball is currently in factory repair, so I am afraid I would need to look at a schematic to do any guesses. \$\endgroup\$
    – PlasmaHH
    May 24, 2015 at 20:46
  • 2
    \$\begingroup\$ You say it doesn't happen when the load is not connected? That suggests the problem is the load is causing the problem - it too may be inductive in which case it too needs a flyback diode, not just the relay coil. \$\endgroup\$ May 24, 2015 at 20:52
  • 1
    \$\begingroup\$ I agree with Tom, the load itself being an electric lock must be inductive and causing the noise. You can also use capacitors in various places to assist with filtering the noise. \$\endgroup\$
    – KyranF
    May 24, 2015 at 20:57

2 Answers 2


While rerouting wiring to avoid noise coupling is definitely a good idea, I would also recommend adding a RC (for AC loads) or diode (for DC loads) snubber at your load, i.e. putting it across the terminals of the electric lock itself -- cleaning up the load's inductive spike at its source also avoids radiating noise from the wiring that could interfere with other devices.

  • \$\begingroup\$ After putting a diode across the load terminal, the MCU now works as expected. Thanks. \$\endgroup\$
    – rudwna
    May 26, 2015 at 3:13

The relay coil flyback diode should be as close as possible to be across the relay coil terminals.

Since you say that the problem does not happen when the load is not connected to the relay then it is likely that the load is what is causing the problem.

If the load is fully isolated from the MCU board and its power supplies then the problem is some type of inductive coupling or injection into your MCU board. Try temporarily wiring the load on longer lead wires so that you can move it around and away from your MCU board. That may help you evaluate the source of the noise problem.

If the load is not fully isolated from the MCU board (such as if they share power supply rails or GND bus connection) then it may be a voltage bounce problem is what is causing the problem. Write a simple version of your program that activates the relay repetitively and then look at the relay load waveform on a scope at the same time as the GND and VCC near your MCU. Look to see if one or the other has a spike or change in its voltage level at the same time the load turns on or off. Current surges in the load can make the voltage rail spike or cause the GND to bounce away from 0V on some parts of the GND wiring. Using this technique can help a lot in evaluating the problem and give you an opportunity to experiment with changes to improve on the design away from the problems.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.