LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I measure the level of a flat region in an anlog signal

Hi.

 

I am continuously acquiring a signal from an LVDT.  The sensor tracks the position of a component which is subjected to an impact. A sketch of the signal is shown in the attached .gif

 

The amplitude of the signal depends on the position of the sample and this continually varies (i.e. the whole waveform continually, and non periodically, alters it's 'y' position). I wish to be able to continuously 'zero' the signal by calculating the amplitude of the flat regions and subtracting this from the original signal.

 

The attached vi uses differentiation to detect the flat (within tolerances) regions.  Each time a flat region is detected, the waveform amplitude is collected.  The vi works but occsionally dectects flat regions in the spikes which upsets my measurements and feedback loops.

 

Does anyone have any idea how I can ensure that the flat regions detected by my vi are actual flat regions and not peaks (or valleys) in the waveform?

 

Any help would be great.

 

Many thanks

 

John

 

LabVIEW 8.6, windows XP.

Download All
0 Kudos
Message 1 of 19
(3,948 Views)

I couldn't open your vi since I only have 8.5 on my machine right now.  I would suggest doing a running average of the differential from the last n samples.  You may have to experiment with 'n', but that should help your program ignore the non-flat areas.  Basically, by using averaging, you are looking for a 'long' flat spot, not a short flat spot.

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 2 of 19
(3,938 Views)

vt92

 

I have attached a screenshot of my vi and the vi saves as version 8.5 format. I'll try your suggestions in a minute.

 

Many thanks!

 

John

Download All
0 Kudos
Message 3 of 19
(3,934 Views)
How do you suggest I code a running average. I have tried averaging the zero reading from my vi but it still occasionaly produces erroneous values.
0 Kudos
Message 4 of 19
(3,920 Views)

Drop this vi in your code. (wire the mean result into your 'in range' function)  It uses an uninitialized shift register to hold and average the last 30 measurements.  You can customize it for your app.

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 5 of 19
(3,916 Views)
OK, thanks for that. When I run your 'moving average' vi, it outputs 'NaN' whatever I wire to its input. Any ideas? The upper loop retains '#0' if i probe it while it's running.
0 Kudos
Message 6 of 19
(3,900 Views)
Aha, in your vi you have to click reset to get it to work.
0 Kudos
Message 7 of 19
(3,898 Views)

Hi. I tried your suggestion and I could not get it to work well. In fact it worked better without the running average (which suprised me). I also played with the number of data points but still could not get it to work well.

 

Do you have any other suggestions on how I could sort this problem out?

 

I have attached a screen shot of the signal. To recap, I'm trying to measure the'y' position of the flat regions of the signal. The signal does not have a constant level, so this 'y' position varies with time in a non-unform manner.

 

I am currently differentiating the signal and selecting the y position when the differential is equal to zero (within a tolerance band).

 

In the screenshot, the signal has been zeroed using the method I have described above. However, it occasionally has glitches which may be caused when the code picks up a zero gradient at a peak or valley in the signal.

 

I therefore need some kind of algorithm that only measures the position of the flat regions.

 

Many thanks

 

John
0 Kudos
Message 8 of 19
(3,857 Views)

I'm guessing this has to happen live, not after the signal has been fully collected?  I do a lot of post-process signal analysis in Maltab and things like this are far simpler if you have the whole waveform to analyze.

 

Assuming that you need this in semi realtime...

  • If the signal is generally repeating and the flat spots are toward the middle, I would use min and max values to help locate true flat spots.  "(max-min)/2 + min" is a theoretical center point for your data.  For example, you could restrict the search for flat regions to the center 50% of the actual range.
  • Try a running average of the signal deltas.  Effectively you are differentiating the signal, then applying a moving average.  The moving average window size will determine how quickly your routine reacts to a detected flat section.  Smaller windows may pick up false flat spot, longer windows will take longer to identify a true flat section.

You could also mix the 2 solutions together.  I've found that my event detection routines are much more resilient if I can identify multiple "features" that constitute a real event such as "flat section".

 

0 Kudos
Message 9 of 19
(3,848 Views)

Another idea:  If the data spends a significant fraction of the time in a "flat area", a running median value waveform (Median PtByPt.vi) or mode (Mode PtByPt.vi) alongside the real waveform could be used as a potential window (i.e. a rule that states the flat section shall not be more than 20% of the range (max-min) from the indicated median value).

 

Your solution may depend on how much available horsepower you've got.

0 Kudos
Message 10 of 19
(3,845 Views)