Fast Frequency and Response Measurements using FFTs Alain Moriat, Senior Architect Fri. 12:45p Pecan (9B) www.natinst.com
Accurately Detect a Tone What is the exact frequency and amplitude of a tone embedded in a complex signal? How fast can I perform these measurements? How accurate are the results?
www.natinst.com
Presentation Overview
Why use the frequency domain? FFT – a short introduction Frequency interpolation Improvements using windowing Error evaluation Amplitude/phase response measurements Demos
www.natinst.com
Clean Single Tone Measurement Time signal
2 Volt 1
FFT Spectrum
20 dBV 0
0
-20
-1
-40
-2 0.0
-60
0.2
0.4
0.6
Clean sine tone Easy to measure
www.natinst.com
0.8ms 1.0
kHz 0
5 10 15 20 25 30 35 40 45 50
Clean tone spectrum
Noisy Tone Measurement Time signal
2 Volt 1
Our signal
FFT Spectrum
20 dBV 0
0
-20
-1
-40
-2 0.0
-60
0.2
0.4
0.6
0.8ms 1.0
Noisy signal Difficult to measure in the time domain www.natinst.com
kHz 0
5 10 15 20 25 30 35 40 45 50
Noisy signal spectrum Easier to measure
Fast Fourier Transform (FFT) Fundamentals (Ideal Case) Time signal
2 Volt 1
0
0
-20
-1
-40
-2 0.0
FFT Spectrum
20 dBV
0.1
0.2
0.3
Fsampling =100 kHz Time res =10 us
0.4ms 0.5
-60 0
5 10 15 20 25 30 35 40 45 50 kHz
Record size =50 samples Freq. res =2 kHz
The tone frequency is an exact multiple of the frequency resolution (“hits a bin”) www.natinst.com
FFT Fundamentals (Realistic Case) Time signal
2 Volt 1
0
0
-20
-1
-40
-2 0.0
FFT Spectrum
20 dBV
0.1
0.2
0.3
Fsampling =100 kHz Time res =10 us
0.4ms 0.5
-60 0
5 10 15 20 25 30 35 40 45 50 kHz
Record size =50 samples Freq. res =2 kHz
The tone frequency is not a multiple of the frequency resolution www.natinst.com
Input Frequency Hits Exactly a Bin 0 dB
Only one bin is activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.01 Bin “off” 0 dB
More bins are activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.25 Bin “off” 0 dB
Real top
-10
Highest Bin
-20
Next Highest Bin
-30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.50 Bin “off” 0 dB
Highest side-lobes
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.75 Bin “off” 0 dB
The Side lobe levels decrease
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +1.00 Bin “off” 0 dB
Only one bin is activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
The Envelope Function 1.1 1.0
Real top
0.8
Highest Bin = a
0.6
Next highest Bin = b
0.4 0.2 0.0 -0.2 -0.3 -4
-3
www.natinst.com
-2
-1
0
1
2
3
Bin 4
The Mathematics Envelope function:
Sin( π ⋅ bin) Env = (π ⋅ bin)
Bin offset:
b Δbin = ± (a + b)
Real amplitude:
(π ⋅ Δbin) Amp = a ⋅ Sin( π ⋅ Δbin)
www.natinst.com
Demo Amplitude and frequency detection by Sin(x) / x interpolation
www.natinst.com
Aliasing of the Side-Lobes Highest Bin = Bin 4
0 dB -10 -20
Aliased Bin = “Negative Bin 4”
-30 -40 -50 -60
0
1
2
www.natinst.com
3
4
5
6
7
8
9 Bin 10
Weighted Measurement Apply a Window to the signal 2
2
Volt 1
Volt 1
0
0
-1
-1
-2 0.0
-2 0.0
0.1
0.2
0.3
0.4ms 0.5
Hanning window – one period of ( 1 - COS ) www.natinst.com
0.1
0.2
0.3
0.4ms 0.5
Weighted Spectrum Measurement Apply a Window to the Signal 20 dBV 0
Without Window
20With dBV 0
-20
-20
-40
-40
-60 0
-60 0
5
www.natinst.com
10
15
20kHz25
Hanning Window
5
10
15
20kHz25
Rectangular and Hanning Windows 0 dB -10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Side lobes for Hanning Window are significantly lower than for Rectangular window
Input Frequency Exactly Hits a Bin 0 dB
Three bins are activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.25 Bin “off” 0 dB
More bins are activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.50 Bin “off” 0 dB
Highest side-lobes
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +0.75 Bin “off” 0 dB
The Side lobe levels decrease
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
Input Frequency is +1.00 Bin “off” 0 dB
Only three bins activated
-10 -20 -30 -40 -50 -60 -6
-5
-4
www.natinst.com
-3
-2
-1
0
1
2
3
4
5 Bin 6
The Mathematics for Hanning ... Sin( π ⋅ bin) Envelope: Env = (π ⋅ bin) ⋅ (1 − bin 2 ) (a - 2b) Bin Offset: Δbin = ± (a + b) (π ⋅ Δbin) Amplitude: Amp = a ⋅ ⋅ (1 −Δbin 2 ) Sin( π ⋅ Δbin) www.natinst.com
A LabVIEW Tool
Tone detector LabVIEW virtual instrument (VI) www.natinst.com
Demo Amplitude and frequency detection using a Hanning Window (named after Von Hann) Real world demo using: The NI-5411 ARBitrary Waveform Generator The NI-5911 FLEXible Resolution Oscilloscope
www.natinst.com
Frequency Detection Resolution 1000.00
Freq error (ppm)
ppm
100.00 10.00 1.00 0.10 0.01 1
www.natinst.com
10
Signal periods
100
Amplitude Detection Resolution 1000.00
Amplitude error (ppm)
ppm
100.00 10.00 1.00 0.10 0.01 1
www.natinst.com
10
Signal periods
100
Phase Detection Resolution 1000.00
Phase error (mdeg)
mdeg.
100.00 10.00 1.00 0.10 0.01 1
www.natinst.com
10
Signal periods
100
Conclusions Traditional counters resolve 10 digits in one second FFT techniques can do this in much less than 100 ms Another example of 10X for test Similar improvements apply to amplitude and phase
www.natinst.com
Conclusions (Notes Page Only) Traditional Counters Resolve 10 digits in one second FFT Techniques can do this in much less than 100 ms Another example of 10X for test Similar improvements apply to Amplitude and Phase
www.natinst.com