How to compute the PWM for a servo?

Hello,

I am trying to understand how to read the servo specs and then compute PWM values for it.

For example, the Arduino starter kit came with SM-S2309S servo. Most of the specs for it which I found online told me

Modulation: Analog
Torque: 4.8V: 13.90 oz-in (1.00 kg-cm)
6.0V: 16.70 oz-in (1.20 kg-cm)
Speed: 4.8V: 0.12 sec/60°
6.0V: 0.10 sec/60°
Weight: 0.32 oz (9.0 g)
Dimensions: **Length:**0.87 in (22.2 mm)
**Width:**0.46 in (11.6 mm)
**Height:**0.85 in (21.5 mm)
Gear Type: Plastic
Rotation/Support: Bushing
Rotational Range: 180°

How can one use this information to compute the PWM?

From trial and error I manage to find the min and max PWM:

const int LED_PIN = 9;
const int PWM_US = 2500; // 500 = one side, 2500 the other side. How to compute this from specs?
const int DELAY_MS = 20; // How to compute this from specs?

void setup() {
   pinMode(LED_PIN, OUTPUT);
}

void loop() {
  // Move the servo to one side
  digitalWrite(LED_PIN, HIGH);
  delayMicroseconds(PWM_US);
  digitalWrite(LED_PIN, LOW);
  delay(DELAY_MS); 
}

To move it continuosly side to side

const int LED_PIN = 9;
const int PWM_US = 15; // How to compute this from specs?
const int DELAY_MS = 20;

void setup() {
   pinMode(LED_PIN, OUTPUT);
}

void loop() {
  for(int i = 1; i < 180; i++) {
    digitalWrite(LED_PIN,HIGH);
    delayMicroseconds(PWM_US * i);
    digitalWrite(LED_PIN, LOW);
    delay(DELAY_MS);
  }

  delay(2000);

  for(int i = 180; i > 1; i--) {
    digitalWrite(LED_PIN,HIGH);
    delayMicroseconds(PWM_US * i);
    digitalWrite(LED_PIN, LOW);
    delay(DELAY_MS);
  }

  delay(2000);
}

Why aren’t we using the servo library ?

https://www.sparkfun.com/servos

https://learn.sparkfun.com/tutorials/hobby-servo-tutorial

You can't compute the PWM signal from the given specification of the servo. Presumably it uses a standard analog servo signal, which would be a pulse with a width of approximately 1000uS to 2000uS, centered on 1500uS, sent 50 times per second (50Hz rate).

Then what is the point of these specs? What can one do with information like " speed: 4.8V: 0.12 sec/60°"?

That tells you how fast the servo shaft can rotate. With a power supply of 4.8 volts, it takes 120mS to rotate 60 degrees, and with a power supply of 6.0 volts it takes 100mS to move the same amount.

1 Like

What is the physical meaning of the following spec:?

Torque: 4.8V: 13.90 oz-in (1.00 kg-cm)

As @david_2018 wrote, standard servos use a common, adjustable pulse train. Here is a simulation using an adjustable pulse train to move a servo... the angle of the servo changes with the values created by the potentiometer. Real values are different from sim values.

Rhetorical question, or are you asking what torque is, and the units that are used to talk about it?

a7

Let me put my question directly --
I have 1.5 kg movable mass sitting at 1-cm distance from the rotaton axis of the Servo Motor. I have attached a handle with the rotating shaft of the Servo. Will this Servo (with rated 1.00 kg-cm torque) be able to shift the mass from its present sitting?

I did not work your example numbers, but assuming you did the physics correctly, no.

Torque in a servo is the maximum force available. This means it can hold a position, not necessarily then in addition move it, which would imply, I think, using additional (unavailable) torque.

When the load is not maximal, the excess torque must be large enough to make the arm accelerate and move at whatever rate is needed.

Obvsly you'd ideally want a servo to be loafing when all it was doing was holding position. Most applications of cheap servos are deployed that way by design. Clever mechanical arrangements can reduce the need for holding torque, but the angular momentum of whatever is being turned will always be something to account for.

I think I should be calling the problem overcoming the moment of inertia. S'been a minute.

a7

I have a 10-kg sliding door situated at 5-ft distance from the rotational axis of a Servo. For the Servo to be able to close the door, should the Servo be rated for a torque of 50 kg-cm?

not provided sufficient information.

What is the coefficient of static friction on the door slide mechanism?

What is the coefficient of kinetic friction on the door slide mechanism?

What time are you hoping to achieve for moving the door from one extreme to the other?

a7

1 Like

That was the correct answer to the question in #9, too (and it seems unlikely that any of this is helpful to the OP)

In a thread, the OP is the main stakeholder; others are benefitted in passing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.