I am currenly working on a measurement driver for the DMM Keithley 7510. I implemented a harmonics measurement using FFT (from MathNet library).
First I simply sample my input voltage signal and apply the FFT. From the complex values I get the amplitudes and the phases of the harmonics. The phase results are the phases relative to the fundamental.
I verified my implementations for the amplitude and phase measurement functions by feeding the functions with an "ideal" signal - a sine signal with harmonics generated in MATLAB.
The amplitude measurement works perfectly fine, but I have huge problems with the phase.
Firstly, with higher frequencies, the deviation of the phase increases. This is due to the input characteristics of the DMM, which is not the main problem. I did my measurements mainy at 50Hz.
Secondly, the phase depends on the number of samples. I did not analyze this too much, because I have a fixed sample rate for my measurement driver.
Now the main problem: there seems to be a correlation between the phase and the amplitudes of the harmonics (including the fundamental). This means that by changing the amplitude of a harmonic, the phase results change for all the harmonics. For instance an increase does not necessarily mean an increase in phase: for some harmonics, the phase increases while for others it decreases. I could not find any reasonable explanation for this behaviour.
I tried many different ways to solve the phase problem:
Windowing: I thought, that it might somehow help. Unfortunately, I found pretty much no sources on the effect of windows on the phase measurement.
Power of 2 for FFT: I have a power of 2 number of samples on which I apply the FFT.
DFT: I also tried to apply DFT and calculate the complex value at exactly the frequecies where I wanted. There is as good as no difference between FFT results and DFT results.
Amplitude interpolation: I found a paper where I found I formula for the amplitude interpolation. By finding the peak amplitude in the frequency domain, I calculated the corresponding phase, but no success. Here I later found, that at the peak amplitude of a harmonic in the frequency domain, the corresponding phase is not the expected/ideal phase. This is also something, that I could not understand ...
My question now is whether I forgot any other things I should check for. Are there any parameters that I should be careful about when computing the phase?
Any suggestions what I could do next?