RC Car Arduino Conversion

Creating an Arduino controlled RC car isn’t all that hard to do, especially with the Arduino Servo library.

 

Read the whole step-by-step process here!

I started off by buying a Traxxas Monster Jam Truck.  This page has some good information on the RC car, long with some pictures of the internals.  This car was chosen because its frame and suspension looked pretty beefy, and it was the cheapest car in the local hobby store!

To get a good build area, I stripped off everything I could.

I created a bracket to hold the Arduino and ESC (Electronic Speed Controller).

Next I soldered a couple of 3 pin connectors onto an XBee shield to make hooking up the ESC and steering servo easier.  Notice the red wire?  I realized the ESC outputs 6v on the power line and not 5v.  That’s why the power line is plugged into VIN, which is put through a 5v regulator.

Pinout:

  • Servo GND = GND
  • Servo PWR = 5v
  • Servo Signal = Pin 13
  • ESC GND = GND
  • ESC PWR = VIN
  • ESC Signal = Pin 12

Next thing I did was drill some holes to hold the bracket above the battery.

I swapped out the wimpy NiCd battery with a beefy 10aH LiPo.

I ended up clipping the sides of the bracket screw holes off, which makes putting the bracket on a lot easier.

Throw on some XBees, and the hardware side is more or less done.  A happy accident is the ESC’s power button, which I haven’t seen much on ESCs.  But the power button allows the rover to be turned on/off without unplugging the battery.

The programming side was a little shaky starting off.  I knew how to control the servo and the brushless motor, but I had no idea what the values were.  After some trial and error, I figured out the values:

  • Stopped = 1500us
  • Reverse = 1500 (min) – 1000us (max)
  • Forward = 1500 (min) – 2000us (max)

An interesting note:  Going into reverse, the first time, causes the car the brake, the second time makes the car move in reverse.

And my servo values:

  • Right = 50
  • Straight = 90
  • Left = 130

The servo values might be different for different cars, but the ESC values should be the same.

I wrote a GUI program to control my car, screen-shots below:

To move the car you can use the buttons on the screen, WASD, or the arrow keys.

To program the Arduino side I started off with just trying different values:

After trying different values, I used serial_sync from MSL to control the speed through the serial connection.  The serial_sync system works by creating a list of values on both sides of the serial link.  When one side changes a value, the value is updated on the other side of the link.

First thing to do is download the files for the serial_sync.

  • serial_sync.h
  • serial_sync.cpp

Put these files in your Arduino sketch folder.

Include the header file in your Arduino code:

Create a serial_sync object:

In the setup function, call the setup() function of the serial_sync object:

In the loop function we have to make two calls. The first call updates the receive (RX) side of the link, always do this at the start of the loop function. The second call updates the transmission (TX) side of the link, always do this at the end of the loop function.

That’s all the setup needed to implement a synchronized serial link. Let’s try setting a value. The call below will set variable 0, to the value 127:

Let’s also read a variable’s value, lets do this with variable 2:

My ESC seems to arm with the button on it, which is great!  As long as you do not have an ESC that requires a signal from the Arduino…  Add the code segment below to arm your ESC, place it at the beginning of the setup() function of the rc_test Arduino code attached below.

Below are links to the GUI program and the Arduino code I used:

GUI Control Program Source Code
GUI Control Program EXE for Windows
Arduino Code

5 thoughts on “RC Car Arduino Conversion”

  1. hooked this up and got it working but I’m wondering how can I reverse the steering and esc? do i have to somehow modify the gui?

    1. You could modify the GUI, but is is probably easier to change the Arduino code:

      To swap the steering, swap the values of LEFT and RIGHT starting on line 16 to:
      //Servo Defines for Steering
      #define LEFT 130
      #define STRAIGHT 90
      #define RIGHT 50

      You will also have to swap these on line 58 to:
      if(link.get(2)>=RIGHT&&link.get(2)<=LEFT)

      To change the direction of the ESC, swap the values starting on line 21 to:
      //ESC Defines for Drive
      #define NEUTRAL 1500
      #define FORWARD_MAX 1000
      #define REVERSE_MAX 2000

      Hopefully that should do the job!

  2. Hi,

    I ran across your post and was hoping you could help me. I am using a Hobbywing ESC. I can go forward and brake fine. The ESC is like yours as in it takes two taps to go in reverse. The ESC does perform as should with a standard RC TX/RX.

    I also am using writeMicroseconds. My neutral is 1460, 1000 is brake max , and 2000 is forward max. I am running it straight from the Arduino. My code is very simple right now. I will be hard coding some movements before I move on.

    I am wondering if I have my sequence wrong to fire the reverse?
    Any help would be great. Thank you!

    #include

    Servo steering;
    Servo esc;

    void setup()
    {

    steering.attach(5); // attaches the servo on Arduino pin 5
    esc.attach(3); // attaches the esc on Arduino pin 3

    steering.write(CENTER); // center steering
    esc.writeMicroseconds(1460); // set neutral
    delay(100);

    }

    void loop()
    {
    esc.writeMicroseconds(1460); // neutral
    delay(6000);
    esc.writeMicroseconds(1540); // forward
    delay(3000);
    esc.writeMicroseconds(1300); // brake
    delay(20);
    esc.writeMicroseconds(1460); // neutral
    delay(20);
    esc.writeMicroseconds(1400); // reverse trigger
    delay(3000);
    }

  3. Hi again,

    I got your program loaded and reverse does work but only at speed 146 when coming from forward. I think this will help. Take care.

  4. It’s been a while since you have posted this. Would you be interested in revisiting the subject? My question is can I hook the arduino or maybe a pi right to the controller? And use the pc to control the traxxas controller itself?

Leave a Reply to scbeltz Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>