1
\$\begingroup\$

What's a reliable method of getting a clean measurement of the potentiometer in a hobby servo?

I've modified a servo for directly polling its position by soldering a wire onto its potentiometer's center lead, as described here. I then wired this lead to an Arduino's ADC pin, but I'm finding the readings to be extremely noisy even when the servo isn't moving. I tried using a moving average to smooth the signal, but even that results in jittery value.

Is this just the nature of a servo's potentiometer, so is there a better way to wire to clean the measurements?

Edit: By "noisy", I mean even when the servo wasn't moving, the ADC measurement taken by the Arduino could vary by ±50 units between readings.

\$\endgroup\$
1
  • \$\begingroup\$ What do you mean by "extremely noisy"? Could you post a plot? Adafruit didn't bother to post their measurements; maybe you can do better. \$\endgroup\$ Feb 2, 2016 at 2:29

3 Answers 3

1
\$\begingroup\$

What is connected to the other two leads of the pot?

The linked page is vague about how that's handled. If it's power and ground, how clean is the power in question - if it's the same power that's being supplied to the motor, it may be a bit filthy when the motor is running, anyway. If you were "following" that vague page and the center pin is the only thing you connected - well, there's your problem - give it clean power and ground and things will get much better.

Try some capacitance (aka, a low pass filter) between the ends of the pot on the one hand, and between your signal input pin and ground on the other.

If you have access to an oscillosope, look at the signal from the wiper (center pin), and at the supply (across the end pins of the pot.)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Don't go overboard with the capacitance - you might make the servo start 'hunting' and not settle on a position. \$\endgroup\$
    – brhans
    Feb 2, 2016 at 2:26
  • \$\begingroup\$ I didn't attach anything else to the pot. All similar guides I've seen on modifying a servo to read its position all say to just attach a wire to the center lead on the pot. As @brhans points out, I'm hesitant to add more components since that may disrupt the servo. However, I'm powering the servo with a fairly clean 5V UBEC, so power shouldn't be too noisy. \$\endgroup\$
    – Cerin
    Feb 2, 2016 at 4:50
1
\$\begingroup\$

There should be no noticeable noise whatsoever on the potentiometer wiper if it never gets disturbed. The noise is coming either from the power supply of the arduino, the digital logic of the arduino itself, other components on the same power supply or the environment:

  • is the motor of the servo being operated? Brushed motors are infamous for the electrical noise they spew out.

  • Is the pot connected with long wires to the arduino? They could pick up interference from the environment, such as 50/60Hz mains hum.

  • is the aref pin connected to anything? What are the ADC settings? A bad reference will ruin measurements, while clocking the ADC too fast may cause spurious readings.

  • What are you powering your circuit with? Some power supplies are very noisy, especially cheap switching mode ones.

\$\endgroup\$
2
  • \$\begingroup\$ That's a good point about it picking up interference. I am using a fairly long generic unshielded hookup wire to connect it to the Arduino. \$\endgroup\$
    – Cerin
    Feb 2, 2016 at 4:53
  • \$\begingroup\$ @Cerin Try a twisted pair with ground on the other wire in the pair. \$\endgroup\$
    – Ecnerwal
    Feb 2, 2016 at 12:20
1
\$\begingroup\$

Also you may have to look at common grounding point resistance. A cheap servo may have very little designed dead zone and can generate motor drive pulses continuously even if the set point is not disturbed, this will cause current spikes (possibly random or alternating polarity) in the common ground. To test this solder (rather than use flimsy press fit servo terminals) a robust wire from your controller ground plane to the ground point on the servo PCB.

Then consider stopping the servo chatter by sampling the voltage just before you send a servo control pulse. Most servos go idle if the control pulses disappear and there will be almost no current drawn by the servo control IC.

Consider a differential measurement. If the ADC has a awesome vRef but the servo is using the internal pot voltage as the reference you may be measuring random servo reference voltage movement that is irrelevant to the servo but a huge uncorrelated gain error on your reading. Place another sense connection to the top of the POT (assuming the tail is grounded) and calculate the position based on the relative values measured.

Lastly you could try shielded cable for the sense connection if you have some high currents in the vicinity. The screen if robust could double as your heavy ground conductor. Always remember ground loops though in this case you can say they should be constrained as your two ground conductors are only feeding one isolated device from one controller and the heavy gauge wire will form part of the measurement path anyway.

\$\endgroup\$

Your Answer

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

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