\

Autonomous R/C Car - Part 1 - Reverse Engineering Signals

Synopsis: This is the first part of a series of articles written to share the experience of my son and me hacking an R/C car into an autonomous vehicle. This article will focus general observations around picking an appropriate R/C vehicle and identifying the signals and characteristics of those signals needed to control the car.

Picking a Vehicle


The original impetus for this was the Sparkfun Autonomous Vehicle competition whose course is a parking lot loop around the Sparkfun building in Boulder. So, the vehicle didn’t need to be off-road or aqueous unless it really went off track like some did last year.

What Not to Use


When we first started thinking about an autonomous R/C vehicle, we thought we’d hack one of the 4x4 R/C trucks that we had sitting in the garage which we bought from RadioShack 10 years ago. What the heck? We haven’t run it for a long time and it was pretty beefy - if it got hacked beyond recognition, who cares?

One of our first observations after tearing it down is that RadioShack R/C vehicles are not good candidates for an autonomous vehicle. A couple reasons stood out:

  • They’re built too safe: RadioShack is bound and determined to be safe and therefore anything that could shock or burn is well protected. They’re so well protected, components like the motor and controller are effectively inaccessible without major disassembly. We would have had to remove the end and complete gearbox to get to the motor. That’s silly - not conducive to hacking.
  • After “liberating” the electronics, our R/C truck had a relay instead of an electronic speed controller. This makes the speed control finicky and jerky - and electrically noisy. It was also all on the same PCB as the radio, so we would have had to hack the board or substitute our own speed controller. Either way, it wasn’t the best choice and we had others.

What We’ll Use for an R/C Platform


Our second choice turned out to be much better. We own two, RC18R, 1/18th scale 4WD rally cars from Team Associated which look like this:
base_media5zne5h4

These little buggers are screamingly fast. They are so fast they could not be run top-speed at a competition without some serious unintended carnage. Nice features of these vehicles are:

  • Relatively inexpensive, though still a lot more money than a RadioShack toy - they’re “serious” R/C vehicles (as much as “serious” and “R/C” can be used in the same sentence.)
  • Electronic speed control
  • All the components are easily accessible and parts readily available via Team Associated (not that we would ever crash one, no.) There is an active aftermarket for components which was definitely not the case with RadioShack toys.
  • Very responsive and super maneuverable all wheel drive drivetrains
  • They can be hacked without ruining the vehicle for its designed purpose as everything is modular and pluggable.
  • The vehicle has both forward and reverse which would be required to potentially get out of a pickle

The final thing about this product is there are off-road versions of it as well, the RC18T series, so the same basic control and electronics we come up for the autonomous component could easily fit onto other types of vehicles if we wanted an offroad autonomous Grand Challenge.

base_media

While 1/18th scale vehicles are very small, they’re still large enough to fit microcontrollers, GPS, and sensors without overloading the platform and making them too top-heavy.

General Electronics of the RC18R


Our basic approach to taking control of the vehicle will be to bypass the stock radio control which is a 27MHz typical R/C transceiver system. Yet, we wanted to use as much of the existing car and electronics as possible to keep costs low.

That immediately implies that the signals which are sent to the motor controller and steering servo by the existing radio receiver are the signals our autonomous controller needs to emulate in order to make the car work under autonomous control.

So the first order of business is to figure out how to make the car move and how to control its steering by reverse engineering how it works as designed.

The receiver in the RC18R has two 3-wire plugs coming into it. One is connected to the motor controller which is, in turn, connected to the NiMH battery pack. The second is connected to the steering servo. There is no separate power to the receiver like some R/C cars which use a 9V battery to power the receiver and another large battery to power the motor.

DSCF4823

In the photo above, the receiver is the blue and silver component on the spine of the chassis. The motor controller is just above the receiver and has the toggle switch for powering on the vehicle. The motor is above and to the right. The battery pack is the blue and yellow rectangle running the length of the chassis. The main pinion gear of the motor is on the right side gear box and there’s a central drive shaft that runs down the middle of the chassis to drive the front gear box making it AWD.

The 3-wire plug going from the motor controller to the receiver carries 5V (red), GND (black), and signal (white) where the signal is one-way from the receiver to the motor controller. The other 3-wire plug is a standard 3-wire servo connection.

I knew that servos were controlled using pulse width modulation (PWM), but I wasn’t sure how the speed control worked. In either case, we wanted to look at the signals for steering and speed control even though the servo was likely standard.

Steering Servo Signal


We started with the servo signal because I knew to expect a PWM type signal. I made a 3-pin servo connector with a 3-wire pigtail that had bare ends. Unplugging the steering servo and plugging in the 3-wire pigtail, we had a simple “tap” we could use to put a scope on and view the signals.
DSCF4812

