Wawa:
Try a diode across the motor, cathode/ring to motor+.
Leo..
Thank you. I tried it but nothing changed. It looks like there is a spike when I switch the motor on or off. The problem is less when I use 2 power supplies, one for arduino and one for motor. But I prefer a single supply.
I tried everything. Of course with the Capacitor and diode across the motor things get a bit better but the problem is still there.
I read other posts about adding and grounding an aluminum case around the Arduino, using shielded cables, decoupling capacitors everywhere, or a ferride bead (which I don't have at the moment).
The mystery is that arduino's pins are affected even with dual power supplies and when only one cable is touching the relay.
Even if nothing is touching the arduino, if I don't include the capacitor and diode across the motor, the interference is passed, even through the air!
I attempted to measure on my oscilloscope the triggered motor alone with the Power Supply (set on 5A limit which is the maximum) with no capacitors and just a single switch. I captured the screen and the parameters at the moment I pressed the switch.
From what you see in the screen, even if oscilloscope probes are directly connected to the 12V power supply (5A max), as soon as I press the switch, it measures spikes high as 29.8V and low as -4.30V. This is unbelievable !
UKHeliBob: As expected, Electric Noise fires Interrupt on digital pin.
Ok thanks for your point.
But what is the single secret to eliminate this particular nasty noise that makes arduino spit like an ugly tart when using a single power supply?
ballscrewbob:
... smaller capacitor as that one is WAAAAY too big....
I must admit you really hit a point with that statement. I googled it and I got the following:
"Its not the larger capacitance value which would cause trouble, its the likelihood of your larger capacity cap also having larger ESR (resistance) or ESL(inductance). Excessive resistance and/or inductance in the cap itself will prevent it from being effective at decoupling."
ballscrewbob:
... And not sure why you have that switch wired the way you have it either. ....
That was just for the demo. Doesn't make sense indeed.
ballscrewbob: @Athanassios
...
Continued cross posting could result in a time out from the forum.
....
Ok. I have made a mistake, not a crime.
Nevertheless, thanks for your wonderful reply. I' m about to order some of those ferrite rings and test my luck with some shielded cables and smaller decoupling ceramic capacitors.
If the pin is triggering when connected to ground you must be picking up strong magnetic interference
that's inducing voltages directly on the wire - this may be due to poor layout, making big loops with
you signal wires will act as magnetic loop antennas.