Skip to main content
FW version: Stable

How to read/write drive parameter over CAN bus

In this example, we will read/write the parameter /driver/limiter/ppos. This parameter has ID 80 (0x50). And we will write the value 1000.0 to it and then read it back.

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 to write a parameter

note
  • A list of available parameters can be found here
  • Always check the parameter type. Most of them are float, but some integers are also used.
CAN IDDLC
0x0C78
Byte 0Byte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7
Receiver address
0x0
Write parameter
0x3
Parameter ID
0x50
Array index
0x0
Float LSB
0x00
Float
0x00
Float
0x7A
Float MSB
0x44
note
  • How to compute CAN ID: SID is 24, sender address is 7 -> (24 « 3) + 7 = 192 + 7 = 199 (DEC) = 0xC7
  • Dec 1000.0 is in float 0x447a0000

Step 2: Receive a response

CAN IDDLC
0x0C06
Byte 0Byte 1Byte 2Byte 3Byte 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 back the parameter

CAN IDDLC
0x0C78
Byte 0Byte 1Byte 2Byte 3Byte 4 - Byte 7
Receiver address
0x0
Read parameter
0x2
Parameter ID
0x50
Array index
0x0
0x0

Step 4: Receive a response with parameter value

CAN IDDLC
0x0C05-8 Depend on parameter type
Byte 0Byte 1Byte 2Byte 3Byte 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) in case of error

Error code

Error codeDescription
-1Parameter ID out of bound
-2Parameter not found
-3Variable is not parameter
-4Set value is below minimum
-5Set value is above maximum
-6Parameter is preset type and value is not in the list