Arduino Assisted RC Truck/Car

by Chowmix12 in Circuits > Remote Control

12938 Views, 24 Favorites, 0 Comments

Arduino Assisted RC Truck/Car

IMG_0988.JPG
IMG_0996.JPG
IMG_0992.JPG
Recently I dusted off my 7 year old Stampede 2wd, designed in 1996. I got it for my 8th birthday. The truck was great, but it had a few caveats. For example, if the truck ran out of range, battery was low, or the transmitter batteries died on you, the truck would keep the throttle on the last position. Thanks to this accidental cruise (out of) control (See what I did there? 0_o), I accidentally drove my truck into a lake in my backyard! 

The newer trucks have some safety features built in, or you can get additional aftermarket parts for your truck. I, however, decided to use an arduino, to make an ultimate computer assisted truck, that has many features of a newer truck. For example, Flashing or steady lighting, Low voltage Cutoff, Training modes (limited speed), Signal loss protection (Cuts off motor when signal is lost.) The list goes on and on!

After reading up on the inner workings of the truck, its quite simple, and it's very inviting for an Arduino! Each channel controls a servo, which run at 5 volts, Arduino's favorite voltage! The servos run off of PWM, Easily interpreted and controlled by an Arduino!

So far, here's the only video I have of the vehicle:  Anti Locking Brakes, And LCD telemetry!
  



Materials!

IMG_0989.JPG
The bare minimum for this build is quite simple!
You will need:
Your Truck/Car
Arduino, I chose a duemilinove. 
3 pin female servo connector (Like the one on a regular servo)
Optional breadboard or Protoshield.

Setup!

IMG_0991.JPG
IMG_0990.JPG
IMG_0988.JPG
Connecting the Arduino to the truck is quite simple. The RC receiver outputs 5 volts, and a PWM servo signal.Using a 3 pin servo wire, you can connect the bare wire ends to the Arduino, Ground goes to ground, 5 volts goes to 5 volts on the Arduino, Signal goes to any digital pin on the Arduino. Tadaa! Now, connect the ESC cable the same way, and make sure to use a digital pin.

As far as mounting the arduino to the truck, I recommend using some sort of plastic enclosure to seal out water, dust, and dirt. For prototyping, I used some open source hardware, RUBBER BANDS!

Servo Reading! With Signal Cutoff!

IMG_0996.JPG
IMG_0995.JPG
Reading the servo signals that come off of your RC receiver is simple.. ish...
Using pulseIn(), you can time how long the pulse coming out of your receiver. Using the output of Arduino's Servo signals, I was able to calibrate the readings.
here is the code to read a signal. note, 520 and 2370 are microsecond values that are used to calibrate the readings. I used the output from Arduino's Servo Library to calibrate it, and it worked fine. PWMpin is an input from the RC receiver. 20000 is a microsecond value that is used as a timeout feature. If the timeout limit is reached, we know that we aren't getting signals from the Transmitter, and we can later use it to cutoff the motors.

RCinput = pulseIn(PWMpin, HIGH, 20000);
ServoVal = map(RCinput, 520, 2370, 0, 180);

after that, we do some data analysis! Note, ThrottleServo is an output on which the ESC's input is connected to an Arduino pin. Pin 13 is an output used to indicate an error.

if(RCinput== 0) { // Signal timed out!
      digitalWrite(13, HIGH); // ALERT!
      ThrottleServo.write(97); // Go to neutral throttle position
    }
  }
else{
    digitalWrite(13, LOW);
    ThrottleServo.write(ServoVal);              // Repeat the data to the truck's ESC
    Serial.print("  PulseMicros ");                // This part is used to debug the values for calibration
    Serial.print(RCinput);
    Serial.print("  ServoRead  ");
    Serial.println(ServoVal);
  }

Final Code for Signal Cutoff

ArduinoCode.jpg
#include <Servo.h>

Servo ThrottleServo;

int PWMpin = 2; // connect RC receiver here.
int ServoVal;
int RCinput;

void setup()
{
  Serial.begin(9600);
  ThrottleServo.attach(9);  // attaches the servo on pin 9 to the servo object
  ThrottleServo.write(97);  // go to nuetral
  pinMode(13, OUTPUT);
}


void loop()
{
  RCinput = pulseIn(PWMpin, HIGH, 20000);
  ServoVal = map(RCinput, 520, 2370, 0, 180);
  if(RCinput== 0) { // Signal timed out!
    digitalWrite(13, HIGH); // ALERT!
    ThrottleServo.write(97); // Go to neutral throttle position
  }

else{
    digitalWrite(13, LOW);                      // everything's fine.
    ThrottleServo.write(ServoVal);              // Repeat the data to the truck's ESC
    Serial.print("  PulseMicros ");             // This part is used to debug the values for calibration
    Serial.print(RCinput);
    Serial.print("  ServoRead  ");
    Serial.println(ServoVal);
  }
}