RCArduinoChannels by DuaneB is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
RC Transmitters multiplex as many as 9 channels onto a single radio signal. Your RC Receiver decodes this single signal to obtain the individual channel signals for your servos and electronic speed controllers.
If we reverse part of this process we can read all of the incoming channels using just two Arduino Pins.
Not only does this keep our pins free for more important tasks within our projects, but it is also more efficient to read them this way, we simply need to count the pulses to know which channel we are looking at.
This is a technique I have been using in the development of the RCArduino library.
The library uses just two interrupt pins to read as many as six RC Channels. The library is also able to generate upto six RC Channel outputs in its current form. I will soon be adding the capability to drive 9 servos using only 3 Arduino digital pins.
UPDATE : The library has been reworked so that it now supports three output modes -
1) Generate six outputs using a selected port
2) Do not generate any outputs, but operate in a mode compatible with the existing servo library and all of the flexibility that it offers - also suitable for working with H-Bridges etc.
3) Serial servos, use less pins and less code to drive more servos - details soon.
So, if you want to be able to do more, with less, with a library that is smaller and faster than the existing general purpose libraries, read on.
The RC Arduino Channel Multiplexer
Some high end receivers offer a 'raw' output, mine don't and yours don't need to either. Instead of modifying the receiver we will simply create a small hardware 'RC Channel multiplexer'. The multiplexer is basically a single diode for each channel.
The key to the multiplexer is that we route all of the even numbered channels 0,2,4 to INT0 (digital pin 2) and all of the odd numbered channels 1,3,5 to INT1 (digital pin 3).
How does it work ?The diodes stop interference between the pulses - if one channel is high and the others are low, the low channels will sink some of the current from the high channel, this would be sufficient to stop the Arduino from detecting the pulse. However adding a diode to each channel prevents any current from the high channel sinking back into the low channels and ensures we can detect all of the channel pulses.
An RC Arduino Channel Multiplexer - 3 Channels into two pins, as simple as that.
Multiplexing the receiver channels into the two Arduino interrupts is as simple as adding a diode to each channel before connecting it to INT0 for 0 and even numbered channels and INT1 for odd numbered channels.
There is an interesting effect where a charge gets trapped between the diodes and the Arduino pins. To overcome this effect a high value resistor can be place between the point where the diodes meet and ground. I am using a 1M resistor. Picture below -.
Schematic - The even half of the channel multiplexer, the odd half is a duplicate but is connected between the odd numbered channels and INT1 (digital pin 3).
The next post in this series will be a conversion of a previous project to use the new library, as always the post will include the full source code of both the library and the project.
Duane B
If the library can control servos, please make sure that it is not just whole degrees. The Servo.h accepts just "int" as a angle.
ReplyDeleteHi, Most servo libraries including the Standard Arduino servo library support fine control using the servo.writeMicroseconds function
ReplyDeleteDuane B
Would this circuit be able to switch control of servos from rc to arduino?
ReplyDeleteHi,
ReplyDeleteMost of the code on RCArduino will allow you to operate a project in two modes - Manual and Autonomous.
The way I usually do this is to have the Arduino connected in between the RC Receiver and the servos/escs and whatever else that makes up your projects.
The Arduino listens to all of the incoming signals and in manual mode (rc mode) it will pass them straight out to the other devices as if it is not there.
In autonomous mode, the Arduino still listens to the incoming signals, but instead of outputting them, it runs additional code to read sensors and control the servos/escs etc.
The benefit of this approach is that you can easily switch back and forth between the two modes while you perfect the autonomous mode.
Here are some links that are a good starting point -
Simple two mode project with RC -
http://rcarduino.blogspot.ae/2012/01/traction-control-part-13-we-have.html
Reading RC Signals intro
http://rcarduino.blogspot.ae/2012/04/how-to-read-multiple-rc-channels-draft.html
Basics if you need them -
http://rcarduino.blogspot.ae/2012/01/how-to-read-rc-receiver-with.html
Duane B
I'm with a high school group and were competing in a autonomous sail boat competition. The thing is we need to drive out our boat manually and then turn it autonomous once out in the water. What are the names of the diodes and resistor you used?
ReplyDeleteThis is not the circuit you need, refer to the links in my previous response, especially this one -
ReplyDeleteReading RC Signals intro
http://rcarduino.blogspot.ae/2012/04/how-to-read-multiple-rc-channels-draft.html
Also have a look at this video which shows one of my cars using similar code with two modes -
http://www.youtube.com/watch?v=dqxlONWB5O8
The first thing you need to do is use the code in the link above to read the channels from your receiver. Once you have that running, you can add some servos and your 90% done.
Let me know when you have this up and running
Duane B
Sorry im a bit confused what am I plugging into the arduino physically?
ReplyDeleteFirst of all, forget about this post, its an advanced technique that you do not need to use.
ReplyDeletePlease post your questions with the background information on this post which is far more relevant to you -
http://rcarduino.blogspot.ae/2012/04/how-to-read-multiple-rc-channels-draft.html
Start with telling us what it is that you want to control - servos ? ESCs ? anything else ? also what do you intend to use for power in the boat and what model of receiver you are using.
Duane B
o have a question, im very new in this about arduino and im making a drone uav, so i want to know how to make the sketch paralel to the move of the joystick , i mean if i can make that while im moving the joystick the servo is moving
ReplyDeleteHi, If I understand your question just about any project on rcarduino will do what you want - or am I missing something ?
ReplyDeleteDuane B
These transmitter are soo dangerous to watch but it is very useful in modern days essay help
ReplyDelete