How to Read/Write Drive Parameters Over CAN Bus
This example demonstrates reading and writing the parameter /driver/limiter/ppos
(ID: 80/0x50). We'll write the value 1000.0 and read it back.
Prerequisites:
- An ESCx Controller that is powered ON
- CAN bus is functioning properly
- Controller CAN address is set to 0
note
- All values use big-endian byte order
Step 1: Write Parameter CAN Frame
note
- See parameter list for available parameters
- Verify parameter type - most are float, some are integer
CAN ID | DLC |
---|---|
0x0C7 | 8 |
Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 |
---|---|---|---|---|---|---|---|
Receiver address 0x0 | Write parameter 0x3 | Parameter ID 0x50 | Array index 0x0 | Float LSB 0x00 | Float 0x00 | Float 0x7A | Float MSB 0x44 |
note
- CAN ID calculation: SID is 24, sender address is 7 -> (24 � 3) + 7 = 192 + 7 = 199 (DEC) = 0xC7
- Decimal 1000.0 in float is 0x447a0000
Step 2: Write Response
CAN ID | DLC |
---|---|
0x0C0 | 6 |
Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 - Byte 5 |
---|---|---|---|---|
Receiver address 0x7 | Write parameter response 0x43 | Parameter ID 0x50 | 0xFF = error Parameter ID if success | Error code (INT16) |
Step 3: Read Parameter Request
CAN ID | DLC |
---|---|
0x0C7 | 8 |
Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 - Byte 7 |
---|---|---|---|---|
Receiver address 0x0 | Read parameter 0x2 | Parameter ID 0x50 | Array index 0x0 | 0x0 |
Step 4: Read Response
CAN ID | DLC |
---|---|
0x0C0 | 5-8 (depends on parameter type) |
Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 - Byte 5 |
---|---|---|---|---|
Receiver address 0x7 | Read parameter response 0x42 | Parameter ID 0x50 | 0xFF = error Parameter ID if success | Parameter value - 0x00007A44 Error code (INT16) if error occurs |
Error Code
Error code | Description |
---|---|
-1 | Parameter ID out of bounds |
-2 | Parameter not found |
-3 | Variable is not parameter |
-4 | Set value below minimum |
-5 | Set value above maximum |
-6 | Parameter is preset type and value not in preset list |