FB_ALY_CurveSketcher_1Ch
Curve Sketcher 1Ch identifies inversions (peaks and valleys) in an input data stream. Furthermore, local maxima of the absolute difference between two consecutive values (referred to as Delta) can be identified. Analogous to a continuous curve, the identified peaks and valleys correspond to local maxima and minima. Delta corresponds to the slope, so that a maximum of the absolute values of Delta can be associated with an inflection point.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_CurveSketcher_1Ch
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fLastPeak: LREAL;
fbTimeLastPeak: FB_ALY_DateTime;
nCountPeaks: ULINT;
fLastValley: LREAL;
fbTimeLastValley: FB_ALY_DateTime;
nCountValleys: ULINT;
fValueAtMaxDelta: LREAL;
fMaxDelta: LREAL;
fbTimeMaxDelta: FB_ALY_DateTime;
nCountMaxDelta: ULINT;
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 |
fLastPeak | LREAL | Y-value of the last identified peak. |
fbTimeLastPeak | FB_ALY_DateTime | Timestamp of |
nCountPeaks | ULINT | Total number of peaks counted. |
fLastValley | LREAL | Y-value of the last identified valley. |
fbTimeLastValley | FB_ALY_DateTime | Timestamp of |
nCountValleys | ULINT | Number of valleys detected. |
fValueAtMaxDelta | LREAL | Input variable guided by the last detected maximum of Delta. The Delta value is the difference between this value and the input value from one cycle before. |
fMaxDelta | LREAL | The last detected local maximum of the absolute difference between two successive values in the input current. |
fbTimeMaxDelta | FB_ALY_DateTime | Timestamp of |
nCountMaxDelta | ULINT | Total number of counted local maxima of Delta. |
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
fbCurveSketcher : FB_ALY_CurveSketcher_1Ch;
fbSystemTime : FB_ALY_GetSystemTime;
fThresholdReversal : LREAL := 0.0;
bCalcInflection : BOOL := FALSE;
fThresholdDelta : LREAL := 10.0;
bConfigure : BOOL := TRUE;
nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
bConfigure := FALSE;
fbCurveSketcher.Configure(fThresholdReversal, bCalcInflection, fThresholdDelta);
END_IF
// Get current system time
fbSystemTime.Call();
// Call algorithm
fbCurveSketcher.SetChannelValue(nInput);
fbCurveSketcher.Call(fbSystemTime.tSystemTime);
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |