10-15-2021 01:43 AM - edited 10-15-2021 01:45 AM
Is there anyway to plot a x-y graph that keep its historic data in the loop?
I have tried using shift register, but DBL, not C1,C2, is showed inside the bundle.
Solved! Go to Solution.
10-15-2021 07:48 AM - edited 10-15-2021 07:48 AM
You need to put some type of while loop around the process and use a shift register with a 2D array of data, or two shift registers each with a 1D array to build up your data array. Then you index the array to get the X and Y sub arrays. One could also put the 2D array in a feedback node within the program. What ever you do you need to build up the array each time that you iterate the loop.
Watch out that you do not allow it to get to big. A few thousand points and it will take 100 ms to update the screen 100,000 points will take a few seconds.
At some point the program will crash because of memory overload. Before that happens you should do something like delete the oldest row and add a new row each time through the loop.
Don't forget to init the shift register either by wiring it to a blank 2D array or internally the first time through the loop.
From a memory allocation standpoint using build array inside of the loop is not really efficient but it will work.
10-15-2021 07:48 AM - edited 10-15-2021 07:48 AM
You used regular Bundle. So it just shows the datatype coming in. Try using Bundle by Name and wire a typedef constant into the top with the names of the elements as C1 and C2 if that is what you want to see.
There is a Build XY Graph Express VI on the palettes. It drops an XY Graph and an Express VI that will keep a history for you.
10-15-2021 09:17 AM
I usually make my X/Y graphs a sub-vi that is basically an "action engine" that way it holds it's own history, has an Initialize function, and makes a neater block diagram.
Here's the graphing state, you can see the shift registers that keep the chart history
Here's the Initialize state, where I clear the graph and set the X-Axis
10-15-2021 04:01 PM
For simplicity, I recommend keeping a complex 1D array in a shift register. No need to bundle.
(XY graphs understand complex arrays and will graph IM vs. RE)