'>Hextor_2.BSx '============================================================== '{$stamp BS2Sx} '============================================================== 'Introduction to controlling the walker. 'This involves sending a single control byte to the 'Bug Commander BOS to initiate various basic moves. ' 'New '--- 'Required knowledge: var, assignment{=}, gosub, return, serout ' 'BOS command: U,F,B,L,R,M,S,O,C,D,P 'Constants: i96n BOSrx BOStx epower poweruptime 'Variables: BOSbusy BOScmnd 'Subroutine: tellBOS '============================================================== 'Experiment with altering the order of the commands, try adding 'more, remember to 'gosub tellBOS' each time BOScmnd is changed '============================================================== BOStx con 0 'pin serial to BOS processor BOSrx con 1 'pin serial from BOS processor epower con 2 'pin high turns on power to electronics BOSbusy var in4 'pin BOS processor busy => high Rled con 8 'pin high turns on right green led Lled con 9 'pin high turns on left red led i96n con 16624 '9600 baud, 8 bit, no parity, inverted poweruptime con 1500 'pause before powering up electronics BOScmnd var byte 'byte to send to BOS processor 'during downloading the power to the electronics is turned off, 'if it is turned back on again too soon the electronics, 'especially the ultrasonics do not power up properly, 'so wait poweruptime before turning power on. init: output Rled output Lled high Rled high Lled pause poweruptime high epower 'turn on electronics debug cls 'Stand up, lift gripper, step forward, close gripper, step 'right, step left, open gripper, step back, down gripper, 'legs to middle position, sit, pause 2 seconds and then do it 'all again forever start:toggle Rled BoScmnd ="U" 'stand Up gosub tellBOS BOScmnd ="D" 'Down gripper 1/4 travel gosub tellBOS BOScmnd ="F" 'step Forward gosub tellBOS BOScmnd ="C" 'Close gripper 1/4 travel gosub tellBOS BOScmnd ="R" 'Right turn one step gosub tellBOS BOScmnd ="L" 'Left turn one step gosub tellBOS BOScmnd ="O" 'Open gripper 1/4 travel gosub tellBOS BOScmnd ="B" 'step Backward gosub tellBOS BOScmnd ="P" 'Pickup gripper gosub tellBOS BOScmnd ="M" 'set legs to Midd position gosub tellBOS BOScmnd ="S" 'Sit gosub tellBOS toggle Lled pause 2000 goto start tellBOS: pause 10 'give the BOS time to go into receive mode if BOSbusy=1 then tellBOS 'wait until BOS not busy serout BOStx,i96n,[BOScmnd] return '------------------------ end program -------------------------