The NXT has a data logging capability similar to that found in the RCX. This capability allows you to save variable and sensor values in a log during program execution. This is useful for collecting data during measurements. It is also useful for program debugging where you may want to analyze the value of a particular variable after a program has been run. There’s room for storage of about 10,000 data points.
The data points are stored into RAM. They can be subsequently copied to a NXT flash file. They are not immediately stored into a flash file during program execution because writing to a file in the flash memory can take 3 to 6 milliseconds which could disturb performance of the user application.
There are utilities within the RobotC IDE to upload the datalog and display in a PC window. These can be found under the “debug display” and the “NXT -> Files Management” display.
AddToDatalog(data)
Adds a new data point to the datalog containing the value ‘data’.
CreateDatalog(size)
This will create a datalog of the specified size.
SaveNxtDatalog()
This function will save the current datalog into a standard NXT data file. The data file has the name “DATAnnnn.RDT” where ‘nnnn’ is a four digit numeric number. The RobotC firmware will scan all the existing files on the NXT looking for the highest existing data file number. It will then increment this number by one to save a new datalog file.
nMaxDataFiles
Sets the maximum number of saved datalog files (DATAnnnn.RTD) that can be stored on the NXT. When saving a new file, older files will be deleted to keep within this limit. This variable is preserved across power-off / power-on sequences.
nMaxDataFileSize
Sets the total size of saved datalog files (DATAnnnn.RTD) that can be stored on the NXT. When saving a new file, older files will be deleted to keep within this limit. This variable is preserved across power-off / power-on sequences.
bHideDataFiles
Boolean variable to indicate whether data files should be displayed or hidden on the NXT GUI. The default value is that data files – i.e files with the “rdt” file extension – are not displayed on the NXT GUI. Setting this value to true will cause them to be displayed. This variable is preserved across power-off / power-on sequences.
UploadDatalog(nStart, nSize)
This is a RobotC internal function that sends a message from the PC to the NXT to upload a portion of the datalog.