Hey guys!
I want to build a remote controlled drone by myself using an arduino nano.
So far i have successfully:
- set up communication with a MPU6050 gyroscope using "I2Cdev" and "MPU6050" libraries
(SCL to analog pin A5, SDA to analog pin A4) - combined gyroscope data with linear acceleration data using a complementary filter and got
sufficiently good angular position/speed values - tuned PID control
The tricky part right now is communicating with the RC Receiver FS-iA10B.
Until now i have used the EnableInterrupt library to read out the PWM signals of the four different RC channels. This approach seems to work, but sometimes those values are not updated fast enough. Besides PWM i could use PPM, but reading a PPM signal needs computation resources too. To get the RC data faster and more reliable i want to use BUS communication. FS-iA10B offers iBus and SBUS. I have tried to use the following libraries:
Those are written only for use with Arduino Mega 2560, which has "Serial1" in addition to "Serial".
On Arduino Nano i have only one serial port, which i need to connect to my notebook and output the data on screen.
So i wanted to use the "SoftwareSerial" library, i changed every occurence of "HardwareSerial" in the SBUS library with "SoftwareSerial".
I ran the following code on my Arduino Nano:
#include "SBUS.h"
#include <SoftwareSerial.h>
// I have made following changes to the SBUS library:
// - I replaced every occurence of "HardwareSerial" with "SoftwareSerial"
// - I set the baud rate _sbusBaud to 115200;
// - in SBUS::begin() i simply removed the if-condition for the
// used microcontroller and instead put "_bus->begin(_sbusBaud);",
// so that the begin()-function is called when using the arduino nano
// SoftwareSerial port for connecting the RC Receiver FS-iA10B
// (Arduino Nano has only one serial port
// we need two: 1) RC Receiver, 2) notebook via USB)
SoftwareSerial mySerial(10, 11); // RX, TX
// an SBUS object
SBUS x8r(mySerial);
// channel, fail safe, and lost frames data
uint16_t channels[10];
bool failSafe;
bool lostFrame;
void setup() {
// begin BUS communication
x8r.begin(); // with RC Receiver
Serial.begin(115200); // with notebook via USB
}
void loop() {
Serial.println(" Loop.."); // Visualize that process is running
Serial.println(x8r.read(&channels[2], &failSafe, &lostFrame)); // successful reading?
Serial.println(channels[0]); // output receiver data CH1 on notebook
Serial.println(channels[1]); // output receiver data CH2 on notebook
delay(500);
}
I don't receive any valid data though.
I only get 3 lines of "0".
Does anyone have experience with SBUS or iBus on Arduino Nano?
Are there any better ways to communicate with the RC Receiver FS-iA10B?
Or did I mess up at some point in my code?
Thanks for your help!