LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get an XY Graph to display a set time window without lagging?

Solved!
Go to solution

Sorry if this title makes no sense, it's a bit hard to explain.

 

I'm designing a readout for a respirator device that measures and displays air-flow to the lungs. I need to be able to show the airflow over time as a graph with real-time seconds as the X Axis, and I need the graph to be live. It needs to display a 30 second history, but does not need to save or log the entire flow data history. It's very important that the data displayed be live.

 

My current setup has a 2D array for the data, with flow data in one column and time (measured as the difference between the millisecond counter and the starting value of the millisecond counter) in the other. I append new rows onto that array until the difference between the last time and the first time in the array is greater than the 30 second window.

 

My first thought was to just let the XY Graph autoscale the X Axis. However, the autoscale feature only updates every 0.5 seconds or so and makes the graph very jumpy and hard to read.

 

I cannot use a Waveform chart because I need to display the real elapsed time on the X Axis, and the iteration time on the loop is not guaranteed to be constant.

 

My current solution uses the property reference to the X Axis > Range > Maximum and Minimum values. Each iteration of the loop I set the Max to the last time value in the array and the min to the first value. This gives me a smoothly updating plot that is easy to read (looks just like the waveform chart, but with a meaningful x axis) BUT I've noticed that it has a strange tendency to lag behind real time. After running it for 30 seconds or so, an input might take a whole second to appear on the graph. I don't know if this is consequence of the graphing function or something else, I am not buffering or storing sensor values before placing them in the array. Each iteration of the loop I read the real time, and collect one fresh sensor value from the sensor to put in the array.

 

I've attached the VI but honestly it's a nightmare and I know it. I'm new to LV and this VI has gotten very complicated for me. I intent to re-write the whole thing from scratch to implement some better practices I've since learned but for now I know it's very hard to read and probably not very useful. I just want to know if anyone else has seen something like this happen with XY graphs.

0 Kudos
Message 1 of 4
(1,580 Views)

I would use a waveform chart for this. If your time spacing between data points is not uniform, see Crossrulz's sporadic waveform chart nugget.

0 Kudos
Message 2 of 4
(1,557 Views)
Solution
Accepted by Tarnarmour

right click on the graph, x-axis, loose fit.

 

Message 3 of 4
(1,545 Views)

Thanks, that's done it, and much more simply than the mess I was trying.

0 Kudos
Message 4 of 4
(1,493 Views)