control-servo
¶
CLI reference¶
glasgow run control-servo¶
Control RC/hobby servomotors using the common pulse width modulation protocol where a pulse of 1000 µs corresponds to a minimum position and a pulse of 2000 µs corresponds to a maximum position. The frequency of the updates is not strictly constrained by the protocol, and is fixed at 50 Hz in this applet.
This protocol is also used in common brushless motor ESC (electronic speed control) modules. For unidirectional ESCs, a pulse of 1000 µs corresponds to 0 rpm and a pulse of 2000 µs to maximum rpm. For bidirectional ESCs, a pulse of 1000 us corresponds to maximum rpm backwards, and 2000 µs to maximum rpm forwards.
usage: glasgow run control-servo [-h] [-V SPEC] [--out PIN]
- -h, --help¶
show this help message and exit
- -V <spec>, --voltage <spec>¶
configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)
- --out <pin>¶
bind the applet I/O line ‘out’ to PIN (default: ‘A0’, required)
API reference¶
- class glasgow.applet.control.servo.ServoInterface(logger: Logger, assembly: AbstractAssembly, *, out: GlasgowPin)¶
- async enable(is_enabled=True)¶
Enable or disable the servo.
When disabled, no pulses are sent over the control line.
- async disable()¶
Disable the servo.
Calls
self.enable(False)
.
- async set_value(value: int)¶
Set servo control value.
value
is an integer number of microseconds in the range of 1000 to 2000 inclusive. Note that the interpretation of this value varies depending on the connected device:For a servo proper, 1500 corresponds to the neutral position.
For an unidirectional ESC, 1000 is 0 rpm and 2000 is maximum rpm.
For a bidirectional ESC, 1000 is maximum rpm backwards and 2000 is maximum rpm forwards.
The servo is enabled after the value is configured.