Communication protocol
Message format
Messages sent to and received from the microcontrollers are byte oriented
streams. All messages start with a caret sign ^
(0x5e
) and end with a
dollar sign $
(0x24
).
Bytes | 1 | n | 1 |
---|---|---|---|
|
|
|
An exclamation mark !
inside a message body indicates a transmission error
and invalidates the whole message. The characters ^
, $
, !
and \
are
special and must be escaped with a backslash \
followed by the two’s
complement of the escaped character (they are thus encoded on two successive
bytes).
Special character | Escaped version inside a message body |
---|---|
|
|
|
|
|
|
|
|
All messages may embed signed or unsigned integers. They are encoded on 1, 2 or 4 bytes (depending on the message format decribred later), in big-endian format (most significative byte first).
Bytes | 1 | 2 | 3 | 4 |
---|---|---|---|---|
8 bits integer |
|
|||
16 bits integer |
|
|
||
32 bits integer |
|
|
|
|
Brushless controller messages
The brushless controller defines the following messages:
ID
This message queries the controller for it’s version, and motor id.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | 1 (unsigned int) | n>4 (string) | 1 |
---|---|---|---|---|---|
|
|
|
|
|
X.Y represent the software version running on board.
Clock timestamp
This message can be sent periodically to the controller so that is calibrates its internal oscillator. The message contains the local time on the sending machine, encoded in micro seconds (possibly wrapped around).
Bytes | 1 | 1 | 4 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
Motor startup
This message starts the motor at a very low speed (about 16Hz).
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
PWM duty cycle
This spins the motor at the given PWM duty cycle. The duty cycle is encoded as
a 16 bit signed integer, but useful range is from -1023
(-100%) to 1023
(100%). Negative values mean spinning in the reverse direction.
The motor must be started for that message to be taken into account.
Bytes | 1 | 1 | 2 (signed int) | 1 |
---|---|---|---|---|
|
|
|
|
Alternatively, an array can be broadcasted to all controllers. Each controller will take the 'i' th value of the message where 'i' is the motor id.
Bytes | 1 | 1 | 2 (signed int) | … | 2 (signed int) | 1 |
---|---|---|---|---|---|---|
|
|
|
|
|
|
Velocity control
This spins the motor at a given velocity. The velocity is encoded as the half of the desired rotational period in micro seconds (the inverse of the velocity), on a 16 bit signed integer. Negative values mean spinning in the reverse direction.
Bytes | 1 | 1 | 2 (signed int) | 1 |
---|---|---|---|---|
|
|
|
|
Alternatively, an array can be broadcasted to all controllers. Each controller will take the 'i' th value of the message where 'i' is the motor id.
Bytes | 1 | 1 | 2 (signed int) | … | 2 (signed int) | 1 |
---|---|---|---|---|---|---|
|
|
|
|
|
|
Velocity query
This message queries the current spinning velocity. The reply contains a bit field with the current spinning state, as well as the current half rotational period in microseconds.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | 1 (bit field) | 2 (signed int) | 1 |
---|---|---|---|---|---|
|
|
|
|
|
Current query
This message queries the instantaneous current consumption. The reply contains the value in miliampers.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | 1 (bit field) | 2 (unsigned int) | 1 |
---|---|---|---|---|---|
|
|
|
|
|
Motor data query
This message ask for important values from the motor to be sent periodically.
Bytes | 1 | 1 | 4 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
Bytes | 1 | 1 | 1 | 1 (bit field) | 2 (signed int) | 2 (unsigned int) | 2 (unsigned int) | 1 |
---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
The peak current is the maximum current recorded since the last time this message was sent by the microcontroller.
The sequence number increments for each sent message.
Sensor data query
This message queries values from various on board sensors.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | 1 (bit field) | 2 (unsigned int) | 2 (unsigned int) | 2 (unsigned int) | 2 (unsigned int) | 1 |
---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
Velocity controller data query
This message queries values from the velocity controller.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | 1 (bit field) | 2 (unsigned int) | 2 (signed int) | 2 (signed int) | 2 (signed int) | 1 |
---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
Flight controller messages
The flight controller defines the following messages:
ID
This message queries the controller for it’s version, and motor id.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
Bytes | 1 | 1 | n>4 (string) | 1 |
---|---|---|---|---|
|
|
|
|
X.Y represent the software version running on board.
Motors startup
This message starts all motors at a very low speed (about 16Hz).
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
It is also possible to start only one motor by specifying its id.
Bytes | 1 | 1 | 1 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
Motors stop
This message stops all motors.
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
It is also possible to stop only one motor by specifying its id.
Bytes | 1 | 1 | 1 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
PWM duty cycle
This spins motors at the given PWM duty cycle. The duty cycle is encoded as
a 16 bit signed integer, but useful range is from -1023
(-100%) to 1023
(100%). Negative values mean spinning in the reverse direction.
Each motor takes the 'i' th value of the message where 'i' is the
motor id.
Bytes | 1 | 1 | 2 (signed int) | … | 2 (signed int) | 1 |
---|---|---|---|---|---|---|
|
|
|
|
|
|
Velocity control
This spins motors at a given velocity. The velocity is encoded as an array of half rotational period in micro seconds (the inverse of the velocity), on a 16 bit signed integer. Negative values mean spinning in the reverse direction. Each motor takes the 'i' th value of the message where 'i' is the motor id.
Bytes | 1 | 1 | 2 (signed int) | … | 2 (unsigned int) | 1 |
---|---|---|---|---|---|---|
|
|
|
|
|
|
Gyroscope calibration
This message runs a calibration procedure for the gyroscopes, for the given amount of time. The board should be still while this procedure runs. There flight controller reports when the procedure is done.
Bytes | 1 | 1 | 1 | 1 (unsigned int) | 1 |
---|---|---|---|---|---|
|
|
|
|
|
Bytes | 1 | 1 | 1 |
---|---|---|---|
|
|
|
IMU query
This message ask for periodic IMU data.
Bytes | 1 | 1 | 4 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
Bytes | 1 | 1 | 1 | 2 (signed int) | 2 (signed int) | 2 (signed int) | 2 (signed int) | 2 (signed int) | 2 (signed int) | 1 |
---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
The sequence number increments for each sent message.
Battery level query
This message ask for periodic battery level.
Bytes | 1 | 1 | 4 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
Bytes | 1 | 1 | 1 | 2 (unsigned int) | 1 |
---|---|---|---|---|---|
|
|
|
|
|
The sequence number increments for each sent message.
Motor data query
This message queries important values from each connected motor.
Bytes | 1 | 1 | 4 (unsigned int) | 1 |
---|---|---|---|---|
|
|
|
|
There is one reply per connected motor, in the same format as the brushless controller message (see Motor data).