# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## How to do a XYZ Scanning?

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

Message 1 of 16
(4,014 Views)

## Re: How to do a XYZ Scanning?

• 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.

Message 2 of 16
(3,995 Views)

## Re: How to do a XYZ Scanning?

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".

Message 3 of 16
(3,967 Views)

## Re: How to do a XYZ Scanning?

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.

Bruce K

Not as smart as many other peepz on here....
Message 4 of 16
(3,955 Views)

## Re: How to do a XYZ Scanning?

@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

Message 5 of 16
(3,934 Views)

Mei

Message 6 of 16
(3,931 Views)

## Re: How to do a XYZ Scanning?

There are several issues I would change:

• "X(YZ) steps" should be renamed to step size, because that's what it is. You can change the ramp pattern to "ramp by delta" and wire your controls directly. No math needed.
• Due to your use of autoindexing, you need to create two copies of the ramp data which seems redundant. My method is more efficient.
• Wire the actual ramp array size to N, not some derived, potentially fractional value.
• You should twiddle the various ramps so each Z layer starts at the last xy position for efficiency. Currently, you move all the way to the origin with every new Z plane.

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! 😄

Message 7 of 16
(3,901 Views)

## Re: How to do a XYZ Scanning?

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.

Message 8 of 16
(3,882 Views)

## Re: How to do a XYZ Scanning?

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

Message 9 of 16
(3,879 Views)

## Re: How to do a XYZ Scanning?

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

Message 10 of 16
(3,859 Views)