Changing Servo library frequency?

Hey guys, I have purchased one of these:
Should arrive within a week, I have another servo I have been testing on and decided to upgrade. I understand that servos are controlled via PPM (Pulse Position Modulation).
I have read that the frequency the Servo library runs at is 2000µs, the frequency listed on the specifications is: 1520µs/333hz. Should it work fine? or is there a way to change the frequency?

Thanks - Luke

No need to change anything.

// Per.

I understand that servos are controlled via PPM (Pulse Position Modulation).

Not PPM. It’s PWM - Pulse Width Modulation
PPM is pulse position relative to a clock.
The pulse width determines the position (or speed with continuous servos.)
There is some wriggle room in the pulse period, ttime between pulses.

Although your servo should work just fine with the standard servo library, you can also take advantage of the higher refersh rate with this alternative library -

Duane B

Although your servo should work just fine with the standard servo library, you can also take advantage of the higher refersh rate with this alternative library -

Duane B

Thanks, ill see how it goes with the standard library then maybe play with the alternative library.

hi I have / Arduino mega / a I need to read exactly three channels of the RC receiver. The / pulsein / is bad. Please advise me. thank you janziki

Pin change interrupts may allow monitoring of multiple servo signals simultaneously - you can arrange to be interrupted
when any of a group of pins changes.


First you need to choose your pins, look up the attachInterrupt function and let us know which pins can be used on the mega, it is then very easy to modify this code, but first let us know what you have found out about the pins -

Duane B

I think that the 1520µs/333hz speed/frequency specification is just the clock speed associated with the digital circuitry within the actual servo. It doesn't have much to do with the pulse widths used to control the servo's position.

You can however explicitly define the minimum and maximum pulse widths with the attach command (in the servo library). The servo library defaults the attach command to a minimum pulse width of 1ms and a maximum pulse width of 2ms.

If you were attaching a servo with a minimum pulse width of 0.9 ms and maximum pulse width of 2.1ms to pin 9, you would do it like this:

MyServo.attach(9, 900, 2100); //MyServo.attach(pin, min, max); //The min and max values are specified in microseconds.

A lot of times people don't explicitly define the maximum and minimum pulse widths because the defaults are close enough to the specified pulse widths, for a specific servo.

HI, I'm very new and apologise in advance if these are annoying questions. Maybe there are alternative references?

I've had a servo and speed controller working quite happily previously. The setup is a radio signal to the device, receiver reports PWM to Arduino (Freetronics Eleven - pin #8). This is converted to a target position (int) which is compared to the value from a rotary encoder on a drive shaft. The drive shaft, which drives a winch, is driven by a brushless motor from an ESC which itself is controlled from pin #10. A servo (pin #9) operated mechanical brake is integrated with the ESC timing so that the winch brake comes on when the drive motor stops (through a controlled deceleration).

I've changed speed controller and run into problems. I really should work out exactly what is happening.

I can set lower and upper pwm limits on the controller and am inclined to use 1000us and 2000us unless there are good reasons to do otherwise.

Part of my confusion is because of the existence of (at least) two servo libraries. Although I can now not find the source for the former, I have both Servo and SoftwareServo libraries. They seem to differ very little (I've compared the headers and code files). Is the latter, from here, the one to use: ? (I've been using the other one.)

The last post from eetscribe indicates that the attach function can take 3 arguments: //MyServo.attach(pin, min, max); But SoftwareServo.h indicates only one argument. Am I using the wrong library?

When I had the previous prototype working, the only call to the servo objects were write (apart from attach). But from looking at the code it appears that refresh() needs to be called at least every 50ms. Should this be called explicitly from the loop ...seemed to work fine (with the previous, very similar, library) only using write().

I've only ever used the servo library, which comes with the Arduino install as a standard library.

Using that, you don't explicitly do a refresh, because it's built in to the library code. By default, the pulse is re-sent every 20ms (ie 50Hz), but that can be changed by editing the value of REFRESH_INTERVAL in servo.h.

Thanks Jimbo.

I’ll put my ignorance on full display… I thought I did a standard install (Windows 7; C:\Users\Trevor\Documents\Arduino). How would I tell if I have the standard servo library to which you refer. Having looked, I guess it’s this one: C:\Program Files\Arduino\libraries\Servo. If that’s a standard, I’d prefer to be using that.

The fact it was working and I didn’t explicitly call a refresh perhaps suggests that I’ve, somewhat inadvertently , been using that library all along? I’d installed the versions I’d referred to above to C:\Users\Trevor\Documents\Arduino\libraries. If each of those folders have a servo.h, which one would be used by my #include <Servo.h> statement? Presumably the system path has precedence?

Update: I got rid of the extra libraries and, though there’s still a lot to fix, at least that component seems to be working - so it seems to be using the standard library now. Thanks again.