Self-Guided RC Car 3

From Hive13 Wiki
Revision as of 18:58, 8 April 2010 by Traylerphi (talk | contribs) (Current Status - Active)
Jump to navigation Jump to search

This is the wiki page for the Self-Guided RC car that TP is working on.

SGRC3 Chassis Proto.jpg



This project is a continuation of my Self-Guided RC Car (SGRC1) and Self-Guided RC Car AI (SGRC2) projects, but enough [has changed / is changing] that I felt it deserved a new page.

The idea is to:

  • Build a RC car that controls itself, and
  • Have that RC car figure out HOW to control itself on its own, using some sort of adaptive learning routine.

The car's intristic goal will be to always be rolling.


"Standard issue cheap piece of junk from Radio Shack."

The car has two simple brushed DC motors. Rear drive motor has High/Low gear box with manual selector; steering assembly is spring-loaded to return to center when steering motor is not powered. Chassis came with a rechargable 9.6 V Ni-Cd battery and an on/off switch. The battery label is somewhat misleading but I think it's trying to tell me that the pack is rated for 1000mAh.

I added the ridiculously oversized terminal strip.

SGRC3 Chassis.jpg
Wire Purpose
Red Positive Lead from Battery
Black Ground from Battery to On/Off switch
Grey (thick) Ground from On/Off switch
Yellow Rear Motor Lead A
Green Rear Motor Lead B
Brown Steering Motor Lead A
Grey (thin) Steering Motor Lead B

Control System


PIC16F688 in 14 pin DIP form. 12 configurable IO pins with up to 8 analog channels. Can run at up to 20MHz on internal clock, but I have software configured it to run at only 500kHz (I have my reasons - I'll come back to this section later).

Motor Drivers

To drive the rear and steering motors, I am using two (2) L6202 DMOS Full Bridge Drivers, which are 18 pin Power-DIPs.

The feature that attracted me to these drivers in particular was their SENSE outputs. This pin outputs an analog voltage that corresponds to the amount of current being drawn by the motors. It is my understanding that with a recommended 0.15 ohm resistor this voltage would spike to full scale when a motor stalls (powered but for whatever reason can't turn), but tests with a 4.9 ohm resistor (the smallest I had on hand) show a spike to just over 2 volts when the motor stalls, which is acceptable to me.

The drivers can handle up to 1 amp of continuous current and up to 5 amps of current when pulsed. Each driver requires three (3) inputs, one for each direction and an enable. I am sharing a common pulse between the two drivers, connected to the enable inputs. Unfortunately this plays havoc with the SENSE readings, so careful timing is needed to only read the SENSE output while: 1) the enable pulse is high, and 2) the driver has had time to dissapate the transient spike associated with the motor turning on and off. Other timing hoops had to be jumped through to not trigger a 'stall' reading when the car first starts moving without hitting an obstacle, but so far the system appears to be working well. It terms of reliability, it is a huge improvement over the crash/idle detection system of SGRC2.

SGRC3 Bridges.jpg

To the right is a picture comparing the footprints of the new IC bridges with the discrete component bridges from SGRC2. The board with the new bridges also has a 5V power regulator setup to power the controller - this regulator is not involved directly in bridge operation. As you can see, there is still plenty of room left on the breadboard for the 14-pin controller IC. I am also leaving room for the accelerometer in case I decide to re-include it at some point in the future. The compactness of the L6202's make up for the fact that they cost me about $5 a piece (plus S&H, of course). I will most likely use the SMD version for the final soldered circuit.

Infrared Sensor

SGRC3 Sensor on Servo.jpg

Sharp 30cm IR range finder mounted on a hobby aircraft servo. The sensor is bolted to an L-shaped piece of stiff plastic which has been screwed down into the horn of the servo. The sensor has a nominal range of 30 cm, but there is a roll-off region when objects are closer than 8 cm or so. This greatly distorts impressions from analog readings of the sensor, so I have set the controller to use the sensor's output in an on/off fashion, which cuts the deadband region to less than 1 cm. Although using the sensor this way losses granularity, it makes the signal very 'trustable.' The limited overall range of the sensor doesn't make this loss of granularity very painful at all.

SGRC2 Servo Postions.png

The servo has a range of slightly greater than 180 degrees, but I will be limiting it to one of seven (7) positions. The binary addresses shown above each position hint at how the neural network will be choosing where to look.

[UPDATE] After long trials in the simulator, I have decided to limit the servo positions to only three: -45, Center, and +45.

Adaptive Learning

Simplified neural network routine

Current Status - Active

  • Basic system control software complete
  • Hardware design and mounting complete (although a higher watt-rated SENSE resistor would be nice)
  • Neural network development underway

Work Log

Nov 20, 2009

Set project to Active status. Removed SGRC2 control system from chasis and began playing with the L6202 motor drivers. I haven't done anything electronic that wasn't school related lately, so it feels good to get back to playing. The drivers ended up being much simplier to wire than I had been led to believe.

Nov 21, 2009

A night of slow going with the PIC microcontroller. Took a minute to get back into the swing of programming one of these things, but I think I'm finding a stride.

I found a 4.9 ohm resistor laying around. The motors still get enough power to slip on my kitchen floor and now I have a readable SENSE output. I'm noticing that the current jumps pretty good when the rear motor first starts out, so I've added a timeout mechanism to hopefully only trip the error flag when continously trying to push up against an obstacle. Right now it works great moving forward but is still a little jumpy going backward, which might be OK in the end, since backward is not the preferred direction anyway, and it doesn't seem to be that bad. It's fairly transisent and may stop showing up as the main control loop gets longer as features are added.

Nov 24, 2009

Stabs in the dark at figuring out the servo timings left me wishing I had ordered the in-circuit programming option hardware for my PIC programmer, but eventually the solutions were found. As expected, pulsing the rear motor driver resulted in havoc with the current sensing routines I had. I wish I had logged this last night (early this morning) when I could remember some details, but I threw in the towel around 6am. It took a couple hours, but I now have all the hardware but the IR sensor input working, which I expect to be relatively simple at this point.

I found some great plexi-glass type plastic at HomeDepot for fashioning a frame. Tonight I'll finish the hardware interfacing and plan to try to do up the frame at the Hive tomorrow. Once I get everything mounted I'll begin with implementing the simplified neural net, which I've been giving considerable thought to.

Nov 29, 2009

SGRC3 Chassis Proto.jpg

I managed to get a few hours of work in on the car before the Thanksgiving holiday kicked off. All components now have their interfaces up and tested. Now all that is really left is building a neural network around those controls.

As for the mounting platform, I began making a pattern out of paper for the future plastic mounded piece, but switched to cardboard since it is stiff enough to actually stand up. Why didn't I think of cardboard before? I have some spray paint in the garage if I find the time for that. I now do not intend to mould the platform out of plastic until if-and-when I have a final soldered circuit board.

One important change the new platform has made is that I have removed the terminal strip. I'll now need to solder some small pieces of wire to all of the wires that needed the terminal strip - this way they can be pushed directly into the breadboard.

Current Issues

  • Battery, motor, and sensor wires do not play well with breadboard

Next Steps

  • Solder tips to non-breadboard friendly wires
  • Paint cardboard mounting platform, maybe
  • Begin work on simplified neural network control routine
  • Test, test, test...
  • Layout PCB board, order, and solder
  • Mould and paint plastic version of mounting platform
  • Final assembly