FB_PMA_BasicValues_Period_1Ph
The function block FB_PMA_BasicValues_Period_1Ph calculates analysis values for the signal sequence of current and voltage in a single-phase system. These include the mean value, the RMS value, the peak value, the rectified value, the crest factor and the form factor for current and voltage. The results refer to a configurable number of signal periods. The period duration refers to the frequency specified at the start of the period at the input of the Call method. The statistical results refer to the entire runtime or the time at which the statistical results were last reset.
The input buffer is provided via the function block FB_PMA_Source_1Ph. This can include one or more signal periods or individual fragments of oversampling arrays.
Syntax
Definition:
FUNCTION BLOCK FB_PMA_BasicValues_Period_1Ph
VAR_INPUT
nOwnID : UDINT;
tTransferTimeout : LTIME := LTIME#500US;
stInitPars : ST_PMA_BasicValues_Period_InitPars;
END_VAR
VAR_OUTPUT
bError : BOOL;
ipResultMessage : I_TcMessage;
bNewResult : BOOL;
nCntResults : ULINT;
fMeanValue_U : LREAL;
fRMS_U : LREAL;
fRMS_U_Min : LREAL;
fRMS_U_Max : LREAL;
fPeakValue_U : LREAL;
fPeakHold_U : LREAL;
fRectifiedValue_U : LREAL;
fCrestFactor_U : LREAL;
fFormFactor_U : LREAL;
fMeanValue_I : LREAL,
fRMS_I : LREAL,
fRMS_I_Min : LREAL,
fRMS_I_Max : LREAL,
fPeakValue_I : LREAL,
fPeakHold_I : LREAL;
fRectifiedValue_I : LREAL;
fCrestFactor_I : LREAL;
fFormFactor_I : LREAL;
bValidStatistics : BOOL;
END_VAR
Inputs
The input parameters of this function block represent initialization parameters and must be assigned when declaring the function block instance (alternative: Init method). They may only be assigned once. A change at runtime is not possible.
Name | Type | Description |
---|---|---|
nOwnID | UDINT | Identifies the function block instance with a unique ID. This must always be greater than zero. A proven approach is to define an enumeration for this purpose. |
tTransferTimeout | LTIME | Setting of the synchronous timeout for internal multi-array forwardings. See Parallel Processing in Transfer Tray. |
stInitPars | Function-block-specific structure with initialization parameters. The parameters must correlate to the above definition of the input and output buffers. |
Outputs
Name | Type | Description |
---|---|---|
bError | BOOL | TRUE if an error occurs. |
ipResultMessage | I_TcMessage | The interface offers detailed information about the return value. |
bNewResult | BOOL | TRUE once new results have been calculated. |
nCntResults | ULINT | Count value is incremented with new output data. |
fMeanValue_U | LREAL | Mean voltage value over n periods |
fRMS_U | LREAL | RMS value of the voltage over n periods |
fRMS_U_Min | LREAL | Smallest value of fRMS_U that has occurred. Can be reset via bResetStatistics of the Call method. |
fRMS_U_Max | LREAL | Largest value of fRMS_U that has occurred. Can be reset via bResetStatistics of the Call method. |
fPeakValue_U | LREAL | Peak voltage value over n periods |
fPeakHold_U | LREAL | All-time peak voltage value over n periods. Can be reset via bResetStatistics of the Call method. |
fRectifiedValue_U | LREAL | Rectified voltage value over n periods |
fCrestFactor_U | LREAL | Crest factor of the voltage (peak/RMS value) |
fFormFactor_U | LREAL | Form factor of the voltage (RMS/rectified value) |
fMeanValue_I | LREAL | Mean value of the current over n periods |
fRMS_I | LREAL | RMS value of the current over n periods |
fRMS_I_Min | LREAL | Smallest value of fRMS_I that has occurred. Can be reset via bResetStatistics of the Call method. |
fRMS_I_Max | LREAL | Largest value of fRMS_I that has occurred. Can be reset via bResetStatistics of the Call method. |
fPeakValue_I | LREAL | Peak value of the current over n periods |
fPeakHold_I | LREAL | All-time peak current value. Can be reset via bResetStatistics of the Call method. |
fRectifiedValue_I | LREAL | Rectified value of the current over n periods |
fCrestFactor_I | LREAL | Crest factor of current (peak/RMS value) |
fFormFactor_I | LREAL | Form factor of the current (RMS/rectified value) |
bValidStatistics | BOOL | TRUE if the Min, Max and Hold value calculation has been performed. These values are valid. |
Methods
Name | Description |
---|---|
The method is called in each cycle to execute the calculations from the input buffer when new data is present. | |
Alternative to the function block initialization | |
As an alternative to the Call method, the method can be called in each cycle if no calculation is to take place. The incoming input buffer is then forwarded accordingly. | |
The method is called in order to reconfigure the function block during the runtime. | |
The current calculations are reset with the method. |
Sample
VAR CONSTANT
cOversamples : UDINT := 10;
cSourceInitPars: ST_PMA_Source_InitPars := (
nBufferLength := cOversamples);
cFrequencyInitPars : ST_PMA_Frequency_Period_InitPars := (
nBufferLength := cOversamples,
fSampleRate := cOversamples * 1000,
fMinFreq := 45.0,
fMaxFreq := 55.0,
nPeriods := 1,
nFilterOrder := 2,
fCutOff := 70.0,
eInputSelect := E_PMA_InputSelect.Voltage,
fMinInput := 200.0);
cBasicValuesInitPars : ST_PMA_BasicValues_Period_InitPars := (
nBufferLength := cOversamples,
fSampleRate := cOversamples * 1000,
fMinInputCurrent := 0.01,
nPeriods := 1);
END_VAR
VAR
aVoltage AT%I* : ARRAY[1..cOversamples] OF LREAL;
aCurrent AT%I* : ARRAY[1..cOversamples] OF LREAL;
fbSource : FB_PMA_Source_1Ph := (nOwnID := 1, aDestIDs := [2,3], stInitPars := cSourceInitPars);
fbFrequency : FB_PMA_Frequency_Period_1Ph := (nOwnID := 2, stInitPars := cFrequencyInitPars);
fbBasicValues : FB_PMA_BasicValues_Period_1Ph := (nOwnID := 3, stInitPars := cBasicValuesInitPars);
END_VAR
// Call source
fbSource.Call(ADR(aVoltage), ADR(aCurrent), SIZEOF(aVoltage), 0);
// Call algorithms
fbFrequency.Call(FALSE);
fbBasicValues.Call(fbFrequency.fFreq, FALSE);
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x86, x64) | Tc3_PowerMonitoring |