Servo Problem (probably actually a problem with me)

EDIT : Forget - I’ve just seen my mistake while reading back the code copied to the message.
I am adding twice 1000000

Sorry for bothering …
:-[

I finally found that the right values for my Modelcraft RS-2 are :

  • Min pulse = 0.540 ms
  • Max pulse = 2.470 ms
  • Angle range = 203 degrees
    If anyone has ever used these models and can confirm similar values …

I’ve just build a small class structure with abstract base Servo and derived Servo_PWM and Servo_OC to be able to use either PWM or OC pins transparently.

br

What is the difference between using the PWM pins and using OutputCompare on other digital pins?

How can I know what pins I can use OutputCompare on? I have a designed system that uses a ton of modules and I’m struggling to make sure I have enough sockets for all the modules.

If I could free up sockets 8 & 11 (used currently for PWM servo control) I could probably fit everything in!

Thanks for any insight!

[quote]I finally found that the right values for my Modelcraft RS-2 are :

  • Min pulse = 0.540 ms
  • Max pulse = 2.470 ms
  • Angle range = 203 degrees
    If anyone has ever used these models and can confirm similar values …[/quote]

Glad you got it working, Those values concern me as they are far out of range from any servo i have seen will accept.
Did you measure this with a scope, or is that from calculations ?

@ jdal

I used a test software with PWM mode and changed the values up/down until I hear the servo hitting the edge.
Then to find out the angle range, I took 2 photos and put them one onto the other (using layers in PaintDotNet), then rotating layer with transparency until it fits the lower layer.

@ Rossman

Any digital output pin can be used for OutputCompare mode, while PWM mode requires dedicated pins.

Disadvantage of OC is that it is software based which might be less precise. The default mode is based on interrupt mode allowing permanent pulse generation. There is another mode which is called blocking-mode. This latest mode is more precise but blocks all threads and - AFAIU - do not allow permanent generation of pulse. This mode does not seems suitable to me for servo positionning.

Disadvantage of PWM pins are that they share the same period for all outputs. This is not a problem is you are only driving servos as they will all run at 20ms. But this would be too slow to drive motors simultaneously.

As a guy coming from hardware, I tends to prefer PWM as a hardware based solution as much as possible… ;D