Datasheet

Chapter 5: Debugging and Datalogging ยท Page 237
' -----[ 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
.
.
.
The last conditional compiler directive in the initialization section sends the program to a
label named
Playback_Round if DATALOG_MODE = 2.
#IF DATALOG_MODE = 2 #THEN
GOTO Playback_Round ' Alternate main routine
#ENDIF
GOSUB Look_About ' Was Goto Look_About
The Playback_Round label comes after the DO...LOOP in the Main Routine. It's kind
of like an alternate main routine when
DATALOG_MODE = 2. It contains a FOR...NEXT
loop that takes the logIndex variable from 0 to MaxBytes in steps of 2. Each time
through the loop, the
READ LogData + logIndex, Word temp command copies the
word at the EEPROM address
LogData + logIndex into the temp variable. The
.HIGHBYTE of the temp variable is then copied to the sensors variable. temp.NIB1 is
copied to the
state variable, and temp.NIB0 is copied to the maneuver variable. Once
those three variables contain the values from a given record, the
Display_All
subroutine is called, and a new line of values appears in the Debug Terminal before the
FOR...NEXT loop does its next iteration.
' -----[ Main Routine ]-------------------------------------------------------
DO
.
.
.
LOOP