Go Down

Topic: Tactile button maximum cable lenght? (Read 6249 times) previous topic - next topic

MrGlasspoole

Hi,

what is the maximum cable length to connect a tactile button to the Arduino?
What cable would be the best (awg)?

CrossRoads

You can probably go pretty far, may need to add addtional pullup resistor to ensure  a good high level when the switch is open.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

MrGlasspoole

Or pulldown. But what do you mean by additional?

So 10-20 meters will not be a problem?
Maybe shielded cable?

I also have some water flow sensors here - here also I ask myself how long I can make
the cable.

CrossRoads

This is what I mean by additional - not relying on internal pullup resistor.

Hard to say about the flow sensor without any data.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

MarkT


Or pulldown. But what do you mean by additional?

So 10-20 meters will not be a problem?
Maybe shielded cable?

I also have some water flow sensors here - here also I ask myself how long I can make
the cable.


_Definitely_ shielded cable for that length, and some protection at the Arduino end from transients (1nF -- 10nF or so to ground?).  
Where-ever you run cables for long distances near mains wiring (hard to avoid) you should expect switching transients to be an issue.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

fungus


what is the maximum cable length to connect a tactile button to the Arduino?
What cable would be the best (awg)?


I dunno, but it's a looooooong way.


Do the math:

At 5V DC the AVR chip recognizes anything below 1V as "LOW" so you can afford to lose 4V over the wire.

The internal pullup resistors are about 30K Ohms so a pin will put out 0.15mA when configured as an input with pullup enabled.

Here's a table of wire gauges with resistances in ohms per kilometer (or kilofeet if you're still using old-fashioned units):

https://en.wikipedia.org/wiki/American_wire_gauge#Tables_of_AWG_wire_sizes

You've now got two of the variables in Ohm's law (current and resistance) so the rest is easy.

V = R * 0.00015

Any value of R that gives an answer less than 4V over your required distance is good enough (though you may want to limit it to 1V just to be on the safe side...)

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

CrossRoads

1V is not correct.
V in high minimum with Vcc = 5V is 0.6 * Vcc, or 3V.
V in low maximum with Vcc = 5V is 0.3 8 Vcc, or 1.5V.
So you want that pin sitting above 3V when the switch is  open, or below 1.5V when it is closed.
1.5V to 3V, you may get high or low readings from that.

See Table 29-1 in the '328 datasheet.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Arty



what is the maximum cable length to connect a tactile button to the Arduino?
What cable would be the best (awg)?


I dunno, but it's a looooooong way.


Do the math:

At 5V DC the AVR chip recognizes anything below 1V as "LOW" so you can afford to lose 4V over the wire.

The internal pullup resistors are about 30K Ohms so a pin will put out 0.15mA when configured as an input with pullup enabled.

Here's a table of wire gauges with resistances in ohms per kilometer (or kilofeet if you're still using old-fashioned units):

https://en.wikipedia.org/wiki/American_wire_gauge#Tables_of_AWG_wire_sizes

You've now got two of the variables in Ohm's law (current and resistance) so the rest is easy.

V = R * 0.00015

Any value of R that gives an answer less than 4V over your required distance is good enough (though you may want to limit it to 1V just to be on the safe side...)




I dont think the resistance is the problem... I would more worry about induced currents and capacitance. Therefore it mainly depends on your environment.

fungus


So 10-20 meters will not be a problem?
Maybe shielded cable?


Should be no problem at all (so long as you don't pass next to any spinning magnets).
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus


I dont think the resistance is the problem... I would more worry about induced currents and capacitance. Therefore it mainly depends on your environment.


I don't think capacitance matters for a push button.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

retrolefty



I dont think the resistance is the problem... I would more worry about induced currents and capacitance. Therefore it mainly depends on your environment.


I don't think capacitance matters for a push button.




I agree. The high voltage switching margins for a AVR input pin (.3vcc/.7vcc) gives the input pin quite a bit of 'noise immunity' and one should be able to run a passive switch contact a pretty long distance. I would consider using an external pull-up resistor of 1K ohms to lower the overall impedance of the switch wiring 'loop'. Anyway, as with any passive switch input you should use some kind of software debouncing function anyway, so any capacitance and inductive effects of a long wire run will not be a factor, you could probably reliably read a passive switch contact with a 1000 ft of twisted pair cable if you really wanted to. The problem with long cable runs is when one is trying to pass higher speed data signals where the cable run capacitance and inductive reactance has an effect of signal rise time, fall time, signal reflections, and external EMI interference.

Lefty

freakdaddy

#11
Apr 25, 2016, 03:18 pm Last Edit: Apr 25, 2016, 03:23 pm by freakdaddy
You can probably go pretty far, may need to add addtional pullup resistor to ensure  a good high level when the switch is open.
(Old thread I know)  I've been researching this topic and I want to question your statement.  I'm a novice but what how does the strength of the pullup have any effect when the switch is open?  It seems that if the switch is open any length of wire attached to the input has no effect.  How can a long wire affect the level?  It seems that even if a signal is induced onto a long wire that it would have no effect since the line is already high.  On a length of open wire what could possibly cause it to bring the line low other than a connection to ground?

MorganS

A long wire is an antenna. It picks up electrical and magnetic noise. The stronger pullup increases the signal-to-noise ratio.
GoForSmoke: "What GShield? You never mentioned a shield."

Steveiboy

This is what I have done in the past, See image.
My switches where 500ma rated gold plated contacts and limit switches are 10amp rated(minimum current for these to work correctly is 50Ma) and I use 8 of them, the system runs from 24V (could be 12V) and I used 3 1K5 resistors in parallel to create 50Ma current draw (this is to make sure good contact is made) A zener diode to clamp and a schottky diode then a 4K7 pull resistor and then 100K current limiting resistor with a 100N as the filter, I've found this very reliable and my cable length is about 10 meters and it has never suffered any problems or incorrect press detects, Also in the code is some debcounce routine. On checking with the scope the signal to the Arduino is very clean. Also carried out noise test's and induced 100-1000khZ noise on the line and still a clean signal and no issues. The 3 resistors and switch are mounted off the PCB, At the end of the 10meters of cable)

Comments welcome.

freakdaddy

A long wire is an antenna. It picks up electrical and magnetic noise. The stronger pullup increases the signal-to-noise ratio.
But that is kind of my point.  So it picks up some noise.  The noise could only be an impulse right?  How could it be a drain that would drag the line low?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy