Open pascalheude opened 1 year ago
I'm a little confused with your post, but my assumption is that you're trying to send SBUS commands from an ESP32 to a flight control system.
Inverted SBUS is supported on the ESP32. If you look at the README, the SbusTx constructor for ESP32 is: SbusTx(HardwareSerial *bus, const int8_t rxpin, const int8_t txpin, const bool inv). The boolean inv flag controls whether the signal is inverted or not. You shouldn't have to worry about HardwareSerial setup, the baudrate, the header bytes or bit order - all you need to do is set the channel values and control the timing of how often you call the Write method. Most flight controllers will expect to receive a packet every 10 to 20 ms.
I effectively set the parameter inv to true in order to make a 0 becomes a 1 (and vice versa) on the serial bus. But, when I mention "inversion", I mean LSBit first and not MSBit first.
I'm not aware of a need to reverse the bit order. I've tested the library with Teensy microcontrollers, Futaba servos, and FrSky receivers and servos. Other community members have used ESP32 microcontrollers and Futaba receivers.
According to this https://github.com/uzh-rpg/rpg_quadrotor_control/wiki/SBUS-Protocol, it's stated: Since the least significant bit is sent first over the serial port, the following bit sequence is transmitted: shhhhhhhhpss | s 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 pss | s 1.8 1.9 1.10 2.1 2.2 2.3 2.4 pss | ...
But (because there is always a but):
And now it works !
I have a FC Skystars F405 HD2 connected with a ESP32 (Arduino) by a serial link (100kbauds, parity even, 2 stop bits, inverted). 25 bytes are sent, starting with byte 0x0F and ending with byte 0x00. The flight controler seems to catch the frame but does not decode it correctly. I spied the serial transmitter using Saleae Logic 16. I attached the capture of the first bytes sent. The first parameter sent is the throttle position (1498=101 1101 1010). According to Futaba S-bus protocol, the LSBit shall be transmitted first. So, that's why the throttle is not equal to 1498 but equal to 733 (010 1101 1101). I've added the inversion in my ESP32 software because the sbus library doesnot do it. Can you confirm that the library does not and I have to do it in my software ? And, finally, if you have any idea why the flight controller shows me the value 1338 for the throttle (observed in Betflight) instead of 1498, it would help me. Thanks.