LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting one period from array (array data selection)

Solved!
Go to solution

Hello. I have mass spectrometer which gives me two analog signals (can be seen on attached Data.png picture). The black one is RAMP, which represents nucleous mass number and the red one is intensity of the atom with correspond mass number (in VI I simulate it with signal generators). The data flow from spectrometer is continuous without any timing.

 

What I am trying to do is measure N samples from both analog channels and do a data proccesing with them:

1. Find and separate one measurement period

2. Convert the period points to amount of actually measured mass (eg I measure nucleous number from 1 to 20, so there will be array of 20 indexes in the end)- that I do in FOR loop

3. Take another measurement and combine with previous to do a statistical processing (not implemented in VI yet)

 

The biggest problem I seem to have is with correct separation of measurement period. I have tried use "min max" function, but there is not always global minimum and maximum at array indexes where I need to. Could you please help me with that separation? Thanks.

Download All
0 Kudos
Message 1 of 13
(2,743 Views)

Hi,

 

to detect period borders I'd suggest something along the lines of this:

Sawtooth periodes.png

 

Best regards

Florian

Message 2 of 13
(2,722 Views)

Thank you for suggestion. As I understand, the code makes differences between neighbour point values and select that ones, where differences are bigger-then (). This could work on clear sawtooth, but do you think it will work also on the "almost sawtooth" which you can see in Data.png (there is not immediate amplitude drop)?

0 Kudos
Message 3 of 13
(2,713 Views)
The question is where the actual data points are at in the black plot. Is there REALLY a downward slope or are there just two points that the plot is connecting and we see a slope due to the timescale?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 13
(2,705 Views)

There is really slope -see attached file.

 

But now I realized- there is always -10,682 at MASS part. Do you think it will be better to work with this instead of RAMP?

Somethink like: find the first "less than -9" point, go to the last <-9 point = period start. Then go find another "less than -9" point = period end.

What do you think? Is there way how to do that without much performance cost?

0 Kudos
Message 5 of 13
(2,700 Views)
If you can find a good starting point and your data is always the same length, that should be a very low cost way of dividing things up.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 13
(2,696 Views)

You are of course right about what my code does - I hadn't thought you really needed it to work for a non-perfect sawtooth.

The code can be adjusted to that however if you'd want to do (seems like you've come up with an alternative).

 

Here's how:

 

I worked with the absolute value - ditch that and detect the sign change, for example with >0 comparison.

You'll then get blocks of true and false in the boolean array. Just alter the search loop such that it alternates between finding true and false.

You'll see where to go from there.

 

Best regards

Florian

0 Kudos
Message 7 of 13
(2,689 Views)

I did a little programming and made this VI. Program goes from the left to the right part of graph (from the first to the last part of array). It firstly finds "wrong" values, then it finds the first right value (period start) and then again wrong value (period end). It uses while loops, so I gave there overflood protection in case data have no period 🙂

I tested it on square and sine- seems it works well. I am looking forward to test it with real data.

 

Meanwhile- do you see any bugs, or performance leaks, which could be repleaced with something easier to calculate? Thank you.

0 Kudos
Message 8 of 13
(2,673 Views)

Looks good.

It does what you said it does. Smiley Wink

If that is what you want youre set. It does not find the whole period though, maybe I got you wrong on this.

 

I'd remove the outer while loop - it doesn't seem to do anything useful.

 

I've reattached your vi - with cosmetic changes only.

 

Best regards

Florian

 

 

Message 9 of 13
(2,644 Views)

Thank you for revision. The final while loop is preparation for another data processing (the measurement will be done more, than once and then I combine output array results for some statistics). "Period" is wrong word you are right :), it is more likely some "measurement period" of my spectrometer.

 

There was one more bug- the number of subarrays. Instead of (+) there has to be (-). Now it gives more reliable Output result.

 

Do you think is it better to use MEAN, or MEDIAN function in for loop? I think in case of spectrometer, median will be more accurate. What is your opinion?

0 Kudos
Message 10 of 13
(2,635 Views)