Jetson RACECAR Part 2 – RACECAR Steering Control

In the first article on the Jetson RACECAR project we described several tasks that need to be completed. The first task on the list that we’ve chosen to work on is building the Jetson RACECAR steering control. Looky here:

Background

In previous articles such as this one, we discussed connecting a servo to a Jetson Development Kit with a PCA9685 Servo Driver. As you might recall, there is an associated repository on Github called JHPWMDriver. This code can be used on both the NVIDIA Jetson TX1 and Jetson TK1 Development Kits. The overall approach is to unplug the steering servo in the Traxxas RALLY from the receiver and plug it into a PCA9685 breakout board which in turn is connected to a Jetson via I2C.

There were two unknowns at the start. First, is the plug on the servo the same as the servo headers supported on the PCA9685? The second unknown is the voltage needed by the steering servo to operate. After removing the steering servo plug from the Traxxas RALLY receiver, it was measured and appeared to have the same IDC type of spacing (2.54mm) as other servos that we have used.

After charging the Traxxas battery, the transmitter was turned on, the battery connected to the car, the ESC powered on, and the voltage was measured as 6 volts on the steering servo header.

Knowing that the PCA9685 breakout board could physically support the servo pins and that through an optional connector the board could supply 6 volts to the servo from an external power supply, it was time to get started. It might just work!

Wiring

We have covered using I2C with the Jetson TX1 in an earlier article. In this demonstration, we used a Jetson TX1 with the same I2C pins wired as in the previous article; the Jetson TX1 J21 pins 27 (SDA) and 28 (SCL). These are I2C_GP1_DAT and I2C_GP1_CLK respectively, on I2C bus 1. The PCA9685 is wired from these signals, using the 3.3V supply from J21 Pin 1, and GND from J21 Pin 6. Note:The Jetson TK1 can also be used for this application, of course the wiring is a little different. See this article for more details.

The wiring is straightforward with 4 wires. The 3.3V from the Jetson goes to VCC on the PCA9685, GND from the Jetson goes to GND on the PCA9685. SDA from the Jetson goes to SDA on the PCA9685, the same with SCL.

Jetson Traxxas Steering Interface
Jetson Traxxas Steering Interface via PCA9685
Jetson Traxxas Steering Interface
Jetson Traxxas Steering Interface via PCA9685
Jetson RACECAR Steering FI
Jetson RACECAR Steering

Tools and Supplies

Software Setup and Installation

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.

JHPWMDriver Install

There is a PCA9685 driver available in the JHPWMDriver repository on the JetsonHacks Github account. To install:

$ git clone https://github.com/jetsonhacks/JHPWMDriver.git
$ cd JHPWMDriver
$ cd example

The example is specifically some other servos, but can be used as a guide. In the source file ‘servoExample.cpp’, uncomment the lines:

// int servoMin = 120 ;
// int servoMax = 720 ;

We’ll have to figure out what good values are for this as we start working on the steering code.
Save the file, and make the example:

$ make

To run the example:

$ sudo ./servoExample

The ‘sudo’ is required to gain permission for the I2C bus from user space.
At this point, all sorts of magic happens! Well, to manage expectations, the front wheels should turn from left stop to right stop. You’ll probably hear that the servo value min and max are off from the sound of a little servo whine at the steering stops.

Conclusion

Now that the Jetson can control the steering servo, with a little work we should be able to calculate the correct control settings. There’s some software to be written to control the steering servo from ROS as part of an Ackerman steering robot. Still, it’s nice to have cleared the first hurdle.

7 Comments

  1. sorry i have a question .
    is pca9685 working on TK1 board 32bit??

    I did just following you. but it happened error when i write $sudo ./servoExample

    The error is pca9685 write byte error.’pca9685 write byte error’ this sentence repeated infinite…
    please solve my problem

  2. sorry i have a question .
    is pca9685 working on TK1 board 32bit??
    I did just following you. but it happened error when i write $sudo ./servoExample
    The error is pca9685 write byte error.’pca9685 write byte error’ this sentence repeated infinite…
    please solve my problem

  3. Could the pca9685 also be used for servo input to TX1, or is it only servo output?
    (Say I have some RC car remote with a couple of servo channels, and want to connect it to TX1 directly to read its values.)

    • The PCA9685 is a PWM output device. To my knowledge, it cannot be used to read PWM pulses. For that application, you need a device which can read PWM pulses reliably with a ADC (Analog to Digital Converter) section. People typically use a microcontoller (such as an Arduino) for this task with a Jetson. An alternative might be something like: https://www.adafruit.com/product/1085

Leave a Reply

Your email address will not be published.


*