REM> Simplhex DLB 16-12-94 READ 255,b0 :DEBUG b0 '0 'History '------- '5-5-97 b0 flag named, TRUE & FALSE added '8-4-97 if both feelers touched, now TURNs left, only waved legs before '7-4-97 pins rearanged to suit new Stamp board ' TURN bugs corrected, always turned left! '6-4-97 clockA, anticlockA was muddled , now corrected ' fromA etc now atA, I think I understand it better!? ' RT and LT now implemented, speed needs to be 2, 1 is very slow '10-3-95 from Simplhex, move now has gosub calc, more room left but slower ' walking and limit of 16 GOSUBS reached hence funny code. ' So still can't do a left turn! 'Note:- "fromA =midswingA :toA =fromA" if fromA is replaced by midswingA 'and simy for B then uses one more byte, why? 'simple walking based on Arc pgm servo configuration ' I6---\ _ /---I7 ' | | ' --C B| |B D-- ' | | ' --D A| |A C-- ' | | ' --C B|_|B D-- 'BS1 Frame rate is about 25ms - there is no frame pause 'Pic16C84 MEL Frame rate is about 6ms - there is no frame pause 'w0 b1 b0 allmoved 'move flag 'w1 servo A b3 toA b2 atA 'middle swing, anticlock->2ms 'w2 servo B b5 toB b4 atB '4 corners swing, anticlock->2ms 'w3 servo C b7 toC b6 atC 'left front triangle, up=2ms 'w4 servo D b9 toD b8 atD 'right front triangle, down=2ms 'w5 b11 toX b10 atX 'w6 GOSUB b13 b12 SYMBOL servoA = 0 'pin SYMBOL servoB = 1 'pin SYMBOL servoC = 2 'pin SYMBOL servoD = 3 'pin SYMBOL feelR = PIN6 SYMBOL feelL = PIN7 SYMBOL allmoved = B0 SYMBOL atA = B2 SYMBOL toA = B3 SYMBOL atB = B4 SYMBOL toB = B5 SYMBOL atC = B6 SYMBOL toC = B7 SYMBOL atD = B8 SYMBOL toD = B9 SYMBOL atX = B10 SYMBOL toX = B11 SYMBOL true = 1 SYMBOL false = 0 SYMBOL touched = 0 'feeler state for touched SYMBOL speed = 2 'if speed=2 then all positions must be even ' >2 then be carefull otherwise toX=atX never!!! SYMBOL upCsit = 180 SYMBOL upDsit = 100 SYMBOL upCwalk = 160 SYMBOL upDwalk = 120 SYMBOL downC = 120 SYMBOL downD = 160 SYMBOL clockA = 110 SYMBOL anticlockA = 150 SYMBOL clockB = 110 SYMBOL anticlockB = 150 SYMBOL midswingA = 140 SYMBOL midswingB = 140 DIRS =%00111111 PINS =0 start: 'DEBUG "start",cr atA =midswingA :toA =atA 'middle legs straight out, see Note atB =midswingB :toB =atB 'corner legs straight out atC =upCsit atD =upDsit GOSUB sit wait: PAUSE 1000 GOSUB stand walk: IF feelL=touched OR feelR=touched THEN turn GOSUB pace GOTO walk 'A, B are now clockwise turn: GOSUB sit 'too many GOSUBs to directly RT / LT IF feelR=touched THEN LT1 'if not feelL must be feelR, so RT RT1: toA =clockA :toB =toA :GOTO t1 LT1: toA =anticlockA :toB =toA t1: toC =downC GOSUB move LT2: toA =clockA :toB =toA 'setup LT check left, saves a GOTO IF feelR=touched THEN t2 'if not feelR must be feelL, so RT2: toA =anticlockA :toB =toA 'RT t2: GOSUB move IF feelL=touched OR feelR=touched THEN turn GOTO start pace: 'DEBUG "pace",cr toD =upDwalk :GOSUB move 'lift right front toA =clockA :toB =anticlockB :GOSUB move GOSUB stand toC =upCwalk :GOSUB move 'lift left front toA =anticlockA :toB =clockB :GOSUB move ' should be GOSUB stand, fall through to stand, move and RETURN stand: 'DEBUG "stand",cr toC =downC :toD =downD :GOTO move 'and RETURN sit: toC =upCsit :toD=upDsit 'fall through to move: and RETURN move: 'DEBUG "move",cr allmoved =true :'if not finished calcnewmove sets allmoved =false atX =atA :toX =toA :GOSUB calcnewat :atA =atX atX =atB :toX =toB :GOSUB calcnewat :atB =atX atX =atC :toX =toC :GOSUB calcnewat :atC =atX atX =atD :toX =toD :GOSUB calcnewat :atD =atX anymore:IF allmoved=true THEN donemove pulse: PULSOUT servoA,atA PULSOUT servoB,atB PULSOUT servoC,atC PULSOUT servoD,atD GOTO move donemove:RETURN calcnewat: IF atX=toX THEN endcalc 'calculate new servo position allmoved =false IF atX