Electronic – arduino – Measuring closures at 50m

arduinonoise

I hate to say it, but I am an electronics noob. Well, I've had some successes, so I probably know enough to that there's a lot I don't know.

I'm having problems with, I think, noise.

I have keypad at my gate which I would like to use to open the gate for people who have a valid PIN. Elementary.

There is a nifty little Arduino library that drives a PIN pad, and got that to work under controlled circumstances: I plugged a test PIN pad directly into the arduino, and, everything worked as anticipated. The documentation is here: http://playground.arduino.cc//Code/Keypad

However, when I connect the gate keypad to the Arduino over a 50m Ethernet cable, things don't work as I expect. The Arduino senses closures on the wire. Dozens, in the space of a few seconds (I think the libraries debounce mechanism may act as a rate limiter).

The closures result in readings as follows:

222222222222112222221
222222222112222212222
212222222221222222222
221321222222222212222
222132222222222221322

So, in general, the centre colum of keys, with a few closures from the first and last columns. If I remove the connector from the first row, a similar, seemingly random pattern repeats, but this time reflecting closures on the second row:

556565555555555555555
555555555555555555555
565555556555555555555
555655555555555565555
556555555555555555554

I conclude that the Arduino is sensing random closures (and that the library scans the first row before it scans the second). Which is interesting as I understood the pullup resistor on the Arduino should have dealt with this ("You won't need external resistors or diodes because the library uses the internal pullup resistors and additonally ensures that all unused column pins are high-impedance").

The keypad is about 50m away from the Arduino, and the connections are made over Ethernet, twisted pair cable (which does not carry current). The cable runs past a pool pump and parrell to (although in seperate conduit) the electrical feed to that pool pump. Somebody ran an angle grinder through the Ethernet wire and consequently the keypad is connected to the Ethernet cable in a junction box that also includes a small 240V to 1A DC transformer, and a slew of other wires.

If I methodically test all the closures from the keyboard over the 50m ethernet run, my tests are positive in that I see the resistance fall to near zero whenever a button is pressed on the keypad.

Software is my game. So, in theory, I could pile into the library and apply myself to improving it. But, I sense that the problem is an electronics one.

I would really value any input as to how to correct this situation (short of moving the Arduino to the keypad). If it is even possible to reliably measure a closure to at 50m.

Best Answer

Looking at that library it uses the internal pull-ups on the AVR which are quite weak. It might be worth adding some 1K pull-up resistors on the rows and see how that goes to drive the lines harder. Also take a look in the code and see how long the delay is between driving the row and reading the column, it might be worth adding a delay in case capacitance over the long cable length is coming into play.

A more robust solution would be to use a microcontroller at the keypad end and transmit the data back using something like the RS 485 standard that is based on a differential balanced line. That could be done quite cheaply but would involve quite a bit of extra research / effort.

Related Topic