LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove DC component of dynamic data from FFT

How does one 0 out the first element (or 2) of an FFT output without disturbing the rest of the data ?  I have converted to array replaced 0 element with 0 and plotted that with the spectra at the wrong frequency.  I converted back to dynamic data with similar results.  I was going to try the extract portion and then append signals with a 0 at the beginning, but this delays the loop somehow where the time plot is not keeping up any longer. 
 
Thanks,
bob
0 Kudos
Message 1 of 12
(7,832 Views)
Hi Bob,

My guess is, is that when you are converting from DDT, you are converting to a 1D array of scalars. By doing that, you lose all the df and f0 information about your frequency domain data. All you retain is the 1D array of Y values. If you want to keep your frequency domain information, try converting your data to a single waveform, or if you are FFT-ing multiple channels at once, a 1D array of waveforms. You can then use the Get Waveform Components and Build Waveform VIs to extract and replace the first or second index of the Y-values array without affecting the df or f0. I've attached an example below that demonstrates this. Good luck!
Jarrod S.
National Instruments
0 Kudos
Message 2 of 12
(7,817 Views)
Bob,

Can you remove the DC component before calculating the FFT? A high pass filter in hardware or software or subtracting the mean from the data will significantly reduce or eliminate the zero frequency component.

Lynn
0 Kudos
Message 3 of 12
(7,810 Views)

Thanks Lynn and Jarrod.  I appreciate your suggestion lynn, but prefer to "window" the data in the frequency domain, and to disturb the spectrum as little as possible.  I can imagine that mutlipling by a matrix (mostly the identity matrix) might work as well, but I have no idea how the data is represented, from FFT output, to dynamic data, from dynamic data, etc.  I was using the FFT (peak) if the Spectra Measurements express VI and kinda thought that maybe it was just magnitude.  I have no idea what those elements are that Jarrod spoke of.  I will try Jarrod's suggestion, it should work, however it is a bit confusing how the "build waveform" can combine the orignal waveform with something else and come out with most of the original waveform, i.e. how does it know to replace the y-component as opposed to multiplyig, adding, OR'ing, etc.?  The help is not real clear on this. 

Thanks, Bob

0 Kudos
Message 4 of 12
(7,806 Views)
Bob,

The build waveform node is like a specialized cluster bundle node. If you connect the orignal waveform, all the components not explicitly changed pass through unmodified.

Lynn
0 Kudos
Message 5 of 12
(7,802 Views)

OK Lynn, things are a bit more clear now.  I see a (time domain) waveform has t0, dt, Y (data), and attributes.  I am guessing f0 and df are the frequency domain counterparts to t0 and dt - of course we need something to reference the X axis.  I am not sure what the attributes are.  Your description of the build waveform helps. 

Do you know how to set the FFT length when using the Spectral Measuements VI?  I have used the Collector express VI to collect the power of 2 samples first (it seems to work) otherwise it would seem the FFT would get bits and pieces at a time, at some point ti would have to calculate - maybe somehow based on f0, df and the x scale I have chosen??

Also, do you know if you can perform a function based on the event when a waveform chart reaches the end, i.e starts over?

Thanks, bob

0 Kudos
Message 6 of 12
(7,799 Views)

You may remove the DC component from the magnitude array. Then build a spectrum cluster with the following information: start frequency (fo), frequency resolution (df) and modified magnitude array (without DC component).

Attached is an example based on Jarrod's code. Wish it helps.

0 Kudos
Message 7 of 12
(7,794 Views)
I have done this zero out feature to reduce the effects of double integrating on an acceleration waveform to get displacement. Is this why you need this function?

Message Edited by WantToGolf on 05-24-2006 03:51 PM

0 Kudos
Message 8 of 12
(7,791 Views)

Thanks for the input.  Jarrod's suggestion is working well.  I basically just want to display a signal that has a DC bias larger than the signal and want to see/analyze the AC part of the signal.  The other thing is that the signal could have a large component at 1Hz and we want to see this along with the other frequency content to 100Hz.  When input a 1Hz sine wave, I see the DC component (bias) of the FFT plot actually move up and down with the wave, as well as interfere with the 1Hz.  Maybe I have not got everything quit right with respect to FFT length, samping, etc, but we just do not want to see the signal without the bias. 

Thanks. bob

0 Kudos
Message 9 of 12
(7,778 Views)
Bob,

If you are seeing it "move up and down with the" sine wave, you are not giving the FFT enough data to adequately detect the 1 Hz. From the Help file for the FFT the resolution df = fs/N, where fs is the sampling frequency and N is the number of samples. The first element of the FFT output, Y[0] is the DC component. The second element y[1] is the frequency bin centered at df. If your sample rate is 1000 samples per second and you take 1000 samples, then df = 1 Hz. With real signals and noise it will be difficult to resolve your 1 Hz signal. FFTs also do not work well until the input array contains several cycles of the lowest frequency signal to be measured. I would want about 10 seconds of data to see the 1 Hz signal well. You can "cheat" a bit by padding the signal with zeros to extend the array and improve the resolution. You don't get something for nothing. You have more processing time and less signal energy in the input array.

Lynn
Message 10 of 12
(7,767 Views)