07-01-2014 05:17 AM - edited 07-01-2014 05:21 AM
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.
Solved! Go to Solution.
07-01-2014 06:04 AM
Hi,
to detect period borders I'd suggest something along the lines of this:
Best regards
Florian
07-01-2014 07:41 AM
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)?
07-01-2014 07:57 AM
07-01-2014 08:07 AM - edited 07-01-2014 08:16 AM
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?
07-01-2014 08:27 AM
07-01-2014 08:49 AM
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
07-01-2014 12:01 PM
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.
07-02-2014 03:11 AM
Looks good.
It does what you said it does.
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
07-02-2014 04:28 AM
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?