Arduino Forum

Using Arduino => General Electronics => Topic started by: allym on Jun 19, 2018, 11:02 am

Title: Interference on an input
Post by: allym on Jun 19, 2018, 11:02 am
Hello I'm using a Leonardo clone and have digital inputs connected to pins 6,7,10,11 and 12.

Pin 7 is configured as an Interrupt. All inputs are setup as INPUT_PULLUP.

The inputs are wired to an alarm system with a 6v NiMh battery backup and an 12v ACDC 250 maH power supply.


The Problem

If the mains supply to the alarm is lost ( power failure, or turning off the switch on the wall socket), then this causes the interrupt to be triggered.

I have tried foil capacitors between +5v and GND - this does reduce noise however there are instances where the interrupt is still triggered.

Also, sometimes if it's not interference on the interrupt pin, then its on another input.

How can I resolve this ?


Thanks
Title: Re: Interference on an input
Post by: MarkT on Jun 19, 2018, 11:23 am
Is the alarm output active-high or active-low?  Is it open-collector or push-pull?

Is your ISR set to trigger on RISING, FALLING or CHANGE?
Title: Re: Interference on an input
Post by: allym on Jun 19, 2018, 01:02 pm
Alarm output is active high.

ISR is set to FALLING.

Apologies, how do I determine whether it's Open Collector or push pull?


Code: [Select]

   pinMode(7, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(7), IRQcounter, FALLING);


Thank you.
Title: Re: Interference on an input
Post by: MarkT on Jun 19, 2018, 01:55 pm
If the ISR is FALLING, it cannot fail to trigger on power down.  If the unit is active high, FALLING is
clearly the wrong mode to use isn't it?
Title: Re: Interference on an input
Post by: allym on Jun 19, 2018, 05:20 pm
Under normal circumstances, the Interrupt will react to Falling and interprets the number of falls..

On a power down of the mains, the alarm battery automatically takes over, so the interrupt should not be triggered at all. So I'm looking for a solution to prevent this from happening.

Please see the O-Scope reading.

_______              _______                _______
                 |                |               |                |
                 |______|                |______|
Title: Re: Interference on an input
Post by: Paul_KD7HB on Jun 19, 2018, 06:11 pm
Under normal circumstances, the Interrupt will react to Falling and interprets the number of falls..

On a power down of the mains, the alarm battery automatically takes over, so the interrupt should not be triggered at all. So I'm looking for a solution to prevent this from happening.

Please see the O-Scope reading.

_______              _______                _______
                 |                |               |                |
                 |______|                |______|
The question to answer is "on power failure, how long does it take for the battery to take over?". Even a microsecond is too long and the Arduino interrupt will detect it.

Paul
Title: Re: Interference on an input
Post by: allym on Jun 19, 2018, 06:49 pm
Thanks Paul. The answer is I don't know :(

By observation, the alarm doesn't lose power.

Is there anyway to resolve this?
Title: Re: Interference on an input
Post by: Paul_KD7HB on Jun 19, 2018, 08:16 pm
Thanks Paul. The answer is I don't know :(

By observation, the alarm doesn't lose power.

Is there anyway to resolve this?
Sure. Don't use interrupts. Monitor the pin in "loop()" and if you see it go low, save the millis() time and set a boolean to true to indicate the pin change happened. Then in your code, if the boolean is true see if the number of milliseconds that have elapsed is now greater than perhaps 500 and the pin is still low, then you know the power is really off and do something.

Probably other ways, but the solution is to test for something over a short period of time.

Paul
Title: Re: Interference on an input
Post by: TomGeorge on Jun 20, 2018, 08:31 am
Hi,

What device does the interrupt monitor?
How long are the wires from the device to the Leonardo?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you post a diagram of your project please, so we can see your component layout?

Thanks.. Tom... :)