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: 

Plotting XY graph in real time with regular intervals on this x and y axis

I am trying to plot X and Y values in real time, and would like a combination of what a waveform chart and an express xy graph provide. They both lack in the labels of one axis. The waveform chart doesn't show constant intervals in the x axis and neither does the y axis on the express xy graph. Is there a way to have constant intervals in both axis while plotting the points in real time?

I am updating the graph within a loop using arrays I add an element to each array during each loop. This is how:

cathborisova_5-1605406999931.png

To plot the arrays in the XY graph, I started with this code:

cathborisova_4-1605406980941.png

Which gave me this result:

cathborisova_2-1605406898254.png

So you can see they are being plotted, but the X axis is not updating for some reason.

Next I tried this (which gave me the same result):

cathborisova_3-1605406909747.png

Lastly, I tried:

cathborisova_1-1605406763990.png

Which gave me this result:

cathborisova_0-1605406718297.png

 

Thanks in advance for the help.

0 Kudos
Message 1 of 5
(1,474 Views)

If the x-values are equally spaced, a plain chart or graph is file. No need for an xy graph. (you can customize axis labels, styles, and also offset/increment to show correct values on the x-scale.

 

Your abundance of local variables and stacked sequences show us that you are probably getting into really bad habits. None of those should be needed in a typical program. Have you done the basic tutorials?

 

Please attach your VIs, we cannot debug images.

0 Kudos
Message 2 of 5
(1,457 Views)

Hi, thank you for the advice, I will try to implement it.

The reason I can only show images is because the company requires that I keep the code confidential, although of course small arbitrary snippets like these are fine.

Also, what would you recommend for basic tutorials? I got an internship and got thrown into labview without any prior exposure to labview, or any kind of programming similar to it. I watched a couple youtube tutorials to understand how it works and that was it.

0 Kudos
Message 3 of 5
(1,408 Views)

Hi cathborisova,

 


@cathborisova wrote:

Also, what would you recommend for basic tutorials?


Did you notice those "Training resources" in the header of the LabVIEW board?

 


@cathborisova wrote:

The reason I can only show images is because the company requires that I keep the code confidential, although of course small arbitrary snippets like these are fine.


You don't need to attach your "confidential" VIs. But you could create small example VIs to demonstrate your problem - without any "confidential" stuff…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(1,396 Views)

@cathborisova wrote:

 

cathborisova_5-1605406999931.png

cathborisova_4-1605406980941.png

cathborisova_3-1605406909747.png

cathborisova_1-1605406763990.png


 

Obviously, you are coming from a text programming background and thought "local variables" are "variables" and should be used as such. Basically, you are using front panel objects for data storage, which is very inefficient (extra data copies in memory!) and can often cause race conditions. Since LabVIEW is highly parallel, it is often impossible to tell what modified a value last. Simplified, in LabVIEW the wire is typically the variable and the resulting data dependency exactly defines execution order. There are plenty of related discussions (example).

 

If you want to retain and modify data between iterations, typically a shift register is the correct tool. While you are at it, also learn about datatypes. For example your "Count" should probably be an integer. Appending a scalar to an array is typically done using "build array", if that is what you are trying to do, no index input needed.

 

Also, if you have xy data, a 1D complex array is often a good choice. It automatically keeps pairs matched and xy graph will directly plot IM vs. RE, no need for clusters and x and y arrays.

 

As you can probably tell now, you are approaching this way too convoluted. Elegantly rewritten, the same functionality probably uses less than 30% of your current code.

 

Once you attach a simplified and sanitized version of your VI, We can give more specific advice. You are at a stage where it is important to avoid bad coding habits that cannot scale to more complicated code later.

0 Kudos
Message 5 of 5
(1,386 Views)