Ultimately I want to be able to control up to 8 servos using node.js - I'm able to control the servos using either pi-blaster or pigpio, but how do I control their speed with which they move?


When using servos that rotate through 180o, one sets the desired position of the servo arm and the servo will try and "get there" as quickly as possible. There is no explicit control of rotational speed on a servo. If one wants to attempt to reduce the speed, one can ask the servo to move to a target position by repeatedly moving to sub fractions of that position and delaying between moves ... however this is unlikely to deliver a desirable result.

For servos that were designed for continuous rotation, some of these use the PWM signal as an indication of their rotational speed. If we assume that a PWM signal is between 1000 and 2000usecs then 1500 means stationery, 1000 means maximum speed in one direction and 2000 means maximum speed in the other direction. Other values between 1000 and 2000 will rotate in the corresponding direction but at less than maximum speeds.

  • Is it possible to set the resolution of movements higher with pigpio so more steps are possible? I'm currently moving to desired angle in substeps of 1 microsecond delayed by 100ms but the steps are very noticeable and that results in less "smooth" movement May 11 '16 at 19:43
  • If we assume that a servo has a freedom of movement of 180o and that the minimum to maximum PWM values are 1000-2000 (i.e. 1000 as the difference), then the question becomes one of what is the resolution of the servo? A servo may have a resolution of 1o which would mean that the PWM value would have to change 1000/180 = 6 usecs before you see movement. But it could also be that the degree of rotation is far more OR less that 180o. We would also want to check with an oscilloscope or logical analyzer what PWM is ACTUALLY being produced vs what you desired/hoped.
    – Kolban
    May 11 '16 at 19:56
  • @alberto2000 By default pigpio will be using 5µs steps, so 200 steps between 1000 and 2000. That will be less than a degree for a servo with a 180 range. I'm not sure how good your servos are, they may not be able to move in degree steps.
    – joan
    May 11 '16 at 20:22
  • @joan: I have pretty hi-spec servos - how can I configure pigpio to use a higher resolution? Is there any config option for that? May 11 '16 at 21:09
  • @alberto2000 If you are using the daemon use the -s option. If you are using the library call gpioCfgClock before calling gpioInitialise. I wouldn't go lower than 2.
    – joan
    May 11 '16 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.