Controlling Tank with 2ch RC Car transmitter

Super nooby to arduino but I was wondering would it be possible with arduino to control 2 individual motors with a 2ch rc car transmitter?

My idea is this, the "trigger" on the transmitter controls both motors and powers them with the same value forward or back like most RC transmitters work, controlling the speed of course varying on how much you have the trigger pressed. But then would it be possible with the arduino to take the outputs from the transmitters receiver and input them into the arduino which then controls the motors but also is running code that is inputting the outputs of the turning wheel on the transmitter and feeding them to the same esc that is controlling the motors to essentially "brake" either of the tracks to turn left or right?

I hope that makes sense, but how about this

Transmitter trigger --> transmitter receiver --> arduino ("run motor" code) --> esc --> motors

while also running

Transmitter turning wheel --> transmitter reciever --> arduino ("brake" code) --> esc --> motors

the "run motor" code essentially "driving" the tank while the "brake" code just making the motor either one to run at a slower speed or perhaps the opposite direction when the transmitter wheel is all the way to one side or the other.

any feedback would be much appreciated! Thanks in advance!

Shadohunter55:
Super nooby to arduino but I was wondering would it be possible with arduino to control 2 individual motors with a 2ch rc car transmitter?

Yes, this can be done.

Shadohunter55:
My idea is this, the “trigger” on the transmitter controls both motors and powers them with the same value forward or back like most RC transmitters work, controlling the speed of course varying on how much you have the trigger pressed.

Ok - so basically what you’re going to do is use a tight loop, and read the output of the receiver via a digital input pin using the pulseIn() function:

http://arduino.cc/en/Reference/pulseIn

Likely (but I am not certain - you will need to experiment) - the center point on the trigger and on the steering “wheel” should be a pulsetrain of 1500us - see:

http://arduino.cc/en/Reference/ServoWriteMicroseconds

So - when the trigger is “at rest” and the steering wheel is centered, both should be outputting around 1500us when read with pulseIn(). Note that this won’t necessarily be exact - so you will need to take this into account; I am not going to do this in my notes below, though - but keep it in mind.

So - for the trigger - you could just write (in the loop) something like:

  1. Read using pulseIn() from the pin for the channel for the trigger.
  2. If the value read is > 1500us then call the function for moving forward.
  3. If the value read is < 1500us then call the function for moving backward.

That basically handles the trigger part.

Shadohunter55:
But then would it be possible with the arduino to take the outputs from the transmitters receiver and input them into the arduino which then controls the motors but also is running code that is inputting the outputs of the turning wheel on the transmitter and feeding them to the same esc that is controlling the motors to essentially “brake” either of the tracks to turn left or right?

Ok - so let’s just deal with the “moving forward” part - because the reverse will be similar anyhow.

So - in that function - you would basically:

  1. Read using pulseIn() from the pin for the channel for the steering wheel.
  2. If the value read is 1500us, then call the function to apply equal values to both ESCs/motors (left and right).
  3. If the value read is > 1500us then call the function to apply a larger value to the right ESC/motor and lower value to the left.
  4. If the value read is < 1500us then call the function to apply a larger value to the left ESC/motor and a lower value to the right.

…and that’s basically it.

Now - the above is basically a “fixed speed” thing; to make it more proportional, you would want to pass in the value read from the trigger into the function for the steering, then use that value along with the value from the steering (likely using the map() function in some manner) to apply varying values to the ESCs/motors.

Thank you very much for the help!

use a tight loop, and read the output of the receiver via a digital input pin using the pulseIn() function

If I am correct, and i just looked at the pulsein() function reference, that only reads the HIGH and LOW value of the receiver because you are using the digital pin to have essentially an “on” or “off” value as you stated.

Now - the above is basically a “fixed speed” thing

But, to accomplish the variable speeds of the forward, and later backward, movement, wouldn’t I have to use the analog pins to get a varying speed thus creating the increasing and decreasing speeds?

Also, isn’t the writeMicroseconds() function to set the servo on the tank to a certain angle or can it to be used to read the input of the steering wheel of the transmitter? or do you have to use the pulsein() function and the writeMicroseconds() function in conjunction with each other to accomplish this goal? I am definitely missing something…

  1. Read using pulseIn() from the pin for the channel for the steering wheel.
  2. If the value read is 1500us, then call the function to apply equal values to both ESCs/motors (left and right).
  3. If the value read is > 1500us then call the function to apply a larger value to the right ESC/motor and lower value to the left.
  4. If the value read is < 1500us then call the function to apply a larger value to the left ESC/motor and a lower value to the right.

