Samples of calculations based on the frequency range
The samples show the highly dynamic analysis of electrical systems in combination with the analysis in the frequency range.
Overview
Two analysis chains are used in the samples. The function block IDs for linking the algorithms are defined in the structure E_AnalysisIDs. The analysis chains begin either with an input from a bus terminal, for example the EL3783, or with the signal generator. Switching is done with the variable eInputSelect.
The analysis chain for the high dynamic analysis is only executed in the MAIN program. The input signal is transferred to the source function block (fbSource_Period), which subsequently forwards the signal to the analysis function blocks assigned to it. This includes the frequency calculation with the function block (fbFrequency), the calculation of basic values with the function block (fbBasicValues), the calculation of power values with the function block (fbPowerValues) and the calculation of harmonics with the function block (fbHarmonics). The buffer lengths correspond to the oversampling factor.
The slower analysis chain for the analysis in the frequency range also starts in the MAIN program with the source function block (fbSource). This collects the incoming data up to the configured buffer length cBufferLength and then sends them to the frequency-based function blocks for the power calculation (fbPowerValues), for the calculation of the spectrum (fbSpectrum) and for the calculation of the harmonics (fbHarmonics) in the slower program MAIN_SLOW.
Program parameters
The most important parameters for influencing the input signal are shown in the following table.
Variable | Description | Default value |
---|---|---|
eInputSelect | Selection of the input signal | E_InputSelect.SignalGenerator |
fFrequency | Base frequency of the generated signals | 50 Hz |
fAmplitudeVoltage | Amplitude of the generated voltage signal | 325.27 V |
fAmplitudeCurrent | Amplitude of the generated current signal | 1.414 A |
fPhaseDifferenceCurrent | Phase shift between the generated current and voltage signals | 5 ° |
bEnableHarmonics | Generation of harmonic components in the current and voltage signals | FALSE |
Global constants
The following global constants are defined:
Variable | Description | Default value |
---|---|---|
cOversamples | Number of oversamples of the input channels | 10 |
cSamplerate | Sample rate of the input channels in Hz | 10000 |
cFFTLength | Length of the FFT | 4096 |
cWindowLength | Internal buffer length with 50% overlap | 3200 |
cBufferLength | Length of the input buffer for the FFT calculation | 1600 |
cHarmonicBands | Number of harmonics to be calculated | 20 |
cFreqMode | Base frequency for the calculation of harmonics | 50.0 |
Download
Single-phase sample program | |
Three-phase sample program |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x86, x64) | Tc3_PowerMonitoring |