LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get cursor positions as usable variables in graphs

Solved!
Go to solution

Hi,

I am using graphs to plot friction coefficient data. I would likw to know how to get the cursor position points as usable variables for further calculations within the program. MicrosoftTeams-image.png

the picture shows what i have in the program now. I used property node to get the position points of Cursor 1 as highlighted in yellow, but i don't see a property to get the position points of cursor 0, in this case circled in red, in a usable form. I might have gone totally missed seeing if there is one at all, but anyways hope i get some help with this.

Cheers!!

0 Kudos
Message 1 of 12
(2,430 Views)

Use property node to set the active cursor first.

 

 

George Zou
0 Kudos
Message 2 of 12
(2,414 Views)

Especially if you want the positions quantized to data values, I recommend cursors locked to the plot and using the cursor.index property. Especially convenient if you e.g. want the subset or similar later.

 

Here's a very old example that should give you some ideas (posted here )

 

altenbach_0-1649519129750.png

 

If you have free cursors, just get the cursor-x property.

Yes, property nodes execute top to bottom, that's why the above works correctly. If you have many cursors, iterate over all cursors to create an array of x positions.

0 Kudos
Message 3 of 12
(2,405 Views)

You have only showed us the front panel, so we don't really know what your needs are.

 

If these cursors are moved by the user, I would use graph:cursor.move events. They will give you the information (cursor#, index, coordinates, etc.) from the event data node.

 

0 Kudos
Message 4 of 12
(2,399 Views)

I am using graph cursor move events to get the mean average data between cursors and was hoping to use the cursor position property node to get the points on the graph where the cursor intersect at. i have attached my code here. I could only get the position of one of the cursors but not the other. I have not used the dynamic event nodes as much, so i have very less idea about it. 

0 Kudos
Message 5 of 12
(2,346 Views)

(Sorry, I cannot look at your code at the moment because this computer only has LabVIEW 2020. Consider "save for previous" before attaching.)

 

My example gets the array subset between the two cursors and it would be trivial to calculate the mean of that subarray, right? The only thing left is to decide if you want to include or exclude the points under the cursor.

 

My code can easily be adjusted for other graph data types (waveform, dynamic, etc.).

0 Kudos
Message 6 of 12
(2,340 Views)

Here is the code saved for previous version.

0 Kudos
Message 7 of 12
(2,332 Views)

what i am really after is the points where the intersections happen between the cursor and the graph. To be more precise, what i require is the Cursor Y positions. The Cursor X positions are of no use for my further calculations. 

Capture.PNG

0 Kudos
Message 8 of 12
(2,326 Views)
Solution
Accepted by topic author themadgreek

As a first step, you need to fix your glaring race condition due to blatant overuse of local variables. For example, the local variable at A will get read way before the terminal at B gets new data. The result critically depends on what happens first and there are currently no guarantees.

 

altenbach_0-1674146750781.png

 

Your code currently is full of landmines, for example if any of the events fire before the stop is pressed, the panel will lock up forever. You need a simple state machine with one toplevel while loop and not a sequence of loops. Your stop button also has the wrong mechanical action.

 

You can get the cursor Y in the same way. Here's a quick draft using simulated data.

 

altenbach_0-1674148050996.png

 

 

 

Message 9 of 12
(2,307 Views)

Thanks for the feedback on the code. I knew there was a lot of improvements i could make to the code. I'll definitely look into it and solve the problems that you addressed. 

As for the Y coordinates from the cursor, thanks a lot for helping with that. I really appreciate that.

0 Kudos
Message 10 of 12
(2,291 Views)