Electronic – Using shielded audio cable for potentiometer sensor

adcfilterlow passnoiseshielding

I'm trying to measure a potentiometer from an Arduino's ADC. The potentiometer has a maximum value of 100k ohms and is located about 1 meter from the Arduino. The potentiometer's wiper is wired to the ADC pin and the pin to ground. I've enabled the 20k internal pullup on the ADC pin, so the potentiometer creates a logical high and low at the extremes. I have the potentiometer wired using two stranded 24 awg unshielded wires, twisted together.

To filter out noise, I'm using an exponential moving average on the Arduino. However, even with this, I'm still seeing a +/- 10 unit change several times a second, even when the potentiometer is completely still.

The two ways I've read about reducing noise in wires carrying analog signals are:

  1. Using a shielded cable

Would it make any difference if I instead used a two-conductor shielded audio cable? I have one audio cable that has a red and black wire, as well as metal shielding. If I attach my potentiometer's pin to the two wires, should I also wire the shielding to the ground or leave it unattached?

I see a lot of conflicting opinions over how to leave the shielding, with commenters in this thread suggesting to leave it ungrounded, or grounded at the sensor end, or grounded at the Arduino end, but definitely not grounded at both ends. Which is best for my case?

  1. Using a capacitor

How much of a difference would it make if I placed a 0.1uF capacitor across the wires, as a low pass filter? Should I place it on the sensor side or the Arduino side? Again, I've seen a lot of conflicting advice about this.

Best Answer

Why don't you connect potentiometer as people normally do, between GND and VCC? If you use 5-10K potentiometer you'll see much less noise on the input.

The reason you see so much noise is that your source impedance is too high, you simply don't allow enough current through to charge sampling capacitor in ADC. You cannot use less then 22k if you use internal pull-up, while ADC in MCUs usually optimized for about 10k source impedance.

There are three methods we use on electrical scooters with about the same distance to multiple resistive sensors.

  • add 0.1 uF capacitor between the wiper wire and GND right before MCU pin. The capacitor performs two functions. First, it filters out high frequency noise. Second, it further reduces source impedance by acting as local low-impedance source during sampling.
  • use shielded cable with shield connected to system ground near MCU. In your case this is not an option, but you might see some noise reduction if you connect shield to GND.
  • add ferrite core to high current switching power lines. Again, this might not be the case for you.

In short:

1) use 5-10K potentiometer
2) connect it between VCC and GND
3) disable internal pull-up
4) add 0.1 uF capacitor near ADC pin