How to Control a Motor Using CAN Bus
Prerequisites:
- An ESCx controller with properly identified, safely mounted motor, that is powered ON
- CAN bus is functioning properly
- Controller address is set to 0
note
- All payloads use big-endian byte order
Step 1: Compose the CAN Frame
We will use driver command with fixed point.
CAN ID | DLC |
---|---|
0x0CF | 4 |
Byte 0 | Byte 1 | Byte 2 - Byte 3 |
---|---|---|
Receiver address 0x0 | Driver mode 3 0x3 | Motor command INT16 0.1 = 3276 = 0x0CCC |
The motor should spin at 10% of the nominal RPM
note
A watchdog timeout of 200ms is active. To maintain motor operation, the motor command frame (0xCF) must be sent periodically with a cycle time less than 200ms
How to Calculate CAN ID
SID is 25, sender address is 7 -> (25 � 3) + 7 = 200 + 7 = 207 (DEC) = 0xCF
Step 2: Receive Response
This message does not generate a response.