In the development from Marvin to Marvin 2.0, I wanted to add the ability to control the rover using remote control. The system used was the FrSky Tandem X18 transmitter with the TD MX receiver.
First, an understanding of SBUS is needed.
In SBUS, a single serial line can be connected to up to 16 servos. The protocol uses an inverted serial logic with a baud rate of 100000, 8 data bits, even parity, and 2 stop bits. The SBUS packet is 25 bytes long.
Depending on the microcontroller being used, a simple circuit may needed to invert the signal, consisting of 2 resistors and a transistor. The inclusion of this required, for example, with Arduino and Raspberry Pi.
CIRCUIT DIAGRAM HERE
The first byte is the SBUS header byte 0x0F (hexadecimal 15), and this can be used to identify the start of the packet.
The next 22 bytes are the 16 channels in the SBUS signal, with each value being 11 bits. Extracting these is a little complicated, requiring bitwise operations to shift, add and mask to retrieve each 11 bits in order. For example, the first channel value is the 8 bits of the first byte and the first 3 bits of the second byte. To do this, we shift the second byte left by 8 bits (such that 01101010 becomes 01101010 00000000) and use the OR operator to put the first byte after this. We then mask out all but the lowest value 11 bits. This method works as SBUS is little endian, that is
channel1 = ((sbusByte1) | (sbusByte2 << 8)) & 0x07FF