PSD – Power Spectral Density
Block SymbolLicensing group: ADVANCED
Function Description
The function block PSD computes a power spectral density (PSD, periodogram) using the
PocketFFT package [17]. The PocketFFT C99 implementation is based on FFTPack (in
Fortran) [18], which is based on the chapter in [19].
PSD is most often calculated from segments of length N samples of the input signal. The data of these segments is multiplied by a window function (e.g. Hamming window), the FFT is calculated from them, and the PSD of each segment is calculated from its result. Finally, the navg of such results is averaged (the navg parameter). The input signal can be divided into segments either sequentially or with a half-overlap (Welch method [20], [21]). The resulting PSD can be calculated in decibels (dB) if the parameter DB = on.
Input data (a vector or a matrix) of the block are referenced by the uc input. If the input uc refers to a column vector (number of columns m = ) with the number of elements n, the PSD will be calculated from a single signal. If uc refers to a matrix with n rows and m columns, the PSD will be computed m times (for each column). If the input n > 0 then the number of samples per segment N = n else N is set to the number of rows of the array referenced by uc.
The input uf references the internal vector of dimension for FFT computing. The resulting PSD with npsd rows and m columns is referenced by upsd. Number of PSD frequencies for even N or for odd N. Working array referenced by uwrk has the same dimension as the array referenced by upsd. If the input data contains more elements than can be processed in one execution of the PSD block, the remaining data is copied into an array referenced by urem that has N rows and m columns.
Input data is processed according to the mode and mtrig parameters (see below). The mode parameter specifies the way the PDS is calculated, whether the data in the input vector referenced by uc is real or complex, and whether segment overlapped by half will be used. The input data sampled with the frequency connected to the input fs may be acquired in a different task (e.g. with a significantly shorter sampling period) than the one in which the PSD is calculated. The method of synchronizing the start of the calculation is provided by the mtrig trigger mode. The calculation can be triggered every PSD block execution period or when a sufficient number of samples are available (at least equal to N) or by the rising edge of the START input.
A vector of dimension N is connected to the uwnd input to store the window function selected by the iwin parameter. Window functions have (optionally) an integer parameter lwnd and/or a real parameter rwnd. Some window functions are used in two variants:
- Symmetric (for lwnd=0). The window of length samples is computed, the first and last elements are equal. This variant is suitable for FIR filter design.
- Periodic (for lwnd=1). The window of length is computed but only the first N samples is stored. The periodic version is the preferred method for spectral analysis because the discrete Fourier transform assumes periodic extension of the input vector.
Window functions are defined by the following expressions:
- iwin=1
- Bartlett-Hahn Window
- iwin=2
- Bartlett Window
- iwin=3
- Blackman Window
where is when is even and when is odd.
- iwin=4
- Blackman-Harris Window
where , , and .
- iwin=5
- Bohman Window
- iwin=6
- Chebyshev Window
Using Chebyshev polynomials of -th order
the Fourier transform of the Chebyshev window is
where
- iwin=7
- Flat Top Window
where and , , , and .
- iwin=8
- Gauss Window
where and is the standard deviation of a Gaussian probability density function.
- iwin=9
- Hamming Window
- iwin=10
- Hann Window
- iwin=12
- Nuttall’s Blackman-Harris Window
where , , and .
- iwin=13
- Parzen Window
- iwin=14
- Rectangular Window
Multiplication of all input data elements by 1 is not performed in this block, therefore the uwnd input may not be connected in this case.
- iwin=16
- Triangular Window
For odd:
For even:
- iwin=17
- Tukey Window
where is so called cosine fraction (set in the parameter rwnd, default value ).
- iwin=18
- Exponential Window
where is a window parameter (set in the parameter rwnd).
- iwin=19
- Welch Window
- iwin=20
- Externally Defined Window
If the user is not satisfied with any of the predefined windows, he/she can set his own window consisting of N samples in the vector referenced by uwnd before executing the PSD block.
The HLD input allows the user to temporarily stop the PSD calculation.
This block does not propagate the signal quality. More information can be found in the 1.4 section.
Input
uc | Input reference to input data | Reference |
uf | Input reference to internal FFT vector | Reference |
upsd | Input reference to output PSD vector/matrix | Reference |
urem | Input reference to remaining (not processed) data | Reference |
uwnd | Input reference to window function vector | Reference |
uwrk | Input reference to working vector/matrix | Reference |
n | Number of signal samples for FFT segment | Long (I32) |
fs | Sampling frequency in [Hz] | Double (F64) |
START | Starting signal (rising edge) | Bool |
HLD | Hold | Bool |
Parameter
mode | PSD computation mode 1 | Long (I32) |
|
|
|
mtrig | Computation trigger mode 1 | Long (I32) |
|
|
|
iwnd | Window function 1 | Long (I32) |
|
|
|
lwnd | Parameter lwnd of some window functions 1 9 1 | Long (I32) |
rwnd | Parameter rwnd of some window functions 1 9 1 | Long (I32) |
navg | Number of FFT segments for averaging 1 10 | Long (I32) |
DB | Computed PSD is converted do decibels [dB] | Bool |
Output
yc | Output reference to input data | Reference |
yf | Output reference to internal FFT vector | Reference |
ypsd | Output reference to output PSD vector/matrix | Reference |
yrem | Output reference to remaining (not processed) data | Reference |
ywnd | Output reference to external window function | Reference |
ywrk | Output reference to working vector/matrix | Reference |
E | Error indicator | Bool |
DONE | Averaging Completion Flag | Bool |
iavg | Current index of segment for averaging | Long (I32) |
lcomp | Number of successfully computed PSDs | Large (I64) |
[Previous] [Back to top] [Up]
2024 © REX Controls s.r.o., www.rexygen.com