GreyGnome / EnableInterrupt

New Arduino interrupt library, designed for Arduino Uno/Mega 2560/Leonardo/Due
329 stars 73 forks source link

Analog PIN - interrupt fired with minimal voltage change #55

Closed ale-trevizoli closed 5 years ago

ale-trevizoli commented 5 years ago

Hi. I'm using Mega2560 and Analog pin A8 to A15. I'm seeing strange behavior, using CHANGE, RISING or FALLING, any voltage change fire interrupt. example, if it's on 0V and goes to 1V interrupt fire. if it's 5V and goes to 4.9V interrupt fire. Could you help me?

Sorry for my poor english!

Thanks a lot! This library save my life!

GreyGnome commented 5 years ago

Hello, I would not expect the interrupt to fire based on the levels you mentioned. Are you sure there are no voltage spikes or dips? I think you need to scope your pin, and watch it very closely. My guess is that it is dropping well below 4.9V, if only for a microsecond, and it's rising above 1V- again, for a very short time. But the Atmega will pick it up.

Also, do you have a resistor on the pin pulling it high (or low)? If you have a switch or other high-impedance device connected to the pin, it may not be pulling the voltage the way you expect.

In short: it sounds to me like the pins are not seeing what you expect. I suspect a circuit problem, so use an oscilloscope to observe your signals.

On Tue, Apr 16, 2019 at 7:47 AM ale-trevizoli notifications@github.com wrote:

Hi. I'm using Mega2560 and Analog pin A8 to A15. I'm seeing strange behavior, using CHANGE, RISING or FALLING, any voltage change fire interrupt. example, if it's on 0V and goes to 1V interrupt fire. if it's 5V and goes to 4.9V interrupt fire. Could you help me?

Sorry for my poor english!

Thanks a lot! This library save my life!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GreyGnome/EnableInterrupt/issues/55, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSimVxVfEAPwB9F3a-EEGPR9vHpiYnTks5vhcZygaJpZM4cyKBk .

-- -Mike Schwager

ale-trevizoli commented 5 years ago

I will confirm it, we are not using resistor on pin. I will put it and test again. I thought it was the voltage variation, because if I put my finger on the pin, it triggers the interruption infinitely, and I used AnalogRead on pin inside function, and it show me random 0.1 to 0.5v decrease. But I will test with PULL-UP and PULL-DOWN resistor.

Again. Thanks a lot!

GreyGnome commented 5 years ago

Yes, the impedance on the ATmega is high. So if you put your finger on the pin, I would expect to see many interrupts. This is from your body's electrical field.

You should use either a pull-up or pull-down resistor, not both. Depending on your circuit. Usually a pull-up resistor is used.

On Wed, Apr 17, 2019 at 5:38 PM ale-trevizoli notifications@github.com wrote:

I will confirm it, we are not using resistor on pin. I will put it and test again. I thought it was the voltage variation, because if I put my finger on the pin, it triggers the interruption infinitely, and I used AnalogRead on pin inside function, and it show me random 0.1 to 0.5v decrease. But I will test with PULL-UP and PULL-DOWN resistor.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GreyGnome/EnableInterrupt/issues/55#issuecomment-484287517, or mute the thread https://github.com/notifications/unsubscribe-auth/AA2KFGMUZWE2MSAHKBSILULPQ6RHVANCNFSM4HGIUBSA .

-- -Mike Schwager

GreyGnome commented 5 years ago

This is not an issues with the library. I'm gonna close it.