02-05-2016 08:24 AM
I was trying to test the ability of the single tone vi to extract the amplitude and phase of a sine wave and so created the simple vi attached. The phase resolution is impressive - better than 1 part in 10^5 with the parameters I was using. However the amplitude measurement isn't close to the input. I generated the input waveform as a 100 Hz phase shifted sine wave with 5000 points sampled at 500kHz (i.e. one wave length at the highest input speed of my hardware)
I read that the single tone vi implements an FFT so tried changing the input to a sampling frequency of 409.6 kHz and a sample fo 4096 points (i.e. a power of 2). This didn't do any better. For the application I have in mind, I need to extract the amplitude and phase to very high precision. What do I need to do to get this vi to measure the amplitude (much) more accurately?
Since I know the frequency of the response, it might make more sense to do this by quadrature (i.e. multiply the input by a sine wave and a cosine wave and integrate the two to give me the in-phase and out-of-phase components. Does anyone have suggestions about the best way to achieve the highest accuracy measurement of a known frequency waveform?
02-05-2016 09:12 AM
As you said, in my opinion, the lock-in technique (in quadrature) should be the best way to achieve the highest accuracy.
02-05-2016 10:45 AM
Not sure if I am 100% correct, but here is what I believe is happening. If you drill into the "Extract Single Tone from Hann Spectrum" subVI they are doing analysis around the "3 domininat BINS" to get phase and amplitude values. Your sample rate is 500kHz with 5000 samples so your BIN width is 100Hz (500kHz/5000pts). All your energy is in the first BIN with a 100Hz stimulus.There probably are NOT 3 dominant BINS to analyze.
The amplitude for 100Hz is 1.03. If you use a freuqency of 100.001Hz to move the stimulus just into the second BIN, the analyzed amplitude is 1.000000233. At 1kHz the amplitude is 1.0000000000
In my experience, it is difficult do do analysis on a single wavelength. You need to time avereage the signal (mulitple wavelengths). Is is possible to obtain more than 5000 samples and aquire data for a longer time?
BTW: I stopped looking at the NI code in the "Extract Single Tone from Hann Spectrum" in the Signal Processing pallet when I got to the block diagram with 3 nested Stacked Sequences
02-05-2016 01:23 PM
The quadrature approach works BUT you need to take the first data point and copyit to the end so that you can complete the integral of f(t)sin(wt) and f(t) cos(wt).(i.e.so that you are integrating over one complete wave length). In this test that works OK, but in a real experimental situation there is nothing to say that you have a pure tone and that f(T) = f(0) where T is the period. I may have to live with that.
02-06-2016 12:08 PM
@rossu wrote:The quadrature approach works BUT you need to take the first data point and copyit to the end so that you can complete the integral of f(t)sin(wt) and f(t) cos(wt).(i.e.so that you are integrating over one complete wave length). In this test that works OK, but in a real experimental situation there is nothing to say that you have a pure tone and that f(T) = f(0) where T is the period. I may have to live with that.
I believe copying the first point to the end (which I think means you add it to the array, making, say, an array of 100 points into an array of 101 points) is wrong! What you are effectively doing is giving double weight to the first point (which can occur at any point in the cycle). Note that when you do a continuous integral over a period, you go from 0 to T, but you have an infinite number of "points" spaced arbitrarily close together. Simulating this with a sum, if you acquire N samples over period T (sampling at N/T Hz), then your sum must be of N samples, either 1 .. N or (using Array Index notation) 0 .. N-1. It becomes a User Convention whether the zero-th sample is considered to be at Time 0 or at Time "delta-t", T/N.
Bob Schor