FB_ALY_Downsampling_1Ch
Downsampling 1Ch processes the values of the input channel with a configurable downsampling factor. This achieves downsampling so that the output signal is a representation of the input signal at a lower sampling rate. This can be useful, for example, to better identify trends or to perform subsequent compression of highly sampled signals if only lower sampling rates are required within the analysis. This is a simple way to increase the performance of the analysis.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_Downsampling_1Ch
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fOut: LREAL;
fbTimeLastSample: FB_ALY_DateTime;
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 |
fOut | LREAL | Output signal with the sampling rate lower by the downsampling factor. |
fbTimeLastSample | FB_ALY_DateTime | Stores the timestamp of the last data point output to |
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
fbDownsampling : FB_ALY_Downsampling_1Ch;
fbSystemTime : FB_ALY_GetSystemTime;
nDownsamplingFactor : UDINT := 10;
bConfigure : BOOL := TRUE;
nInput : INT;
END_VAR
// Configure algorithm
IF bConfigure THEN
bConfigure := FALSE;
fbDownsampling.Configure(nDownsamplingFactor);
END_IF
// Get current system time
fbSystemTime.Call();
// Call algorithm
fbDownsampling.SetChannelValue(nInput);
fbDownsampling.Call(fbSystemTime.tSystemTime);
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |