cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform graph inside loop

MichailM
Member

Waveform graph inside loop

Message contains an image Message contains an attachment

Hi,

 

I want to insert a graph inside a while loop which will build gradually on each iteration. The X and Y axis ranges will be prespecified outside the loop and the expected curve will build while the code is running. Please have a look on the attached script. The output is pretty much the input squared and the curve on the graph at the end of the code execution should look like the one below

 

Pic1.png

 

Cheers!

6 REPLIES 6
Gregory
Trusted Enthusiast

Re: Waveform graph inside loop

The easiest way would be to use a waveform "chart". You feed it one point at a time and it maintains a history.
If you want to clear the chart, write an empty array to the "history" property via property node.
To specify x and y axis limits, turn off autoscaling and set x.min, x.max, y.min, and y.max via property node once before the loop.
MichailM
Member

Re: Waveform graph inside loop

Message contains an image Message contains an attachment

@Gregory thank you for your suggestions. They seem to work however I can not figure out hot to set-up properly the X axis on the chart. For example my X values need to be x_min=0 and x_max=6 and stay like this for the entire code execution.

 

MichailM_0-1604097028011.png

 

 

Gregory
Trusted Enthusiast

Re: Waveform graph inside loop

The default is dt=1. If you are plotting 7 points (0 to 6) this will fit perfectly. If not, you have to set the XScale.Multiplier to property to reflect your actual dt. You can set it as the reciprocal of your resolution control and it should get you pretty close. Set the multiplier first (top of the property node) or run twice for a proper update.
MichailM
Member

Re: Waveform graph inside loop

Message contains an image Message contains an attachment

Seems to work that way. The only minor issue is that the XScale.Increment property does not seem to respond to its input. The Y one does. Any ideas on how to fix that?

 

MichailM_0-1604155094291.png

 

UliB
Active Participant

Re: Waveform graph inside loop

Message contains a hyperlink

I don't know if you are looking for that, but if you want to see all the X markers from 0 to 6 you have to set xscale.style property to 0. You can also set it in the right click menu of the chart.

 

https://zone.ni.com/reference/en-XX/help/371361R-01/lvprop/scl_style/ 

srikrishnaNF
Active Participant

Re: Waveform graph inside loop

Hi MichailM,

The reason may be a race condition...Inorder to fix that ,please wire the error out from the property node to the while loop to ensure that all the properties are set before execution of while loop.

 

 

Regards,
Srikrishna