servo pwm control

Hi, i am abit confused about servo pwm control. I have mega board and connect servo to pwm pin 8 . the pwm frequency from this pin by default is 976 hz. However, i read that servo is controlled by internal pwm of 50 hz . The thing is my servo still work correctly even though theres a huge different in pwm frequency.

I used servo library.

can anyone clarify this for me please ?

https://arduino-info.wikispaces.com/Servos

Servos don't use PWM. They use a variable pulse width. There's a servo library so you just have to supply an angle, but I've never used that library.

PWM can be used to dim an LED or control the speed of a regular DC motor (but you need a motor driver).

i got no idea what you mean. pulse width and pwm are the same thing

1 Like

No...servo signal and pulse width modulation for motor speed or whatever are entirely different.

Pwm is an on/off generated pulse with varying on and off time ratio. The longer it's on the higher the output average.

Servo signal is a 20mS generated signal within which are channels each having a servo signal pulse of between 1 and 2 milliseconds. (representing full travel from one end to the other)

This is received by the servo amp and compared to it's onboard signal.

Any difference and the servo moves until the feedback pot in the servo which is responsible for the onboard signal, says it matches the incoming and the servo stops. ( basically)

Hi,
The 50Hz referred to is the frequency of the PWM used to directly control the drive motor.

The servo signal is a tailored PWM to the servo control standard, this pulse length represents the position you want the servo shaft to turn to.

The controller inside the servo then drives the motor with 50Hz PWM to the desired position, this is a speed/direction control specifically produced inside the servo to control the motor.

Tom.... :slight_smile:

2 Likes

Unfortunately PWM is widely used to describe the sort of signal produced by the Arduino analogWrite() command and the very different signal produced by the Servo library.

analogWrite() produces a signal with a duty factor that varies between 0% and 100% which is intended to modulate the power in an electric motor or in an LED, for example.

The Servo library produces a pulse 50 times per second and the width of that pulse (which varies between about 1000 and 2000 microsecs) indicates to the servo mechanism the position that the servo arm should move to. It is modulating the position, not the power. Presumably the internal servo mechanism uses PWM (i.e. power modulation) to move the motor but the details of how what happens are of no concern and I have no idea what the internal PWM frequency might be. There is no reason for it to be the same in every servo.

If you do the maths, the duty cycle for a servo position signal varies between about 1/20 and 2/20.

...R

1 Like

Doesn't seem all that different.
analogWrite is either ~ 500 or ~1000 Hz with waveform that can be full off to full in 1/255 increments.

Servo is 50 ~Hz (20mS period) with high signal that varies from 1mS to 2mS.
So a slower analogWrite frequency with more limited output.
I imagine you'd want the 255 steps to occur over that 1mS time width, so maybe a 4uS in difference between steps, 250 total would provide 1mS.

Why does simple PWM cause so many problems?
RC servos are designed for multichannel man-in-the-loop control systems.
They do indeed use PWM (the position of the output shaft is proportional to the pulse width) and operate at low duty cycles (5 to 10%) to allow a reasonable number of channels to be multiplexed into a 20 ms frame and still allow a long enough frame sync.

Groove:
Why does simple PWM cause so many problems?

Because that acronym is also used for an altogether different system that has nothing to do with position control.

...R