Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Futaba S-bus protocol requires to send LSBit first #65

Open
pascalheude opened this issue Feb 22, 2023 · 4 comments
Open

Futaba S-bus protocol requires to send LSBit first #65

pascalheude opened this issue Feb 22, 2023 · 4 comments

Comments

@pascalheude
Copy link

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).
sbus inversé avec EPS32
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.

@flybrianfly
Copy link
Member

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.

@pascalheude
Copy link
Author

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.

@flybrianfly
Copy link
Member

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.

@pascalheude
Copy link
Author

pascalheude commented Feb 23, 2023

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):

  1. I change the value of each channel by limiting it between 192 and 1792 (192 for 1000, 1792 for 2000), based on what is stated in the url above
  2. I also revert to MSBit first

And now it works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants