LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Multiple Plots on an XY Graph as New Data Arrives

This isn't so much a question as much as a potential solution, and any comments or feedback would be appreciated.

 

I'm working on a VI to log and graph multiple voltages, multiple temperatures, one current measure, and one controller setpoint for a fuel cell experiment. The current and setpoint XY graphs would have one plot each, and the voltage and temperature XY graphs would potentially have several plots each.

 

On the current and setpoint graphs, I had already figured out how to append the latest data onto each graph's Value property as the data is acquired. But for the multiple-plot graphs, it wasn't as easy (since Value is a 1D array of clusters of paired 1D arrays, it takes a while to wrap your head around it). The VIs below should solve the problem for both the single-plot case and the multiple-plot case:

 

multiple graph demo front panel.png

 The demo's front panel, with three plots being updated once per second

 

multiple graph demo block diagram.png

The demo's block diagram

 

 multiple graph block diagram.png

The SubVI's block diagram

Download All
0 Kudos
Message 1 of 6
(7,586 Views)

Since you didn't ask a question, I will Smiley Very Happy

Why didn't you just use the XY Chart.vi from the help?

0 Kudos
Message 2 of 6
(7,563 Views)

Is there an XY Graph example that updates the graph as each point arrives, or do they all update the graph once at the end of the VI? My guys' application samples very slowly over a period of several days or weeks (think samples per hour instead of samples per second) and they want to see the trend of recent measurements as new measurements are added.

 

I did look at XY Graph to get the data structures required for a multi-plot graph, but there's a chance I've missed something more fundamental (I once spent several hours working around a theorized deficiency with running Write Measurement File inside a loop, and then when I tried it in the loop, things just worked properly). So there's always a chance I've greatly overcomplicated something -- LabVIEW isn't my main development environment, and I may working under false assumptions somewhere.

 

0 Kudos
Message 3 of 6
(7,560 Views)

Look in the help for "XY Chart" instead of "XY Graph"!

It's the same control on the front panel, an XY Graph, but the code behind make it act as a chart, just what you need, add one point once in a while.

 

 

You can handle XY Graph in two ways:

In case you get all points at once: Then use a cluster of two 1D array's, 1 for X data and 1 for Y data. In case of multiple plots, just build a 1D array of clusters.

 

In case you get one point at the time: Then use a 1D array of clusters where each cluster contains X and Y data of one data point. In case of multiple plots, make a cluster of that 1D array and place it in a new array.

 

 

Reading your post, you have the second option but use the first data structure Smiley Sad

 

Message 4 of 6
(7,553 Views)

You're correct that XY Chart, not XY Graph is much closer (nearly identical) to what I'm looking for. I'm having some trouble adapting it to accept an arbitrary number of channels for input, but I'm going to work on it for another day or two before posting again. Thanks.

 

0 Kudos
Message 5 of 6
(7,538 Views)

A Waveform Datat type Chart has a lot of functionality that most people miss.

 

When you use a WF data type

 

1) the chart will plot based on the "t0" values.

2) An empty "Y" arrray will not plot.

 

So you may want to investigate using the WF version of the chart.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(7,518 Views)