Datasheet

Chapter 5: Debugging and Datalogging ยท Page 245
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
#IF DATALOG_MODE = 1 #THEN
temp.HIGHBYTE = sensors ' Copy values to parts of temp
temp.NIB1 = state
temp.NIB0 = maneuver
WRITE LogData + LogIndex, Word temp ' Store record in EEPROM
logIndex = logIndex + 2 ' Word values -> index + 2
IF logIndex >= (LogData + MaxBytes) THEN END
#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
RETURN
' -----[ Subroutine - Pulse_Servos ]------------------------------------------