How to get a signal from the driver 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
Setup sampling of Motor 4 and Driver 1 messages with 100ms period and 10ms delay.
CAN ID | DLC |
---|---|
0x0C7 | 8 |
Byte 0 | Byte 1 | Byte 2 - Byte 3 | Byte 4 - Byte 5 | Byte 6 - Byte 7 |
---|---|---|---|---|
Receiver address 0x0 | Setup sampling 0x8 | Bank selector Byte 2 = 0x2 (Motor4) Byte 3 = 0x4 (Driver 1) | Sampling period [ms] 0x64 (100ms period) | First period [ms] 0xA (10ms delay) This must be non-zero to start sending. |
Bank selector byte | Bit | Description |
---|---|---|
0 | 0 | Motor 3 |
0 | 1 | Motor 4 |
0 | 2-3 | reserved |
0 | 4 | Driver state 2 |
0 | 5-7 | reserved |
1 | 0:1 | reserved |
1 | 2 | Driver state 1 |
1 | 3 | Range and reference |
1 | 4 | Supply 1 |
1 | 6 | Motor 1 |
1 | 7 | Motor 2 |
How to compute CAN ID
SID is 24, sender address is 7 -> (24 « 3) + 7 = 192 + 7 = 199 (DEC) = 0xC7
Step 2: Receive response
The controller started to send out the requested banks. Each bank has its CAN ID. CAN IDs with signal layouts are in the table below
Bank | Driver state 1 | Range and reference | Supply 1 | Motor 1 | Motor 2 | Motor 3 | Motor 4 | Driver state 2 |
---|---|---|---|---|---|---|---|---|
CAN ID | 0x0D0 | 0x0D8 | 0x0E0 | 0x0F0 | 0x0F8 | 0x100 | 0x108 | 0x120 |