Let's Make Robots!

My First Robot - MIND THE . . . (Obstacle avoidance)

Obstacle avoider. Other behaviours planned.
Avoider1.bas6.08 KB

Early March - GREAT PROGRESS - Giving it a brain, and a problem solved.

I've built the brain-board with its 20x2, pluggged everything together and IT'S ALIVE! - but the servos were all over the place.  I am running the electronics from the same supply as the servos and thought I was going to have to split them (although I was very careful with the decoupling on the build) as the rail was dropping by 2 volts when the servos activated

However, I tracked the problem down to a dodgy rechargeable battery.  I replaced the batteries and everything was wonderful.  Around .25V noise on the rail with motors running and no nasty spikes - I can live with that.  Ultrasonic sensor (SRF05) worked a treat mounted on its servo.

NO SPEEKA DA LANGUAGE :-  I spent a bit of time planning this as I wanted to control the motors in a flexible way for either manual entry of a command list or by a 'fuzzy logic' type method.  I have two motors (L and R) and chose to run them at slow and fast forward, and slow and fast reverse (the reverse speeds being a bit slower then the forward ones).  These (along with motor off) give 25 possible combinations of L and R motor activity.  I chose 17 of these to be represented as commands, and have come up with a simple control language for the robot, each command represented by a single letter.


TURN (fwd or back, left ot right) - This is a slow turn with both wheels turning.

PIVOT (fwd or back, left or right) - One wheel stopped.

SPIN (left or right, fast or slow) - Wheels turning opposite directions.

With the control language I can use a simple data statement such as F,2,U,1,B,1,S,2,G,1,X,99.  Numbers represent seconds so this string would go fwd for 2 secs, spin slow right for 1, reverse fast for 1, pivot right fwd for 2, fwd slow for 1, then stop.  The 99 is the string terminator.

I coded this in such a way that the comands are incremental, i.e. ordered by speed or 'degrees of turniness' so under purely logic control a step increment or decrement for each type of function will increase or decrease that parameter.  The first part of the processing (the command parsing) is bypassed.

This sounds a lot more complicated than the final result.  The meat of the routine is a PicAxe LOOKDOWN then a LOOKUP command. I will expand this to include other functions as things progress.

Here's a statement for discussion - The difference between a toy robot and a serious robot is wheel encoders!  It's all very well going back for 3 seconds or left for 2, but where are you?  Once you can determine how far a robot has moved relative to its environment you can start mapping your surroundings and planning ahead.  The first major upgrade to this beast will be wheel encoders - Break out the hall sensors and hardware interrupts!

ONWARD AND SIDEWAYS (but mind the hedgehog!) :-  I was amazed at how quickly this routine came together with just a handful of conditional statements.  I'm taking 3 distance measurements; mid, left and right and using the raw values.  The heuristic is this :-


If you are TOO CLOSE to an object ahead, back up for 2 seconds.

If you are CLOSE to an object ahead, PIVOT to the L or R - whichever has the greatest distance to an object.

If you are CLOSE to an object on the L or R, TURN slightly away from it.

The larger wheels I'm using now give it a decent speed, but it won't win any sprint races.  The 'flip and turn' mounting of the PCB to access the batteries was partially an accident due to the Lego parts I used, but it is rather handy.


Problems :  Left servo mid position wanders and has to be recalibrated in software.  Need to strip it down.

Have visions of running out of pins on the 20x2.  Too late to change this.

Give the robot a NAME!

Glue wheel back on - Will use epoxy this time.

Next step : Add sound and fit the LASER!



Robot with control board

Ultrasonic sensor and servo





Over the past few decades I've made all manner of things ranging from the mundane to the totally tecchie with a few utterly useless but great fun things along the way (some of which can be seen on Instructables),  but I have never made a robot before.  Now is the time to rectify that omission.

This is a work in progress which I will be updating as I go along.  I am currently working on the motor / battery base and the pictures and video show the first iteration of this.  In the video it is being controlled by my 08m based servo tester (I'll post details and code of that later) because I just wanted to get the thing moving, but the final product will have a prototyping board mounted above and have a PicAxe 20x2 brain.


This is the battery and motor chassis.  I'm more an electronics guy than a mechanics one, so I raided my sons' various Lego sets.  Now I've started the project, I want to get something trundling around the living room as soon as possible, so this approach produced a rugged base (I'll firm it up more with glue later) in an afternoon.

The PicAxe 08m board is doing the driving at the moment, and it is running 'blind''



 Here is a top view  with the battery pack removed showing the Lego construction.  Once I started testing I realised it was far too slow, so the wheels have now been replaced with some 3.5" diameter ones.  Speed is a lot better no


 I've used RipMax SD200 servos modified for continuous rotation.  I didn't want to spend too much on this so didn't go for metal gears, but the RipMax have a ball-raced output shaft, very chunky final (but nylon) gears, give 2.5 Kg/cm torque and weigh 16 grams. 

 Next step is to add the controller board - I've already cut and drilled it - and build the 20x2 circuit.  Soon after that will come the ultrasonic sensor (SRF05) and laser assembly.  I can't wait to give this thing some sensing capability - I think I've got the robotics bug!

The motor base with temporary 08m



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
he's  just waiting for some brains! I'm liking the gentle turns, I'm going to get that programmed into Gerald because just now he looks so jerky compared to yours.
I've lost some of the smoothness that I had on the earlier test. Then I had 3 speed increments so there was an intermediate between the slow turn and the pivot turn.  Now there isn't, but it's early days yet.  Plenty of scope for playing around.
Yep, the intermediate speed needs to go back in.  It's too jerky without.
Hmm. Very interesting approach to programming your robot. Would you be willing to post your code so we can have a look?
I would love to take a look at your code as well...
Clean navigation is only something i've seen in Devantech ultrasonics
where is the IR love!
my robot is still without clean navi and i can't figure out how to write such a program for it

If you're referring to my comment about mapping the environment, I'm not expecting an inch-perfect diagram of a room - just a fuzzy map of where things are in relation to others.  I've got a  Dinsmore compass module which is going to go on at some point, and an IR module is part of the plan but this IS my first robot so I'm learning as I go along.  I'm going into this with no real knowledge specifically of robotics, but plenty of electronics experience, a fair amount of varied programming experience and LOTS of ideas.  Things should get interesting #;¬)

(Should have gone for a 28x2 though!  In fact, I'm wondering whether to do a rebuild now and save myself pain later.)

BTW, I'll post code later.

Gasps of awe / howls of derisive laughter all welcomed.

Very cool project. Please tell more about the lasers? I'm wanting to build my own laser range finder with a Picaxe 20X2.

I didn't really do any more development in this robot, however the laser was only going to be for show.  Laser rangefinding is getting pretty specialised and isn't easily done.  Much better to stay ultrasonic (like I've done) or use one of the infra red range sensor modules. 

Plenty of examples of both on LMR.