Specifications

45
commands a delay is implemented to reduce some of the jerky motion. The delay
subroutine is used to create this delay.
;********TURNING CODES******************************************************
TURNL LDX #$0A00
LP BRCLR PORTA,$01,FALSE ;|
DEX ;LOOP TO CHECK SENSOR $0A00 TIMES
TO ENSURE NOT JUST NOISE
BNE LP ;|
BRCLR PORTA,$04,SKR ;IF LEFT SENSOR(3) BLOCKED, TURN
JSR TURNR ;RIGHT INSTEAD
SKR LDAA #'L'
JSR TXBYTE
MOVB #$00,PWDTY0 ;|
MOVB #$00,PWDTY2 ;|STOP MOTORS
JSR DELAY ;WAIT FOR DELAY PERIOD
MOVB #$00,ODMA ;|
MOVB #$00,ODMB ;|CLEAR ODOM COUNTERS
MOVB #$80,PWDTY1 ;TURN MOTOR B BACKWARDS
CONTL LDAA #$00
LDAB ODMB
CPD #90 ;SET NUMBER RELATIVE TO A 90 DEGREE
TURN
BLT CONTL ;WAIT FOR TURN TO COMPLETE
MOVB #$00,PWDTY1
JSR DELAY
JSR DRFWD ;CONTINUE FORWARDS
FALSE RTS ;RETURN FROM SUBROUTINE
The backup subroutine is called only after the code has deemed it impossible to move
forward or turn in either direction. The code is designed to only reverse long enough to
clear one side of the robot and allow it to turn in that direction.
Initially it ensures both motors are stopped, and then turns both wheels backwards at the
same speed as it normally drives forward. The code then drops into a loop which waits
for either side sensor to clear. First it checks the left sensor and turns left then exits the
loop if clear; followed by the right sensor and turns right and exits if it is clear. If
neither is clear then the loop continues until either one of the directions is vacant. After