Skip to content

servo module

doomke edited this page Aug 24, 2023 · 8 revisions

Description

Uses the PWM controler of the ESP32 to drive a servo motor. Handles initialization, position control and speed limitation.

Settings

setting type default range description
pin integer 26 > 0 number of the pin connected to the control input of the servo
frequency integer 50 > 0 frequency (in Hz) of the PWM signal for the servo -- defaults to 50 Hz
minDuty integer 1000 ≥ 0 minimum duty time (in µs) per PWM cycle
maxDuty integer 2000 > 0 maximum duty time (in µs) per PWM cycle
minAngle integer 0 minimum of the range used to control the servo[1]
maxAngle integer 90 maximum of the range used to control the servo[1]
maxSpeed float 0 ≥ 0 maximum speed at which the motor moves from one position to the next[2]
initial integer 0 (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]
  1. 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.
  2. 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.
  3. Defaults to an empty String, in which case no attempts to operate the LED will be made.

Command Keys

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)
  1. infoLED must be assigned, otherwise no LED will light up

Status

"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

Events

  • busy – occurs when the motor starts moving
  • ready – occurs when the motor is done moving

General

Guides

Principle of Operation

Modules

Software Hardware
camera camera
infoLED infoLED
input input
macro macro
output output
servo servo
socket socket
stepper stepper
WiFi wifi

Clone this wiki locally