LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform graph losing history

Solved!
Go to solution

Hello all you helpful forum-goers!  🙂

 

I am implementing a strip chart displaying the values of multiple real-time parameters, using a waveform graph, but while running it keeps resetting the history of the chart at random intervals.  Unfortunately due to it being for my work I cannot post the code.  I'll do my best to describe the problem and setup, though.

 

I have a data acquisition loop reading the real-time values as an array of floats and storing them in a Data Buffer functional global variable which holds a 2D array of floats, one "page" of floats per time interval.  This is running at 50Hz via the Wait for Millisecond timing VI.

 

I then have a chart updating loop running at 10Hz via the Wait timing VI.  This loop reads the Data Buffer VI for all the samples it has accumulated (usually 5, but sometimes 4 or 6), and converts them into an array of waveforms via the Build Waveform VI by taking each column of data and assigning it to Y, setting dt to 0.02 (50Hz), and setting t0 to the current time minus dt times the number of samples in the array.  The waveform graph terminal is then set to this array of waveforms.

 

Most of the time this works well, with the new values being appended to the previous values creating a smooth graph of multiple plots with the correct values being displayed.  However, sporadically the graph will blink empty and start filling again from scratch.  I can tell it is not just jumping in time (the x-axis) because I can move the x-axis scroll bar and there is no other data to which to scroll.

 

I have in addition to the two above loops a GUI event-structure loop, and a state machine task loop.  However, I have ruled out these two loops resetting the graph's history property via inspection and breakpoints.  Therefore I can only think that there is some condition or type of data which when fed into the graph's terminal results in NOT appending to the current data as usual.  An empty array is not the answer; I have tested that with a separate simple test VI, and it results in the graph retaining the currently displayed data but not updating any new data.

 

I would appreciate any insight any of you have as to the possible causes for this behavior.  I apologize again for not being able to post the actual code, although I may work on putting together a similar setup with the Data Buffer, etc. in a separate VI, and post that.  Also, let me know if you would like me to describe any of the other logic, settings, or circumstances for you.

 

Thank you very much for your assistance!

 

-Joe

0 Kudos
Message 1 of 18
(6,513 Views)

Hi Joe,

 

Thanks for the detailed explanation to start things off! I'm curious if this is occurring at random intervals or if there's some kind of periodic occurrence of this problem?  I'm also wondering if it would be possible to see just the chart updating loop, because I think that's where some of the more important configuration is happening that seems like it could be throwing this off.  And, obviously any kind of visibility we can get will help to troubleshoot this.  

 

Regards,

 

-Dave C

Applications Engineer
National Instruments
0 Kudos
Message 2 of 18
(6,486 Views)

Hi Dave,

 

Thanks for your reply!  Unfortunately, I have not been able to discern any sort of timing pattern for the issue.  With no user interaction at all, I have seen it happen after 2 seconds, 8 seconds, and then not for more than a minute.

 

I am trying to post images, but this website keeps giving me "Error Code: HTTP Error".  Regardless of whether my images are png or gif, or uploaded in this post or in my public images folder for this website.  They are less than 10kB.  Any ideas?  Temporary glitch?

 

-Joe

0 Kudos
Message 3 of 18
(6,477 Views)

First, I think you mean waveform chart instead of waveform graph. The chart keeps a history of data internally. The graph just displays what you wire in. That being said, I often make my own "chart" using the graph. I prefer having control of the data myself. A change in the number of waveforms will cause the history to go blank. You said that typically it's 5 elements, but sometimes 4 or 6. If you mean that sometimes you get more or less elements in your waveform array, that will cause the history to blank out. If you want to keep the current approach, you could force the waveform array to have a fixed length (whatever the longest is), and just have waveform elements with empty arrays pad the array.

 

I might be totally off track here, but hopefully this helps.

Chris

Message 4 of 18
(6,470 Views)

Joe,

 

from your explanation I do not have a clue for the reason of your problem, sorry. If you can not provide the code, what about a picture of it?

What I found suspicious is your timing with 'wait miliseconds', though. Probably not the cause, but what about replacing this with a 'wait multiple milliseconds'? This would recuce jitter and the systematic error of execution of other code in series with your waits.


Greetings from Germany!
--
Uwe
0 Kudos
Message 5 of 18
(6,469 Views)

Minnella,

 

You are absolutely correctly, it is a waveform chart.  I've been using the terms chart and graph interchangeably, but from your description of how they behave differently, that is incorrect and I'll try to stop doing it.  Thank you!

 

To be clear that we are talking about the same thing, when I say sometimes 4 or 6, I mean that in my chart of (for example) 10 plots, sometimes I add 4 new data points for each of the 10 plots, and sometimes I add 6 new data points.  The number of plots stays consistent, though.  In other words, it is the size of the Y array in each waveform that is changing, not the size of the waveform array I am passing to my chart.  That said, the pseudo-random timing of a different number of data points per update would match the seemingly random clearing of the chart history, so I am hopeful that you are on the right track!  🙂

 

