FFT Block (fft)
Samples a signal and outputs one bin of its discrete Fourier transform once a period.
Group: Control · Kind: {"block":"fft","kind":"control"}
When to use it
Use it to model the harmonic analysis a digital controller runs on its samples, aliasing included. Use Harmonic Meter for a continuous measurement and analysis.fft for the spectrum after the run.
Pins
| Pin | Domain | Meaning |
|---|---|---|
in |
signal | Signal to sample |
amp |
signal | Peak amplitude of the bin |
phase |
signal | Phase in degrees, as the phase of a Sine Source |
Common parameters
f: Fundamental frequency: one transform per period (50 Hz mains, IEC 60038:2009 Table 1) (Default: 50)samples: Samples per period; harmonics up to samples/2 − 1 are resolved, higher ones alias (Default: 64)order: Bin read out: the harmonic order, below samples/2 (Default: 1)
Parameters
| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
f |
Hz | 50 | Fundamental frequency: one transform per period (50 Hz mains, IEC 60038:2009 Table 1) | |
samples |
— | 64 | Samples per period; harmonics up to samples/2 − 1 are resolved, higher ones alias | |
order |
— | 1 | Bin read out: the harmonic order, below samples/2 |
Parameter descriptions are in English in both languages.
Model
The input is sampled at t = k/(samplesf); the instants are events, so the solver lands a step on each. At the last sample of every period the block takes bin order of the DFT of that period's samples, the bin a radix-2 FFT gives: a = (2/N)sum(x_jsin(2piorderj/N)) and b the same with cos, amp = sqrt(a^2 + b^2) and phase = atan2(b, a) in degrees. The outputs hold until the next period ends and are 0 before the first one does.
Common mistakes
- Harmonics above samples/2 fold back onto lower bins, as in a real ADC without an anti-aliasing filter. Raise samples, or filter the input, when the signal has switching ripple.
- The output changes only once a period, so a loop closed through it sees a delay of up to two periods.
Problems rules: pin.unconnected
Datasheet and sources
In a microcontroller the samples per period is the ADC trigger rate divided by the line frequency; a DSP library FFT of N points matches this block with samples set to N.
Example
Open the example with the command file.openExample and the name demo:fft.
Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.