12-02-2013 03:05 AM
Hello,
I would like to know, wheather my solution is efficient, or it can be done in a better way.
I have a mass spectrometer with a shipped labview driver and example VIs.
I want to modify one of the VI. Here the used structure of the spectrum is a kind of waveform cluster. I have attached a non funcional only-test VI, to show it. For data evaluation, I need to use XY-data pairs, so I need to create X,Y arrays from this cluster type. The size of the arrays are in the order of 10 thousends... Just in case, I will use a queue wire to do the data evaluation (consumer loop) independent of the producer loop (about 0.5 Hz data production, so every 2 sec I get a new spectrum from the MS driver).
So my question is that, is there a better way to create the XY arrays from that cluster type? Depending on the data size, in my experiance, this can be a bit slow...?
Thanks for advice!
dropbox link: (the discussion forum is not able to upload my VI... 😞 )
https://dl.dropboxusercontent.com/u/8148153/test1.vi
Solved! Go to Solution.
12-02-2013 05:18 AM
There is slight room for improvement according to me.
12-02-2013 05:47 AM
In LV 2013 I think the solution proposed would be OK but in earlier versions you're always better off allocating the full array to begin with and replace instead of using the autoindexing of a for-loop. The reason for the LabVIEW version dependence is that exactly this operation has been greatly optimised by the compiler in LV 2013.
Shane
12-02-2013 06:12 AM
Recently I have LV2013 for the project, so I guess I just keep it as it is.
But thanks for the info, I will keep in mind this difference when I have to deal with pre-2013 systems...
regards,
12-02-2013 06:16 AM
And to quote Altenbach before he writes it, the loop can be replaced with a Ramp-function. 🙂
(Whether that preallocates the array i dont know)
/Y
12-02-2013 06:18 AM
could you show an example? I do not know this "ramp function"...
12-02-2013 06:27 AM
See attached snippet.
/Y
12-02-2013 06:33 AM
thanks! it is also useful 🙂
12-02-2013 06:48 AM
I agree with the ramp function being a bit more efficient, but I am not sure about replacing array subset for building sequential numbers. I would be interested to learn if it was otherwise.
The following post seems (I agree is old) seems to back up my understanding. I also did a quick benchmark and it seems to back my belief
http://forums.ni.com/t5/LabVIEW/create-an-array-of-consecutive-integers/td-p/127751
12-02-2013 07:13 AM
I need to make a quick correction to my earlier post:
I was thinking of conditional indexing when I mentioned the difference between LV Versions. This kind of unconditional indexing has been pretty efficient for some time now. I wouldn't bother replacing it with a ramp VI. I would just leave it as it is to be honest. It's clear for any programmer what's going on.
Shane.