LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset XY graph after plotting a certain number of points

Hi all, 

 

Here is my scenario.  I am plotting the result of a mathematical operator (in this case the area under a curve) as the Y axis and the data in the X axis is generted from a small while loop incrementing from 0 with +1.  I would like to run the plot for 1000 points, then have the entire thing reset to begin at 0 and start plotting again.  I tried using the Reset feature of the Express XY Graph VI but the data was still going beyond the 1000 points, even though the graph reset (I check by autoscaling the X-axis).  Any suggestions are appreciated.  Thanks in advance.  

0 Kudos
Message 1 of 9
(4,364 Views)

Learn how to use the Graph (or Chart) functions without relying on Express VIs.  This will give you explicit control (though you may need to learn about Property Nodes).  Have you looked at LabVIEW Tutorials or use the LabVIEW Help system?  One place to start is Help, LabVIEW Help, Contents, Fundamentals, Graphs and Charts.

 

If you still need help with your code, then post your code (this means "Attach your VI", not a picture -- we can't "edit" or "run" a picture).  You need to do some of the work here ...

 

Bob Schor

0 Kudos
Message 2 of 9
(4,328 Views)

Hi Bob, 

 

I normally do not use the Express VIs because they lack fine control.  But, I saw this one had a Reset feature and figured it was worth a try.  I will take a look at the Property Nodes and see if they have a reset-style feature - I use these all the time to pull arrays from plots using the cursors and am familiar with their useage.  Thanks for the tip.  

 

My XY reset problem is particularly vexing as I can do this with 4 lines of Visual Basic code and it works every time.  If you (or any one) has a practical suggestion, please let me know.  You don't have to "do it" for me; I am simply trying to not re-invent the wheel if someone else has encountered a similar situation.  

 

 

0 Kudos
Message 3 of 9
(4,308 Views)
I haven't tested this, but thought similar check if it suits your needs: http://forums.ni.com/t5/LabVIEW/Clear-XY-Graph-amp-Delete-Old-Data/td-p/2473414
Thanks
uday
0 Kudos
Message 4 of 9
(4,306 Views)

Hi jdepalma,

 

Attached below is a link to a screenshot of an adaptation to a piece of code from a previous suggestion in the forum. The contents of this loop plot 1000 points to the graph and then the graph resets and starts graphing data again. Hopefully this will help you along as you resolve your issue!

 

Best,

0 Kudos
Message 5 of 9
(4,274 Views)

As Altenbach noted in the response cited by Uday, when you plot a graph, you are sending the entire array to the Plot, so clearing the graph is simply the action of writing an empty array to it.

 

On the other hand, when you use the Express XY Graph, you are creating an ever-expanding Array, as each point that you add gets appended to an Array kept internally in the Express VI.  Generally, appending to the end of an Array is, perhaps, the slowest and most memory-intensive way to "grow" an array.  Of course, this sub-optimal behavior is "hidden" inside the Express VI.

 

Is this really something that you want to do?  Do you want to see each point on the Graph be added, one at a time?  Are you really plotting a graph, where X and Y are independent variables (as opposed to a chart, where there is no explicit X, as it is an implicit implementing variable, such as Time)?  [Wow, that's an awkward sentence ...].

 

Having said all that, I have used "Graphs as Charts", but I had a specific problem in mind, and managed the memory myself (I don't quite remember the details, but suspect Queues might have been involved ...).

 

If you really do want a Chart, I'd say "Replace the Graph by a Chart".  Note that clearing a Chart involves writing an empty array into its "storage" location, called its "History", which you do using a Property Node.

 

Bob Schor

0 Kudos
Message 6 of 9
(4,262 Views)

After some effort, an engineer at NI and I came up with a functional solution to my issue of resetting an XY graph back to zero after a certain number of points.  I have included a VI here for anyone to use at their leisure.  

 

It uses some true/false and comparator logic to reset the plot (the XY Graph Express VI) after a certain number of points and will start plotting again at zero.  Hopefully someone finds it useful.

0 Kudos
Message 7 of 9
(4,190 Views)

Hi jdepalma,

 

you need a NI engineer to control the "Reset" input of an ExpressVI? 😄

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(4,180 Views)

Hi GerdW, 

 

Thank you for your code screenshot.  It is always nice to see another way of doing something.  Glad to see you were "amused" by my conversation with an NI engineer! Smiley Very Happy

 

To be fair, I had the engineer on the phone for an unrelated hardware question (one of our DAQ boards is being funny) and I figured it would not hurt to ask her opinion of what I was trying to do.  I had tried something similar with the quotient and remainder function for an earlier post, but didn't have much luck - I could get the screen to reset, but the data was not replotting.  Everything is working fine now!

0 Kudos
Message 9 of 9
(4,169 Views)