PLC-API bWriteTimeStamps : If this parameter is set to TRUE, the time stamp of the measurement is written into the first row of the data array. bWriteRowDescription : If this parameter is set to TRUE a cell array is created into which the descriptions of the rows are written. pLogBuffer_ADR : Address of the external LogBuffer. To be recognized, the buffer's address must be unequal to 0. nLogBuffer_SIZEOF : 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. NOTE 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 ); (* creat test data *) fIn := fIn + 0.01; fOut := SIN(fIn); (* copy test data to the Logger-Input *) LoggerData[ 1 ] := fIn; LoggerData[ 2 ] := fOut; LoggerData[ 3 ] := fOut * 2; (* log only 1000 columns *) IF fbCtrlLogMatFile.nLoggedColumns >= 25 THEN eMode := eCTRL_MODE_Passive; TS4100 118 Version:
1.1