LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to get rid of spikes of noise in a sinusoidal signal...

See attached picture (a snipet of the signal) to see what I am talking about.

 

I would like to get the index of the maximum and minimum points for every second, but these random spikes are interfering with the measurement.

I tried using the median filter vi with ranks of 5 for right and left (I tried values from 1-10, and 5 worked the best), but this has caused problems with the index calculation (the index is higher than it should be based on the graph).

 

Any ideas on a different filter I should be using? Or am I making an error with the median filter vi?

 

0 Kudos
Message 1 of 5
(4,598 Views)

You don't want a median filter. Your noise is at a so much higher frequency than your signal that you can get by with a simple low-pass filter (1-pole Butterworth in the signal processing-> filtering VI palette) with a cutoff of, say, 50 Hz. (You may have to adjust that a bit either way.) Anything more for a signal this clean is overkill. However, any filter will cause a lag of the output relative to the input (index) and you just have to figure out how much that is and compensate for it in your data analysis (it won't change from run to run, so you only have to do this once).

 

Cameron

 

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 5
(4,580 Views)

Another possibility is to use Savitsky-Golay smoothing. You can adjust the number of side points used to get the amount of smoothing you want.  This has a time shift just as any other filter does, but it is exactly the number of side points. You can pad the array or shift by the number od side points to eliminate the delay.

 

Lynn

0 Kudos
Message 3 of 5
(4,569 Views)

Okay, Lynn, you made me look it up.

 

For a low pass filter (analog), the phase shift is:

 

, where w is the filter center frequency and w(0) is the signal frequency (can't do omegas here, I guess).

 

So, for a 50 Hz filter on a 1 Hz signal (pretty much what the picture shows), the phase shift is 1.14 degrees or 3.18 milliseconds, whatever number of data points that comes out to in the sampling rate Laura121 is using.

 

I thought about a Savitsky-Golay filter, but it looked like the amount of calculating it would take would not be worth any possible advantages. YMMV.

 

Cameron

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 4 of 5
(4,559 Views)

Cameron,

 

I put together a Savitsky-Golay VI several years ago primarily because I wanted to use it for the derivatives. I have since used it several times for smoothing as well.  Agreed, it does a fair amount of number crunching, but many times that is not the limiting factor.

 

Lynn

0 Kudos
Message 5 of 5
(4,552 Views)