# Calculating THD where peaks are not exact harmonics

I have captured an FFT of a 1 kHz signal that I am generating using a WM8904 codec running at 48k samples/second connected via I2S to a ARM microcontroller (Atmel SAME70). It appears to have some jitter in it, which I believe is due to a small delay in restarting the DMA after each block (which I know how to fix, but I was more interested at this point in the particulars of taking this measurement). I am using a Agilent MSO7054B to make the measurements. The fundatmental is clearly visible at 1.0 kHz. But the next peak is at 2.1 kHz, not 2.0; the one after that at 3.2 kHz, etc. Is that due to the jitter?

Can I still use those peaks to calculate a THD value? When doing so, I got a value of 4.12%. Does that seem reasonable?

• How many points N in the FFT? I see the sample rate Fs = 111 kHz. The reason I ask is that if N is small enough, i.e. N = 1024, the frequency resolution will be Fs/N = 108.4 Hz, which could explain your errors. Jul 26, 2018 at 20:25
• @CarlosDanger The only control I have over that is the "span" figure, which I do have set at 10 kHz. If I increase that (to 20 or 50 kHz), the peaks do seem to move left relative to the frequency grid, although it gets harder to read since the scale changes. So can I use these peaks as shown to compute a valid THD? Jul 26, 2018 at 20:50
• If you put in a triangle wave, do the harmonica appear where they are supposed to?
– user28715
Jul 27, 2018 at 0:59
• I don't believe that's a jitter at all. More like a noise.
– jojeck
Jul 27, 2018 at 9:12

In that case, the frequency bin spacing is $\frac{f_{sample}}{256}=\frac{111\,\text{kHz}}{256}\approx433.6\,\text{Hz}$; that explains why you see an "unsharp" peak for your fundamental, and why your harmonics don't happen to land in exact multiples of where you presume they should be. (The wide peak is just leakage in action – oscillations that don't fit in one DFT window of observation leak energy in multiple DFT bins.)