TectLogFile (FB)

FUNCTION_BLOCK TectLogFile

Function block TectLogFile logs the predefined process status and values together with timestamp in a logging buffer when trigger LogTrigger has a rising edge. To execute this block memory card is recommended for saving log files. The predefined process status and values are:

  • Control Word

  • Status Word

  • Set Temperature

  • Actual Temperature

  • Duty Cycle

  • Control State

  • Output Status

  • Latest Error

  • Consolidated Errors

The logging buffer has a size of NumberBufferEntry (number of entries) for each zone. As long as the logging entry reaches the end of logging buffer, the entries in logging buffer will be saved as a log file in .csv format under a user defined folder. The file name is generated automatically from the zone index, its group index and the month and date value while saving. This log file can be opened in e.g. Excel with comma as delimiter and can be analyzed. The second function of this function block is to display entries in logging buffer using visualization as live log. This function block can be used not only to monitor the process but also for system diagnosis.

  • Note: For continuous datalogging it is not recommended to use “MC5102 - Micro memory card with adapter”. Instead use “MC-5141 - Memory card”.

InOut:

Scope

Name

Type

Initial

Comment

Input

Enable

BOOL

FALSE

2: A TRUE at the input will enable logging to the buffer and copying of files from buffer to .csv file when buffer is full.

EnableLog

BOOL

FALSE

2: A TRUE at the input will enable logging to the buffer and copying of files from buffer to .csv file when buffer is full.

LogTrigger

BOOL

FALSE

3:A TRUE at the input executes logging a data entry into logging buffer with a rising edge.

AdrLogBuffer

POINTER TO BYTE

4: Start address of the logging buffer. It is recommended to connect the input through ADR function.

NumberBufferEntry

WORD

100

5: The size of logging buffer for each zone is the number of entries. Range: 1..65535.Following conditions to be checked to avoid data loss while logging in the buffer:
  • NumberBufferEntry should always be greater than NumberOfZone. Recommendation: NumberBufferEntry > NumberOfZone x 2.

  • Interval of trigger for logging LogTrigger must be greater than one second.

  • Monitor the output NumberLogLost for the logs/data lost in the buffer as indication of possible adaptation of log configuration.

Selection

WORD

2#111111111

6: Selection of predefined values to be logged: bit 0 to bit 8 indicates the current version.Bit x = TRUE: the corresponding value will be logged.
  • Bit 0: Control Word,

  • Bit 1: Status Word,

  • Bit 2: Set Temperature,

  • Bit 3: Actual Temperature,

  • Bit 4: Duty Cycle,

  • Bit 5: Control State,

  • Bit 6: Output State,

  • Bit 7: Latest Error.

  • Bit 8: Errors

Mode

WORD

2#0

7: Define different mode of logging.
  • Bit 1, Bit 0: log mode
    • 00: log all items as long as log trigger is active

    • 01: log if one of the log values changes when trigger is active

    • 11: log if ControlWord or StatusWord changes or for Actual Temperature: changes out of threshold (+/-Threshold)) when trigger is active

  • Bit 4: internal log trigger, TRUE: It will provide internal trigger to log the files. When Bit 4 is TRUE and there is change in Control word or Status word, a trigger signal will be created. It is a trigger additional to LogTrig.

  • Bit 8: FALSE: Create subfolder automatically; TRUE: Do not create subfolder.

  • Bit 9: Valid, if bit 8 is FALSE.
    • FALSE: subfolder name with index in decimal. For example, for group 10, index 3, subfolder name is G010Z003.

    • TRUE: subfolder name with index in Hexadecimal. For example, for group 10, zone 12, subfolder name is G0AZ0C.

Threshold

REAL

0

8: Threshold of actual temperature. Set the value in combination with Mode (log mode). Log operation will be active when acutal temperature is out of +/- of the threshold value.

NumberFileEntry

DINT

0

9: The logging of data depends on the value of NumberFileEntry input is assigned.
  • If NumberFileEntry = 0, then a new log file is created daily, previous day file is backed up with the same file name but a different suffix. The suffix is the last three hexadecimal numbers of current time (without second).

  • If NumberFileEntry >0, a new file is created when number of log entries is equal to NumberFileEntry defined. Old file will be backed up with the same file name but a different suffix. The suffix is the last three hexadecimal numbers of current time (without second).

  • If NumberFileEntry <0, it is a invalid condition and function block will generate error INVALID_INPUT_9.

FilePath

STRING(80)

