FB_ALY_MovingAvg_1Ch
The Moving Average 1Ch calculates the moving average, the minimum and the maximum of the most recent input values in an interval of specified length. Furthermore the time values of minimum and maximum are shown. The calculation of the moving average depends on the configuration parameters Num Values and Startup Behaviour.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_MovingAvg_1Ch
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fMovingAvg: LREAL;
fMovingMin: LREAL;
fMovingMax: LREAL;
END_VAR
Outputs
Name | Type | Description |
---|---|---|
ipResultMessage | Contains more detailed information on the current return value. This special interface pointer is internally secured so that it is always valid/assigned. | |
bError | BOOL | This output is |
bNewResult | BOOL | When a new result has been calculated, the output is |
bConfigured | BOOL | Displays |
fMovingAvg | LREAL | Moving average value of the input value. |
fMovingMin | LREAL | Moving minimum of the input value. |
fMovingMax | LREAL | Moving maximum of the input value. |
Methods
Name | Definition location | Description |
---|---|---|
Call() | Local | Method for calculating the outputs for a specific configuration. |
Configure() | Local | General configuration of the algorithm with its parameterized conditions. |
Reset() | Local | Resets all internal states or the calculations performed so far. |
SetChannelValue() | Local | Method for passing values to the algorithm. |
Sample
VAR
fbMovingAvg : FB_ALY_MovingAvg_1Ch;
nNumValues : UDINT := 100;
eStartupBehaviour : E_ALY_MovingAvgStartupBehaviour := E_ALY_MovingAvgStartupBehaviour.AvgOverExisting;
bConfigure : BOOL := TRUE;
nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
bConfigure := FALSE;
fbMovingAvg.Configure(nNumValues, eStartupBehaviour);
END_IF
// Call algorithm
fbMovingAvg.SetChannelValue(nInput);
fbMovingAvg.Call();
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |