VESC extensions are built-in functions available in all LispBM scripts running on VESC hardware. They expose motor control, sensor reading, CAN communication, hardware I/O, and more. Extensions are registered at startup — no import is needed.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vedderb/bldc/llms.txt
Use this file to discover all available pages before exploring further.
Extension availability varies by platform and firmware version. Functions marked ESC run on STM32-based controllers. Functions marked Express run on VESC Express (ESP32). Many extensions work on both.
Console and utilities
| Function | Signature | Description |
|---|---|---|
print | (print arg1 ... argN) | Print values to the VESC Tool console. Each argument prints on its own line. |
puts | (puts str) | Print a string without quotes. Supports up to 400 bytes (vs 256 for print). |
set-print-prefix | (set-print-prefix str) | Prefix all console output with str. Useful when multiple devices share a console over CAN. |
systime | (systime) | System time in ticks since boot. |
secs-since | (secs-since timestamp) | Seconds elapsed since a systime value. |
sleep | (sleep seconds) | Suspend the current thread for the given number of seconds. |
timeout-reset | (timeout-reset) | Reset the motor timeout watchdog. Must be called at least once per second while controlling the motor. |
sysinfo | (sysinfo param) | Read system information (see below). |
Motor set commands
These functions command the motor. Each call also resets the timeout watchdog.| Function | Signature | Description |
|---|---|---|
set-duty | (set-duty dutycycle) | Set duty cycle. Range -1.0 to 1.0. |
set-current | (set-current current) | Set motor current in amperes. Positive = motoring, negative = regeneration. |
set-current-rel | (set-current-rel current) | Set current relative to max current. Range -1.0 to 1.0. |
set-rpm | (set-rpm rpm) | Set RPM speed control target. |
set-brake | (set-brake current) | Set braking current in amperes. |
set-brake-rel | (set-brake-rel current) | Set braking current relative to max current. Range 0.0 to 1.0. |
set-handbrake | (set-handbrake current) | Open-loop hold current. Holds position at 0 rpm at the cost of efficiency. |
set-handbrake-rel | (set-handbrake-rel current) | Handbrake current relative to max. Range 0.0 to 1.0. |
set-pos | (set-pos pos) | Position control. Target in degrees, range 0.0 to 360.0. |
set-kill-sw | (set-kill-sw state) | Set kill switch state. 1 disables the motor immediately (emergency stop). |
foc-openloop | (foc-openloop current rpm) | Run FOC open-loop at given current and RPM. |
foc-beep | (foc-beep freq time voltage) | Play a beep through the motor at freq Hz for time seconds. |
Motor get commands
All motor get commands accept an optionaloptFilter argument. When set to 1, the return value is the average since the function was last called rather than the instantaneous reading.
| Function | Returns |
|---|---|
(get-duty) | Current duty cycle, range -1.0 to 1.0. |
(get-rpm) | Motor electrical RPM. |
(get-rpm-fast) | Faster RPM reading (less filtered). |
(get-speed) | Speed in m/s (requires si-motor-poles, si-gear-ratio, si-wheel-diameter to be configured). |
(get-current) | Motor current in A. |
(get-current-in) | Input current in A. |
(get-current-dir) | Directional current. Positive = forward torque. |
(get-id) | FOC d-axis current. |
(get-iq) | FOC q-axis current. |
(get-temp-fet) | MOSFET temperature in °C. |
(get-temp-mot) | Motor temperature in °C. |
(get-vin) | Input voltage in V. |
(get-batt) | Battery charge level, range 0.0 to 1.0. |
(get-fault) | Current fault code as a symbol. |
(get-ah) | Amp-hours consumed since boot. |
(get-wh) | Watt-hours consumed since boot. |
(get-dist) | Distance traveled in meters. |
(get-pos) | Encoder position in degrees. |
Configuration
conf-get and conf-set read and write motor and application configuration parameters. Parameters are identified by quoted symbols.
CAN bus
LispBM provides both low-level frame I/O and high-level VESC protocol commands over CAN.Low-level CAN frames
VESC protocol over CAN
can-cmd sends a LispBM expression to another VESC on the CAN bus and returns the result:
CAN message events
Enable CAN event processing to receive frames asynchronously:IMU and sensors
| Function | Returns |
|---|---|
(get-imu-rpy) | Roll, pitch, yaw in radians as a list (r p y). |
(get-imu-quat) | Quaternion (q0 q1 q2 q3). |
(get-imu-acc) | Acceleration (x y z) in G. |
(get-imu-gyro) | Angular rate (x y z) in deg/s. |
(get-imu-mag) | Magnetic field (x y z) in µT (if magnetometer present). |
(get-imu-acc-derot) | Acceleration derotated to horizon frame. |
(get-imu-gyro-derot) | Angular rate derotated to horizon frame. |
(get-adc ch) | Raw ADC voltage on channel 0–3. |
(get-adc-decoded ch) | Decoded ADC value mapped to 0–1 per app configuration. |
(get-ppm) | Decoded PPM input, range -1.0 to 1.0. |
(get-encoder) | Encoder position in degrees. |
(get-encoder-error-rate) | Encoder error rate as a fraction. |
GPIO
pin-rx, pin-tx, pin-swdio, pin-swclk, pin-hall1, pin-hall2, pin-hall3, pin-adc1, pin-adc2, pin-ppm.
Pin mode symbols: pin-mode-out, pin-mode-od, pin-mode-in, pin-mode-in-pu, pin-mode-in-pd, pin-mode-analog.
AUX outputs
The AUX output mode must be set to Unused in Motor Settings → General → Advanced. Otherwise the firmware will override any value set from Lisp.
