From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-19-2018 11:04 AM
Hi all,
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?
Thanks,
Mei
Solved! Go to Solution.
03-19-2018 11:55 AM
See how far you get.
03-19-2018 01:41 PM - edited 03-19-2018 02:10 PM
Here's a very simplified version that does YX. Expanding to XYZ is trivial, just another loop and tweak boundary conditions as desired.
You would use the current X,Y(,Z) integers to index into your ramp arrays using "index array".
03-19-2018 02:25 PM
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.
03-20-2018 07:10 AM - edited 03-20-2018 07:11 AM
@altenbach wrote:
- 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.
Thanks,
Mei
03-20-2018 07:17 AM
Thanks for your kindly reply, Bruce.
Mei
03-20-2018 04:40 PM
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! 😄
03-21-2018 11:58 AM
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.
03-21-2018 12:42 PM - edited 03-21-2018 12:43 PM
Thanks, but I cannot understand this suggestion, I did not find out how to revise this one...
@altenbach
- 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.
Thanks,
Mei
03-21-2018 05:33 PM
Hi,
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.
Thanks,
Mei