DSCF4808

The first thing was to bracket the servo signal and figure out its basic period and duty cycle (the % on vs % off time in one period.) You could look this up and be pretty sure this vehicle was identical, but part of this exercise is to go through the process of actually doing the work and seeing how it works. Here’s a o-scope waveform of the steering servo signal:

steering

A couple things to note. 1) I was using a nearly depleted battery in the car when I took the image above, so the signal amplitude is not full - it’s about 3V to 3.3V typically as you’ll see below. 2) The full period of the wave is slightly less than 20ms...something about 18ms. If you google PWM and servos you’ll quickly learn that most run at 20ms periods.

Next we needed to figure out the duty cycle of the wave so we zoomed in on one cycle above and then manipulated the steering control on the transmitter to see what neutral and full right and full left looked like.

With the transmitter wheel in a neutral position, hands-off, this is the signal we saw:

str0

Not quite 1600 microseconds (1.6ms) of the 20ms wave asserted high.

When the wheel was full left we saw:

strleft

A little over 1ms on full left.

and when the wheel was full right we saw:

strright

A little over 2ms when full right.

So, we measured and verified what is common knowledge amongst anyone who’s worked with servos before: the typical period is about 20ms and the neutral position is half way between 1 and 2 ms (1/20th and 1/10th duty cycles) or about 1.5ms for straight ahead steering. Finally, the servo signal level is just over 3V...call it 3.3V.

Speed Control Signal


The next order of business was to examine the speed control signal. We could not use the simple 3-wire pigtail for this signal because the power for the receiver and servo came in via the 3-wire strand with the signal I needed to measure. There was no choice but to cut the signal wire to tap it, leave the plug in place and then splice it back together later to keep the car intact so it could be used as a normal R/C car, too.

DSCF4810

After stripping the end coming from the receiver, we fired up the vehicle and measured the motor control signal. I don’t know why I was surprised by this, but the motor control signal had exactly the same characteristics as the steering servo just applied to speed. Instead of left, right and straight, it was forward, reverse and neutral.

Here’s neutral speed control wave form:

throttle

Here’s neutral, 0 speed from a duty cycle perspective:

spd0

Approximately 1500us asserted high.

Here’s full throttle forward:

spd9

A little over 1800us asserted high.

Here’s full throttle reverse:

spd_9

A little over 1200us asserted high.

So, the summary of the throttle signal is this: a period of about 18ms similar to the steering servo, a neutral duty cycle at around 1.5ms, full throttle about 1.8ms and full reverse 1.2ms. So, the band on either side of neutral is about 300us.

The throttle signal was just slightly different from steering in terms of duty cycle - it didn’t go through the 1 to 2ms range of steering, but it followed a similar pattern.

In the case of both the steering servo signal and throttle signal, as we turned the wheel or squeezed the throttle trigger on the transmitter we could see the wave form smoothly transition from longer or shorter duty cycles. That’s what we’ll need to emulate to make slight steering or throttle adjustments with our autonomous controller...it’s not all or nothing as these waves seem to imply - it’s a graduated duty cycle from end to end.

Our test setup was our kitchen table and it looked like this:

DSCF4807DSCF4809

Since I wanted Nakoa to be able to repair our intentional damage to the wiring for testing purposes, he needed to practice some soldering. He’d done some in prior years, but hadn’t done any for a time, so I gave him a perf board, a bunch of wire, some wire strippers, my good soldering iron and solder and he went to town on solder practice. It almost looked like a work of art when he got done:

DSCF4815
DSCF4814

DSCF4816

We call him “Harry”. I’m not sure why people buy soldering practice kits - this is a lot cheaper and just as fun for the kid.

So, he’s all tuned up to do the splice to put the single wire back together from the motor controller.

I think if Nakoa had his pick of autonomous vehicles, it would be this nitro buggy we saw at an R/C Hobbies store in Boulder. Maybe when he gets older...and a good job.

IMG_0081

Summary



This article has shown how to reverse engineer the internal motor control and steering signals needed to control an R/C car. While a specific R/C car was shown in the example, nearly any modern R/C car will work in a similar way. The next installment in this series will demonstrate how to emulate these signal wave forms using Pulse Width Modulation (PWM) features available on an ATMega AVR microcontroller.

Landon Cox
www.ESawdust.com

Other articles in this series:
Building Bots with Kids
Autonomous R/C Car - Part 1 - Reverse Engineering Signals
Autonomous R/C Car - Part 2 - Taking Control
asdfasdf