PLC API NOTICE Error during file handling The parameter set can only be changed when the file is closed (bFileClosed = TRUE). Otherwise errors can occur during file handling. Sample PROGRAM PRG_LOG_MAT_FILE_TEST_BUFFERED VAR eMode : E_CTRL_MODE; stParams : ST_CTRL_LOG_MAT_FILE_PARAMS; LoggerData : T_CTRL_LOGGER_DATA; eErrorId : E_CTRL_ERRORCODES; bError : BOOL; fbCtrlLogMatFile : FB_CTRL_LOG_MAT_FILE; LogBuffer : ARRAY[0..2000] OF BYTE; bInit : BOOL := TRUE; fIn : LREAL; fOut : LREAL; fMaxBufferUsage :
LREAL; END_VAR IF bInit THEN stCtrl_GLOBAL_CycleTimeInterpretation.bInterpretCycleTimeAsTicks := FALSE; stCtrl_GLOBAL_CycleTimeInterpretation.fBaseTime := 0; stParams.tLogCycleTime := T#2ms; stParams.tTaskCycleTime := T#2ms; stParams.nNumberOfRows := 3; stParams.sFileName := 'D:\test.mat'; stParams.sMatrixName := 'TwinCAT_ControllerToolbox_Log'; stParams.arRowDescription[1] := 'Input'; stParams.arRowDescription[2] := 'Output 1'; stParams.arRowDescription[3] := 'Output 2'; stParams.bWriteRowDescription := TRUE; stParams.bWriteTimeStamps := TRUE; eMode := eCTRL_MODE_ACTIVE; bInit := FALSE; END_IF stParams.nLogBuffer_SIZEOF := SIZEOF( LogBuffer ); stParams.pLogBuffer_ADR := ADR( LogBuffer ); fIn := fIn + 0.01; fOut := SIN(fIn); TF4100 130 Version:
2.2.4 Name Type Description tLogCycleTime TIME Cycle time with which entries are written into the log file. This must be greater than or equal to the TaskCycleTime. tTaskCycleTime TIME Cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task. sFileName STRING Name and path of the log file, for example: d:\Logfile.mat nNumberOfRows INT Number of columns written into the file (maximum 10). sMatrixName STRING Name of the data array arRow Description ARRAY Array of strings that contain the line headings.
bWriteTime Stamps BOOL If this parameter is set to TRUE, the timestamp of the measurement is written into the first row of the data array. bWriteRow Description BOOL If this parameter is set to TRUE a cell array is created into which the descriptions of the rows are written. pLogBuffer ADR _ POINTER TO ST CTRL _ _ MULTIPLE PWM _ OUT DATA _ _ Address of the external LogBuffer. To detect a buffer, the address must not be 0. nLogBuffer _ SIZEOF UDINT Size of the LogBuffer. The buffer must be an ARRAY OF BYTE with at least 1501 elements. The size of the buffer can be optimized with the aid of the fBufferUsage output.