davidbuckley.net
home  >  TinyTim < Groundhogs > Nevik 16 May 2011

Groundhogs by David Buckley May 1995
A pair of self contained robot vehicles with onboard Parallax Stamp-1 microcontrollers,
programmed in Stamp-Basic,
to seek light whilst avoiding obstacles.
Built May 1995.
Clarissa-May with wire bumpers
and Snowdrop with red bumper.
I saw some toys with those wheels and tyres and just had to make all terrain robots using them.
Clarissa-May was the first, followed shortly by Snowdrop.

The front wheels are castors and the the whole front of Clarissa pivots while just the wheel support beam on Snowdrop pivots.
It took some time for me to work out how to attach Clarissa's wire bumpers and so when I made Snowdrop just the beam pivots.
Snowdrops bumper is suspended from four lengths of thin music-wire (guitar strings), two at the front from the top of the pillars by the microswitches and two at the back by the microswitches.
The centre Yellow LED is a flasher on the power rails - as all work vehicles seem to have.

Just before I put them back in the cupboard after creating this page I decided to let them run round again.
It is really kind of weird how they seem know what they are doing besides having different personalities.
If they are approaching each other one will stop and back up then turn away. The eye behaviour doesn't invoke Back and the thresholds are too insensitive to detect one another by the shadow, certainly in my workroom.
Also Snowdrop is much more adventurous than ClarissaMay and ventures much further.
Same motors, same circuit, same sensors, same code, yet behave differently.
Just before writing this I was going to rescue Snowdrop because I thought she was stuck in the wires under my bench, as I got up she turned and came out.

ClarissaMaySnowdrop


Materials
Wheels The front-wheel Support-beam is shaped from a PVC bar;
the rest of the chassis is made from ABS sheet;
all cemented together with "Bison Hard Plastic Cement".
The motors and gearboxes are Como adjustable ratio gearbox kits the same as I used in Zeaker.
The front wheel axle and castor pivot is 1/16" welding wire with inboard wheel position washers and top support washers soldered on.
The "V" handle, which was designed so they could be picked up by some automatic mechanism, is 1/16" brazing-wire soldered to wire-tags and bolted to the chassis (for some reason the brazing-wire was reallty difficult to solder).
Clarissa May's bumpers are 1/16" welding wire;
Snowdrop's bumpers are PVC bar shaped using a hot-air-gun.

Program

'>Groundhog
' {$STAMP BS1}
'010

'#34 May95 ClarissaMay  wire bumpers
'#35 May95 Snowdrop     red bumper

'Hardware
'--------
'Eyes = 0u1 + LDR
'Bump Sensors = 0u1 + 4k7 front, 10K side, 22k back
'Motors operate from split battery +-3v
'Stamp brain 6v
'
'Operation
'---------
'React to bumps
'if no bumps choose something to do at random, weighted in branch cmnd.
'            chose a willpower at random
'decay WillPower by half
'do it
'for Back, decay Willpower more
'for R L turn, set Willpower to minimum to prevent wild oscillations
'for Sound, decay Willpower more
'repeat forever

'Pins
SYMBOL p_MotorR    =0
SYMBOL p_MotorL    =1
SYMBOL p_WhiskersR =2         'touch<>0
SYMBOL p_WhiskersL =3         'touch<>0
SYMBOL p_EyeR      =4         'dark=255  timeout=0
SYMBOL p_EyeL      =5         'dark=255  timeout=0
SYMBOL p_LEDR      =6         '1=on
SYMBOL p_LEDL      =7         '1=on
SYMBOL p_Speaker   =7

'SYMBOL           =B0
SYMBOL temp      =B1
SYMBOL senseR    =B2
SYMBOL senseL    =B3
'SYMBOL Will     =W2
'SYMBOL newwill   =B4 'W2.Highbyte
'SYMBOL willpower =B5 'W2.Highbyte
SYMBOL thisWill  =B6
SYMBOL nextWill  =B7
SYMBOL Willpower =B8

'touch thresholds     L   R
SYMBOL tfront =70   ' 57, 56          B+S=82
SYMBOL tside  =170  '115,114
SYMBOL tback  =240  '224,217

