USB Servo Controller

v0.4.1
io.github.Lukasz-Juranek/usb-servo-controller Checked 4 days ago Published 1 month ago

Drive 12 hobby servos on an open-hardware USB-C controller: moves, poses, sequences, rail current

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

board_status

Rail current/voltage, faults, protection limits, and every channel's name, mode, travel limits, speed and current position (0 = off).

move_servos

Move one or more servos and wait until they arrive. positions: {channel number or name: pulse width in us}, e.g. {"0": 1200}. duration_s: time for all to arrive together (0 = each channel's own speed). Positions are clamped to each channel's limits. Turns channels on if off.

ParameterTypeDescription
positions *object
duration_snumber

disable_servos

Stop driving the given channels (numbers or names); the servos go limp.

ParameterTypeDescription
channels *array

stop_all

Panic stop: every channel off immediately.

list_poses

Poses and the sequence saved from the GUI (servogui.json).

go_to_pose

Move to a saved pose (see list_poses) and wait until it arrives.

ParameterTypeDescription
name *string
duration_snumber

play_sequence

Play the GUI's saved sequence of poses (move and hold times as saved), repeated `loops` times. Stops early on a fault; capped at 120 s.

ParameterTypeDescription
loopsinteger

read_analog

Read channel 0-7 as an analog input (0-4095 counts, 0-3.3 V).

ParameterTypeDescription
channel *string

measure_current

Sample the servo-rail current continuously; returns peak, mean and min mA.

ParameterTypeDescription
secondsnumber

set_protection

Set the rail trip limits (0 disables either). Overcurrent is capped at 7500 mA: the board's continuous budget is ~5 A. Resets at power-up.

ParameterTypeDescription
overcurrent_ma *integer
undervoltage_mvinteger

clear_faults

Clear a latched overcurrent/undervoltage fault so channels can move again.

upload_script

Compile a servo script and store it in the board's flash, where the firmware runs it without a PC (autorun: also start at every power-up). One statement per line; channels by number or name; times in ms or '1.5s': label: jump/loop target move <ch> <us> [<time>] ramp there; does not wait: moves on different channels run together, a repeat move of the same channel waits for the previous one pose <name> [<time>] move every channel of a GUI pose sync wait until all mo…

ParameterTypeDescription
script *string
autorunboolean
runboolean

script_status

What script is stored on the board, and whether it is running.

run_script

Start the stored script from the top.

stop_script

Stop the stored script; servos keep their positions (stop_all to let go).

release_port

Close the serial port now (servos keep holding) so the GUI or flash.py can use the board. It reopens automatically on the next tool call.