-
Notifications
You must be signed in to change notification settings - Fork 1
servo module
doomke edited this page Jul 11, 2023
·
8 revisions
Uses the PWM controler of the ESP32 to drive a servo motor. Handles initialization, position control and speed limitation.
| setting | type | range | description |
|---|---|---|---|
| pin | integer | > 0 | number of the pin connected to the control input of the servo |
| frequency | integer | > 0 | frequency (in Hz) of the PWM signal for the servo -- defaults to 50 Hz |
| minDuty | integer | ≥ 0 | minimum duty time (in µs) per PWM cycle |
| maxDuty | integer | > 0 | maximum duty time (in µs) per PWM cycle |
| minAngle | integer | – | minimum of the range used to control the servo[1] |
| maxAngle | integer | – | maximum of the range used to control the servo[1] |
| maxSpeed | float | ≥ 0 | maximum speed at which the motor moves from one position to the next[2] |
| initial | integer | (minAngle, maxAngle) | position on the value range that the motor will drive to on initialization |
| infoLED | String | – | ID of an LED, module will attempt to send commands to the LED to indicate when changes have been made by a user[3] |
- ↑The value range (minAngle,maxAngle) can be chosen freely and adjusted to suit the purpose. For example a symmetric 90° range (-45,45) or a percent range (0,100) can be used.
- ↑Speed limit does not apply to first initialization, where the motor moves as fast as possible. Unit of measurement is that of the value range per second. Value of 0 means as fast as possible.
- ↑Defaults to an empty String, in which case no attempts to operate the LED will be made.
| key | type | range | description |
|---|---|---|---|
| move | integer | – | move the specified distance on the value range starting from the current position |
| moveTo | integer | (minAngle, maxAngle) | move to the specified position on the value range (absolute position) |
| binaryCtrl | boolean | – | move to minAngle if false and to maxAngle if true |
| hold | hold | – | keep motor powered after movement if true |
| identify | integer | > 0 | highlight the hardware by its LED[4] for the specified time (in ms) |
-
↑
infoLEDmust be assigned, otherwise no LED will light up
"controlId":"pinhole",
"status":
{
"busy":false,
"absolute":90,
"relative":100
}-
busy– boolean, true if the motor is currently moving to a new position -
absolute– integer, current position of the motor on the value scale -
relative– float, current position of the motor as percentage of the total range
-
busy– occurs when the motor starts moving -
ready– occurs when the motor is done moving