Appendix 2

index ]

Software listing for BigFoot

The program incorporates a command processor which interprets high level robot commands stored in EEPROM at the section user routine many routines can appear in the listing but due to memory constraints only one can be active. The rest must be commented out.

'>BigFt-2S 'BigFoot walked 2:45 am Saturday 7 Nov. 98 DLB 7-11-98 'Program for Parallax Stamp BS-1 ' {$STAMP BS1} 'from BigFt-1S READ 255,B0 :DEBUG B0 'b0 =26 'History '------- 'based on BigFt-0 '>BigFt-1 '_WAIT added, _Stop removed, jump changed to _Start, labels changed 'alias rfootat=atpace added 'pE was pu '>BigFt-1S 'Sensors incorporated 'stackmove added 'nomove added '11Mar07 stackmove was B12 but conflicted with Gosub stack, no doubt why step back didn't work! ' revealed by using Editor 2.2 '>BigFt-2S '17Oct10 removed turnbias, turned better with it at 0, added min and max to move calcs so can do speed>1 'Bugs '---- 'none 'Fixed '----- 'The bump code does not work proprly, after a toe switch is activated BF ' should step back one step before entering the _LT/_RT routines. 'DigiFleet FPS-17 servos 'roll - 100=left 150=stand 200=right nominal 'pace - 100=left(FD) 150=stand 200=right(FD) nominal SYMBOL servoroll =0 'servo on pin 0 SYMBOL servopace =1 'servo on pin 1 SYMBOL S_rtoe =PIN2 'right toe switch on d2 - normally high SYMBOL S_ltoe =PIN3 'left toe switch on d3 - normally high SYMBOL touched =0 'p2,p3 state if sensor touched SYMBOL atroll =B1 SYMBOL roll =B2 SYMBOL atpace =B3 SYMBOL rfootat =B3 SYMBOL pace =B4 SYMBOL atX =B5 SYMBOL toX =B6 SYMBOL servoX =B7 SYMBOL pE =B8 'pointer to current move in user EEPROM SYMBOL m =B9 'current move SYMBOL i =B10 'loop counter in init 'SYMBOL Sstate =b11 'sensor state; 0=none,1=right,2=left,3=both 'SYMBOL Sdo =i 'flag, 1=>act on toe switch sensors SYMBOL stackmove =B0 SYMBOL r_left =125 'roll_left 135 for speed=2 SYMBOL r_stand =155 'roll_upright SYMBOL r_right =185 'roll_right 175 for speed=2 SYMBOL p_l_fd =120 'left foot forwards SYMBOL p_r_bk =p_l_fd SYMBOL p_stand =145 'feet together SYMBOL p_r_fd =180 'right foot forwards SYMBOL p_l_bk =p_r_fd SYMBOL speed =1 'servo increment 'far too jumpy with speed =2 SYMBOL tweenpulse =10 '---------------- main user routine names ---------- SYMBOL nomove =0 'null move SYMBOL S =1 'Start, jump back to EEPROM 0 SYMBOL F =2 'Forward SYMBOL B =3 'Back SYMBOL R =4 'Right turn SYMBOL L =5 'Left turn SYMBOL H =6 'Halt, stand to attention SYMBOL W =7 'Wait secs in next byte '---------------- user routine ---------------- EEPROM 0,(F,F,F,F,R,R,H,W,2,L,L,B,H,S) 'roughly F & B about same spot 'EEPROM 0,(F,R,F,L,F,S)'roughly F & B about same spot 'EEPROM 0,(H,W,2,F,F,H,W,1,B,B,S) 'EEPROM 0,(W,2,B,H,W,1,F,S) 'EEPROM 0,(H,W,1,F,W,1,F,S) 'EEPROM 0,(R,R,R,R,R,L,L,L,L,L,J,S) 'EEPROM 0,(L,L,S) 'EEPROM 0,(R,R,S) 'EEPROM 0,(R,F,R,F,L,F,L,B,S) 'EEPROM 0,(F,S) '---------------------------------------------- init: atroll =r_stand atpace =p_stand ' FOR i=0 to 20 ' PULSOUT servoroll,r_stand ' PULSOUT servopace,p_stand ' PAUSE tweenpulse ' NEXT stackmove =H pE =0 'set pointer to start of DATA sense: DIRS =%11 ' Sstate =pins^255&15/4 ' debug %Sstate IF S_rtoe=0 THEN _LT IF S_Ltoe=0 THEN _RT m =stackmove stackmove =nomove case: 'debug m'"c" BRANCH m,(_Read,_Start,_FD,_BK,_RT,_LT,_HALT,_WAIT) 'CASE movetype 'illegal value =>fall through GOTO init _Read: READ pE,m 'debug #pE,#m,cr pE =pE +1 GOTO case _FD: 'debug atpace,"F" IF rfootat<p_stand THEN r_fd 'moverightfoot else moveleft l_fd: pace =p_l_fd 'move left foot forwards GOTO R_roll r_fd: pace =p_r_fd 'move right foot forwards GOTO L_roll _BK: IF rfootat>p_stand THEN r_bk 'moverightfoot else moveleft l_bk: pace =p_l_bk 'move left foot backwards GOTO R_roll r_bk: pace =p_r_bk 'move right foot backwards GOTO L_roll _RT: 'debug "R" IF rfootat%gt;p_stand THEN StackandBK pace =p_r_fd 'swivel right GOTO S_roll _LT: 'debug "L" IF rfootat<p_stand THEN StackandBK pace =p_l_fd 'swivel left GOTO S_roll StackandBK: 'step back and do turn again ' debug "sB",#pE,cr ' pE =pE -1 stackmove =m GOTO _BK _HALT:'debug atpace,"H" IF rfootat<p_stand THEN r_fd_H l_fd_H: pace =p_stand GOTO R_roll r_fd_H: pace =p_stand GOTO L_roll _WAIT: 'DEBUG "W" READ pE,m pE =pE +1 SLEEP m GOTO sense _Start: 'DEBUG "S",cr pE =0 GOTO sense '------- end of branch (CASE movetype) R_roll: roll =r_right GOTO move S_roll: roll =r_stand GOTO move L_roll: roll =r_left 'GOTO move move: 'DEBUG "move" '--------roll onto foot toX =roll :GOSUB rmove :atroll =atX '--------move other foot atX =atpace :toX =pace :servoX =servopace GOSUB domove :atpace =atX '--------roll upright toX =r_stand :GOSUB rmove :atroll =atX GOTO sense rmove: atX =atroll :servoX =servoroll domove: IF atX=toX THEN endmove IF atX<toX THEN addspeed 'else subtract speed atX =atX-speed MIN toX :GOTO Spulse addspeed: atX =atX+speed MAX toX Spulse: PULSOUT servoX,atX PAUSE tweenpulse GOTO domove endmove: RETURN '------------------------ end program -------------------