FB_ALY_MinMaxAvg
The Min Max Avg calculates the minimum, maximum and the average of the input values from the beginning of the analysis up to the current moment. Compared to Min Max Avg 1Ch, any number of input channels are supported. The calculations are performed separately for each input channel. Additional output values are also calculated across all input channels.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_MinMaxAvg
VAR_OUTPUT
ipResultMessage : Tc3_EventLogger.I_TcMessage;
bError : BOOL;
bNewResult : BOOL;
bConfigured : BOOL;
fResult : LREAL;
fOverallMin : LREAL;
fOverallMax : LREAL;
fOverallAvg : LREAL;
fbTimeOverallMin : FB_ALY_DateTime;
fbTimeOverallMax : FB_ALY_DateTime;
END_VAR
Outputs
Name | Type | Description |
|---|---|---|
ipResultMessage | Contains more detailed information on the current return value. For this special interface pointer, it is ensured internally that it is always valid/assigned. | |
bError | BOOL | The output is |
bNewResult | BOOL | When a new result has been calculated, the output is |
bConfigured | BOOL | Displays |
fOverallMin | LREAL | Minimum of all input values. |
fOverallMax | LREAL | Maximum of all input values. |
fOverallAvg | LREAL | Average of all input values. |
fbTimeOverallMin | FB_ALY_DateTime | Timestamp of |
fbTimeOverallMax | FB_ALY_DateTime | Timestamp of |
Methods
Name | Definition location | Description |
|---|---|---|
Call() | Local | Method for calculating the outputs for a specific configuration. |
FB_init() | Local | Initializes the number of input channels. |
GetChannelOutputArray() | Local | Getting the result array for a specific channel without adding new values. |
Reset() | Local | Resets all internal states or the calculations performed so far. |
SetChannelValue() | Local | Method for transferring values to the algorithm. |
Example
VAR
fbMinMaxAvg : FB_ALY_MinMaxAvg(nNumChannels := 2);
fbSystemTime : FB_ALY_GetSystemTime;
fInput : LREAL;
nInput : INT;
aMin : ARRAY[1..2] OF LREAL;
aMax : ARRAY[1..2] OF LREAL;
aAvg : ARRAY[1..2] OF LREAL;
END_IF
// Get current system time
fbSystemTime.Call();
// Call algorithm
fbMinMaxAvg.SetChannelValue(1, fInput);
fbMinMaxAvg.SetChannelValue(2, nInput);
fbMinMaxAvg.Call(fbSystemTime.tSystemTime);
fbMinMaxAvg.GetChannelOutputArray(1, ADR(aMin), SIZEOF(aMin));
fbMinMaxAvg.GetChannelOutputArray(2, ADR(aMax), SIZEOF(aMax));
fbMinMaxAvg.GetChannelOutputArray(3, ADR(aAvg), SIZEOF(aAvg));Requirements
Development environment | Target platform | Plc libraries to include |
|---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |