Datasheet

Page 134ยท Applied Robotics with the SumoBot
RCTIME qtiSigLeft, 1, temp ' <--- New measure charge time
LOW qtiPwrLeft ' Turn left QTI off
multi = temp ' <--- Add
HIGH qtiPwrRight ' Turn right QTI on
HIGH qtiSigRight ' Discharge capacitor
PAUSE 1
' RCTIME qtiSigRight, 1, qtiRight ' Measure charge time
RCTIME qtiSigRight, 1, temp ' <--- New measure charge time
' qtiThreshold = (qtiLeft + qtiRight) / 2 ' Calculate average
multi = (multi + temp) / 2 ' <--- New calculate average
' qtiThreshold = qtiThreshold / 4 ' Take 1/4 average
multi = multi / 4 ' <--- New take 1/4 average
'IF qtiThreshold > 220 THEN ' Account for code overhead
' qtiThreshold = qtiThreshold - 220
' ELSE
' qtiThreshold = 0
' ENDIF
IF multi > 220 THEN ' <--- New
multi = multi - 220 ' <--- New
ELSE ' <--- New
threshold = 0 ' <--- New
ENDIF ' <--- New
WRITE QtiThresh, multi ' <--- New threshold to EEPROM
RETURN
Since there's no more qtiThreshold variable and the value is instead stored at the
QtiThresh address in EEPROM, the Read_Line_Sensors subroutine will have to be
changed too. A
READ command is used to copy the QtiThresh value from EEPROM to
the
temp variable. Then, PULSOUT DummyPin, temp replaces PULSOUT DummyPIN,
qtiThreshold
.
' -----[ Subroutine - Read_Line_Sensors ]------------------------------
Read_Line_Sensors:
.
.
.
READ QtiThresh, Word temp ' <-- Add get threshold time
INPUT qtiSigLeft ' Start the decays
INPUT qtiSigRight