ST_PMA_Harmonics_InitPars
Function block-specific structure with initialization parameters that are evaluated when the function blocks FB_PMA_Harmonics_1Ph and FB_PMA_Harmonics_3Ph are initialized.
Syntax
Definition:
TYPE ST_PMA_HarmonicAnalysis_InitPars :
STRUCT
fSampleRate : LREAL := 1000; // Sample rate
fBaseFreq : LREAL := 50.0; // Multiple of base frequence is used for band limit definition
nFFT_Length : UDINT := 512; // Length of FFT
nWindowLength : UDINT := 400; // Length of FFT window
nNumBands : UDINT := 10; // Number of bands
fBandwidth : LREAL := 4.0; // Whole bandwidth for each frequency band, min 1.0
eWindowType : E_PMA_WindowType := E_PMA_WindowType.HannWindow; // Window function used
bTransformToDecibel : BOOL := TRUE; // Transform result to decibel
fDecibelThreshold : LREAL := 1.3E-308;// Logarithm threshold for decibel transformation
bTransformToPercent : BOOL := FALSE; // Transform result to percent (1st harmonic=100%)
END_STRUCT
END_TYPE
Parameter
Name | Type | Parameter |
---|---|---|
fSampleRate | LREAL | Indicates the sampling rate (samples per second) of the input signal. |
fBaseFreq | LREAL | Frequency of the first harmonic. |
nFFT_Length | UDINT | Length of the FFT. It must be greater than one and an integral power of two. |
nWindowLength | UDINT | Length of the analysis window in samples. The length must be greater than one and an even number. |
nNumBands | UDINT | Indicates the number of bands for which the RMS is calculated. |
fBandwidth | LREAL | Total bandwidth of each RMS band |
eWindowType | Defines the window function that is used. The window type "„HannWindow" is a good default value. The windowing can be switched off by the use of the window type "RectangularWindow". Further explanations and the list of possible window functions can be found in the introductory section Window functions. | |
bTransformToDecibel | BOOL | Boolean value that indicates whether the result of the FFT is to be transformed to the decibel scale, according to transformation x → 20 * log10(x). |
fDecibelThreshold | LREAL | Very small floating point value greater than zero. Values that are less than this number are replaced with this value before any transformation to the decibel scale, since the logarithm of zero is not defined mathematically. The smallest possible value is 3.75e-324. |
bTransformToPercent | BOOL | Boolean value indicating whether the result should be output in percent. The first harmonic corresponds to 100%. |
Window length The value of nWindowLength must be less or equal the value of nFFT_Length. The length of the FFT can orient itself to the required frequency resolution. Typically a value of about 3/4 of the FFT length is used as the window length. |
If nFFT_Length is greater than nWindowLength, the frequency resolution of the FFT (and therefore also the length of the return values vector) is increased. The length difference is filled with zeros before the Fourier transform . This can be useful for achieving a higher frequency resolution, or for avoiding circular aliasing in calculations with inverse transformation in the time domain . Despite the higher frequency resolution, however, the result contains no more information.