I am intrigued by your approach of tracking all of the data internally and using the graph instead.  Some questions:

1) Do you just use a 2D array of points where one dimension is the number of plots, and the other is the number of data points you have? 

2) Do you find performance suffers with that large of an array, or is it basically the same thing as what I have because that large array is just being maintained in the chart control?

3) Do you have example code you could post using a waveform graph?  I put one in my test VI, and the X-axis didn't seem to match the T0 I was inputting, although admittedly I probably just need to play with it more to understand how it works differently compared to the chart.

 

Thank you very much for your assistance!

 

-Joe

0 Kudos
Message 6 of 18
(6,463 Views)

Lul,

 

I appreciate your attempts to help even though you're not sure what the answer is.  🙂

 

I tried replacing the Wait in the chart update loop with a Wait Until Next ms Multiple timing VI, and it actually made the loss of chart history happen nearly constantly (multiple times a second) very consistently.  I'm not sure what this means, but hopefully it will be helpful in determining the root cause, so thank you!  😉

 

As I mentioned earlier, I am getting an error when trying to post pictures of the VIs in question, I will continue working on that.  I think my company IT policy is blocking me from attaching any files.  😛

 

Thank you again for taking a look at this!

 

-Joe

0 Kudos
Message 7 of 18
(6,459 Views)

Minnella,

 

I have tested my chart, and if I force only updates with 5 data points, it seems to eliminate the history erasing problem.  Conversely, if I add to a test VI (which adds one data point every loop) a button which for one iteration adds two data points, I can consistently erase the history every time I push the button.  So clearly, adding a different number of data points at one time than has previously been added will erase a waveform chart's history, despite the fact that the number of plots is the same.  Thank you for your help in tracking down the root cause!  🙂

 

That said, the answer is not exactly what your post indicates (your post says it might be a change in the number of plots that causes the issue).  I would like to mark one of your posts as the solution rather than my own (which always feels self-serving); do you want to re-post the final answer so I can do that?  Or should I just mark this post as the solution?  😉

 

Also, I would still be interested in your answers to my above questions regarding using a waveform graph as opposed to a chart, as maintaining my own data seems like it would have some advantages.  Right now I'm guessing I can use the chart's history data as a way to, for example, selectively erase some plots, but it would probably be easier and/or cleaner with my own code.  Thoughts?

 

Honestly, this issue seems like a bug in either the LabVIEW code, or a lack of documentation indicating how it works.  I'm too busy to go through the process of officially reporting it, though; someone else should feel free to it they want.

 

Thanks again for everything,

 

-Joe

0 Kudos
Message 8 of 18
(6,456 Views)

Thanks for the detailed info and feedback. Please feel free to mark your explanation as the solution. I still don't feel like I understand exactly where the problem is though. I just made a quick example with a chart where I experimented with changing both the number of points added/iteration along with changing the number of channels while running. It confirmed my original thought that the history only gets wiped when the number of channels changes. This seems to contradict your finding, so I think there must be something else going on that was affected by the changes to your graphing logic.What exactly is the datatype wired to the chart indicator?

 

I've attached my example. You can see that I've unchecked the "Transpose Array" item on the chart's context menu. When run, you can change the number of points freely; it is not until the number of channels changes that the history gets wiped. If you think about what is happening behind the scenes, a History array is held within the control. The size of the array is equal to the number of plots x history length. If you change the number of plots going in, it changes the array size. Each time that happens, LabVIEW initializes a new history array. The programmers would have had to make a lot of assumptions about what you wanted to do when changing the number of plots, so the easier solution was to start from scratch. If you build your own data storage system, you don't have to assume anything--you can just program it to do what you want.

 

I typically build my data storage into an Action Engine. I preallocate space for each channel (with NaNs--they don't plot) and use replace array subset to insert data into the buffer. I also recently decided that using Rotate Array was my preferred technique to make it act as a circular buffer. It gives up a little something on each insert, but it is much more efficient to get the data out. Particularly if the entire buffer is read out. One reason I go this route instead of using the charts is that I often provide the user with the ability to select which channels they want to see while running the program. With a chart, every time they changed their selection, all the data would be wiped out. The way I do it, I just index out the channels they want to see when I update the graph. Of course, I'm speaking of live data acquisition applications here.

 

Chris

 

Chart Example.png

0 Kudos
Message 9 of 18
(6,444 Views)
Solution
Accepted by topic author jmorris

Every time I have seen that issue when using a Waveform Chart it endded up being an issue with;

 

1) The number of plots changed.

 

2) The plot names changed (attribute of WF).

 

3) Goffy time info where the t0 and dt were inconsistant with what was already displayed (e.g. new data point has t0 that predates what is already plotted for that plot)

 

It was a pain to figure it out the first time.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 18
(6,441 Views)