FB_ALY_LogicOperationCounter
The Logic Operation Counter executes a logical operation on the values of two or more channels and provides the result of this logical operation. Therefore, each input value can be combined with a threshold and an operator. Furthermore, the logic operator and the count mode can be configured individually.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_LogicOperationCounter
VAR_INPUT
bPersistent: BOOL;
END_VAR
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
bOperationOut: BOOL;
nCount: ULINT;
fbTimeLastEvent: FB_ALY_DateTime;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
bPersistent | BOOL | If the value is |
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 |
bOperationOut | BOOL | Result of the logical operation. |
nCount | ULINT | Incremented when the output value is |
fbTimeLastEvent | FB_ALY_DateTime | Timestamp of last change from |
Methods
Name | Definition Location | Description |
---|---|---|
Call() | Local | Method calculates the outputs for a given configuration. |
Configure() | Local | General configuration of the algorithm with its parameterized conditions. |
FB_init() | Local | Initialize the number of input channels. |
ConfigureChannel() | Local | Channel-specific configuration for the respective algorithm. |
Reset() | Local | Resets all internal states or the calculations made so far. |
SetChannelValue() | Local | Method to pass values to the algorithm. |
Properties
Name | Type | Access | Definition location | Initial value | Description |
---|---|---|---|---|---|
fTolerance | LREAL | Get, Set | Local | 0.0 | Tolerance value for the Equal / NotEqual comparisons |
Sample
VAR
fbLogicOperationCounter : FB_ALY_LogicOperationCounter(nNumChannels := 3);
fbSystemTime : FB_ALY_GetSystemTime;
eLogicOperator : E_ALY_LogicOperator := E_ALY_LogicOperator.AND_;
eCountMode : E_ALY_CountMode := E_ALY_CountMode.OnChange;
stThresholdLevel : ARRAY[1..3] OF ST_ALY_Threshold :=
[(eComparisonOperator := E_ALY_ComparisonOperator.GreaterThan, fThreshold := 10),
(eComparisonOperator := E_ALY_ComparisonOperator.LessThan, fThreshold := 2),
(eComparisonOperator := E_ALY_ComparisonOperator.Equals, fThreshold := 1)];
bConfigure : BOOL := TRUE;
nInputCh1 : INT := 11;
fInputCh2 : LREAL := 1.5;
bInputCh3 : BOOL := TRUE;
END_VAR
// Configure algorithm
IF bConfigure THEN
bConfigure := FALSE;
fbLogicOperationCounter.ConfigureChannel(1, stThresholdLevel[1]);
fbLogicOperationCounter.ConfigureChannel(2, stThresholdLevel[2]);
fbLogicOperationCounter.ConfigureChannel(3, stThresholdLevel[3]);
fbLogicOperationCounter.Configure(eLogicOperator, eCountMode);
END_IF
// Get current system time
fbSystemTime.Call();
// Call algorithm
fbLogicOperationCounter.SetChannelValue(1, nInputCh1);
fbLogicOperationCounter.SetChannelValue(2, fInputCh2);
fbLogicOperationCounter.SetChannelValue(3, bInputCh3);
fbLogicOperationCounter.Call(fbSystemTime.tSystemTime);
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |