Read analog servo feedback while powered

For my project I have modified a servo to get make usage of it’s internal potentiometer to get a position feedback which works very well while the potentiometer is not powered.

Goal of the project is to simulate different torque, meaning I need to be able to manually override (turn by hand) the servo while powered.

The problem is that while overriding I don’t get a linear feedback from the the internal potentiometer, but instead it seems to fluctuate around the set position.

Eg. if I set the position of the servo to 100 the feedback shows:
Overriding clockwise increases to 280
Rotating counter clockwise increases to 430

Is there a way to remove this behaviour or do I have to rely on an external encoder to track the position while moving the powered servo?

I know a servo might not be the perfect tool for a project like this, but would love to understand this behaviour.

Thanks ahead for any help!

#include <Servo.h>

Servo servo;

int serPin = 9;
int potPin = A1;
  
int serPos;
int i = 0;


void setup() {

  Serial.begin(9600);
  servo.attach(serPin);
  
}

void loop() {
  
  serPos = map(analogRead(A1), 50, 441, 20, 180);
  Serial.println(serPos);


  if (serPos < 100){
    for (i = serPos; i <= 100; i += 1){
    servo.write(i);
    delay(10);
    }
    
  }
}

For my project I have modified a servo to get make usage of it's internal potentiometer to get a position feedback which works very well while the potentiometer is not powered.

What? You can't measure the pot without an applied voltage. (An Ohmmeter applies a voltage/current.)

I would have assumed the pot feeds-back a DC voltage proportional to the position but I'm not sure. Have you measured the voltage on the 3 pot terminals?

Thanks for the reply!

I'm sorry, instead of 'not powered' I am referring to the 'detached' mode. And yes, you are absolutely right, the pot returns a dc voltage proportional to the position.

My problem is: If the servo is 'detached' and manually turned I am getting the exact position feedback. However when in 'attached mode' and manually turned, the feedback is not anymore proportional to the position.

I hope this cleared the confusion.

If you are forcing the servo away from it's set position, you are causing the motor to draw maximum current and probably pulling the voltage down. Check the voltage from servo power + to - while "overriding" .

JCA34F: If you are forcing the servo away from it's set position, you are causing the motor to draw maximum current and probably pulling the voltage down. Check the voltage from servo power + to - while "overriding" .

Thanks - that seems to be the case. What happens during the override is that the voltage drops to 0 and right away jumps to about 2,5V fluctuating depending on the amount of force applied to the servo.

Is there any way to avoid this from happening, maybe by modding the servo? Or do I have to rely on an external encoder to get actual position feedback?

One thing I realised just now: I am using a digital servo, might that be the reason for the behaviour?

In plain language, you can't do that, you will burn out the servo and / or the power supply, where is the servo power coming from anyway?

JCA34F: In plain language, you can't do that, you will burn out the servo and / or the power supply, where is the servo power coming from anyway?

Thank you for your comment.

The 'override' actuation is only a quarter revolution of the servo for a second every once in a while. I am also limiting the current to a third to make it actually movable. But of course you are right and it will eventually damage the gear.

So far I am using an external desktop power supply.

On top of your head, could you think of a more suitable solution? What I need in the end is a linear motion which I can manually 'override' so simulate different torque. Maybe using a stepper motor or dc gear motor with encoder is a better idea?

You could check the use of a pony brake dynamometer, but, that is usually used for continuous rotation motors. How do you plan to measure gram-centimeters of torque?

herbschwarz: pony brake

:o

Prony brake.

Goal of the project is to simulate different torque, meaning I need to be able to manually override (turn by hand) the servo while powered.

Your experimental setup is flawed. (incorrect). You can't use your hand for obvious reasons (it is imprecise and cannot be quantified accurately) Second, your method of inducing torque is wrong.

You need get a postal scale and measure the mass of weights placed inside a tiny plastic bucket and the have the servo lift the bucket OFF the scale. The starting position should be with 100% of the bucket weight ON the scale (mass viewed on scale) and then lift the weight incrementally by commanding a position to take up the slack on the string connecting the bucket and the servo arm and increase the position while measuring the servo current by inserting an ammeter in series with the servo power. The experiment should then collect the following data WITHOUT YOU TOUCHING IT ! A. Mass of weight B. Linear Distance weight lifted. (you have to figure out how to measure this. It shouldn't be that hard) C. Servo arm position change in degrees D. Servo current.

A standard RC servo arm should be able to lift the tiny bucket (or whatever holder you use) completely off the scale so the scale reads 0.00000.

As you increase the weight, the current increases. It should be possible to convert linear movement of a given mass to rotational torque. At the end of your experiment you should be able to plot delta-mass vs servo current. P = I*V

1 horsepower = 745.7W You should be able to convert linear force (the force needed to lift the weight) to angular torque. Clearly, that is your job , not mine. The physics may be more complicated than it seems at first . If it becomes necessary to measure velocity you may need to add opto-interrupters or use Millis() function to measure elapsed time between start and stop of servo arm.