# FFT Power Spectrum and PSD (Power Spectrum » Single-shot) (G Dataflow)

Version:

Computes the single-sided or double-sided power spectrum of a time-domain signal.

## signal

The input time-domain signal, usually in volts.

This input can be a 1D array of double-precision floating-point numbers or a 1D array of complex double-precision floating-point numbers.

The time-domain record must contain at least three cycles of the signal for a valid estimate.

## single-sided

A Boolean specifying whether this node computes the single-sided or double-sided power spectrum.

 True Computes the single-sided power spectrum. False Computes the double-sided power spectrum.

Default: False

## error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: No error

## dt

The sample period of the time-domain signal, usually in seconds.

Set this input to 1/fs, where fs is the sampling frequency of the time-domain signal.

Default: 1

## power spectrum

Power spectrum of the input signal. If the input signal is in volts (V), the units of this output is volts-rms squared (Vrms2). If the input signal is not in volts, the units of this output is the input signal unit-rms squared.

## error out

Error information. The node produces this output according to standard error behavior.

## df

The frequency interval of the power spectrum. The unit of this output is Hz if the sample period is in seconds.

## Algorithm for Computing the Power Spectrum

If single-sided is True, this node first computes the double-sided power spectrum, and then converts the power spectrum into a single-sided power spectrum.

This node uses the fast Fourier transform (FFT) and discrete Fourier transform (DFT) routines to compute the double-sided power spectrum, which is given by the following equation:

${S}_{xx}=\frac{{|F\left\{X\right\}|}^{2}}{{n}^{2}}$

where

• x is the input signal
• Sxx is the output sequence power spectrum
• n is the number of samples in the input signal

When the number of samples in the input signal is a valid power of 2, such that $n={2}^{m}$ for $m=1,\text{\hspace{0.17em}}2,3,\text{\hspace{0.17em}}\text{\hspace{0.17em}}...,\text{\hspace{0.17em}}23$, this node computes the fast Fourier transform of a real-valued sequence using the fast radix-2 FFT algorithm and efficiently scales the magnitude square. The largest power spectrum the node can compute using the FFT is 223 (8,388,608 or 8M).

When the number of samples in the input signal is not a valid power of 2 but is factorable as the product of small prime numbers, this node computes the discrete Fourier transform of a real-valued sequence using an efficient DFT algorithm and scales the magnitude square. The largest power spectrum the node can compute using the fast DFT is 222 - 1 (4,194,303 or 4M - 1).

Let Y be the Fourier transform of the input signal and n be the number of samples in it. Then the following equation is true.

${|{Y}_{n-i}|}^{2}=|{Y}_{-i}^{2}|$

You can interpret the power in the (n - i)th element of Y as the power in the -ith element of the sequence, which represents the power in the -ith harmonic. You can find the total power for the ith harmonic (excluding DC and Nyquist components) by using the following equation.

$\begin{array}{cc}\text{Power in the}{i}^{th}\text{harmonic}=2{|{Y}_{i}|}^{2}={|{Y}_{i}|}^{2}+{|{Y}_{n-1}|}^{2}& 0

The total power in the DC and Nyquist components are ${|{Y}_{0}|}^{2}$ and ${|{Y}_{\frac{n}{2}}|}^{2}$ respectively.

If n is even, let $k=\frac{n}{2}$. The following table shows the format of the output sequence Sxx corresponding to power spectrum.

Array Element of Double-Sided Spectrum Array Element of Single-Sided Spectrum Interpretation
${S}_{x{x}_{0}}$ ${S}_{x{x}_{0}}$ Power in DC component
${S}_{x{x}_{1}}={S}_{x{x}_{\left(n-1\right)}}$ ${S}_{x{x}_{1}}*2$ Power at frequency Δf
${S}_{x{x}_{2}}={S}_{x{x}_{\left(n-2\right)}}$ ${S}_{x{x}_{2}}*2$ Power at frequency 2Δf
${S}_{x{x}_{3}}={S}_{x{x}_{\left(n-3\right)}}$ ${S}_{x{x}_{3}}*2$ Power at frequency 3Δf
$⋮$ $⋮$ $⋮$
${S}_{x{x}_{\left(k-2\right)}}={S}_{x{x}_{n-\left(k-2\right)}}$ ${S}_{x{x}_{\left(k-2\right)}}*2$ Power at frequency (k - 2)Δf
${S}_{x{x}_{\left(k-1\right)}}={S}_{x{x}_{n-\left(k-1\right)}}$ ${S}_{x{x}_{\left(k-1\right)}}*2$ Power at frequency (k - 1)Δf
${S}_{x{x}_{k}}$ ${S}_{x{x}_{k}}$ Power in Nyquist harmonic

If n is odd, let $k=\frac{n-1}{2}$. The following table shows the format of the output sequence Sxx corresponding to power spectrum.

Array Element of Double-Sided Spectrum Array Element of Single-Sided Spectrum Interpretation
${S}_{x{x}_{0}}$ ${S}_{x{x}_{0}}$ Power in DC component
${S}_{x{x}_{1}}={S}_{x{x}_{\left(n-1\right)}}$ ${S}_{x{x}_{1}}*2$ Power at frequency Δf
${S}_{x{x}_{2}}={S}_{x{x}_{\left(n-2\right)}}$ ${S}_{x{x}_{2}}*2$ Power at frequency 2Δf
${S}_{x{x}_{3}}={S}_{x{x}_{\left(n-3\right)}}$ ${S}_{x{x}_{3}}*2$ Power at frequency 3Δf
$⋮$ $⋮$ $⋮$
${S}_{x{x}_{\left(k-2\right)}}={S}_{x{x}_{n-\left(k-2\right)}}$ ${S}_{x{x}_{\left(k-2\right)}}*2$ Power at frequency (k - 2)Δf
${S}_{x{x}_{\left(k-1\right)}}={S}_{x{x}_{n-\left(k-1\right)}}$ ${S}_{x{x}_{\left(k-1\right)}}*2$ Power at frequency (k - 1)Δf
${S}_{x{x}_{n-k}}$ ${S}_{x{x}_{k}}*2$ Power at frequency kΔf

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported