02-14-2009 11:39 AM
Background: I've designed a control system that controls the position of an object. I want to monitor both the "ideal position" (the path the object should be following) and the "actual position" (the real-time position of the object). The ideal path is a simple sine wave, and I receive the "actual position" via encoders.
The Problem: What I want to do is this: Plot the sine wave on an XY Graph, and then as i acquire samples indicating the current position of the object (via encoder), add these samples, one at a time, to the existing plot. So basically, the sine wave will be plotted prior to the "Acquisition Loop". Then my program will enter the "Acquisition Loop" (a while loop), where a new point will be read from the encoder on every iteration. I want this new point to be added to the existing plot. I implemented code to do this (I add the new point to an array that is being plotted), but the problem I am seeing is this: Apparently "XY Graph" replots all the points every iteration instead of just adding the new point to the existing plot. My program needs to be able to run for a long time, and it also gathers new data points fairly quickly, so I potentially need to gather many data points. Unfortunately, as the total number of data points I have acquired gets large, the time needed to plot them all becomes too long and the execution rate of my loop slows way down.
I have considered alternatives such as using a circular buffer to plot only the "N most-recent points", but my application really needs to be able to retain ALL the data points. I also would also really like to be able to use an "XY Graph" due to some of the properties it has that fit my application well. Is there any way to get "XY Graph" to accept a new data point and add it to an existing plot without erasing the plot first?
02-16-2009 01:20 PM
Hi Nate33,
I believe you can just use an XYgraph Buffer.vi. Take a look at the attached example.
02-16-2009 04:02 PM
If you use the Express XY graph there is an input called reset. Wiring a false to this input will add points to the existing plot. I'm not 100% certain, but I believe it does not redraw the entire plot every time.
See attached VI
03-04-2009 09:05 PM
Could you do me a huge favor and re-post your example as a Labview 8.2 file? I'm running 8.2.1 and can't open the attachment. Thanks so much
03-05-2009 08:22 AM
03-05-2009 12:53 PM
Thanks, i was able to open your example. However, the Express XY Graph seems to have some peculiarities when it comes to timing. As i mentioned previously, i need my loop to run at a fairly consistent speed. Thus it needs take a consistent (and short) amount of time to add a point to an already existing plot (no matter how many points are on that plot already). I thought this is what the Express XY Graph was doing at first, but after adding some timing to the example you sent me, i could see that the more points that were currently on the graph (ie, the higher the "iteration" number), the longer it would take to plot the next point. This resulted in an overall slow-down of my loop-execution. I attached your example with the added timing control.
Also, as a side note, i set the "Reset" option to false and also unchecked the "clear data on each call" box (accessed by clicking on the Build XY Graph.vi). Any idea what the difference is between these two options?
Also attached is an excel file where i plot the iterations vs. time. The slow down is very apparent from the graph.
03-05-2009 02:15 PM
There are a couple problems I see in your VI. One, you do not have any wait timer so you are asking the computer to run this loop as fast as it can go, and you will probably choke the processory by doing this. Second, you are using build arrays so at some point you would have exhausted a lot of memory, not to mention the memory allocation that must occur at every iteration.
I would put a wait timer in there, initialize the arrays and use replace, and then see if you are still having timing problems. It may not be related to the XY graph.
03-05-2009 02:41 PM
03-10-2009 10:27 AM
I have put a lot of effort into trying to get graphs updating in a timely fashion when faced with a continuous stream of data.
Here are my tips:
06-20-2013 10:38 AM
Hi
I am also having the same timing issue, the first few values are generated pretty fast, but then it slows down.
where exactly should I add the timing delay?
I tried but doesnt seem to really help...
My vi generates the random 2d array, then displays each row on a separate xy graph...
Thanks!!
(this is my vi in case you need to take a look at it!)