3
\$\begingroup\$

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.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ How about a keypad schematic and datasheet? There is no way to determine if it is a hardware problem without knowing what the hardware is \$\endgroup\$
    – Matt Young
    Commented Jun 28, 2013 at 21:45
  • 1
    \$\begingroup\$ So, in a nutshell you are asking, can I connect a keypad to an arduino over a distance of 50m? \$\endgroup\$
    – Andy aka
    Commented Jun 28, 2013 at 21:46

2 Answers 2

3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ thanks - i think the way to go might be to move the microcontroller. But, I'll tryt he pull-up strategy as well and let you know. I really appreciate the input. \$\endgroup\$
    – renen
    Commented Jun 29, 2013 at 21:15
  • \$\begingroup\$ Thanks to all. I moved the Arduino controller to within 2m of the keypad and it worked perfectly. Interesting that Ethernet worked happily at that distance - clearly Ethernet does some other clever things! \$\endgroup\$
    – renen
    Commented Sep 9, 2013 at 19:25
2
\$\begingroup\$

Without having a circuit to go from I can envisage the electrical side of things working like this: -

3 column drivers and 4 row inputs. Each column is driven, in turn, with a short pulse and the 4 row inputs are "read" to see if the column pulse has been transferred to any of the rows because of a button closure.

OK so far? There could be a subtlety on this where there are 4 row drivers and 3 column inputs but the problem and solution would be the same.

With long cables that have inter-capacitance the pulse transmitted by a column driver would be capactively connected to all the row inputs. How much cable capacitance? About 50pF per metre for CAT5.

50m means 2.5nF and this will almost certainly be a problem because a column pulse will be strongly coupled to the other 4 wires used as inputs.

The solution is to try and lower the impedance on the 4 inputs and this may prove successful. You say the MCU provides weak pull-ups - these need to be reduced to smaller values for this to work and, as PeterJ suggests maybe try 1kohms.

\$\endgroup\$
3
  • \$\begingroup\$ thanks. as i said to peterj, I really appreciate the guidance. And, your explanation on the capacitance definitely helps my understanding. I'll certainly keep you posted as I muddle towards a resolution! :-) \$\endgroup\$
    – renen
    Commented Jun 29, 2013 at 21:17
  • \$\begingroup\$ @renen definitely keep us posted because it's an application that is good to get some data on its success. I'm sure others will be interested even if sometimes it might be flakey due to interference. The local MCU is probably the best route though ultimately. \$\endgroup\$
    – Andy aka
    Commented Jun 29, 2013 at 21:27
  • \$\begingroup\$ thanks - it took me a long while to create the time and space to get back to this. But, cutting the distance felt like the simplest solution. And, indeed, it worked. I appreciate your time and guidance though. \$\endgroup\$
    – renen
    Commented Sep 9, 2013 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.