To be updated
The flight controllers receive data frame by frame and use NULL (0x00) bytes as frame delimiters. There will be no 0x00 bytes in a data frame. Each frame contains a key (1 byte), a value (3 bytes) of the and a checksum (1 byte).
<1 key byte>: The description in the keys table. The value of the key byte should be key + 1.
<3 value bytes>: This 3 bytes is to contain a value from 0 to 16581375 (= 255*255*255).
For example, the number 1000000 will be converted to 3 bytes as bellow:
byte[2] = 156 as 1000000 % 255 = 156, take 156 + 1 = 157
byte[1] = 97 as integer of (1000000 / 255) = 3921 and 3921 % 255 = 96, take 96 + 1 = 97
byte[0] = 16 as integer of (3921 / 255) = 15 and 15 % 255 = 15, take 15 + 1 = 16
<1 checksum byte>: Is calculated from the key & value bytes then modulo 255
For example, key is 5, value is 1000000, then we have 4 bytes of key and value as bellow:
bytes: 6, 16, 97, 156
checksum = (6*255^3 + 16*255^2 + 97*255 + 156) % 255 = 156
The frame is: 6, 16, 97, 156 156 0
key = ...
value = ...
let out_bytes = [-1, 0, 0, 0, 0, 0]
let byte1 = key;
value = parseInt(value);
let byte4 = value%255;
value = parseInt(value/255);
let byte3 = value%255;
value = parseInt(value/255);
let byte2 = value%255;
let check = (byte1*(255*255*255) + byte2*(255*255) + byte3*(255) + byte4) % 255;
let byte5 = check;
out_bytes[0] = byte1 + 1;
out_bytes[1] = byte2 + 1;
out_bytes[2] = byte3 + 1;
out_bytes[3] = byte4 + 1;
out_bytes[4] = byte5 + 1;
Python code
key = ...
value = ...
out_bytes = [-1, 0, 0, 0, 0, 0, 0]
byte1 = key
value = int(value);
byte4 = value%255
value = int(value/255)
byte3 = value%255
value = int(value/255)
byte2 = value%255
check = (byte1*(255*255*255) + byte2*(255*255) + byte3*(255) + byte4) % 255
byte5 = check
out_bytes[0] = byte1 + 1
out_bytes[1] = byte2 + 1
out_bytes[2] = byte3 + 1
out_bytes[3] = byte4 + 1
out_bytes[4] = byte5 + 1
Key | Description |
---|---|
1 | Initial motor speed (PWM) |
2 | Minimum motor speed (PWM) |
3 | Take-off motor speed (PWM) |
4 | Maximum motor speed (PWM) |
5 | Token-off height (PWM) |
6 | P gain (Roll) |
7 | I gain (Roll) |
8 | I accumulation gain (Roll) |
9 | D gain (Roll) |
10 | Offset (Roll) |
11 | P gain (Pitch) |
12 | I gain (Pitch) |
13 | I accumulation gain (Pitch) |
14 | D gain (Pitch) |
15 | Offset (Pitch) |
16 | P gain (Yaw) |
17 | I gain (Yaw) |
18 | I accumulation gain (Yaw) |
19 | D gain (Yaw) |
20 | Offset (Yaw) |
21 | P gain (Position hold) |
22 | I gain (Position hold) |
23 | I accumulation gain (Position hold) |
24 | D gain (Position hold) |
25 | Brake after releasing the control |
26 | P gain (Altitude hold) |
27 | I gain (Altitude hold) |
28 | I accumulation gain (Altitude hold) |
29 | D gain (Altitude hold) |
30 | Tilt compensation (Altitude) |
31 | Moving support 1 (Altitude) |
32 | Moving support 2 (Altitude) |
33 | Moving support 3 (Altitude) |
34 | PID smoothing 1 (Roll/Pitch/Yaw) |
35 | PID smoothing 2 (Roll/Pitch/Yaw) |
36 | PID smoothing 3 (Roll/Pitch/Yaw) |
37 | PID smoothing 1 (Position hold) |
38 | PID smoothing 2 (Position hold) |
39 | PID smoothing 3 (Position hold) |
40 | PID smoothing 1 (Altitude) |
41 | PID smoothing 2 (Altitude) |
42 | PID smoothing 3 (Altitude) |
43 | Monitor request |
44 | RC type |
To be updated
To be updated