10:File Path for saving log file (followed with or without ‘/’), e.g. ‘sdcard/folder’. The physical disk like sdcard or userdisk must be specified in the FilePath. The following folder will be created if it does not exist yet. But only one folder level will be created, this means the parent folder must already exist.For Bit 8 of input Mode: FALSE: a subfolder will be created for each zone. The log files will be saved under FilePath/subfolder. See input Mode description, bit 8 and bit 9 for details. It is recommended to save the log file on memory card.

ManualSave

BOOL

FALSE

11: A rising edge at the input will save logging buffer to .csv log file manually.

ClearBuffer

BOOL

FALSE

12: A rising edge at the input clears the logging buffer. New entries in the logging buffer are written into the .csv file. The .csv file is renamed into a backup file with same file name but different extension. The extension is composed of the last three hexadecimal numbers of current time without seconds.

AdrVisuBuffer

POINTER TO TectLogInfoType

0

13: Start address of the log visualization data. It is recommended to define the log visualization data in array. This can be used only with visualization. For example, if there are 4 zones to be logged and each zone has 10 log visualization entries, then a one dimensional or two dimensional array can be defined with TectLogInfoType.
For example:
  • visu_array : ARRAY[1..40] OF TectLogInfoType; (in one dimensional Array).

  • visu_array : ARRAY[1..4, 1..10] OF TectLogInfoType; (in two dimensional array).

NumberVisuEntry

BYTE

10

14: Number of log entries displayed in log visualization for one zone. It must be equal or less than the Log Visualisations configured.

NumberOfZone

WORD

1

15: Number of zones to be logged into the .csv file or displayed in visualization. Range: 1 to 254. .. Note:: The Number of Zones must be configured accurately based on the actual number of zones configured in the system

Inout

FirstLogFileData

TectLogFileDataType

16: First structure of data logging internal settings and values TectLogfileDatatype

Note

It is highly recommended to define an array of TectLogfileDatatype for this input. The size of the array must be the same as the input NumberOfZone.

FirstZoneData

TectTempZoneDataType

17: First structure of process data and parameters for the zone TectTempZoneDataType

Note

All zones must be declared one after another without break. It is highly recommended to define an array of TectTempZoneData for the whole system.

Output

Busy

BOOL

FALSE

1: Operation is running (while output Error is FALSE)

Error

BOOL

FALSE

2: Operation is stopped with error (while output Busy is FALSE). This output is TRUE for at least one cycle or until Enable is set to FALSE. The output ErrorID gives more details about the error.

ErrorID

ERROR_ID

3: Error code in case of error in the function block execution

ErrorOperation

TECT_FILE_ENUM

TECT_FILE_ENUM.TECT_NO_OPERATION

4: Display the logging operation, during which the error occurs.

LogFileErrorStatus

FILE.ERROR

5: Status of Error during file handling

ErrorZone

WORD

0

6: Indicate the zone in which error is generated.

FolderCreated

BOOL

FALSE

7: This output variable is TRUE, if folder and subfolder have been created.

Each time input Enable has a rising edge, creating folder action will be executed. Depending on the number of zones and Mode 8, it could take some seconds to some minutes to create the folder and subfolders. If the folder already exists, the files inside will be kept untouched. It is recommended to enable logging (EnableLog = TRUE) after FolderCreated is TRUE. Otherwise it could cause a loss of log data

LogBusy

BOOL

FALSE

8: This output variable is TRUE, as long as input Enable is TRUE and input EnableLog is TRUE. This output variable is FALSE, if input Enable is TRUE and input EnableLog is FALSE (pause), or if input Enable has a falling edge. Then LogBusy will be FALSE as soon as the backup of all log files have been created.

NumberLogLost

WORD

0

9: Number of log entries lost in the logging buffer due to busy of file operation, e.g. log saving operation of other zones.

SavingBusy

BOOL

FALSE

10: This output variable is TRUE, as long as log files are getting saved to the log folder. This output variable is FALSE, if no saving of files to log folder is ongoing.

ZoneSaving

WORD

0

11: The particular zone, for which the file operation is executing (require: SavingBusy is TRUE)

ClearDone

BOOL

FALSE

12: Clear logging buffer is done

EntrySize

DWORD

0

13: Size of one log entry in byte. The size depends on input data Selection

BufferSize

DWORD

0

14: Size of whole buffer for all zones in byte. The size depends on output data EntrySize and input data NumberBufferEntry and NumberOfZone.

Note

Check this value to make sure the BufferSize doesn’t exceed the available size of specified data area.

Structure: