LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV 2011 - Displaying multiple plots on a waveform graph, with accurate time as the X axis.

I know this is commonly asked but I have done a lot of researching to try and figure this out to no avail. As I am using LV 2011 I can't even view most of the examples which are posted. 

 

I am trying to continuously plot multiple pressure values (numerical, double) vs. time as multiple plots on a waveform chart. The x-axis should display the time in HH:MM. Ideally the X axis would display "time elapsed" with 0 being the current point, if that makes sense. Using x/dx/[y] data won't cut it because the time in-between readings is variable.

 

As far as I can tell this is simply impossible with waveform charts - they won't accept absolute X data - but there's probably something I'm missing. When I try this with XY charts I see the previous values erased whenever I plot the new values, making it more of a display than a chart. 

 

Is my only option to use an XY chart and try to replicate the autoscaling and buffer behavior of waveform charts programatically? Does anyone have an example of this?

0 Kudos
Message 1 of 14
(4,008 Views)

It's easy, just right-click on the waveform control, Properties, Display Format, Relative time.

 

Screenshot_1.png

0 Kudos
Message 2 of 14
(3,988 Views)

While the other user's response is correct, this can sometimes lead to a few issues depending on how you are manipulating your data. If at any point you convert your waveform data into double format, the wvfrm timestamp will be lost. 

 

The easiest way I have found of getting around this is to create a property node for waveform chart in question.

Property nodes --> x-axis --> offset and multiplier --> offset

 

Place this node at the beginning of your code so that upon running, will initialize the plot and override and other defaults that have been set. Feed "get time and date" block into the "convert to double" block" and send this value into the property node you've created. That should do the trick.

0 Kudos
Message 3 of 14
(3,979 Views)

If the time interval between measurements is variable, then you can't represent your signal using a waveform. Instead, keep an array of x values and an array of y values (or an array of x,y clusters) and feed that to an XY graph. You don't have to implement autoscaling, the graph does that for you, but you do have to manage the size of the buffer array yourself, by adding new points to one end and deleting old ones from the other end when they get too old. I do this all the time, though I don't have an example handy to show you, but if there's something specific about it that's confusing just ask.

0 Kudos
Message 4 of 14
(3,945 Views)

Thanks - this is probably what I needed to hear. In this loop, speed is very important, so I'd love some advice on what the fastest way to implement this would be. I'd assume it would take longer to re-plot all of those values each time, and milliseconds matter here.

 

Is it as simple as "insert into array" to throw a value on the front, and then "drop from array" (or whatever that function would be) to delete a value off the back, each time a measurement is made? 

 

This is part of a state machine so I guess I would be storing the array in a shift register across every state. I hate having to do that kind of wiring but I'm not aware of a shortcut for that.

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

That's pretty much it; I write a subVI that starts at one end of the array and deletes points older than the desired age, then stops when it gets to one that's not, and run that each time I add a new point to the other end. It doesn't matter which direction the array goes, whether the oldest or newest points are at index 0, it'll be drawn the same either way. With an XY Graph (or any graph or chart, really) it does have to redraw the plot every time you add or remove points, but if you put the graph update in its own loop separate from your time-critical code, there shouldn't be a problem. You also don't need to update the graph every time you acquire new data, or with every point you acquire. Decimate the data if there's more than you need to display, and only update the graph as often as you need to to get the desired smoothness; 20 updates/second is usually more than enough to get a smooth display, and over 50 will exceed the refresh rate of your monitor.

0 Kudos
Message 6 of 14
(3,922 Views)

In this case I can only acquire data at a rate of about 1/680 ms. Part of this is lag on the DAQ device, but part of it is that between each acquisition I have to do some things in my main program loop, and that's as fast as that loop will run. I've been trying to think of ways to speed it up but that's a topic for another post, I think.

 

In any case I am updating the graph only once every 800ms or so, so there's no need to worry about when to update the data.

 

I think I have a working solution using a timing loop which stores the X and Y data in separate arrays. I still think that a prebuilt graph object that plots data vs. system time in the same way as a waveform chart would be a no-brainer for labview to include. 

0 Kudos
Message 7 of 14
(3,918 Views)

You can present an array of Waveform data types to a chart via a property node>>> History, and provided the "ignore attributes" option is NOT selected the data will be plotted  using the "t0" value from the Waveform.

 

So is using a chart an option for you?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 14
(3,910 Views)

Ben, 

 

Possibly - but I have a working solution with an XY graph and two arrays of XY data fully under my control, so unless I need to slim down my program I will likely stick with this. This way I can have the X-axis in "time since current measurement" which is most relevant for my application.

 

If I have time I will mock up a waveform data VI and see how that solution would have played out, and comment on this thread again.

0 Kudos
Message 9 of 14
(3,898 Views)

Are there advantages to feeding an array of one-point waveforms to a Waveform Chart compared to feeding an array of points to an XY Graph? It seems largely equivalent.

0 Kudos
Message 10 of 14
(3,894 Views)