How to control a motor using CAN bus
What do you need to prepare before:
- The controller is turned ON
- CANbus works properly
- The controller CAN address is set to 0
note
- All the values are in big-endian
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
There is a watchdog set for 200ms. To keep the motor spinning it is necessary to send the motor command frame (0xCF) periodically with a cycle time below 200 ms
How to compute CAN ID
SID is 25, sender adress is 7 -> (25 « 3) + 7 = 200 + 7 = 207 (DEC) = 0xCF
Step 2: Receive response
There is no response to this message.