LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determining changing wave base value

I am using a magnetometer to detect magnets in pavement. I test these magnets by driving over them with my sensor. The resulting wave has lots of peaks where it found magnets. To determine the exact amplitude of the peak, I need to know what the value of the sensor would have been on that particular time if there wasn't any magnet at all. this is the "local base value." It is dependent on the earth magnetic field and changes in value as the heading and position of my vehicle changes. I have found a way to detect the peaks in the wave (find peaks.vi) and I could then recalculate the amplitude of the peaks by finding the value exactly between peaks. This is a little cumbersome, though. I think there may be much smarter wa
ys to solve this. Does anyone have a suggestion?
the attached file is an example 1d array waveform. in this file the base value doesn't change at all, but in reality it would. what I am looking for is to know what the "local" base value is in any location in the wave
Thanks!
AJ
Download All
0 Kudos
Message 1 of 6
(2,980 Views)
You won't be able to use the EASY VIs to do this - you're asking for too much intelligence for that. You'll have to do some work yourself.

You need to go thru each point in a loop.

Keep a BaseLine[] array of the latest N points ( judging from your data, try N = 200 or so).

Define a threshold T (0.1, I guess) - more than this above the baseline starts a peak.

Set Base = Data[0]

Initialize array BaseLine[] = N seroes

PeakInProgress = false

For each point Data[i]:
  If Data[i] < Base + T
    If PeakInProgress
      Store (PeakSoFar - Base) in Peak array
      Store IndexOfPeak in IndexOfPeak array
      PeakInPro
gress = false
    BaseLine[IndexOfOldest] = Data[i]
    IndexOfOldest = (IndexOfOldest + 1 ) mod N
    Base = Average (BaseLine[] )
    PeakSoFar = Data[i]
  else
    if Data[i] > PeakSoFar
      PeakSoFar = Data[i]
      IndexOfPeak = i

The idea is that you track the baseline by the average of the last 200 (or whatever) points.

When the signal goes above the threshold, don't use it to calc the baseline any more.

While it's above the threshold, track the peak value.

When it comes below the threshold again, store the peak value - baseline somewhere. If you need to, store the index of the peak as well.

Hope that helps.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 6
(2,980 Views)
Hi CoastalMianeBird!

Have you concidered applying to be an Enthusiast?

You answers have been well thought out and they have demonstrated that you have a good understinding of LV and software development in general.

Once you register as an Enthusiast, other readers on this forum can subscribe to your answers. Without this subscription, we can only learn from your postings if if we just happen to look at a Q that you answered.

I think you are a "shoe in".

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 6
(2,980 Views)
Yes I have, but I'm busier than a one-legged man in a b*tt-kicking contest these days, and didn't want to fill out the profile stuff just yet.

Thanks for your kind words.

Been doing LabVIEW since version 1.2 in 1989.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 6
(2,980 Views)
Since 1.2!

You can always edit your profile whenever you want.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 6
(2,980 Views)
thanks for your detailed answer. here's my solution. It's a bit different, but it works beautifully.
aartjan
0 Kudos
Message 6 of 6
(2,980 Views)