Arduino Project – Gyro Based RC Controller
I’ve started work on a new project – a Gyro Based RC controller using an Arduino Uno as the microcontroller – for use on my RC planes and multirotors (maybe even cars at some point). But for now I’m developing the software using this board:
The components I’m using are:
Arduino Uno – Basic Arduino Card (normal form factor)
Sain Smart Servo Shield – Shield which is useful for RC modellers to connect their radio and servos to
OrangeRX 6 Channel Receiver – OrangeRX 6 channel receiver
Gyro breakout card – I made my own which you can read about here, but you could also use the SparkFun one
Right now I’m still getting my feet wet with Arduino, but have been able to do a number of useful things with it.
To date I’ve been able to read the values out of the gyro using the I2C bus – here is what the raw data looks like:
Basically this shows the raw values coming out of the gyro. Every least significant bit represents 1/14.375 degrees per second (which means 14 means the Tricopter is turning about one degree per second in a particular axis). The other characteristic of this gyro is that the rate drifts which temperature and that is why they’ve build in a temperature sensor into the chip. If you want to learn more about these chips you can find it on the Invensense website.
Introduction to Processing
Once I had all of this I wanted to visual the data better. I considered doing this in Visual C++, but frankly got discouraged with all of the object classes which were involved in setting up the even most simple GUI. Not at all for the casual user. As I’ve been learning more about the Arduino – maybe of the texts mentioned the “Processing” environment. After looking at a few example I saw how easy it was to write graphical program with very little knowledge of new libraries. If I wanted to make a line – I use the command:
line (x1, y1, x2, y2)”
and that is it! Also, interfacing to the Arduino was just as easy, and used a format very similar to the format used by the Arduino. For example, to open the serial port I would just do:
myPort = new Serial(this, Serial.list()[portIndex], 9600);
So, after about an hour or so of coding up a simple GUI – I had my Arduino successfully talking to Processing (on my Mac) and I was able to see the effect of waiving the little micro controller around in real time. Really neat!
You can really see from the graph when I moved the board slowly, and when it was moved abruptly.
Interfacing to the OrangeRX Receiver
The next piece of work I’ve done is in terms of interfacing to the OrangeRX Receiver. For those of you who don’t know – an RC receiver “talks” to the servo but sending a short pulse over and over again.. The length of the pulse determines the position of the servo:
The first column show the position of the throttle and I moved it from 0 up to about 3/4s – and you can see the numbers (which represent microseconds – 1 millionth of a second) go from about 960 -> 1693.. All happening in real time…
Next – Installing the Controller onto the Tricopter
I’ve been having great success with the RCExplorer.se Tricopter and I recommend building it to anybody interested in getting started with multi-rotors. For me it is also serving as an excellent platform for the controller development. Here’s the Tricopter with the controller installed:
And from a winder angle:
Fits very nicely on top of the standard base plate.
About the Controller
The Controller will be a PID based controller which stands for, and if you’d like to know more about the PID controller I suggest you check the paper on this website:
Initially I have coded up just the “P” component of the controller (which is the proportional control). This works to counter act the current about of rotational turn of the Tri.
I plan to describe the controller at a later time, but now you’re going to have to trust me…
Here – a picture is worth a thousand word, so here’s a video describing it all:
I hope you are enjoying this thread and I’d like to continue developing it.. Comments are very welcome.