'stack-move values
SYMBOL mFD =0
SYMBOL mBK =1
SYMBOL mRT =2
SYMBOL mLT =3


START:
DIRS =%00000000      'kill motors and turn off LEDs to indicate motors are off
                     'oscillates R L too much otherwise
DEBUG CR,"S"

Mind:
  'test bump sensors
  POT p_WhiskersR, 51, B2
  POT p_WhiskersL, 52, B3
  IF B2=0 AND B3=0 THEN Qwill
  'react to bump sensors
  DEBUG CR,"M ",#B3," ",#B2," "
  'GOTO start
_QtR:                        'Query touched Right
  IF B2=0 THEN _QtL          'not touched at right
  IF B2>tfront THEN _QtRS    'not touched at right front
  nextWill =mLT
  GOTO BK
_QtRS:
  IF B2>tside THEN _QtRB     'not touched at right side
  GOTO LT
_QtRB:
  nextWill =mLT              'must be touched at right back
  GOTO FD

_QtL:                        'Query touched Left
  IF B3=0 THEN QWill         'not touched at left
  IF B3>tfront THEN _QtLS    'not touched at left front
  nextWill =mRT
  GOTO BK
_QtLS:
  IF B3>tside THEN _QtLB     'not touched at left side
  GOTO RT
_QtLB:
  nextWill =mRT              'must be touched at left back
  GOTO FD


QWill:                       'Query Will
  IF Willpower>0 THEN DoWill
NewWill:
  RANDOM W2
  thisWill =B4 & %1111       '16 options
  Willpower =B5

  IF nextWill =255 THEN DoWill    'see if there is a stacked move
  thisWill =nextWill              'do a stacked move for reverse and turn avoiding
  nextWill =255

DoWill:
  willpower =willpower/2      'reduce Willpower
  DEBUG "w ",#Willpower
  BRANCH thisWill,(FD,BK,RT,LT,ST,Eyes,Eyes,FD,Eyes,FD,Wheep,Eyes,Eyes,Wheep,Eyes,Eyes) '16 options
  '16 options =>7 Eyes, 3 FD, 2 wheep, 1 others
  'drop through to Eyes for error options

Eyes:
  'LOW p_LEDR                   'so LED doesn't shine in eye - already off from Start:
  'LOW p_LEDL                   'so LED doesn't shine in eye - already off from Start:
  POT p_eyeR, 12, B2            'Snowdrop
  POT p_eyeL, 36, B3            'Snowdrop
  'POT p_eyeR, 18, B2            'ClarissaMay
  'POT p_eyeL, 19, B3            'ClarissaMay
  B2 =B2 -1                     'avoid timeout=0, black is now 255
  B3 =B3 -1                     'avoid timeout=0, black is now 255
  'debug takes too long
  'DEBUG CR,"E "
  'DEBUG CR,"E ",#B3," ",#B2," " 'how can this statement only take two bytes!? - that is what the Map says
  B1 =B2/5 +B2 MAX 255
  IF B3>B1 THEN RT
  B1 =B3/5 +B3 MAX 255
  IF B2>B1 THEN LT
  'GOTO FD           'just drop through


FD:
  PINS =%11000010
  DIRS =%11000011
  DEBUG "F"
  GOTO start

BK:
  PINS =%00000001
  DIRS =%11000011
  DEBUG "B"
  willpower =willpower/4
  GOTO start

RT:
  PINS =%01000011
  DIRS =%11000011
  DEBUG "R"
  willpower =0                 'lowest sensitivity
  GOTO start

LT:
  PINS =%10000000
  DIRS =%11000011
  DEBUG "L"
  willpower =0                 'lowest sensitivity
  GOTO start

ST:
  PINS =%00000001
  DIRS =%11000000
  DEBUG "s"
  GOTO start

wheep:
  FOR B1=110 TO 127
  SOUND p_Speaker,(B1,1)       'make a SOUND
  NEXT
  willpower =willpower/8
  GOTO start

home   <   top   >