### RDFT – Running discrete Fourier transform

Function Description
The RDFT function block analyzes the analog input signal using the discrete Fourier transform with the fundamental frequency freq and optional higher harmonic frequencies. The computations are performed over the last m samples of the input signal u, where $\mathtt{\text{m}}=\mathtt{\text{nper}}∕\mathtt{\text{freq}}∕{T}_{S}$, i.e. from the time-window of the length equivalent to nper periods of the fundamental frequency.

If $\mathtt{\text{nharm}}>0$ the number of monitored higher harmonic frequencies is given solely by this parameter. On the contrary, for $\mathtt{\text{nharm}}=0$ the monitored frequencies are given by the user-defined vector parameter freq2.

For each frequency the amplitude (vAmp output), phase-shift (vPhi output), real/cosine part (vRe output) and imaginary/sine part (vIm output). The output signals have the vector form, therefore the computed values for all the frequencies are contained within. Use the VTOR function block to disassemble the vector signals.

Inputs

 amp Amplitude of the fundamental frequency double thd Total harmonic distortion (only for $\mathtt{\text{nharm}}\ge 1$) double vAmp Vector of amplitudes at given frequencies reference vPhi Vector of phase-shifts at given frequencies reference vRe Vector of real parts at given frequencies reference vIm Vector of imaginary parts at given frequencies reference E Error flag bool iE Error code error i .... REXYGEN general error
 freq Fundamental frequency  $↓$0.000000001 $↑$1000000000.0 $\odot$1.0 double nper Number of periods to calculate upon  $↓$1 $↑$10000 $\odot$10 long nharm Number of monitored harmonic frequencies  $↓$0 $↑$16 $\odot$3 long ifrunit Frequency units  $↓$1 $↑$2 $\odot$1 long 1 .... Hz 2 .... rad/s iphunit Phase shift units  $↓$0 $↑$2 $\odot$1 long 1 .... degrees 2 .... radians nmax Allocated size of array  $↓$10 $↑$10000000 $\odot$8192 long freq2 Vector of user-defined monitored frequencies  $\odot$[2.0 3.0 4.0] double