ST_PMA_Spectrum_InitPars
Function block-specific structure with initialization parameters that are evaluated when the function blocks FB_PMA_Spectrum_1Ph and FB_PMA_Spectrum_3Ph are initialized.
Syntax
Definition:
TYPE ST_PMA_Spectrum_InitPars :
STRUCT
nFFT_Length : UDINT := 512; // Length of FFT
nWindowLength : UDINT := 400; // Length of FFT window
fSampleRate : LREAL := 1000; // in Hz
eScalingType : E_PMA_ScalingType := E_PMA_ScalingType.NoScaling; // Scaling type used
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
END_STRUCT
END_TYPE
Parameter
Name | Type | Parameter |
---|---|---|
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. It must be not greater than nFFT_Length. |
fSampleRate | LREAL | Indicates the sampling rate (samples per second) of the input signal. |
eScalingType | Allows selection of the scaling used if absolute scaling is required. | |
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, which is equivalent to the constant |
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 difference in the length is filled with zeros by the Fourier transformation. 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.
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x86, x64) | Tc3_PowerMonitoring |