LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

average time domain signal with fft

Hello,

 

I am having a couple of problems trying to average a time domain signal using a power spectrum vi and then going back to the time domain using the inverse FFT.

 

First let me start by describing what I am trying to accomplish. I have a PXI 5114 high speed digitizer and a Panametrics Pulser/Receiver. I am sending the pulse to the device and then reading the echo through channel 0 of the oscilloscope. I use a producer/consumer loop to pass the data. The problem that comes up is that the time domain signal fluctuates quite a bit. I need to take an average of this signal to plot on the front panel. I have tried a running average (bypassed for the moment) but this takes entirely too long for the averages to show on the graph. At the same time I am getting the power spectrum of the signal and using some averaging. I would like to take the signal after the power spectrum and averaging and go back to the time domain (hopefully a much smoother signal).

 

I am attaching the vi so that you can see some of the things I have tried to implement ( the running average using the case structures at the top of the producer loop and the FFT real-imaginary vi and then the IFFT).

 

I would appreciate any help that can be offered. Thank you.

 

 

0 Kudos
Message 1 of 11
(6,338 Views)

I can't look at your code right now but a couple of thoughts occur to me.

 

1) How many averages do you want to do?

 

2) Would it be possible to average in time on the 5114 instead?  Might be a bit tough with the triggering, but I thought I would ask.  If you can do that, you might not need the FFT at all.

 

3) Is the fluctuation due to noise or does it only happen at particular frequencies?  Perhaps a filter would be better.

 

Just some ideas....

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 2 of 11
(6,318 Views)

Thank you for your reply.

 

1.) I would like to do somewhere in the neighborhood of 20 to 30 averages. Just enough to get the jitter out of the waveform.

2.) It is possible to do the averaging using the 5114 but when the waveform is moved in time, the new averaged waveform takes quite some time to display.

3.) The fluctuation may be partly due to noise but I think it may also be due to triggering. I am not so  sure exactly where it is coming from but I will try the filter this morning.

 

As far as the FFT, it is needed for the application so I thought since I have to do it why not use it for averaging also. I would really like to know how to go from the power spectrum output back to the time domain, if possible.

 

Thanks again for your help.

 

Giles

0 Kudos
Message 3 of 11
(6,296 Views)

Hi Giles,

 

I am not able to run your VI since I do not have the hardware, but what is going wrong with doing an inverse FFT after averaging the data? I would think that this would be the only way to go from power spectrum to time domain.

 

Regards,

 

Stephen S.

National Instruments
Applications Engineering
0 Kudos
Message 4 of 11
(6,269 Views)

Hey Stephen, thank you for your reply. The main problem is that I can not figure out how to go from the power spectrum data to an inverse fft. The power spectrum has a cluster of three elements that are not complex and the IFFT requires complex data. I have tried to do the conversion without any success. The amplitude comes out wrong as well as the timing. Could you possibly go over how to go from spectrum back to time domain? Thank you,

 

Giles

 

Also I could post the waveform as a constant if that would help.

0 Kudos
Message 5 of 11
(6,255 Views)

Hi, Giles.

 

The power spectrum is not invertible. It preserves only magnitude information, and throws away phase information. Unfortunately that phase information is essential to represent the time information. You can take a normal FFT, which produces complex spectrum data, and invert that to get back to the time domain, but averaging the complex spectra and inverting the result would be the same as averaging the time domain data in the first place.

 

I'm not completely clear on what you're trying to do, but if you're triggering on signal information, the most practical thing to do would be to average the acquisitions as ensembles, such that the result is a time domain waveform with the noise averaged away. That's what I do when I want to recover a noisy signal that I can trigger on.

 

Hope this helps,

Ed

 

0 Kudos
Message 6 of 11
(6,236 Views)

Thank you Ed. That makes a lot  of sense. and was extremely helpful.

 

So can you describe what you mean by averaging ensembles. I have, in the VI, two case structures that are meant to average the time domain signal, however the averaging takes too long. This method of averaging just averages one waveform with the previous. I would like to know how to implement a faster more effiecient way. Please!!!!

 

Thank you,

Giles 

0 Kudos
Message 7 of 11
(6,221 Views)

Hi, Giles.

 

By ensemble averaging, I mean averaging the time-domain waveform point-by-point.

 

I've attached an example VI. In it I create a noisy sine wave by adding a sine wave to some Gaussian noise. This simulates a situation where you might be trying to digitize the sine wave in the presence of noise and have a reliable trigger. If you leave the number of acquisitions set at the default value of 1, then you'll see the raw acquired waveform, noise and all. If you set it to a higher number, the loop will run that many times, and the acquisitions will be accumulated one by one and then averaged after the loop. Here, the sine amplitude is set at a peak value of 1 and the noise has a standard deviation of 1. With one acquisition, the sine is fairly obscured by the noise. However, if you average 1000 cycles, the noise is almost eliminated.

 

The key is having a good trigger. If your waveform isn't nearly this noisy, you should be able to trigger fairly reliably on your waveform. On the other hand, if your signal is buried in noise, triggering may be a problem. The solution would likely depend on the nature of your signals. A virtual lock-in amplifier might be appropriate. 

 

Hope this helps,

Ed

 


0 Kudos
Message 8 of 11
(6,204 Views)

Thank you for your help. I have implemented the ensemble averaging and it does work, As long as I average less than say 20 waveforms the response is relatively quick. However if I want to average more than 20, the response is very slow and any movement of the waveform in time does not show up for a few seconds. How can I get around that:? Any ideas?

 

Thank you,

Giles

0 Kudos
Message 9 of 11
(6,160 Views)

Hi, Giles.

 

Well, without more information about the nature of the signals and the noise, it's going to be hard to improve on the suggestion of averaging. Can you post a few images of the kinds of fluctuations you're seeing?

 

Also, I suppose you've already tried to remedy the source of the noise.

 

Ed

 

0 Kudos
Message 10 of 11
(6,149 Views)