7

I learned in school that typical servos use a simple "PWM" system to control a servo. To do this, we would generate a 1000 μs pulse to put the servo at 0 degrees and a 2000 μs pulse to set it at 180 degrees. Simple basics, right?

I recently tried configuring my HS-311 with these values and I found the servo moving less than 90 degrees. I switched to the Servo.h library and it worked fine. I peeked at the Servo.h file and found the following:

#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached

544? 2400? Where are these numbers coming from?

I looked at an old datasheet for this servo and found

OPERATING TRAVEL: 40°/ONE SIDE PULSE TRAVELING 400 usec
DIRECTION: CLOCK WISE/PULSE TRAVELING 1500 TO 1900 usec

A bit hard to tell what the numbers mean but they are definitely not 1000 to 2000!

Then I took a look at the specs on servocity.com and I see:

Max PWM Signal Range 575-2460 μsec.

This matches with the Servo.h source code!

What's going on here? Do manufacturers normally move outside of the 1000 μs to 2000 μs range? The values that I see far exceed what I'd think are acceptable tolerances. Please help me figure out where these numbers came from!

the busybee
2,4089 silver badges18 bronze badges
asked Jun 13, 2023 at 9:43
3
  • 1
    IIRC the first models of such servos were available in the 70s, about 50 years ago. At least one manufacturer used low pulses in contrast to other brands. The pulse width range was not standardized, too. So these variations can be historically necessary, or by the inevitable different quality of products, or simply trying to go to the limits. But since I'm no expert, this is just a comment, not an actual answer... You might want to start a research on the matter. ;-) Commented Jun 13, 2023 at 13:02
  • 1
    You may want to change this to "Why does Servo..." or something to that effect. Most of the people reading the current title will probably think that it's about analogWrite(). Commented Jun 13, 2023 at 16:27
  • No it uses 2ms and 1ms and 1.5ms to go somewhere around 90 degrees the 1000 and 2000 are micro seconds and not milliseconds Commented Jun 27, 2024 at 13:53

1 Answer 1

3

I've ran into this same issue. In the research I've done and the servo's I've worked with, the only way to know what the true max and min pulse widths are is to do some experimentation.

For example, servocity.com says this:

Different brands, and even different servos of the same brand, will have different maximum and minimums. Generally the minimum pulse will be about 1 ms wide and the maximum pulse will be 2 ms wide.

From my own testing with 3 or 4 different servo brands, 1ms-2ms is a "safe range". The servos will move within that range, but it likely won't be the full range that the servo is capable of. Start by looking at the data sheet, and then proceed to testing if you really need to eek out the most range.

For the HS-311, I believe the datasheet can be read as, "a change of 400usec corresponds to a rotation of 40°". If we assume the midpoint is 1500usec and the servo is capable of 180° rotation, then that would put the pulse width in the range of 600usec-2400usec which is close to the default range of the Servo.h library which is why it likely worked without needing to change the default max and min values.

answered Oct 18, 2024 at 18:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.