Datasheet
Page 226ยท Applied Robotics with the SumoBot
RETURN
' -----[ Subroutine - Calibrate_Qtis ]----------------------------------------
Calibrate_Qtis:
HIGH qtiPwrLeft ' Turn left QTI on
HIGH qtiSigLeft ' Discharge capacitor
PAUSE 1
RCTIME qtiSigLeft, 1, temp ' Measure charge time
LOW qtiPwrLeft ' Turn left QTI off
multi = temp ' Free temp for another RCTIME
HIGH qtiPwrRight ' Turn right QTI on
HIGH qtiSigRight ' Discharge capacitor
PAUSE 1
RCTIME qtiSigRight, 1, temp ' Measure charge time
multi = (multi + temp) / 2 ' Calculate average
multi = multi / 4 ' Take 1/4 average
IF multi > 220 THEN ' Account for code overhead
multi = multi - 220
ELSE
multi = 0
ENDIF
WRITE QtiThresh, Word multi ' Threshold to EEPROM
RETURN
' -----[ Subroutine - Servos_And_Sensors ]------------------------------------
Servos_And_Sensors:
#IF DEBUG_MODE = 1 #THEN
GOSUB Display_All ' Call Display_All subroutine
#ENDIF
GOSUB Pulse_Servos ' Call Pulse_Servos subroutine
' Call sensor subroutine(s).
sensors = 0 ' Clear previous sensor values
GOSUB Read_Object_Detectors ' Call Read_Object_Detectors
GOSUB Read_Line_Sensors ' Look for lines