mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-20 22:14:34 +08:00
3.4 KiB
3.4 KiB
ASCII Protocol
How to send commands
- Via USB:
- Windows: Use the Zadig utility to set the ODrive's driver to "usbser". Windows will then make the device available as COM port. You can use PuTTY to manually send commands or open the COM port using your favorite programming language
- Linux/macOS: Run
/dev/tty*to list all serial ports. The ODrive will show up as/dev/ttyACM0on Linux and/dev/tty.usbmodem[...]on macOS. Once you know the name, you can usescreen /dev/ttyACM0(with the correct name) to send commands manually or open the device using your favorite programming language. Serial ports on Unix can be opened, written to and read from like a normal file.
- Via UART: Connect the ODrive's TX (GPIO1) to your host's RX. Connect your ODrive's RX (GPIO2) to your host's TX. The logic level of the ODrive is 3.3V.
- Arduino: You can use the ODrive Arduino library to talk to the ODrive.
- Windows/Linux/macOS: You can use an FTDI USB-UART cable to connect to the ODrive.
Command format
The ASCII protocol is human-readable and line-oriented, with each line having the following format:
command *42 ; comment [new line character]
*42stands for a GCode compatible checksum and can be omitted. If and only if a checksum is provided, the device will also include a checksum in the response, if any.- comments are supported for GCode compatibility
- the command is interpreted once the new-line character is encountered
Command Reference
Motor trajectory command
t motor destination
tfor trajectorymotoris the motor number,0or1.destinationis the goal position, in encoder counts.
Example: t 0 -20000
For general moving around of the axis, this is the recommended command.
Motor Position command
p motor position velocity_ff current_ff
pfor positionmotoris the motor number,0or1.positionis the desired position, in encoder counts.velocity_ffis the velocity feed-forward term, in counts/s (optional).current_ffis the current feed-forward term, in A (optional).
Example: p 0 -20000 0 0
Note that if you don't know what feed-forward is or what it's used for, simply omit it.
Motor Velocity command
v motor velocity current_ff
vfor velocitymotoris the motor number,0or1.velocityis the desired velocity in counts/s.current_ffis the current feed-forward term, in A (optional).
Example: v 0 1000 0
Note that if you don't know what feed-forward is or what it's used for, simply omit it.
Motor Current command
c motor current
cfor currentmotoris the motor number,0or1.currentis the desired current in A.
Parameter reading/writing
Not all parameters can be accessed via the ASCII protocol but at least all parameters with float and integer type are supported.
- Reading:
r [property]propertyname of the property, as seen in ODrive Tool- response: text representation of the requested value
- Example:
r vbus_voltage=> response:24.087744
- Writing:
w [property] [value]propertyname of the property, as seen in ODrive Toolvaluetext representation of the value to be written- Example:
w axis0.controller.pos_setpoint -123.456