LGF_DataLogC (FB / V1.0.0)

Overview

Author: Siemens Industry Support

Short description

LGF_DataLogC (C -> Compact) function integrates all the datalog system functions and can be used as standalone data logger.

Block Interface

LGF_DataLogC (FB)
Bool  enable valid  Bool
    
String  name busy  Bool
    
Bool  triggerLogEntry error  Bool
    
Bool  clearLog status  Word
    
Bool  deleteLog writeEntryDone  Bool
    
LGF_typeDataLogParameter  parameter clearLogDone  Bool
    
   deleteLogDone  Bool
    
   lastEntryReached  Bool
    
   noOfEntries  UDInt
    
   diagnostics  LGF_typeDiagnostics
    
Variant  data  Variant
       
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE TRUE: Enable functionality of FB
nameString 'DefaultDataLog' Name of datalog, also used as file name
triggerLogEntryBool FALSE Rising edge trigger one entry in data log (only if `parameter.isLoggingByInterval` := FALSE)
clearLogBool FALSE Rising edge triggering clearing of datalog file
deleteLogBool FALSE Rising edge triggering deletion of datalog file if exist
parameterLGF_typeDataLogParameter --- This UDT belongs to the Module `LGF_DataLogC` and lists all possible parameter to configure its behaviour.

Output parameter

IdentifierData type Description
validBool TRUE: Valid set of output values available at the FB
busyBool TRUE: FB is not finished and new output values can be expected
errorBool TRUE: An error occurred during the execution of the FB
statusWord 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
writeEntryDoneBool TRUE: DataLog write done successfully
clearLogDoneBool TRUE: DataLog clear done successfully
deleteLogDoneBool TRUE: DataLog delete done successfully
lastEntryReachedBool TRUE: Last entry of datalog reached, if `enableRingBuffer` is set, start from beginning, otherwise block ends here
noOfEntriesUDInt Number of entries in datalog
diagnosticsLGF_typeDiagnostics Diagnostic structure to store and transfer diagnostic information from blocks trough the interface.

In/Out parameter

IdentifierData type Description
dataVariant Data structure to log in datalog file

Retain static parameter

IdentifierData type Retain Description
statNoOfEntriesUDIntNumber of entries in datalog
statLlastEntryReachedBoolTRUE: Last entry of datalog reached, if `enableRingBuffer` is set, start from beginning, otherwise block ends here

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_FINISHED_NO_ERROR
NO error occurred during call / Active processing
16#7000STATUS_NO_CALL
No job being currently processed
16#7001STATUS_FIRST_CALL
First call after incoming new job (rising edge `enable`)
16#7002STATUS_SUBSEQUENT_CALL
Subsequent call during active processing without further details
16#7010STATUS_MAX_ENTRIES_REACHED
maximum Number of entries reached
16#8401ERR_WRONG_COMMAND_CALL_ORDER
Error: wrong command call order - `deleteLog` or `clearLog` must be false during startup / enabling the block
16#8600ERR_UNDEFINED_STATE
Error due to an undefined state in state machine
16#8601ERR_DATALOG_OPEN
Error: `DataLogOpen` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information
16#8602ERR_DATALOG_CREATE
Error: `DataLogCreate` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information
16#8603ERR_DATALOG_CLOSE
Error: `DataLogClose` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information
16#8604ERR_DATALOG_WRITE
Error: `DataLogWrite` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information
16#8605ERR_DATALOG_CLEAR
Error: `DataLogClear` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information
16#8605ERR_DATALOG_DELETE
Error: `DataLogDelete` throws an error, please see `diagnostics.subFunctionStatus` in diagnostic structure for more detailed information

User defined datatype(s)

LGF_typeDataLogParameter (UDT / V1.0.0)

This UDT belongs to the Module LGF_DataLogC and lists all possible parameter to configure its behaviour.

Identifier Data type Default value Description
header String '' Headline of datalog, string of all data fields, separated by a comma: "field1,field2,field3,..."
maxNumberOfEntries UDInt 1000 Maximum number of entries in datalog
timestampFormat USInt 0 Timestamp format - see manual in "DataLogCreate" for used PLC Type (S7-1200 or S7-1500)
clearOnOpen Bool FALSE Clear datalog during opening datalog while enabling block
deleteFile Bool FALSE Delete as well datalog file during datalog delete
enableRingBuffer Bool FALSE TRUE: Overwrite old values and start from the beginning if datalog reaches its maximum entries
FALSE: Stop logging if `maxNumberOfEntries` entries reached
loggingByInterval Bool FALSE TRUE: Log on interval time parameter
FALSE: log on "triggerEntry"
loggingInterval Time T#1M Time for automatic logging interval

LGF_typeDiagnostics (UDT / V1.0.0)

Diagnostic structure to store and transfer diagnostic information from blocks trough the interface.

Identifier Data type Default value Description
status Word 16#0000 Status of the Block or error identification when error occurred
subfunctionStatus Word 16#0000 Status or return value of called FB's, FC's and system blocks
stateNumber DInt 0 State in the state machine of the block where the error occurred

Functional description

The function LGF_DataLogC combines the system functions for creating and writing data logs in one block.

The procedure provides that an existing Datalog is opened on the basis of the name (name), if it was not created before, this is recognized and the function creates the Datalog.

Afterwards, depending on the parameterization, the data is written from data in an adjustable interval or only on request to triggerLogEntry.


ReadMe The functionality of Datalogs can be found in the user manual:


NOTICE

The following parameters are only effective when creating a data log:


NOTICE
When logging data by interval (isLoggingByInterval) time variances occur, which are caused by a fluctuating cycle time.
Therefore it is recommended to call the function in a time interrupt OB besides the call in the cyclic program and to set the trigger for writing in this interrupt OB.

NOTICE
A data log which is deleted by the function without deleting the file cannot be created again as long as the file exists, it must first be deleted manually in the system.
Please also note the parameter parameter.deleteFile which also deletes the file next to the data in case of a delete command deleteLog.

Change log

Version & DateChange description
01.00.00Simatic Systems Support
19.02.2022First released version