CAN modes
VESC
Default VESC CAN bus. Required for CAN forwarding and configuring multiple VESC-based devices using VESC Tool.
UAVCAN
Basic implementation of
uavcan.equipment.esc. See the DroneCAN documentation for details.Comm Bridge
Bridges the CAN bus to commands. Useful for using VESC Tool as a generic CAN interface and debugger.
Unused
CAN frames are not processed and are ignored. Custom applications and scripts can still process CAN frames. Similar to Comm Bridge, but received frames are not forwarded using commands.
VESC ID configuration
Each VESC-based device on the bus must have a unique ID. You can set the VESC ID in VESC Tool under App Settings -> General -> VESC ID. A device only accepts incoming CAN frames that match its configured ID.Timeout
By default, the VESC stops the motor when nothing has been received on the CAN bus for more than 0.5 seconds. You can change the timeout value in VESC Tool under App Settings -> General. Setting it to0 disables the timeout entirely.
A timeout brake current can also be configured. When timeout occurs, the VESC applies this current to brake the motor. The default is 0, which simply releases the motor with no braking force.
Frame format
All VESC CAN frames use 29-bit extended IDs. The receiver ID and command ID are both embedded in the extended frame ID:
The extended ID is constructed as:
Single-frame commands
Simple CAN commands each fit in a single CAN frame. The data payload is always a 32-bit big-endian signed integer representing the command argument, multiplied by the scaling factor for that command. Example: Setting 51 A of current (CAN_PACKET_SET_CURRENT, command ID 1, scaling 1000) on VESC ID 23:
51 * 1000 = 51000 = 0x0000C738
Available simple commands
Commands sent outside the valid range are clamped at the limit. For example, if the maximum braking current is configured to 50 A and you send 60 A with
CAN_PACKET_SET_CURRENT_BRAKE, the firmware will use 50 A.C code example
The following implementation shows how to construct and send all simple CAN commands. Provide your owncan_transmit_eid function that writes an extended-ID frame to the bus.
Status messages
The VESC can broadcast periodic status messages on the CAN bus. Enable them in VESC Tool under App Settings -> General -> CAN Status Messages Rate x. Two independent rate groups are available. Each group can carry any combination of the six status message types. Using two rates lets you transmit high-priority telemetry frequently and lower-priority data at a reduced rate, keeping bus utilization in check.Available status messages
Status message encoding
CAN_PACKET_STATUS (ID 9)
CAN_PACKET_STATUS (ID 9)
CAN_PACKET_STATUS_2 (ID 14)
CAN_PACKET_STATUS_2 (ID 14)
CAN_PACKET_STATUS_3 (ID 15)
CAN_PACKET_STATUS_3 (ID 15)
CAN_PACKET_STATUS_4 (ID 16)
CAN_PACKET_STATUS_4 (ID 16)
CAN_PACKET_STATUS_5 (ID 27)
CAN_PACKET_STATUS_5 (ID 27)
CAN_PACKET_STATUS_6 (ID 58)
CAN_PACKET_STATUS_6 (ID 58)
Full CAN packet ID reference
The completeCAN_PACKET_ID enum is defined in datatypes.h. Multi-frame commands (IDs 5–8) are used internally for tunneling full VESC serial protocol packets over CAN.
For the authoritative list see
datatypes.h and the implementation in comm/comm_can.c.