Servo PWM

Hi:

I have a HS-645MG servo and when used with the Servo library works pretty well, but when I try to control it with a PWM it exhibits a weird behavior. For example, it is supposed for the servo to be at zero position when the duty cycle is 0.5ms (50Hz PWM) but when I implement this code:

 pinMode(3, OUTPUT);
  pinMode(11, OUTPUT);
  TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20);
  TCCR2B = _BV(WGM22) | _BV(CS22)| _BV(CS21)| _BV(CS20);           //
  OCR2A = 156;
  OCR2B = 4;

the position changes to 45º. The Servo library states that the motion range is between 0 and 180º and the duty cycle between 544us and 2400us. Im also trying to control the servo with a FPGA and the result is the same.

If I am recreating the same period and duty cycles (at least I think so) why does the servo doesnt react in the same way?

If I am recreating the same period and duty cycles (at least I think so) why does the servo doesnt react in the same way?

Because one of those assumptions is incorrect?

What does the control signal look like on an oscilloscope?

AWOL:

If I am recreating the same period and duty cycles (at least I think so) why does the servo doesnt react in the same way?

Because one of those assumptions is incorrect?

What does the control signal look like on an oscilloscope?

To be honest, I don't have an oscilloscope handy :~ so I couldnt say.

The range of pulse widths for 0deg and 180 deg is 1000 microsecs to 2000 microsecs.

I presume there is a reason for reinventing the wheel?

Perhaps the servo library is interfering with something else? There is also a ServoTimer2 library that uses Timer2.

...R

Actually I'm trying to understand how the servo works in order to make it work on FPGA

Gilgamesh90:
Actually I'm trying to understand how the servo works in order to make it work on FPGA

1000 to 2000us pulse every 20ms.

Servos work with PPM.
PWM is not PPM, the servo you have is not liking the signal you are giving it.

Grumpy_Mike:
Servos work with PPM.
PWM is not PPM, the servo you have is not liking the signal you are giving it.

Then what about the pages about servomotor control description? are they wrong? or just the Servo library works on PPM?

Individual R/C servos have their position set by PWM.
The position of thè servo is proportional to the width of the pulse, hence Pulse Width Modulation.

The multiplexed stream of pulses between R/C transmitter and receiver however combines a sequence of PWM signals into a PPM stream.. The position in the sequence determines the channel.

Massive HOWEVER - the frequency of PWM signal to control an R/C servo is about one tenth that provided by an Arduino analogWrite.

R/C servos do not like the frequency of the Arduino analogWrite.

I hope that is clear.

PPM and PWM are not the same thing.

While a lot of servos will work with PWM not all will, some need real PPM
See this picture for the difference.

PPM.png

AWOL:
R/C servos do not like the frequency of the Arduino analogWrite.

I hope that is clear.

But if I'm sending the frequency directly with a timer (not with analogWrite) why is not working then? I took the code from another post in this forum and the said it was tested on an oscilloscope.

I give up.

Please, Massimo, accept this as my resignation.

Gilgamesh90:
Then what about the pages about servomotor control description? are they wrong?

They are an over simplification.

Without an oscilloscope or equivalent you are probably just wasting your time trying to debug this problem.

As the servo signal is very slow you could write a sketch on another Arduino that would behave as a rudimentary oscilloscope.

...R

Robin2:
Without an oscilloscope or equivalent you are probably just wasting your time trying to debug this problem.

As the servo signal is very slow you could write a sketch on another Arduino that would behave as a rudimentary oscilloscope.

...R

You're right... I'm going to test the signal on an oscilloscope, there's no other choice!

Thanks to all of you!

there's no other choice!

Have you tried Google? Below is an old article that shows what is inside a typical analog hobby servo.

http://www.seattlerobotics.org/encoder/200009/S3003C.html