10-06-2008 09:47 AM
Dear all,
Thanks for taking the time to read my post.
I have a question related to the Amplitude and spectrum.vi.
I am using LV8.0 on a Pentium D 3.4Ghz Win XP machine.
I am acquiring time domain data via a PIC and displaying it using LV on my PC monitor.
I am also performing an FFT using the attached VI.
The waveforms you see below have been acquired (/saved in excel format) using LV.
The two waveforms show the same signal, one the time domain and the other in the frequency domain.
NO input voltage was applied on the time domain waveform you see i.e. the waveform shows dc offset/noise of the ADC input/acquiring front end.
The problem I am having, is that the actual dc offset one measures ‘by eye’ on the time domain signal is smaller to what is computed by my FFT function. This difference, I am almost certain, is exactly Ö2.
I am pretty confident that my FFT function is wrong and that the dc component should not be multiplied by Ö2. I do not quite understand, though why this is the case?
I would be grateful if someone could look through my VI and make some comments constructive comments on it.
Is my understanding wrong, for the Amplitude and Spectrum VI? Shouldn’t all component (from DC to Fsampling/2) be multiplied by Ö2 or NOT?
Does my problem potentially lie somewhere else maybe?
Regards
Alex
10-06-2008 10:15 AM
The message did not come out very well. The part in question meant Sqrt(2). Multiplication by Sqrt(2) is done so that the peak value can found.
Regards
Alex
10-06-2008 10:23 AM
Alex,
It is helpful for questions related to data if you include some data. Run your VI so that data like that shown in your graphs is in "Input Array" and the "Make Current Values Default" and save the VI.
Why not eliminate the DC offset before you do the spectrum analysis? It appears that you are trying to get rid of it later anyway. To eliminate it simply subtract the mean from the Input Array before feeding it to the spectrum VI.
The RMS value of a DC signal is equal to its DC value. For a sine wave the peak value is sqrt(2) times the RMS value. If you look inside the Amplitude and Phase Spectrum.vi diagram, you will find that it multiplies the magnitude of the spectrum by sqrt(2) except for the first point (the DC component). So you should not need to multiply it again in your VI.
Lynn
10-06-2008 10:24 AM
I have seen this before and the way this error was removed in my scenario was putting more points through the FFT. I needed something like 1200 samples to get a decent FFT and the correct DC Voltage Offset. A quick (and ugly) way to check would be to just concatonate your existing data a few times over to get a larger sample then FFT it.
Hope it works for you!
Craig
10-06-2008 11:04 AM
Thanks for you replies.
I have changed my function so that it does not multiply the DC component by sqrt(2).
To answer Lynn first. I would like to add (as the offset is negative) this dc offset compensation programmatically in the PIC itself before transmitting the data, as in my opinion this is much easier, as long as you know excactly what the DC offset is. This is why I am measuring my input without a signal applied to it. To figure out what dc offset I get.
Craig, I am not certain my dc offset problem is due to the sampling speed of my signal. For the record, I am sampling at 20kHz, thus i get a signal with a frequency content of 10kHz. The dc offset problem is something inherent in the Op-amp (which comes before the ADC and acts as an impedance isolator) and the ADC itself.
I think my mistake was that I misunderstood the Amplitude and Phase VI ans should NOT have multiplied the DC component by sqrt(2).
Regards
Alex
10-06-2008 11:44 AM
Alex,
Anytime you have a question about the behavior of a VI that is not answered by the help files, it is often useful to open the diagram and look inside. Most NI VIs are accessible.
Remember that if you want to change a VI that is in the vi.lib or an example, you should make a copy under a different name first so that other programs which may call that library VI do not get changed as a result.
Lynn
10-06-2008 12:03 PM
Alex,
How stable is the DC offset? If the transducer or the op amp is subject to temperature changes while in operation the offset may change. Unless you have some way of programmatically disconnecting the signal source from time to time, subtracting a fixed offset may reduce the offset, but not eliminate it completely. And it may not be feasible to remove the input to the transducer.
Removing the mean from each data segment eliminates the offset for that segment. As long as the segments are short compared to the offset drift rate this works well and can adapt to long term changes in the offset without any action by the user.
If you can modify the circuitry ahead of the ADC to eliminate the offset before it is converted that is often the best. If you do not need the DC component and the lowest frequency components a simple capacitor coupling might be sufficient. Since you are sampling at 20 kHz and dropping the first spectral elements, it seem that this might be a reasonable approach.
Lynn