Undesired inputs being triggered...

Combining the power of the ATmega2560 MCU with onboard Ethernet, a microSD card slot, an efficient switchmode power supply, and a small prototyping area. [Product page]
Post Reply
Hmbucker
Posts: 6
Joined: Mon Feb 10, 2014 11:03 am

Undesired inputs being triggered...

Post by Hmbucker » Mon Feb 10, 2014 2:16 pm

Hi all,

I 've created a small lighting control system based on the Freetronics Ethermega.
I am using pins D14 to D33 as inputs all setup to be INPUT - HIGH to make use of the build in pull-up resistors.
I am using pins D34 to D49 as outputs to steer a Sainsmart relay board (OUTPUT - HIGH going to LOW in order to make the switch).
Meanwhile I also use the ethernet controller to make it possible to set the outputs using simple TCP commands.
All works fine, however, now and again I notice that lights have been switched on during my absence.
I am using the debounce library found here: http://www.arduino.cc/playground/Code/Debounce and increased the debounce to 100 ms.

Are there some pins involved apart from D4 (SS - Micro SD) and D50 to D54 for the ethernet?

Thanks in advance,
Koen

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Undesired inputs being triggered...

Post by andrew » Mon Feb 10, 2014 9:19 pm

Hmbucker wrote:Hi all,

Are there some pins involved apart from D4 (SS - Micro SD) and D50 to D54 for the ethernet?

Thanks in advance,
Koen
No, just those pins. Two things come to mind from a hardware perspective:
If you're just powering the EtherMega by USB and using Ethernet, it might reboot randomly. Use an external DC supply instead.
Use external pull-up resistors, much more reliable.

Hmbucker
Posts: 6
Joined: Mon Feb 10, 2014 11:03 am

Re: Undesired inputs being triggered...

Post by Hmbucker » Mon Feb 10, 2014 10:39 pm

I 've added extra debugging code which learned me that whenever I find lights turned on, it is caused by a "ghost" button press for at least 100 ms (debouncing).
So either, there is something weird with the ethermega, causing the pins to be pulled down for more than 100 ms, or there is something wrong with the debouncing algorithm.

Anyone same experience, ... solution?

Hmbucker
Posts: 6
Joined: Mon Feb 10, 2014 11:03 am

Re: Undesired inputs being triggered...

Post by Hmbucker » Mon Feb 10, 2014 11:44 pm

johnb wrote:
No, just those pins. Two things come to mind from a hardware perspective:
If you're just powering the EtherMega by USB and using Ethernet, it might reboot randomly. Use an external DC supply instead.
Use external pull-up resistors, much more reliable.
Thanks for the reply.
I am using an external regulated 12 V DC supply. I am logging to RAM so I noticed that the device is not rebooting, otherwise my debug info should be gone.
Regarding the reliability of the pull - ups, is that a known issue? I would expect pull -ups from 40K to 50K should be sufficient no?
I also saw that there appear to be 2 debouncing libraries: Debounce and Bounce. The Arduino website recommends to use the latter. I just find it strange that this one is older that the other.
I will check the difference between both tomorrow and check whether a root cause might be found there.

Hmbucker
Posts: 6
Joined: Mon Feb 10, 2014 11:03 am

Re: Undesired inputs being triggered...

Post by Hmbucker » Thu Feb 20, 2014 10:59 am

I 've added extra pull-up resistors, but unfortunately to no avail.
I keep finding my lights turned on once in a while, but I noticed that the two debouncing objects "Debounce" and "Bounce2" differ quite a lot, so I will try the other library and see what gives... :?

freak
Posts: 1
Joined: Wed Sep 10, 2014 2:36 am

Re: Undesired inputs being triggered...

Post by freak » Wed Sep 10, 2014 2:44 am

I know this is an old post but I had this same problem with the sainsmart relay boards. In my case I was switching 120VAC with the relay. The problem goes away if the 120V is removed and the system is left running as normal. What was happening was that when the relay switches this somewhat high voltage AC it was inducing a spike in the circuit which could appear on the input data lines. Therefore a input would go high without the signal actually being there. The solution was to place filter caps on the arduino outputs to ground. Before I knew what was happening, someone demonstrated it to me on a DSO.

Post Reply