Go Down

Topic: Interrupt attached to PIN 2 triggers unexpectedly, caused by 12v motor (Read 308 times) previous topic - next topic

Athanassios

Please refer to the attached image. I simplified my project to a bare minimum in order to show the problem.

Every time I press the switch (please see the attached image) the interrupt at pin 2 trips unexpectedly

I share a single power supply with Arduino UNO, the relay and the motor.

Even if I exclude the relay completely, any powering of the motor triggers unwanted interrupts at pin 2.

I even connected the pin 2 to ground.


My Code is simple and includes:


Code: [Select]

...
attachInterrupt(0, myfunction, FALLING);

...

 

I would ask you please if you know something and help me a bit because I am becoming crazy.

Thank you.


Wawa

Try a diode across the motor, cathode/ring to motor+.
Leo..

Athanassios

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.

Any ideas?

groundFungus

In addition to the flyback diode, try a 0.1uF (or bigger) across the motor. 
You will save everyone's time if you read and follow the forum guidelines.  :)          
https://forum.arduino.cc/index.php/topic,148850.0.html
and
https://forum.arduino.cc/index.php?topic=97455.0

Athanassios

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 !







Athanassios

#5
Sep 21, 2020, 09:23 am Last Edit: Sep 21, 2020, 09:28 am by Athanassios
SOFTWARE: 

I simply attach PIN 2 to interrupt:

Code: [Select]
attachInterrupt(0, fired, FALLING);

HARDWARE:



PROBLEM:

Every time motor starts, the interrupt on PIN 2 fires unexpectedly, probably due to noise.


UKHeliBob

Surely the thread title should be

As expected, Electric Noise fires Interrupt on digital pin.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

TheUNOGuy

Every time motor starts, the interrupt on PIN 2 fires expectedly due to noise.

Your answer
It's better if you check the internet  ( your friend ) before posting..! :D
#Learn how to use the FORUM - https://forum.arduino.cc/index.php?topic=148850.0

Athanassios

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

Ferrite rings, shielded cables, smaller capacitor as that one is WAAAAY too big, feedback / flyback diode, twisted pair cables.

Any or all the above.

Google "reduce emi interference"

EDIT
Also think one of the caps on your voltage regulator may be wrong size too. Normally one is a larger value and one is a much smaller value.



And not sure why you have that switch wired the way you have it either.

Most look like simple fixes



It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

ballscrewbob

@Athanassios

MERGED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Athanassios

... 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."



... 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.


@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.


MarkT

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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up