LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph cursor handling

Hello

 

Here is an example that diplays a curve and epmploys 2 cursors.

The question is how to "attach" cursors to the curve in order to specify only X coordinate.

 

Thanks in advance.

 

cursor_handling.png

 

cursor_handling.JPG

0 Kudos
Message 1 of 14
(5,621 Views)

On Front Panel it can be done by specifying "Single plot" option.

But how to do the same programmatically ?

 

 

cursor_handling (1).JPG

0 Kudos
Message 2 of 14
(5,612 Views)

The cursors need to be locked to a plot. If you have free cursors, you can calculate Y by interpolating into the data. (or just applying the formula).

 

Some notes:

  • You while loop should be replaced by a FOR loop because the final number of iterations can be calculated from the inputs. No need to constantly check for a termination condition. Also autoindexing on a while loop is more expensive, because output allocation is incremental. The compiler does not know the final array size and has to guess.
  • All you need is ramp pattern (see image). No loops needed.
  • Don't wire N of the FOR loop if you are autoindexing, unless the autoindexing array contains more elements than you need.
  • You don't really need an xy graph if the x spacing is regular as in your case. Just set x0 and dx of a plain waveform graph.

0 Kudos
Message 3 of 14
(5,603 Views)

Thanks Altenbach

 

The curve generation staff is just for example ... cursor handling I use in my testbend, where data comes from experiment.

Concerning cursors, is it possible to lock them to a particular plot programmatically, or the only solution via Front Panel ?

 

 

0 Kudos
Message 4 of 14
(5,596 Views)

Yes, use the "cursor.plot" property 

0 Kudos
Message 5 of 14
(5,593 Views)

Actually the Cursor.CursorMode does the job (please see the snippet below).

The value 1 corresponds to Single-plot mode (https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/properties-and-methods/vi-server/generic/c...

Also it should precede Cursor.Posx.

If I correctly understood, the Cursor.Plot selects to which plot cursor will be locked.

I've tried to check it by adding 2nd plot.

Surprisingly, the 2nd plot is displayed, but 1st is lost (please see screenshot below) !

Any ideas ?

 

Thanks

 

cursor_handling (0).png

 

 

cursor_handling (0).JPG

0 Kudos
Message 6 of 14
(5,576 Views)

You are not setting the Cursor.plot, so both cursors go to the same plot.

 

You are only seeing one plot because you are not autoindexing on the output tunnel of the first FOR loop. Only the plot from the last iteration is currently retained.

 

Also, once you set the cursor mode (via properties or property node) you don't need to call that property ever again, so why is it even in the loop

Message 7 of 14
(5,572 Views)

Your for loop executes twice, but there is no autoindex on output tunnel and first iteration is useless.

Message 8 of 14
(5,568 Views)

Try something like this (I left the lame while loop in there for now ;)):

 

 

0 Kudos
Message 9 of 14
(5,561 Views)

Yes !

Tunneling mode resolves the issue with non-displaying of the 1st curve.

Concerning cursor handling, my results are different from yours (please, see the screenshot below)

cursor_handling (1).png

 

cursor_handling (1).JPG

0 Kudos
Message 10 of 14
(5,554 Views)