Jetson RACECAR Part 3 – ESC Motor Controller

In the third part of our Jetson RACECAR build series, we are working through controlling the ESC motor controller. Looky here:


In an R/C car such as the TRAXXAS Rally that we’re using in this project, servo motors and the drive motor Electronic Speed Ccontroller (ESC) are controlled by PWM pulses sent from an on board receiver. A remote radio transmitter controlled by a user is the source for the receiver signals. PWM stands for Pulse-Width Modulation, a modulation technique used to encode a message into a pulsing signal. In this particular application, you can think of PWM as a technique for getting analog results by digital means.

Jetson Development Kit controlling a ESC on a TRAXXAS Rally car

In order to control a servo or ESC, a PWM signal is sent to the device as repeating pulses of variable width. The devices are attached via a standard three wire connection, two wires for a DC power supply and one for a control, which carries the pulses. The pulses are defined by the frame size, which is the frequency of the pulse and the PWM duty cycle which is the ON vs. OFF time of the signal. Here’s what a single signal frame looks like:

PWM Signal

For a servo or ESC, the device expects to see a frame every 20 milliseconds, but this can vary from device to device. For this discussion, we’ll stick with 50Hz (50 cycles per second) which is a 20ms frame (1 second = 1000 milliseconds then divide by 50 ). The device expects a pulse between 1.0 and 2.0 ms. For a servo the pulse width represents the position of the servo motor, 1.0ms represents -90 degrees, 1.5ms represents 0 degrees (center), and 2.0 ms represents +90 degrees. For an ESC the pulse width represents throttle position, 1.0 ms represents full reverse (or the lowest throttle setting, depending on the interpretation of the ESC), 1.5ms is neutral, and 2.0 represents full throttle.

Note: When using a SoC like the Jetson, interfacing with a dedicated PWM driver or other micro-controller hardware simplifies generating correctly timed PWM frames and pulses. In part this is because most SoCs do not run real time operating systems nor generate suitable clocks for the task. The result is that the timing signals can drift without dedicated hardware.

PWM Driver

In the video, a PCA9685 PWM/Servo Driver is connected to the TRAXXAS Rally ESC to control the car motor. The Traxxas ESC, a Velineon VXL-3s, is a brushless motor controller which creates tri-phase AC power from the onboard DC battery. The ESC contains a micro controller which interprets the supplied PWM signal and appropriately controls the car motor using built-in firmware. The ESC has three performance modes, regular, race, and training. For the purposes of the Jetson RACECAR, the ESC is placed into training mode, which limits the motor power to 50%.

The PCA9685 is a 12 bit device, which means basically that you can think of each frame as being split into 2^12 slots (4096). To calculate throttle pulses:

1.0ms/20ms*4096 = 204 full reverse
1.5ms/20ms*4096 = 307 neutral
2.0ms/20ms*4096 = 409 full forward


The PCA9685 is connected to the Jetson Development Kit over I2C. Here’s a previous article on how to do this, look in the Wiring section. The steering servo should be wired into the first PWM slot on the PCA9685.

Before wiring, make sure the Jetson is powered off. In order to connect the ESC to the PCA9685, remove the ESC connector from the receiver and using 2.54mm m/f jumpers connect the connector black wire (GND) to the GND of the second PWM slot of the PCA9685. Connect the white wire (signal) to the SIGNAL of the second slot of the PCA9685. The red wire is not connected. Note: The red wire supplies power (6V) to the receiver. Because the PCA9685 is already powered by an auxiliary power source, the additional power wire should not be used. Looky here:

ESC PWM Wiring


Once the board is wired up, power up the Jetson.
In order to be able inspect the PCA9685, you may find it useful to install the i2c tools:

$ sudo apt-get install libi2c-dev i2c-tools

After installation, in a Terminal execute:

$ sudo i2cdetect -y -r 1

You should see an entry of 0x40, which is the default address of the PCA9685. If you have soldered the address pins on the PCA9685 (as is the case if you are using multiple boards chained together) you should see the appropriate address.

In order to experiment with controlling the steering and ESC of the TRAXXAS Rally car, a couple of small applications were written for exploration. The source for the apps are in the JetsonHacks jetsonRACECAR repository on Github. In a Terminal:

$ git clone
$ cd jetsonRACECAR/research

You will see two folders, setThrottle and throttleControl. You can open the enclosed .pro files in each folder with Qt Creator and build the applications. Here’s an article on how to install Qt Creator on a Jetson.

ESC Motor Control Calibration

The ESC comes calibrated to work with the supplied radio transmitter. In the case where we substitute our own signals to the ESC, we need to calibrate with the new signals. In order to do this, open a Terminal and navigate to the folder where the ‘setThrottle’ application was built and:

$ sudo ./setThrottle

This should send out a ‘Neutral Throttle’ signal over PWM on startup. Hookup the battery in the car, and go through the ‘Calibrating the Speed Control’ instructions from the TRAXXAS Rally Quick Start Guide, using the on screen ‘Full Reverse’, ‘Neutral’, and ‘Full Throttle’ buttons in place of the transmitter triggers.

Once the speed controller has been calibrated, turn the power off on the car. In a Terminal, switch to the build directory for the ‘throttleControl’ application and:

$ sudo ./throttleControl

Running the program outputs a ‘Neutral’ PWM signal.
You are then ready to start the car and place it into ‘Training’ mode. Hold down the ESC EZ-Set button until the LED blinks red three times, then release. The LED will then turn red, indicating that the car is armed and ready.

There is an item selector which chooses either the ESC or the Steering Servo to control. By default, it is for the ESC. Make sure that the wheels are not touching anything and increment the value until the motor starts. The car in the video starts forward motor at a control value of 317. There is a ‘Neutral’ button in the app that will set the control value to 307. You can experiment with the values to see how the motor is controlled, and also experiment with the servo controller to find out the optimal maximum, minimum, and center values.


Two of the bigger challenges on this project, and probably the most unknown getting started, are how to control the steering and the car motor. As it turns out, the mechanics to accomplish this were relatively simple with the addition of a PWM driver. One concern at this point is being able to control the RACECAR at slower speeds, as even the slowest setting of the ESC appears to be quite fast. There are a couple of ways to think about this issue, though it pains me to think about actually slowing down a race car in the first place. The next challenge is to get the Jetson on board the car and powered.