Let's Make Robots!

Wall Following RC car using 16F887

Here are two videos of my hobby level radio control car following the wall around a room.  This car uses channel 3 of the radio control system to toggle between RC control and autonomous control.



The idea is to hook middle school kids (USA grades 7th and 8th.  ages 11 - 14) into Science, Technology, Engineering and Math.  This offers the speed and excitement of RC car
 racing, the trial and error of RC race car design plus the clear thinking and discipline of computer programming.

 THE COMPETITION:  A car race.

 Build an oval race track on a polished wooden gymnasium floor defined on the inside by
 cardboard boxes large enough to echo back a SRF05 sonar proximity detector's signal.

 The race is to lap the track, say, six times;  three by radio control;  three by autonomous control.  Either time trials or multiple cars at the same time.  If the race has multiple cars on the track at one time, some more work must be done on the car to avoid collision.

  I will design and build a PIC kit that attaches to almost any RC car that has Electronic Speed Control (ESC) driving the wheels and a servo driven steering mechanism.  It will use the car's 7+ volt battery, knocked down to 5 volts by the ESC.  There must be a third channel on the RC system to tell the car who is boss.

 I need to borrow, steal, or design a microcontroller programming language that forces the students to think about the signals from the front and side facing sonars and create the corresponding commands to the wheels and the steering.  Presently the 16F887 compiler runs on a WINDOWS PC and communicates to the car via special hardware connected to the USB port.  (Available from MicroChip Inc.)

----------The post below seems to be way ahead of me----------

Author: bendjamin
| Title: I made some similar robots a

I made some similar robots a while ago.  I'll try and post a video of them.  They are designed to race around a track, in other words they are doing wall avoiding so when you make a track with walls on the inside and outside they will go around and around.  I made the robots myself, they are differential steering with a body made from laser cut polycarbonate.  I used the sharp IR rangefinders for navigation and have four on each robot, two forward facing and two side facing. They also have four bumber switches, one pair in front and the other at the rear.

| Link: http://letsmakerobots.com/node/696#comment-43464

What do you all think?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

What I would do:

First; Make a version that goes so much slower; Drive slower, and make things work, then gradually speed up.

Second; when problems arise only at higher speeds:

Add a speaker, or a bright LED to the robot.

When the turning should happen, make this beep or flash.

Film it.

Analyze; The LED or Sound will make it possible to see excactly at what distance to the wall the action is taken, and you can make slow motion and watch them. Question will be; At the speed & weight it has, is it even physical possible to turn and avoid?

PS: If it turns out that everything works at lower speeds, but the robot seams to react later at higher speeds, it may be because your sampling frequency is too low.

If you only measure distance at say 2 times pr second, it does not matter at low speeds where you have only moved 20 cm between, but is a problem at higher speeds, where it could be 2 meters.

The Electronic Speed Control wants this PWM signal to arrive at 50 hz.

I was not clear in my last posting. The Electronic Speed Control PWM specification is for a single positive pulse no less than 1ms and no more than 2ms once per 20 ms, ie 50 pulses per second. The one to two millisecond pulse width is divided into 256 parts. 1.5 ms corresponds to 128 which corresponds to neutral in a servo.

Neutral is steering straight on a steering servo. Neutral is stopped on a wheel driving servo.

I discovered that using HPWM with the 4mhz default oscillator a pulse width of 100 to 110 gets the behavior of 'neutral' on my car. For example "HPWM 1, 100, 50" turns the front wheels of my car to straight. See the attached picture. Channel 2 is the HPWM version of neutral. Channel 3 is what the radio receiver sends.

Oscilloscope of real PWM vs PIC PWM

Turns out that one of my problems has been the length of the trigger pulses that I have been sending the SRF05s.  They were too long using PAUSE 1 with the 4mhz oscillator.

I changed the technique to the following:

SYMBOL trigright PORTD.0

LOW trigright

HIGH trigright

HIGH trigright

LOW trigright

With this technique I can make positive pulses as short as 10usec and grow them in units of the HIGH command..


I now have the sonic ping devices (SRF05's) flashing continuously.  This means that there is no blockage in the PIC's processing.

Now the car is reacting too quickly. There is a bit of code that used to guarantee a 1/2 second backing up when backing up was necessary.  Now the count down for this delay is instantaeous.   While turning a corner the proximity sensor data gets confusing.  Both the side sensors and the forward sensors are hearing important echos.   I might need to adjust the positions of the two SRF05's.  I am not sure.....



Since the system is running so much faster now, maybe you can afford to add a delay between when the front and right SRF05's run their detection subroutine? It wouldn't have to be a 'dumb' delay where you just waste cycles, but instead you could for example run 'puls' in one iteration of the main loop and then run 'pulsf' in the next iteration, just to give the SRF05's a bit of breathing room so they don't interfere with each other.

Is there a cover for this car? Or did you bust it up already?

I have the cover for the car, but I have not put it on because all my circuitry is in  the prototype stage.

Once I get a vehicle that really races I will purchase a different radio transmitter - one with a pistol grip that has three channels.  I will also select a new car or truck.  I need to neaten up my prototyping system so that it will fit on most any chassie.  That plus the PICkit 2 might do the trick.

Here is a video of my car on my version of a race track.

It works some times and not other times.  It seems that as the speed increases something is becoming less sensitive.  Maybe the reactions are too slow, but that should be fixable.


Excellent Job on your last video convincing that middle school kid. I think he's a Believer and will stick around for a couple more years of this...............