Hi there,
First post on the forum. Hello to everyone!
I am looking to get some input on using SBUS on the Arduino Due. Hopefully I am posting this in the right thread. Please forgive me if I am not. I'll give some background on myself and then on the project I am working on.
I have done one or two really simple projects on Arduino's before (previously on a Nano, and now I am using a Due). I would consider myself a novice and although I am a engineer by profession (mechanical) and have a reasonable understanding of electronics and circuits as well as some coding ability. I know very little about the inner working of COM protocols or the more technical aspects of microcontrollers. So I guess what I am looking for is advice but explained in layman's terms if possible. I have tried searching for the answers I need but can't quite find what I am looking for, and most of what I find is a bit beyond my understanding or is some library or piece of code without any documentation.
So that's a background in terms of me. And now for info on the project I am working on.
So basically I am building a quadcopter/VTOL drone of sort (Its not necessary to explain further) and I am using the Due as the flight controller. The little RF receiver I currently have is the R161 from Radiomaster (and I have a openTX Radiomaster transmitter). The R161 uses SBUS and I am looking to find out how I can read in this SBUS on one of the Due's Rx pins, decode it, map/scale it, and use this as the inputs for the LQR controller.
So Question 1 is on the RF receiver. I understand that FrSky uses inverted SBUS whereas Futaba uses non-inverted - is this correct? I think the R161 is FrSky compatible, so I am assuming this means that it uses inverted SBUS?
Question 2, if it is inverted, is it correct to say that I will need to un-invert the SBUS before connecting it to the Rx pin on the Arduino? I have the resistors and transistors on hand to do this if I indeed do need to do this. I found the details of the resistors and transistor needed to do this online somewhere.
Question 3. I was looking at what libraries are available. And it looks as though the bolderflight one wont work on the Due, as the device is not supported - is this correct? I found another library: GitHub - mikeshub/FUTABA_SBUS: SBUS driver for arduino - which although isn't accompanied by documentation, I think it may potentially be something that would work. Not sure if anyone can confirm this? I'll probably seek advice on the code of the example in this library and how I would change it for the Due. But I'll leave this perhaps for the next post after these initial questions.
Question 4. Lets assume that I have an SBUS signal coming in (un-inverted if need be). Can I put this on any of the Serial ports? Preferably not the native USB one right? so if I say put it on the Rx1 pin. Would I initiate the coms by saying Serial1.begin(baud rate)? I think the FUTABA_SBUS library allows you to specify the Serial port in the header file.
Question 5. If you read in SBUS from say Serial1 and you map it to the values you need, if I wanted to see this in real time, would I then write the values to the usual Serial port to see it on the Serial Monitor window?
Question 6. I have seen that the baud rate is typically specified at 100k or possibly 115200 but nothing more than this. Lets say I specify the baudrate at 115200. What sort of time are we talking here to read in the 16 channels on the SBUS in the main loop of the code? I have seen values of a good few milliseconds - that seems quite slow. I would like to keep this value as low as possible.
I think that is it for now. I apologize for the bombardment of questions. I would appreciate any help to any of the above questions. I am quite far along in my project in terms of the physical build, I have also got my BLDC motors, servo motors working. I have modelled the state space, simulated the LQR controller etc. so things are almost there. Getting the control inputs from the radio receiver is the last major obstacle for me. Building a rather complicated VTOL aircraft from scratch and using an Arduino is almost certainly not the easiest/cheapest option, but I have mainly decided to do this as a learning experience (and a hobby to keep me busy).
Thanks again,
G