FB_ALY_MathOperation
The Math Operation executes a mathematical operation on two or more different input channels and provides the result of the mathematical operation. The operator is the same for all operands.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_MathOperation
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fResult: 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 |
fResult | LREAL | Outputs the result of the mathematical operation. |
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. |
FB_init() | Local | Initializes the number of input channels. |
Reset() | Local | Resets all internal states or the calculations performed so far. |
SetChannelValue() | Local | Method for passing values to the algorithm. |
Sample
VAR
fbMathOperation : FB_ALY_MathOperation(nNumChannels := 3);
eMathOperator : E_ALY_MathOperator := E_ALY_MathOperator.Addition;
bUseAbsValues : BOOL := FALSE;
bConfigure : BOOL := TRUE;
nInputCh1 : INT;
fInputCh2 : LREAL;
nInputCh3 : UDINT;
END_VAR
// Configure algorithm
IF bConfigure THEN
bConfigure := FALSE;
fbMathOperation.Configure(eMathOperator, bUseAbsValues);
END_IF
// Call algorithm
fbMathOperation.SetChannelValue(1, nInputCh1);
fbMathOperation.SetChannelValue(2, fInputCh2);
fbMathOperation.SetChannelValue(3, nInputCh3);
fbMathOperation.Call();
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |