SFL: Datalogger |
Top Previous Next |
The Datalogger functions implement an advanced and flexible facility for logging data records in a circular buffer schema. X32 and NX32 devices have support for a single Datalogger that is stored in Data Flash. NX32L devices also have support for additional Dataloggers that are stored in the file-system or in memory, see the NX32L file-based Datalogger section below for details.
NX32L file-based DataloggerOn NX32L devices it is possible to create additional Dataloggers in the filesystem and in memory using the functions logCreate and logCreateMem. The file-based Dataloggers support larger entries that contain raw data and are stored in the internal file-system. The Dataloggers can be copied to external storage either by closing the log with logClose and then copying the file with the file-system functions or by using logSaveToFile. The stored files can then be opened read-only at a later time.
Memory usage of the Datalogger
The capacity of the Datalogger depends on what kind of device in use. For NX32 based devices the capacity is approx. 1024 KB.
Each entry in the Datalogger has the following internal format:
The number of bytes occupied by each entry depends on the number of values stored in each entry and is defined by using the function logInitialize(). The minimum number of bytes a log entry uses is 5 bytes, and the maximum is 37 bytes. When the logInitialize() function is called, one of the parameters is the number of entries that the Datalogger should be able to contain. When the logInitialize() function is called, it will calculate how much flash memory is needed to store the number of log entries based on the number of records needed, the number of log values stored in each record, and the amount of memory available in flash memory. If there is not enough memory for the requested Datalogger size, the logInitialize() function will return FALSE - otherwise it will return TRUE.
Write limitations:
The Datalogger is implemented using flash memory technology, which means that there is a limited number of writes possible before Flash memory wear-out occurs. Using the logWrite() functionblock usually does not impose a problem as the firmware automatically performs write balancing on the flash memory. The following minimum number of logWrite() operations can be performed without any risk of flash wear-out:
NX32 architecture devices:
X32 architecture devices:
Caution must be taken when using logRewrite() and logRewriteTag() because for each rewrite operation, the number of logWrite operations will be divided by the number of rewrites done on each log entry.
As an example, this means that with 8 log values per log entry, there will be approx. 27.4 million (NX32) logWrite operations with no rewrite operations. With 1 rewrite operation, this number will be 13.7 million, and with 2 rewrite operations, it will be 6.85 million etc.
|