Make your own free website on Tripod.com

PROGRAMMING

   Eventually, this will probably be the biggest part of the Ebot project.  Right now, it just has  sample code which will allow a Basic Stamp 2 to drive Ebot.  It has provisions for two bumper inputs.   You can get a schematic to wire up your ebot to be compatible with this code here.

' -----[ Title ]-----------------------------------------------------------
'
' File...... EB.BS2 (for the Basic Stamp 2 model BS2-IC)
' Purpose... Bump and Go software for the Ebot
' Author.... Jim Ubersetzig
' Date...... 9 Apr 01

' -----[ Revision History ]------------------------------------------------
'
' 9 Apr 01 original software



' -----[ General Description ]---------------------------------------------
'
' The Ebot rolls forward until it hits something, 
' then it backs up turning to avoid the obstacle. 
' After a while it resumes rolling forward again.


' -----[ Electrical Pin Connections ]--------------------------------------
'
Right_Wheel CON 5 ' Pin marked IO5 on the Basic Stamp 2.
Left_Wheel CON 7 ' Wire to white wire of modified servos.

Right_Feeler VAR IN9 ' Pin marked IO9
Left_Feeler VAR IN11 ' The feelers test for obstacles ahead.


' -----[ Variables and Constants ]-----------------------------------------
'
Timer VAR word ' Keeps track of time.
Right_Speed VAR word ' Speed of the right wheel.
Left_Speed VAR word ' Speed of the left wheel.

OK CON 1 ' Feeler has not bumped anything.
SHORT_TIME CON 100 ' About 2 seconds of backing up.


' -----[ Main Code ]-------------------------------------------------------
'

Reset: Timer = 65535 ' Maximum = 21 minutes.
Right_Speed = 750 + 50 ' 750 stops a modified servo.
Left_Speed = 750 - 50 ' Values make robot roll forward.

Continue:
if Right_Feeler = OK then No_Right_Hit

Timer = SHORT_TIME
Right_Speed = 750 - 50 ' Right backs up fast.
Left_Speed = 750 + 30 ' Left backs up slowly.

No_Right_Hit:

if Left_Feeler = OK then No_Left_Hit
Timer = SHORT_TIME
Right_Speed = 750 - 30 ' Right backs up slowly.
Left_Speed = 750 + 50 ' Left backs up fast.

No_Left_Hit:

pulsout Right_Wheel, Right_Speed ' Keep the wheels turning.
pulsout Left_Wheel, Left_Speed
pause 20 ' Repeat every 0.02 second.

Timer = Timer - 1 ' Keep track of the time.
if Timer <> 0 then Continue
goto Reset ' Change to forward motion.


' -----[ The End ]-------------------------------------------------------