With parts 3 and 4 of this little idea of the function if I am reading this correctly is saying that if the wheel is turned in either direction it will turn in an arc formation if that makes sense but still a fixed arc formation with the wanted variable speeds still in play. So with that will we just have to read the outputs of the receiver and then patch them into a variable speed to make it turn at different rates in different arcs depending on how much the receiver is actually turned?

Thanks so much for the feedback! and even more would be appreciated.

Shadohunter55: If I am correct, and i just looked at the pulsein() function reference, that only reads the HIGH and LOW value of the receiver because you are using the digital pin to have essentially an "on" or "off" value as you stated.

A standard hobby-grade R/C receiver outputs a PPM waveform meant for a servo; in other words, this waveform is what a servo uses to position itself (it's like PWM - but it is -not- PWM - only similar). The pulseIn() function can read this PPM signal, and convert it to a numeric value (in microseconds).

This value could then be used to write directly to the servos (if wanted) via the Servo library function writeMicroseconds() - but this can't be used in the case of a "steering wheel" style 2-channel controller for obvious reasons (if the channels were instead mapped to two forward/backward joysticks - one for left-thumb, one for right-thumb - it would be a different matter).

Shadohunter55: But, to accomplish the variable speeds of the forward, and later backward, movement, wouldn't I have to use the analog pins to get a varying speed thus creating the increasing and decreasing speeds?

Ultimately you would be using the Servo library, if you are using R/C ESCs to control the motors - so you can use any pin on the Arduino for that (you aren't limited to PWM pins for the Servo library). Now - if you were using an h-bridge, and the standard PWM output - yes, you would need to use a PWM pin for each channel (motor) of the h-bridge, but you indicated in your first post that you were using an R/C ESC to control each motor, not an h-bridge. It should also be noted, though, that there is a "SoftPWM" library out there to allow you to control any pin in a PWM fashion (it works in a similar manner to the Servo library - taking over a timer interrupt to generate the PWM waveforms).

Shadohunter55: Also, isn't the writeMicroseconds() function to set the servo on the tank to a certain angle or can it to be used to read the input of the steering wheel of the transmitter?

I indicated that particular function in order to show that the "center" PPM value that is output from the receiver is 1500us, I wasn't meaning to imply that you use it for reading (as if the name of the function wasn't clear enough?).

Shadohunter55: or do you have to use the pulsein() function and the writeMicroseconds() function in conjunction with each other to accomplish this goal? I am definitely missing something...

Yes - you read from the receiver using pulseIn() the value of the PPM number of microseconds, then you use that value to decide/control the output to the servos (or in your case, the ESCs) using writeMicroseconds().

Shadohunter55: With parts 3 and 4 of this little idea of the function if I am reading this correctly is saying that if the wheel is turned in either direction it will turn in an arc formation if that makes sense but still a fixed arc formation with the wanted variable speeds still in play. So with that will we just have to read the outputs of the receiver and then patch them into a variable speed to make it turn at different rates in different arcs depending on how much the receiver is actually turned?

In short, yes. It is actually a bit more difficult - because the speed of your motors (to operate the treads) and turn properly will depend not just on how far right or left your steering wheel is, but also how far forward or backward the trigger is as well - so you have to integrate them together in some manner. Likely, that manner isn't very difficult (I would try taking the value from the forward/reverse and mapping it to something smaller, then using that to multiply/divide the left/right values then re-mapping them to 0-1023 to keep them in range).

Shadohunter55: Thanks so much for the feedback! and even more would be appreciated.

Good luck - your best bet is to put something together, and try it out to see what you get (you may want to mount your vehicle up on blocks first while experimenting). Something else to keep in mind (unless you are already aware of this) - most R/C ESCs will require some kind of "arming sequence" before they will control your motors - so you'll need a function to something to send the proper commands for this (which vary depending on the ESC - read the manual for the ESC to find this out).

Finally, some 2-channel R/C controllers of the "trigger/wheel" combo you describe have the "midpoint" of the trigger set not in the "middle" (1500us), but somewhere else. Sometimes this can be altered (check the manual for your R/C controller) - other times it can't. Just keep it in mind - you may want to set your code up initially to dump the values it reads to the serial port so you can monitor what your controller is actually sending to the Arduino...