Datasheet

Chapter 5: Debugging and Datalogging · Page 233
Click Run -> Memory map again and compare how much EEPROM is used by
the code that was added for debugging.
ACTIVITY #4: DATALOGGING A COMPETITION ROUND
Displaying values in slow motion while the SumoBot is sitting still won't necessarily
expose or solve problems the SumoBot has when it's up against another SumoBot in the
competition ring. It's also not convenient to try to have a round while the SumoBot is
tethered to the serial cable. Even if it was convenient, the serial communication of all
those characters to the PC takes so much time that it would reduce the servos to twitching
between each message.
This activity introduces a solution to the tether problem. The solution works like this:
Save all the information the previous activity's example program displayed in EEPROM
during the round. After the round is over, connect the SumoBot to the PC again, and
have it display all the SumoBot's sensor readings, navigation states and maneuvers.
Logging and Reporting Routines
Another #DEFINE can be added to select the various datalogging features. In the next
example program, the
DATALOG_MODE symbol can be set equal to 0 (no logging), 1 (log
round), or 2 (display logged round).
' -----[ Compiler Definitions ]-----------------------------------------------
#DEFINE DEBUG_MODE = 1 ' 0 -> wrestle
' 1 -> display
#DEFINE DATALOG_MODE = 1 ' 0 -> No log
' 1 -> log round
' 2 -> display log
Since the same constants and variables that were used for debugging will be used for
datalogging, the conditions of the compiler directives for these constants have to be
updated. For example, the condition for the
#IF...#THEN directive below used to be
DEBUG_MODE = 1. Now, it's DEBUG_MODE = 1 OR DATALOG_MODE > 0. Why greater
than zero? When
DATALOG_MODE is set to 0, the datalogging features are not needed.
However, when it's set to 1 or 2, the datalogging features should be compiled, and this
includes the extra constants and variables used in the previous activity's debugging
program.