I want to do a xyz scanning by a xyz stage, and wrote a vi to mimic the scanning process (without hardware part). When the scanning is starting, the stage would move to the x,y,z starting position. And the xy scan order as follows,
My vi is redundancy, but I do not know how to simplify it. Can anyone help me to optimize it?
Solved! Go to Solution.
See how far you get.
For point to point translations like that, i typically use while loops and compare the current position to the desired. It makes it easier to interrupt but you could just use a conditional terminal on the for loop. Having the points calculated prior to execution probably makes the code look a little cleaner, but is a little less intuitive looking at the diagram in my opinion. But I'd definitely use a cluster and typedef it for the scan paramters.
- Create three ramps (x, y, z) using "ramp pattern".
- Create a stack of three FOR loops, indexing into the ramps from the beginning or the end based of odd/even index [i] and N.
- Place all indicators in a location where they change, no local variables or case structures needed.
See how far you get.
Thanks, altenbach! I modified the vi as your advice, can you please help me check whether I need to revise more ? And, I want to save the scan data (3D or more dimensions array) as a .txt or . xls file. Can you give some suggestion about this? I do not know how to start it.
There are several issues I would change:
Saving the scan data as a 3D text file is supported by "array to spreadsheet string", but be aware that a typical file only has 2 dimensions. For higher dimensions, LabVIEW will insert page markers (details). Write the resulting string to file. To read it back into a 3D array, simply reverse the procedure. Of course saving all the ramp data seems redundant, because it can be recreated by saving the values of the 9 controls. The ultimate lossless compression! 😄
Another option to save the data would be a 2D array where each row contains an xyz set as three numbers.
If this file is supposed to be read by other software, you need to adapt as required.
Thanks, but I cannot understand this suggestion, I did not find out how to revise this one...
- Due to your use of autoindexing, you need to create two copies of the ramp data which seems redundant. My method is more efficient.
In my revised vi, I cannot save y,z data even I wire the y data and there exist some zero rows between each z scan, are these the page markers?? I want to process the saved data by matlab.
I changed data saving function in this version, it could save x,y,z data now. But the saving data seems strange as the follow pictures show.
The y,z data are saved in the last and extra page, and there are some zero rows after t 'array to spreadsheet string' and in the .txt file. Is it right? I will load the .txt file in matlab.