Specifications

43
CLR COPCTL ;DISABLE COMPUTER OPERATING
NORMALLY WATCHDOG
JSR INITSC0 ;INITIALISE SERIAL PORT
JSR INITKWG ;INITIALISE PORT G
JSR INITPWM ;SET UP PULSE WIDTH MODULATION ON
PORT P
JSR INITIRQ ;INITIALISE IRQ INTERRUPT
JSR INITPA
WAIT BRCLR PORTA,$01,SKP ;CHECK FRONT SENSOR AND IF ON
BRANCH TO TURNL
JSR TURNL
SKP LDAA COUNT
CMPA #$5A ;HAS MOTOR A COUNTED xx TIMES YET
(xx/2 REVOLUTIONS)
BMI WAIT ;IF NOT ,WAIT AND CHECK AGAIN
JSR COMP ;IF SO JUMP TO COMP (compare function)
BRA WAIT ;AFTER COMP GO BACK AND WAIT FOR
ANOTHER xx/2 REVOLUTIONS
The main loop code runs indefinitely until the reset button on the microcontroller is
pressed or the power source is interrupted. Firstly it checks port A to determine
whether the front sensor is triggered. If port A shows the front sensor has been
triggered the program branches out of the main loop to the turn left subroutine. This
subroutine will be explained further on. If the sensor does not show to be triggered the
main loop continues on to check how many times it has been since the odometer was
serviced. It does this by loading the number of revolutions motor A has turned and
comparing it with a set number, currently $5A. This number can be adjusted to alter the
performance of the robot. If motor A has not turned $5A counts, the main program
branches back to the start of the loop and continues checking the sensor followed by the
odometer counters. Once motor A has turned $5A counts, the main loop branches to the
subroutine ‘COMP’ which compares motor A counts with motor B counts and adjusts
the motor speeds accordingly to achieve straight line driving. This subroutine will also
be detailed later.
4.6.4 DRFWD Drive Forward Subroutine
This subroutine is very basic and is called in order to start the robot in a forwards
motion. Bytes relative to the desired speed are moved into the PWDTY address that