FB_PMA_PowerValues_Period_3Ph
The function block FB_PMA_PowerValues_Period_3Ph calculates the power values of the connected consumer in a three-phase grid. These include the fundamental components and the phase shift angle. For this purpose, only the first harmonics of the input signal are used for the calculation in addition to the signal sequence in the time domain. The advantage of these algorithms is the high dynamics of the calculations. 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.
Alternatively, the function block FB_PMA_PowerValues_3Ph can be used. This uses the individual harmonics internally to calculate the power values.
The input buffer is provided via the function block FB_PMA_Source_3Ph. This can include one or more signal periods or individual fragments of oversampling values.
Syntax
Definition:
FUNCTION BLOCK FB_PMA_PowerValues_Period_3Ph
VAR_INPUT
nOwnID : UDINT;
tTransferTimeout : LTIME := LTIME#500US;
stInitPars : ST_PMA_PowerValues_Period_InitPars;
END_VAR
VAR_OUTPUT
bError : BOOL;
ipResultMessage : I_TcMessage;
bNewResult : BOOL;
nCntResults : ULINT;
aApparentPower : ARRAY[0..2] OF LREAL;
aApparentPower_1 : ARRAY[0..2] OF LREAL;
aApparentPower_1_Min : ARRAY[0..2] OF LREAL;
aApparentPower_1_Max : ARRAY[0..2] OF LREAL;
aActivePower : ARRAY[0..2] OF LREAL;
aActivePower_Min : ARRAY[0..2] OF LREAL;
aActivePower_Max : ARRAY[0..2] OF LREAL;
aReactivePower_d : ARRAY[0..2] OF LREAL;
aReactivePower_1 : ARRAY[0..2] OF LREAL;
aReactivePower_1_Min : ARRAY[0..2] OF LREAL;
aReactivePower_1_Max : ARRAY[0..2] OF LREAL;
aTotalReactivePower : ARRAY[0..2] OF LREAL;
aPhi : ARRAY[0..2] OF LREAL;
aCosPhi : ARRAY[0..2] OF LREAL;
aPowerFactor : ARRAY[0..2] OF LREAL;
fPowerQualityFactor : LREAL;
fSumApparentPower : LREAL;
fSumActivePower : LREAL;
fSumTotalReactivePower : LREAL;
fSumReactivePower_1 : LREAL;
bValidStatistics : BOOL;
END_VAR
VAR_OUTPUT PERSISTENT
aEnergy_Pos : ARRAY[0..2] OF ST_PMA_Energy;
aEnergy_Neg : ARRAY[0..2] OF ST_PMA_Energy;
aEnergy_Res : ARRAY[0..2] OF ST_PMA_Energy;
END_VAR
Inputs
The input parameters of this function block represent initialization parameters and have to be assigned during the declaration of the function block instance (alternatively: 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. |
aApparentPower | ARRAY[0..2] OF LREAL | Total apparent power |
aApparentPower_1 | ARRAY[0..2] OF LREAL | Fundamental apparent power |
aApparentPower_1_Min | ARRAY[0..2] OF LREAL | Smallest value of fApparentPower_1 that has occurred. Can be reset via bResetStatistics of the Call method. |
aApparentPower_1_Max | ARRAY[0..2] OF LREAL | Largest value of fApparentPower_1 that has occurred. Can be reset via bResetStatistics of the Call method. |
aActivePower | ARRAY[0..2] OF LREAL | Active power |
aActivePower_Min | ARRAY[0..2] OF LREAL | Smallest value of fActivePower that has occurred. Can be reset via bResetStatistics of the Call method. |
aActivePower_Max | ARRAY[0..2] OF LREAL | Largest value of fActivePower that has occurred. Can be reset via bResetStatistics of the Call method. |
aReactivePower_d | ARRAY[0..2] OF LREAL | Distortion reactive power |
aReactivePower_1 | ARRAY[0..2] OF LREAL | Fundamental shift reactive power |
aReactivePower_1_Min | ARRAY[0..2] OF LREAL | Smallest value of fReactivePower_1 that has occurred. Can be reset via bResetStatistics of the Call method. |
aReactivePower_1_Max | ARRAY[0..2] OF LREAL | Largest value of fReactivePower_1 that has occurred. Can be reset via bResetStatistics of the Call method. |
aTotalReactivePower | ARRAY[0..2] OF LREAL | Total reactive power |
aPhi | ARRAY[0..2] OF LREAL | Phase shift angle |
aCosPhi | ARRAY[0..2] OF LREAL | CosPhi (active power/fundamental apparent power) |
aPowerFactor | ARRAY[0..2] OF LREAL | Power factor (active power/total apparent power) |
fPowerQualityFactor | LREAL | Power Quality Factor. Represents the quality of the power supply simplified in a value range between 0 and 1. The frequency, the RMS values of the voltages, the THD of the voltages and optionally the voltage unbalance are included. |
fSumApparentPower | LREAL | Sum of the total apparent power of all phases. |
fSumActivePower | LREAL | Sum of the active power of all phases. |
fSumTotalReactivePower | LREAL | Sum of the total reactive power of all phases. |
fSumReactivePower_1 | LREAL | Sum of the values of the fundamental shift reactive power of all phases. |
bValidStatistics | BOOL | TRUE if the Min and Max value calculation has been performed. These values are valid. |
aEnergy_Pos | ARRAY[0..2] OF ST_PMA_Energy | Energy in positive direction. The output is saved persistently and can be reset via bResetEnergyCalc of the Call method. |
aEnergy_Neg | ARRAY[0..2] OF ST_PMA_Energy | Energy in negative direction. The output is saved persistently and can be reset via bResetEnergyCalc of the Call method. |
aEnergy_Res | ARRAY[0..2] OF ST_PMA_Energy | Resulting energy. The output is saved persistently and can be reset via bResetEnergyCalc of the Call method. |
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);
cPowerValuesInitPars : ST_PMA_PowerValues_Period_InitPars := (
nBufferLength := cOversamples,
fSampleRate := cOversamples * 1000,
fMinInputCurrent := 0.01,
nPeriods := 1);
END_VAR
VAR
aVoltage AT%I* : ARRAY[0..2] OF ARRAY [1..cOversamples] OF LREAL;
aCurrent AT%I* : ARRAY[0..2] OF ARRAY [1..cOversamples] OF LREAL;
fbSource : FB_PMA_Source_3Ph := (nOwnID := 1, aDestIDs := [2,3], stInitPars := cSourceInitPars);
fbFrequency : FB_PMA_Frequency_Period_3Ph := (nOwnID := 2, stInitPars := cFrequencyInitPars);
fbPowerValues : FB_PMA_PowerValues_Period_3Ph := (nOwnID := 3, stInitPars := cPowerValuesInitPars);
END_VAR
// Call source
fbSource.Call(
ADR(aVoltage[0]),
ADR(aVoltage[1]),
ADR(aVoltage[2]),
ADR(aCurrent[0]),
ADR(aCurrent[1]),
ADR(aCurrent[2]),
SIZEOF(aVoltage[0]),
0);
// Call algorithms
fbFrequency.Call(FALSE);
fbPowerValues.Call(fbFrequency.aFreq[0], FALSE, FALSE);
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x86, x64) | Tc3_PowerMonitoring |