From a toy to a boy... How to turn a bulldozer into a tank-like robot

Submitted by TrickyNekro on September 1, 2007 - 2:07pm.

Introdution

After three years of robot building and still having to learn more and learning day by day I can say that I gathered enough experience to build a robot out of a toy. All I needed was some basic tools (screw driver, driller, e.t.c.) a toy, to be used as a base some electronics (Two OEM Basic Stamp chips, photoresistors, IR leds and decoders e.t.c.) some plastic sheets and some metal stand offs...

 The basic idea was building a almost totally autonomous robot capable of recharging itself by a top-level solar panel but not having enough money is a serious problem (I have already gone over-budget but it was worth trying). The solar panel needed for recharging the NiMH battery in a reasonable time (4 hour charge aprox.) costed 60Euro ( 12V @ 5W). Also by the end of the month a change in prices is expected in my country (Hellas - Greece). But even without having a solar panel the proccess can by analysed (program code - video cover - algorithm) and it will be (but don't expect to recharge itself?!?!?!).

That being the situation, by building and displaying my robot I will also try to give to you the basics of advanced sonar scan and object avoidance, photovere function with object avoidance, how to check the battery voltage with BS2 (RC circuit, 555 as ADC and maybe by an external ADC(I try to explore the BS2 and not ADCs but it will also be a way to show serial communiation with BS2!!!. If the samples from Analog Devices arrive soon enought using the ADXL 202AE+ as a dangerous incline finder will be displayed.

Generally the lack of money leaded to a lack of sensors but hoping to be able to cope up with school (I'm a 3rd grade senior High school student and I have to study long hours in order to give exams by the end of May and be accepted to a University!!!) I'll enrich the tutorial.

The contest was only a motivation being or not able for me to take a place doesn't really matter!!! I only hope to be able to finish before the voting ends....


STEP 1:  Building The Robot

Making a choise:
Having build two tank robots out of toys before I had to make something more advanced and better!!! The first robot was made out of a caterpillar, it was very short with the batteries in the back making it difficult to climb anything. Also the maching was very bad (connection of the servos to the wheels). The second bot was also very short but these problems were fixxed!!! NOW I will be building a taller robot displaying various analog sensor (heat seaker, light seaker) and digital ones (sonar, IR) able to climb almost anything and in a very high speed!!! Also ways to improve the toy's machining is shown (how the gear system is held together tighter!!!). The past problems are overcame and everything is kept simple!!!

So this is what i came up to!!!
The bulldozer before the operation

So I have also to mod it so I can mount the electronics and use the motors and the case!!!
And this video shows how:

After that the robot looked like this:
Look after 1

And after removing some unwanted plastic parts:

Then some extra screws had to be placed to ensure the smooth and successfull fuction of the motors gearset!!!  :

The red boxes show where screws were added in order to re-enforce the gearset and hold tight the wheel axes!!!
Note: Some hot glue is placed to protect the wires!!!

And from above!!!

Now where we'll be mounting the BS2 OEM (a special version) Board... For this purpose I drilled some holes in the center of the case so the weight of the vehicle is balanced both in the front and the middle!!!

And should really look like this for instance:

So here I'm having the robot finished finally!!!
The first thing we had to attach was the battery. For a battery I chose a NiCad @ approx. 600mA to power both electronics and mechanics!!! To reduce the noise level I used some 0.1?F and 0.01?F caps near the noise production units such as IC's and motors!!! The bad thing is that the battery is wasted in less than an half hour of roaming!!! The good thing is that in this half hour it's nearly unstopable!!! The battey can deliver huge amounts of energy at any time!!!
Now where to place the battery???
Tank vehicles are usually able to overcome many object in their way!!! My robot is no exeption!!! But having the center of weight high placed reduces the height of the objects that the robot can pass!!! So the battery was placed in the lowest position that was able!!!
And here we come!!! Note that the battery is mounted on a soldering breadboard!!!

And the battery board!!!


And this is what the robot should look like!!!
 The battery finally mounted

Now in the next level what should be placed is the Stamp Board... Why because we need the top level for the sensor board (we'll talk about this in a minute!!!)
And vualla!!!
The stamp is mounted!!
And here is the Power LED mounted on the front of the vehicle:                                           (It can turn the night to day!!!)
The Power LEDThe Lights ON!!!


But what is a robot without sensors and a powerfull H-bridge... A human without senses and legs!!!
For these reasons I builded a board to host all these items. I could have used the board's breadboard (ruster) but I needed the sensors to be as high as possible!!! The sensors included is a pair of photoresistors, a pair of NTCs and two pairs of IR receiver - transmitter (TSOP1730 and some single IR LEDs!!!).
So these are the schematics of the sensors 1)Note than the IRF9540 is for driving the LED circuit as it drow up to 350mA!!! 2)Note that the 555 circuit isn't used yet... The H-bridge consume too many ports of the Stamp and will be connected to any co-microcontroller (probably AVR) later!!!
The schematics
The board is a simple soldering breadboard as shown below:
The sensor board mountedAnother View


STEP 2: Programming the Robot


The first action a robot must make is to avoid odjects!!! That could be quit easy to quit sophisticated!!! Why? If you need a robot to find an object and then find where should it go the thing get mud up!!! At least two kinds of sensor with a linear output!!! Think about it later!!! The BS2 is too slow for this!!! It can handle these task but the speed is a main factor!!! So we are about to find an object and just avoiding it by turning to another direction!!!

But first let's make a board of values for the H-Bridge ports!!! (when the motors move forward or backward!!!)

  Right Tread of the Tank  
 ActionP6 P2 
 Forward

 Backward
STOP 
 Not Allow

   Left Tread of the Tank   
 ActionP14 P15 
 Forward
 Backward
 STOP
 Not Allow


Now its far better!!! So let's see the program!!!
The progra, is based on the ability of the Stamp to produce various freqences!!! IR demodulators usually have an IR filter around 38500 Hz!!!
From my experience these demodulators will work with an up to 45000 Hz signal!!! But the higher the frequency is the shorter the wave lenght will be!!! Cause TSOP1730 are quit sensitive and also the IR Leds quite powerfull I used a frequence round 42000 Hz!!! With this settings It can detect objects up to 25cm away!!! if the frequency is turned to 38500 Hz it will detect object up to 1m!!!
And here is a chart with the frequences and the distances
Range of IR
And here is the code:

' {$STAMP BS2}        ' identify the chip
' {$PBASIC 2.5}        ' and the compiler

' Set the variables and their
' place in the RAM
IR_det_Left  VAR Bit
IR_det_Right VAR Bit

' Initialize the program
FREQOUT 11, 200, 359
LOW 1  'Turn off the
LOW 7  'IR LEDs

DO
' The main program foe detecting the objects
' a short burst and emendiately after the detection
 FREQOUT 1,1, 42000
 IR_det_Left  = IN0
 FREQOUT 7,1, 42000
 IR_det_Right = IN8

' Conditions of turning... 
  IF (IR_det_Left = 0) AND (IR_det_Right = 0) THEN
   GOSUB go_back
  ELSEIF (IR_det_Left = 0)  THEN
   GOSUB turn_right
  ELSEIF (IR_det_Right = 0) THEN
   GOSUB turn_left
  ELSE
   GOSUB straight
  ENDIF

LOOP

' The main subroutines table
' this program has only subroutines
' about the motion!!!
Straight:
 HIGH 6
 LOW  2
 HIGH 14
 LOW  15
RETURN

Turn_Left:
 HIGH 6
 LOW  2
 LOW  14
 HIGH 15
RETURN

Turn_Right:
 LOW  6
 HIGH 2
 HIGH 14
 LOW  15
RETURN

Go_Back:
 LOW  6
 HIGH 2
 LOW  14
 HIGH 15
RETURN

But the program's main bug is that it stucks if both detectors are activated!!!
Why? Because it will back up but emediatly after go forward so in reality there is no movement!!!
The next code solves this problem by inserting another variable for counting!!! (actually not so needed, we will see why...)

Here is a video displaying the operation of the robot under this program!!! The robot finally stuck!!! This problem is to be fixxed next!!!


So how we fix the bug? The problem is the last routine (Go_Back routine)
The robot goes back instandly, but actually it remains still!!!
So here is the routine fixxed!!!

Go_Back:
 LOW  6
 HIGH 2
 LOW  14
 HIGH 15
 PAUSE 700 ' This means that the ports will be that way for 0.7sec!!!
' So it will go back for 0.7 sec!!!
' This value is placed by random.
' Then steer to the left for 0.5sec (choosen also by random)!!!
 HIGH 6
 LOW  2
 LOW  14
 HIGH 15
 PAUSE 500
' And return to the main routine!!!
RETURN

And now let's take a look to the analog sensors which is the LDR and the NTC (more popular light resistors and thermal resistors!!!)!!! Both use an RC circuit, there resistors are connected in parallel with a capacitor (0.1?F) charged but triggering the port High and then the time which takes the capacitor is mesured!!! That's an RC time circuit using Basic Stamp 2(the schematics are above!!!)
Now let's see the code... This code is for light detection!!! The Tank roams towards the light!!!
Note that these programs are old, last years due to school I aborted many of my projects and I just kept to know what's going on...
Don't be surprised that some of them are well documented and some are not!!!

' -----[ Title ]--------------------------------------------------------------
' TrickyNekro2007
' For Society of Robots and Greekbotics
' Last edited by TrickyNekro @ 9/19/2007
' Tank-Bot roams, and turns away from dark areas in favor of brighter areas.
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
' DEBUG "Program Running!" 'Not really needed...
' -----[ Variables ]----------------------------------------------------------
' Declare variables for storing measured RC times of the
' left & right photoresistors.
timeLeft VAR Word
timeRight VAR Word
average VAR Word
difference VAR Word
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 11, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
GOSUB Test_Photoresistors
' timeLeft = (timeLeft */ 351) + 7
GOSUB Average_And_Difference
GOSUB Navigate
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
Test_Photoresistors:
HIGH 3 ' Left RC time measurement.
PAUSE 1
RCTIME 3,1,timeLeft
HIGH 5 ' Right RC time measurement.
PAUSE 1
RCTIME 5,1,timeRight
RETURN
' -----[ Subroutine - Average_And_Difference ]--------------------------------
Average_And_Difference:
average = timeRight + timeLeft / 2
difference = average / 6
RETURN
' -----[ Subroutine - Navigate ]----------------------------------------------
Navigate:
' Shadow significantly stronger on left detector, turn right.
IF (timeLeft > timeRight + difference) THEN
 LOW  6
 HIGH 2
 HIGH 14
 LOW  15
' Shadow significantly stronger on right detector, turn left.
ELSEIF (timeRight > timeLeft + difference) THEN
 HIGH 6
 LOW  2
 LOW  14
 HIGH 15
' Shadows in same neighborhood of intensity on both detectors.
ELSE
 HIGH 6
 LOW  2
 HIGH 14
 LOW  15
ENDIF
PAUSE 10
RETURN

And now let's see now the heat seaker mode!!! The code is just like the light seaker but some values are changed a little!!!

' -----[ Title ]--------------------------------------------------------------
' TrickyNekro2007
' For Society of Robots and Greekbotics
' Last edited by TrickyNekro @ 9/19/2007
' Tank-Bot roams, and turns away from cool areas in favor of hotter areas.
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
' DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
' Declare variables for storing measured RC times of the
' left & right NTCs.
timeLeft VAR Word
timeRight VAR Word
average VAR Word
difference VAR Word
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 11, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
GOSUB Test_NTCs
' timeLeft = (timeLeft */ 351) + 7
GOSUB Average_And_Difference
GOSUB Navigate
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
Test_NTCs:
HIGH 9 ' Left RC time measurement.
PAUSE 1
RCTIME 9,1,timeLeft
HIGH 10 ' Right RC time measurement.
PAUSE 1
RCTIME 10,1,timeRight
RETURN
' -----[ Subroutine - Average_And_Difference ]--------------------------------
Average_And_Difference:
average = (timeRight + timeLeft) / 2
difference = average / 20
RETURN
' -----[ Subroutine - Navigate ]----------------------------------------------
Navigate:
' Cold significantly stronger on left detector, turn right.
IF (timeLeft > timeRight + difference) THEN
 LOW  6
 HIGH 2
 HIGH 14
 LOW  15
' Cold significantly stronger on right detector, turn left.
ELSEIF (timeRight > timeLeft + difference) THEN
 HIGH 6
 LOW  2
 LOW  14
 HIGH 15
' Cold in same neighborhood of intensity on both detectors.
ELSE
 HIGH 6
 LOW  2
 HIGH 14
 LOW  15
ENDIF
PAUSE 10
RETURN

And here is a video displaying all fuctions mentioned above (tried to make the bugs less everywhere!!!)


And here is the end for now... Updates will come to you shortly, cause I want to change both the microcontroller (a Parallax Propeller or the Dallas DS89C430 (hehehe... Free sampled!!!)) and update the codes with more sophisticated ones!!!

Finally here is the bill of meterial... Note that all the tools I had was a wall impact drill, some screw drivers and a saw!!! The robot though is very stable and tight!!! See the video!!!

 

Bill of meterials:
10x 1.5cm standoff for 3.00 Euro
10x 0.4cm standoff for 2.50 Euro
The case from a old toy for 30.00 Euro (Bought the whole toy!!!)
The NiCad and the charger for 9.50 Euro
The soldering breadboard for 3.00 Euro
2x IR LEDs for 0.50 Euro
2x TSOP1730 for 4.00 Euro
The power LED for 3.75 Euro
The BS2 chip for 7.50 Euro
The BS2 Board for 12.50 Euro (a special offer here in Greece!!!)
The L298 for 3.00 Euro (not sure)
The resistors for about 1.00 Euro
The capacitors for about 1.00 Euro
The IRF9540 for 2.00 Euro (not sure)
The switch was salvaged from old toy
The piezo for 0.50 Euro
Some other stuff (hot glue, protective wire, UTP wires e.t.c.) for about 6.00 Euro
So the whole project costed about 90 Euro but the result was very good for me!!!
Hope you en'joyed this short trip!!!
Cya with the updates!!!

( categories: )