Let's Make Robots!

Controlling an Arduino with a standard RC transmitter/receiver

 

 

Controlling an Arduino with a standard RC transmitter/receiver

There are many ways to remote control an Arduino, Xbee, RF link, IR…

I decided to try and use something I had laying around and that is common among large group of hobbyist : RC transmitter and receiver pair

 

I will be using this 2 channel transmitter and receiver pair:RC transmitter Receiver

 

 

From what I have found there are 3 ways of getting the signals to the Arduino and making them useful.  (If I am missing one tell me)

-Method 1 involves poking around inside the receiver looking for a pin that is outputting all the channels together and then separating the pulses to get the values of each channel.

-Method 2, use interrupt to read the pulses coming from each individual channel, very efficent but needs more coding, will be used for version 2.

-Method 3, use Pulsein, inneficent but I have chosen this methos since I am not great at coding and it is fairly simple to use.

 

For now I will be controlling this guy: 

BOL

 

He is driven by 2 continuous rotating servos.    

So far reading the pulses and getting the bot to turn on the spot have been fairly easy, but now comes the hard bit(s).

 

To do list:

-Get robot to go straight ahead.Somehow I need to “revers” the signal coming from the RC receiver since both servos are going in opposite direction for the bot to go forwards.   

-Make values smooth for low speed control .The value coming from the receiver tends to jump around a bit, so maybe take the average of 5 values and send that to the servo?

 

-How to make the servos stop totally and not slowly turn when stopped.Usually to make these servos stop, you send the centre position. Well with these particular ones, they don’t seem to have a centre position, no matter how close to the centre position, it still slowly turns to one side.  

-Use two pots to adjust centre/trip the servos.  So when the stick is at rest on the remote the servo will be stopped.This is still a work in progress so it might be some time before I declare it complete.

 

I might even post a forum topic as I am struggling with coding.

 

 

 

AttachmentSize
RC_servo_v_3_4.txt1.72 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

To get your continuous rotation servos to stop completely you need to stop sending the control pulse to the servo. Ground your signal pin and the servo will stop completely.

I think you might be able to do this by simply digitalWrite(servopin,0) and then start the servo again when you write a new speed/direction to the servo. If not then you may have to detach - re-attach the servo.

You seem to have methods 2 & 3 confused.

Using interrupts (method 2) is extremly efficient as the alternative is for your MCU to waste up to 90% of it's time (20mS) to read a pulse between 1&2mS wide. The only way you would not use an interrupt (method 3) is if the interrupt pins were unavailable or used by something else like wheel encoders.

Method 1 is not a practical option.
Even if you could find such a pin, why would you bother. You would end up adding another MCU just to decode the signal when the receiver is already doing that for you.

 

You are right ! 

I was using the wrong word, interupts would be the best solutions as you said since it would allow the arduino to run other code while waiting for a singal from the receiver. 

The word I should have used is Pulsein.  

I will update the blog to correct this mistake. 

since you have two channels, and, your transmitter has a stick that moves front to back and one that moves side to side, just read the outputs of the receiver, and, decide based on those outputs what the arduino should do relative to control of the servos. To explain better, if the left/right stick is centered, but, the forward/reverse stick is sending forward, then send signals to the servos to move forward dependent on stick position. If the left/right stick is off center, but, the forward/reverse stick is centered, then rotate in place. If both sticks are off center, then move the servos in proportion to the stick placement. If the sticks are both centered, then don't send any signal to the servos, or, send a zero pulse to the servos (I would think that should keep them from moving.).

 

Yes that would work and would be fairly easy to do. 

I was hoping to keep the proportional control. Push the stick a bit and the robot moves slowly, push more and it goes faster.I might write one as you suggested for the practice and to get a basic one written.

When you say send a zero pulse, do you mean literally 0 ? As in servotwo.write(0); 

So, my suggestion to send a 0 was only a guess. Maybe, if the stick(s) are centered, you don't need to send anything and the servos won't move. Someone with actual experience will have to help you there.

As far as proportional, I would hope that what I suggest will in fact give you proportional control, if you write it correctly.