1
\$\begingroup\$

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.

\$\endgroup\$
  • 3
    \$\begingroup\$ It could be just noise inherent in the ADC. How much noise is there if you just put a fixed resistor directly at the Arduino, without the pot and cable attached? \$\endgroup\$ – crj11 Aug 20 '18 at 23:23
  • \$\begingroup\$ No. An Arduino ADC should be rock steady if the impedance is low enough (even 100K should be ok). \$\endgroup\$ – squarewav Aug 21 '18 at 4:42
1
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Because you would need an extra conductor for that (2 conductors with shield for ground). \$\endgroup\$ – squarewav Aug 21 '18 at 4:45
  • \$\begingroup\$ Yes, and you would eliminate the noise in the process. What's you point? \$\endgroup\$ – Maple Aug 21 '18 at 4:48
  • \$\begingroup\$ I connected it as I did, using only 2 wires and the internal pullup, to reduce wiring. I have a few of these installed, and although it might not seem like much, having 2 wires per sensor instead of 3 reduces a lot of clutter. How would a conventional pin-1=VCC, pin-3=GND wiring reduce ADC noise? \$\endgroup\$ – Cerin Aug 21 '18 at 4:53
  • \$\begingroup\$ @Maple - Because two conductors with a proper shield is much less common than coax. If they have to order something anyway, then I agree, use 2 conductor with shield to allow lower impedance. That would definitely solve the problem. \$\endgroup\$ – squarewav Aug 21 '18 at 4:55
  • \$\begingroup\$ @Cerin - You would need 2 conductor + shield to supply Vcc separately to pin 1 as stated in my answer. That would allow you to use a 10k pot which is lower impedance and will pickup less noise by at least a factor of 10 (20dB). That and the shield would definitely solve the problem. \$\endgroup\$ – squarewav Aug 21 '18 at 4:57
0
\$\begingroup\$

Your question does not define your PSU conducted or radiated noise or method of grounding. Thus radiated noise, conducted ground noise and common mode local noise from SMPS is unknown.

To isolate your problem you can place a cap directly across the source output and measure, then move to receive input and measure.

Zc(0.1uF)=30kOhm @50Hz

If the noise problem is fixed, with 0.1uF then you know the noise is not 50 Hz but much higher than this.

If not fixed then you may suspect 50 Hz and try 100uF or more. If this makes an improvement, then you can suspect a common mode noise creating a differential noise signal due to the layout of cables and supply. Then consider a 0.1uF cap from Earth ground to 0V DC on the Arduino. retest and compare results.

Earth shielded twisted pairs may be a good solution as well.

By grabbing both DC power cable and signal cable and check noise results you can infer that if it increases, that CM noise coupling is an issue with unbalanced input impedance for the ADC, which causes CM stray noise current to be converted into a differential voltage. Cable proximity and 0V ref. and decoupling may also be improved.

\$\endgroup\$
0
\$\begingroup\$

Yes, to 1. A good piece of coax will almost certainly solve your noise issues completely. No cap necessary. But it has to be a full-coverage shield. It can be either foil or copper wrap but if the cable is moved at all or even if there's a small vibration, a foil shield can generate noise so a wrap shield is better. If the pot terminals are 1 for CW, 2 for wiper and 3 for CCW - connect the coax signal wire to both 1 and 2 and then the shield to 3. Try to make the shield get as close to pin 2 as possible. At the ADC end, obviously the conductor goes to the ADC pin and shield to ground of uC. Use internal pull as stated.

If that doesn't resolve the issue to your statisfaction, you can improve things further by using a 2 conductor w/ shield cable (like the kind used in wiring audio patchbays like Redco TGS-02 with the jacket removed) and use one conductor for pot terminal 1, the other for the wiper and pin 3 to the shield. Then supply the logic high voltage to terminal 1 through a 100R resistor and use a 10k pot. Dot NOT use internal pullup in this case. This will reduce the impedance of the whole thing drastically and reduce noise accordingly.

Neither of these scenarios leave the shield unconnected at either end. You would only consider that if you had more circuitry at the far end that is connected to a different ground.

\$\endgroup\$
  • \$\begingroup\$ "if there's a small vibration, a foil shield can generate noise" Huh?! Just where did you get this from? "coax will almost certainly solve your noise issues completely" where did coax came into picture? Shielded cable and coax are two different things. \$\endgroup\$ – Maple Aug 21 '18 at 4:59
  • 1
    \$\begingroup\$ Yes, it's called "Handling Noise". Google it. Coax is a type of shielded cable so they are not really different. I would bet $5 that coax would work because the shield impedance would be very low and protect the signal conductor. If not, then yes, 2 conductor + shield is necessary. \$\endgroup\$ – squarewav Aug 21 '18 at 5:11
  • \$\begingroup\$ I did google it. Most of so called "handling noise" is related to microphone. Very few references on the "noise produced by be bending" shielded cable. Reads more like science fiction or marketing for gullible audiophiles. \$\endgroup\$ – Maple Aug 21 '18 at 5:24
  • \$\begingroup\$ No. I have a cheap mic cable that makes noise that you can actually hear. If you just move it back and fourth it makes a crackling sound. \$\endgroup\$ – squarewav Aug 21 '18 at 15:15
  • \$\begingroup\$ You realize that the currents, voltages and amplifier gains related to microphones are nowhere close to typical ADC use cases in MCUs. Unlike microphones there is a flexibility in the choice of potentiometers. Reducing source impedance is an easy and sure way to deal with ADC noise. Using coax with high resistance pot is basically fighting self-created problem without guarantee of success. \$\endgroup\$ – Maple Aug 21 '18 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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