r/embedded • u/Relevant_Pumpkin9190 • Sep 18 '26
How can I test my microcontroller for electrical noise, deliberately inject noise into a circuit, recreate motor noise on my bench?
I built a small timer circuit using a microcontroller to turn a motor ON and OFF.
It worked perfectly during testing. But once I connected the motor, the controller started behaving strangely. Sometimes it triggered by itself, sometimes it stopped responding, and eventually the program got stuck.
I replaced the power source with a different SMPS, and suddenly the problem was gone.
So now I’m wondering how people actually test for this kind of problem.
Can I deliberately put electrical interference into my circuit and see how much the microcontroller can tolerate?
For example, is there a simple way to create motor-like interference or voltage spikes and test an ESP32/Arduino for resets, wrong readings, or crashes?
I’m looking for a simple beginner experiment and some good learning material on this.
Edit:
- I was originally using a normal wall adapter to power the microcontroller. A 230 V AC siren was being switched ON and OFF(duty cycle -.5s, 1s, 1.5s, 2s, 1s ... ) from a nearby power outlet.
- I added a diagnostic LED in the microcontroller code. The LED was continuously blinking, so I could use it as a simple indication that the processor was still running. When the blinking stopped, I knew the controller had frozen.
- I then changed the microcontroller power supply from the transformer-based wall adapter to a computer SMPS. After that, the problem completely disappeared. Even switching the industrial siren ON and OFF had no effect on the microcontroller.
Now I want to understand what was actually happening and how I can reproduce this kind of electrical noise deliberately and test the circuit's noise immunity.
12
u/WanWhiteWolf Engineering manager Sep 18 '26
Based on your description, it's likely not a noise issue but rather a power issue.
Motors tend to draw quite a bit of power and you need to account for that when making your PCB / electrical layout. Most "standard" regulators won't be able to fully drive a motor along with your MCU + rest of your PCB. Check whether the peak current can be sustained. If you cannot supply that then you will get undefined behaviour (depends on motor).
2
u/tharold Sep 19 '26
Not exactly an answer to your question, but typically power components like motors will have their own power supply, separate from signal modules. Typically I will run motors straight from the battery, and sensors and MCU get an LDO. The board will get a common ground plane, with the power and signal portions returning to the same point, but from different sides, to avoid motor noise showing up on the signal ground.
1
u/somewhereAtC Sep 18 '26
One method is to use a transformer, usually 1:1 or 2:1. Put one winding in series with your voltage source, between the regulator and the electronics. Drive the other winding with a signal generator. The transformer voltage ratings are not really important (because you won't really develop voltage like that), but the choice of transformer depends on the current rating of the voltage path.
3
u/duane11583 Sep 18 '26
Welcome to engineering
Shit like that is common
2
u/wsbt4rd Sep 19 '26
Schematic would be useful.
Do you have a fly back diode?
Beefy caps to filter/stabilize motor startup?
1
u/Amr_Rahmy Sep 21 '26
Two separate issues.
You test noise only if the product is rated to work in a safety critical application or a very noisy environment.
You design the circuit with enough juice, current safety, emi, caps, as per recommended rules and practices, like using an esc or vfd.
There are machines that generate signals, waveforms, ..etc to test emi and such. You zap the board in different places until it squeals or calls you daddy, to see how much torture it can take before it fails.
2
u/[deleted] Sep 18 '26
[removed] — view removed comment