beckhoff TF4100 — 4.2.1.2.6 FB_CTRL_TRANSFERFUNCTION_1

PLC API Example: PROGRAM PRG_TRANSFERFUNCTION_1_TEST VAR CONSTANT nTfOrder : USINT := 2; END_VAR VAR aNumArray : ARRAY[0..nNumOrder] OF FLOAT; aDenArray : ARRAY[0..nDenOrder] OF FLOAT; aStTfData : ARRAY[0..nTfOrder] OF ST_CTRL_TRANSFERFUNCTION_1_DATA; eMode : E_CTRL_MODE; stParams : ST_CTRL_TRANSFERFUNCTION_1_PARAMS; eErrorId : E_CTRL_ERRORCODES; bError : BOOL; fbTansferfunction : FB_CTRL_TRANSFERFUNCTION_1; bInit : BOOL := TRUE; fIn : FLOAT := 0; fOut : FLOAT; b_0, b_1, b_2 : FLOAT; a_0,a_1,a_2 :

FLOAT; END_VAR IF bInit THEN aNumArray[0] := 1.24906304658218E-007; aNumArray[1] := 2.49812609316437E-007; aNumArray[2] := 1.24906304658218E-007; aDenArray[0] := 0.998501124344101; aDenArray[1] := -1.99850062471888; aDenArray[2] := 1.0; stParams.tTaskCycleTime := T#2ms; stParams.tCtrlCycleTime := T#2ms; stParams.nOrderOfTheTransferfunction := nTfOrder; eMode := eCTRL_MODE_ACTIVE; bInit := FALSE; END_IF stParams.pNumeratorArray_ADR := ADR(aNumArray); stParams.nNumeratorArray_SIZEOF := SIZEOF(aNumArray); stParams.pDenominatorArray_ADR := ADR(aDenArray); stParams.nDenominatorArray_SIZEOF := SIZEOF(aDenArray); stParams.pTransferfunction1Data_ADR := ADR(aStructTfData); stParams.nTransferfunction1Data_SIZEOF := SIZEOF(aStructTfData); fbTansferfunction (fIn := fIn, eMode := eMode, stParams := stParams, TF4100 37 Version:

2.2.4 Name Type Description 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. tCtrlCycleTime TIME Cycle time with which the control loop is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input value to calculate internally whether the state and the output values have to be updated in the current cycle.

nOrderOfTheTra nsferfunction USINT Order of the transfer function [0...] pNumeratorArray ADR _ POINTER TO FLOAT Address of the array containing the numerator coefficients nNumeratorArray SIZEOF _ UINT Size of the array containing the numerator coefficients, in bytes pDenominatorArr ay ADR _ POINTER TO FLOAT Address of the array containing the denominator coefficients nDenomiantorArr ay SIZEOF _ UINT Size of the array containing the denominator coefficients, in bytes pTransferfunction 1Data ADR _ POINTER TO ST CTRL _ _ TRANSFER FUNCTION 1 _ _ DATA Address of the data array nTransferfunction 1Data SIZEOF _ UINT Size of the data array in bytes