Servo Library seems to set pulse width modulation outside of acceptable range for a servo

Issue #462 resolved
Eric Vanderhoof created an issue

Hi there microblocks team! When using an RC car electronic speed control with pulse width modulation control, the controls lock up above 50% power setting. I took a look at the definition for the servo speed block, and it looks like the pulse width initialization math needs the 10 changed to a 5. The usual expected range for a servo is something like 1000 to 2000 microsecond pulses. 100% power with the current math would make it 2500, which falls outside that range. I made the correction locally and it fixed the issue, but it keeps coming up when my students update their servo libraries.

Thank you,

Eric Vanderhoof

Comments (5)

  1. John Maloney repo owner

    That's not a bug.

    Unfortunately, servo's differ, and some require a wider range of pulse widths than the standard 1000 to 2000 microsecond range. The current range was found to cover a wide variety of servos.

    But it's unfortunate that your RC car doesn't like the out-of-range wider pulses.

    Not sure what to do to make the servo library work with all servos. Maybe an intermediate scale between 10 and 5. Could you see if 8 works with your car?

  2. John Maloney repo owner

    I realized that the "set servo to speed" was independent of the "set servo to angle" block, so I made this change. It is in the latest pilot release, 1.2.51.

  3. Eric Vanderhoof reporter

    Great, thank you!

    I suppose a servo block could also be an expandable with “PWM Min” and “PWM Max” as inputs with a function inside to map percentages/angles to their corresponding PWM values. I’m not sure how the speed of the map block compares to simpler adding and subtracting though.

    Thanks again!

    Eric Vanderhoof

  4. Log in to comment