From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation of relative position from dynamic data

I have developed this code for plotting the voltage from the PSD(Position Sensitive detector) in terms of position in LabVIEW. It gives me the exact map of the position of the LASER beam on the PSD, on the graph in LabVIEW.

 

Now what I need to do is calculate out the relative displacement between two positions of the spot. Suppose at time t1 the position is at A(x1,y1) and then at time t2 it moves to B(x2,y2). I know the mathematical formula for the displacement from A to B.

 

But my problem is how do I get the values of (x2,y2) and the previous position value of (x1,y1) dynamically. I need to do this continously al long as the experiment gos on and then also save it.

 

Thank You for the help.

0 Kudos
Message 1 of 8
(2,740 Views)

Sounds like a good time for shift registers 🙂

 

How about something like this:

 

 

Compare the current (X,Y) coordinates to the (X,Y) coordinates of the previous iteration.

Then you can build an array of the displacements for each iteration.

That array could make for a nice graph for you: displacement vs time.

 

Also, just a quick comment on your code:

- you use a lot of dynamic data/signals, this isnt neccessary. You could do the same thing without using the Express VI's, since those are the functions creating that data output.

For example, note, in my VI, I used a Formula node instead of an Express VI for a formula. This allows me to pass data types such as DBL, SGL, I32, etc instead of dynamic data.

Message Edited by Cory K on 03-26-2009 11:40 AM
Cory K
Message 2 of 8
(2,736 Views)
Thank You for the reply Sir, but the problem is how do i compare the values of x,y. I am not able to extract the vales from the graph/array for 2 consequtive times.
0 Kudos
Message 3 of 8
(2,709 Views)

Burhanuddin wrote:
Thank You for the reply Sir, but the problem is how do i compare the values of x,y. I am not able to extract the vales from the graph/array for 2 consequtive times.

 

After you use the 'Split signal' function, right after your 'DAQ Assistant', you should have a signal of X values, and one of Y values.

Convert each of these signals to type DBL. They should now be 1D arrays of type DBL.

Then, you can do the following, since For Loops auto-index:

 

Edit: In my example, I switched the X and Y inputs Smiley Surprised,
however, in this circumstance, it doesnt matter for the formula used.
Either way, in your VI you could correct that if you want.
Message Edited by Cory K on 03-27-2009 11:56 AM
Cory K
0 Kudos
Message 4 of 8
(2,704 Views)

Sir, I think I did not explain correctly.

 

My x and Y values come after the formula blocks. One formula blocks gives X and one gives Y. so at a certain time we get x1,y1 and then at the next moment we get x2,y2. now with these values I need to find the displacement, using the same formula and continously.

 

Thank you

0 Kudos
Message 5 of 8
(2,697 Views)

In your attached VI, what is the output of this:

I thought it was an array of x values, or y values.

Is it an array, with only a single point in it?

 

If so, you will need to build an array of these values.
I can show you what to from there if this is the case.

Message Edited by Cory K on 03-27-2009 12:13 PM
Cory K
0 Kudos
Message 6 of 8
(2,692 Views)

the output of that is an array of the points (x,y), then after that I am seperating the x values and y values and then plotting x v/s y for all the corresponding x and y.

 

Now what I need to do is that, as the position keeps on changing the (x,y) will also change. I will have an initial position which is constant. With every change I need to measure the displacement of the new (x,y) from the constant original point. Then  I have to save these displacement result.

 

Thank you.

 

0 Kudos
Message 7 of 8
(2,679 Views)

Then why does my solution in the first post not work?
After you use 'Index Array':

- replace where I said 'xval' with your 0 index

- replace where I said 'yval' with your 1 index

 

The rest should work fine.

Cory K
0 Kudos
Message 8 of 8
(2,670 Views)