madhephaestus / ESP32Servo

Arduino-compatible servo library for the ESP32
133 stars 53 forks source link

Add release method to release servos #37

Closed JoeSc closed 11 months ago

JoeSc commented 11 months ago

It may be useful to release the servos(so that the motor inside the servo does not burn up).

Use case is a latch. Drive the servo 0 degrees(the servo may only be able to reach, for example, 40 degrees) for 100ms then release the servo. To unlatch drive the servo 180 degrees(again the servo may only be able to reach 130 degrees) for 100ms then release the servo

madhephaestus commented 11 months ago

It seems that you should use detach() instead of writing the PWM to 0.

The other configuration you should look at is the extra parameters to attach() that let you set the uS timing for the bounds of the servo pulse.

JoeSc commented 11 months ago

It seems that you should use detach() instead of writing the PWM to 0.

Does it make sense to teardown the Timers when I might want to immediately move it again(therefore requiring the timer to be re-setup)

The other configuration you should look at is the extra parameters to attach() that let you set the uS timing for the bounds of the servo pulse.

The minimum uS timing I can pass to the servo is bounded by the following in attach()

#define MIN_PULSE_WIDTH       500
...
        if (min < MIN_PULSE_WIDTH)          // ensure pulse width is valid
            min = MIN_PULSE_WIDTH;
madhephaestus commented 11 months ago

hmm good point, ok.

madhephaestus commented 11 months ago

added to 1.1.0