SFL: Datalogger

Top  Previous  Next

The Datalogger functions implement an advanced and flexible facility for logging data records in a circular buffer schema.
The size of each record in the Datalogger can be determined by the application and there is functionality to navigate and traverse the logged data.

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.

 
Please have a look at the Datalogger Example Program.

 

 


logInitialize

Initializes the Datalogger system.


logClear

Clears the contents of Datalogger.


logNext

Advances read position (forward in time).


logPrev

Advances read position (backward in time).


logFirst

Sets the read pointer to the oldest record.


logLast

Sets the read pointer to the newest record.


logNumOfRecords

Returns the number of records currently in the Datalogger.


logMaxNumOfRecords

Returns the maximum number of records the Datalogger is configured for.


logValuesPerRecord

Returns the number of values logged in each record.


logGetMaxRecordSize

Returns the maximum record size the Datalogger is configured for.


logIsInitialized

Check whether the Datalogger is initialized.


logWrite

Writes an entry into the Datalogger.


logWriteRaw

Writes raw data to an entry in the Datalogger.


logReWrite

Writes (updates) an entry at the current read position.


logReWriteTag

Writes (updates) the tagvalue for the entry at the current read position.


logRewriteRaw

Writes (updates) a raw entry at the current read position.


logRead

Reads data from Datalogger at the current read position.


logReadRaw

Reads raw data from an entry in the Datalogger at the current read position.


logDestroy

Destroys the setup and contents of the Datalogger.


logGotoLinsec

Searches and places a read pointer at specified timestamps.


logSeek

Moves the read pointer a number of elements forward/backward in time on a specific tag-id.


logCreate

Create a new Datalogger in the filesystem.


logCreateMem

Create a new Datalogger in memory.


logOpen

Open an existing Datalogger.


logClose

Close an open Datalogger.


logSaveToFile

Saves the Datalogger to a file.

 

 

 


 

NX32L file-based Datalogger

On 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.
For an X32 based the capacity depends on the the specific device in question and is in most cases 470 KB.
 

 

Each entry in the Datalogger has the following internal format:

 

clip0026

 

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:

Values per. entry

Total number of log entries

Number of logWrite() operations

1

111360

6620689

2

76800

9600000

3

57600

12800000

4

46080

16000000

5

38400

19200000

6

34560

21333333

7

30720

24000000

8

26880

27428571

 
 

X32 architecture devices:

Values per. entry

Total number of log entries

Number of logWrite() operations

1

51968

3089655

2

35840

4480000

3

26880

5973333

4

21504

7466666

5

17920

8960000

6

16128

9955555

7

14336

11200000

8

12544

12800000

 
 

 

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.

 

clip0018

 

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.