LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine wave analysis

Hi all,

I am looking to get some feedback on how to analyze a sine wave in Labview. I have done lots of reading on the topic, but not really sure what I have seen will work. I hate to ask these questions even though I do not have labview yet (should be here next week), but I am on a very tight timeframe and need to figure this as soon as possible.

What I want to do is analyze a sine wave that I read in on my M series DAQ. The sine wave will actually be the analog output of a DMM connected to a probe measuring field strength on a magnet. There will be one period for each pole pair (North and South). Mechanically everything is done. The probe will not move at a constant speed, however, there is a high resolution encoder that will also be read. This encoder could either feed a counter, then a counter value read (giving the position, measured in counts but a simple calculation converts this to degrees). My other option is to connect the encoder output to a clock that triggers reading the analog (probe measure). That would mean I take measurements from the probe at equal increments, and this is how I would prefer to do it.

So all of that I think I have down pretty well, and will be able to do fine, but if anyone has any alternate ideas, please feel free to share them.

My real question involves analyzing this wave. The two biggest things I want to measure are peak values (all of them), and zero crossing locations (all of them). Then, for both peaks and zero crossings, I want to do some basic statistics (min, max, mean, stdev, etc.). Hopefully I will be able to do much more analysis in the future, but this will be enough to start with first. If anyone, however, has any ideas on other wave analyses that I could do, I would love to hear them.

The zero crossing posts and examples I have seen before for labview seem to measure by tracing the waves path, then finding if it rises or falls at the zero point. My problem arises if I have noise and two or more zero crossings forming around the same point as a result. zcerror.jpg (attached) should help demonstrate what I mean. In the picture the problem is grossly exaggerated, but its just to get the point across, my data should not look that bad.

What should my approach be? Is there something I can do to clean that noise up enough, or should I find every zero crossing then come up with an algorithm to get rid of extras? If I clean up the noise, I will be distorting my original data, will it have bad effects on the position of the zero crossing? A lot of that Ill be able to know better once the software arrives, but if anyone has any experience this or other similar projects I would really appreciate whatever you can share.

Thank you

Garrett

0 Kudos
Message 1 of 7
(4,109 Views)
Garrett,

LabVIEW has some peak detection VIs so that should be easy.

The zero crossing can be handled several ways. Filters may take out the noise but they will add delay and phase shift to the signal. If the frequency is constant or varies only a small amount, compensating may be fairly simple. If the noise amplitude is small near the zero crossings, try looking at several points either side of the zero. Approximate a segment of the sine as a straight line (using regression techniques) and find the intersection of the line with the X-axis.

Looking at all the zero crossings might work, too, depending what the noise is really like. It is very difficult to determine what the best signal proceesing method will be without knowing more about the data.

Lynn
0 Kudos
Message 2 of 7
(4,103 Views)

Thanks for the reply!

 

"If the noise amplitude is small near the zero crossings, try looking at several points either side of the zero. Approximate a segment of the sine as a straight line (using regression techniques) and find the intersection of the line with the X-axis."

How would I know when to start and stop the linear regression?  If I started or stopped them at the wrong time, I could get two lines right near each other that both cross the x axis.

0 Kudos
Message 3 of 7
(4,101 Views)
Garrett,

Find the positive and negative peaks first. Then take the middle third of the segment between the peaks. This will be +/-30 degrees so there will be some curvature, but the positive and negative curvature should cancel out. This should give you enough data points so that the noise effects are minimized. The value "third" is not magic. Adjust to suit your needs.

Lynn
0 Kudos
Message 4 of 7
(4,096 Views)
You can also sum up the points as you take them (integrate).  The peak values should occur at the falling zero crossings and the minimum values should occur at the rising zero crossings.  This should be more immune to noise that a direct zero crossing measurement.
Randall Pursley
0 Kudos
Message 5 of 7
(4,094 Views)
Once you've identified the peaks & valleys, you may want to consider applying a median filter to the +/- ~30 deg region that Lynn mentioned.  The median filter  is nonlinear in nature and can be used to clean up random-ish noise without introducing phase shift.  It seems like it might be useful for your example.
 
It'll also be helpful if you have some way to characterize the nature of the "noise."  Is it likely to be some sort of random distribution?  Or is it more in the nature of harmonic distortion (the true response may be a summation of the fundamental sine wave frequency plus attenuated higher harmonics)?
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 7
(4,085 Views)

Thanks for the input.  Using the middle third of data between peaks is an excellent idea.  I suppose I would set up a loop so that I could test twice for each period?  I am worried, however, that I will have the same problem at the peaks, so I cant always count on them.  I will have to look at the peak detector in labview to see how well it works, though.

The noise I am getting is line noise, quite random.  It comes from other equipment in this facility and I have done all I can in electrically to get rid of it.

 

Thanks all.

0 Kudos
Message 7 of 7
(4,080 Views)