LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building 2D Array of X,Y positions

I am trying to build an array of x,y data.  What I have is X&Y min/max values from a graph that is controlling an XY table with 1" range.  The graphs scales are travel - e.g. .2" to .5" - I translate the XY to positional counts and I can control the position of the table by dragging the cursor.  Now I need to create a SCAN function .vi - take the min/max of both axes and create and array of X,Y values.  In the attachment I just created min/max controls to simulate.

 

So knowing the range of X&Y, plus the step value, its easy to determine the number of X,Y positions needed for the scan.  I just can't figure out how to wire the FOR LOOPS to get the array 😛

 

In the example, I know I need 100 X,Y pairs (based on the min/max values and step value).  The Y's will repeat every 10 iterations, and X will increment once every 10 iterations.  Can someone show me how to wire this?

 

In the main .vi I will check if a timer has expired (time per step) and read the next pair of X,Y values and move the table; wait, repeat...

 

Many thanks!!!

Steve

0 Kudos
Message 1 of 4
(2,852 Views)

Put the X & Y values into a cluster, then create a 2D array of clusters.

Message 2 of 4
(2,847 Views)

Your current code makes very little sense overall, but at least try not to abuse local variables. None of the controls change during the execution of the FOR loops, so there is no need to constanty re-read the controls via local variables. Just wire straight from the control and eliminate the middleman. 😉

 

Anyway, LabVIEW has "ramp pattern" that allow you to create the basic ramp. All you need to do is assemble then in a stack of two FOR loops, each autoindexing over one dimension. Here's a very quick rewrite. Modfy as needed.

 

Persnally, I would probably use a 1D array of complex datatype, keeping it even simpler. 😉 A complex scalar can easily keep an xy pair. (not shown)

 

 

Message 3 of 4
(2,822 Views)

Thanks! Didn't know about the "ramp" will look it up.  I'm still in Core2 learning curve - would have never figured out that solution!

0 Kudos
Message 4 of 4
(2,808 Views)