Let's Make Robots!

The Constructed 'M'

Explores and avoids - More on the way.
GoodAvoider.bas4.26 KB
AvoiderSM1.bas6.36 KB

Phase 1 (Updated 29/4 - New video & code.)    

Here's a little robot built on CTC's excellent Tiny Tank chassis. It's based on a Picaxe 28X2 which handles the navigation side of things and will be joined by a 14M2 to do other things in due course.  Pololu motors driven by a L293D are the motion side of things, and a servo and SRF05 do the sensing.

The name is inspired by a Philip K Dick short story - The Unreconstructed 'M'.  Unreconstructed in this sense meaning without morals and ineducable, and M standing for 'machine'.  This M had antisocial habits including planting evidence and assassination.   My one hopefully will have less of a bad attitude and I'm constructing it so . . . The Constructed 'M'.

At the moment I've just got it doing the usual thing of avoiding stuff.  It explores an area with CURIOSITY (green LED) and has FEAR of hitting objects (red LED).  Its path through an area is an alternation of these states.  Eventually it will be actively seeking out certain objects and doing the YDM thing on them (with added accompaniment).

The tiny PCB above the M is a compass board which works but is not active in the initial video.  Also, note the change in sweep rate of the U/S sensor as it gets near objects.  I rewired the 28X2 project board to give full PWM control of the motors.  This is not a task to attempt unless you really mean it as it requires several track cuts and joins.


I've reformatted the code to run as a finite state machine and tweaked the distance thresholds to make it get up close and personal and it is good.  It is very good. Wikipedia article on FSMs here : http://en.wikipedia.org/wiki/Finite-state_machine.

The robot will always be in one of 6 states; by 'state' I mean performing a certain operation (e.g. avoiding an object slightly to the left by slowing the right track).  There is a specific rule or rules to enter each state (e.g. if 30 left sensor range is less than lower range threshold) and once in a state it will continue to perform that operation until either the condition to leave the state is met (e.g. 30 left sensor value is greater than lower range threshold)  or the conditions are met to enter a state with a higher priority (e.g. mid sensor range is less than lower range threshold. Crash imminent).  State 0 is 'flat out straight ahead' and is the default state.

It still just wanders around with no purpose in life.  That will be the next step.

Comment viewing options

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

The programming seems pretty competent as well. It only seemed to have a minor issue when it got into the tight corner. Maybe a counter to check how many times it turns left and right to say "hey, I am in a corner and should probably try a complete 180" ?

Totally agree about the corners.  Currently it only 'lives for the moment' (i.e. the last sensor sweep) but I think it really needs a memory to set a course of action and follow it, unless something with higher priority comes along.  This was just a first try to get things moving, but I'll also be looking at a state machine type concept as well as a 'big loop' structure.

Cool! - And nice code ;D

Two-speed head, dude! That right there, is pure gold! I have no idea why no one has thought of this yet. Its perfect.

I am so stealing this.

My head code only works with a step of 1 or 2 at the moment; It has to hit the sensing values.  Easy enough to expand it though.

I'm just rewriting the code as a state machine(ish) which is running a bit sluggish at the moment.  I'll be doing a new board using a 28x2 module soon so can up the processor clock from 8MHz to 32Mhz which will sort it.

Nice! Cool! Cute! ;)


Very neat robot!

What is that chip stuck up in the air?

It's a Honeywell compass module.  I've tested it but I'm not using it in the videos.  It's an I2C device which outputs the orientation of the module when you ask it to. From this you can work out the bearing of the robot and steer it to go in the compass direction you want.

It's up in the air like that to keep it away from the thrashing magnetic flux around the motors.  In practice I found the readings were pretty accurate whatever the motors were doing. 

soft iron plate between motors and compass , twisting motor wires together , some ways to reduce thrashing magnetic flux , but its not a problem so it don't matter :)

This was my first play with a compass module so I had no idea what to expect and was wondering if it was possible at all on a small robot. I was pleasantly suprised by the result.  It was one of those things which just worked - first time #;¬) 

I'd like to get it closer to the main board so I'll be seeing what happens and possibly playing about with the methods you suggest at some point.