LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display all loop data in chart

Solved!
Go to solution

Hello,

 

I have uploaded a program where I want to display 3 sets of array of size 4, so totally 12. And I want it to be a continously running plot where the plot adds on from the previous loop, but currently the plot is displaying only the current loop and not the previous loop. Why is that? Let me remind you, I cannot use a shift register because this is an example for another program which I am trying to do and in that program this plotting is a small subVI where the program goes out of the subVI, does a lot of stuff and in the next loop comes back. You can say then add shift register in the bigger loop, but that is also not possible, because that loop part was designed by someone else and its a mess with a stacked sequence inside and having many frames, so adding a shift register wont do. So I am trying to solve it in this small problem using a local variable. This is the main issue. And also as I said i am trying to plot 3 sets of data, and when I combine them together, it turns into a 3d data, so that is why you can see i do stuff like reshape array and index array in between. If you can help me correct that to a better way would also be nice. 

govindsankar_0-1754834467965.png

 

Thank you

0 Kudos
Message 1 of 7
(447 Views)
  • A chart has an internal buffer and should only accept one set of values per iteration. Don't wire it to an evergrowing array!
  • If you want to accumulate the data in memory, use a shift register instead of bouncing it back and forth via a local variable. It should be a 2D array where you append one row of values, then display it in a plain graph (not char!). If the corrent program design does not allow that, your problems are much bigger, While you can use a local variable and badaid solution, I would you rewrite from scratch.
  • You sequence structure has no purpose.
  • You have glaring race conditions due to overuse of local variables. For example there is no guarantee that the empty array is written before the loop starts.
  • To clear a chart, you write an empty array to the chart history, not write an empty array
0 Kudos
Message 2 of 7
(433 Views)

Yu have not explained how you want to add the 12 data points. A graph with three traces growing by 4 points each? A singe graph growing by 12 points per iteration?

0 Kudos
Message 3 of 7
(427 Views)
Solution
Accepted by topic author govindsankar

See if this can give you some ideas....

 

altenbach_0-1754840030548.png

 

0 Kudos
Message 4 of 7
(404 Views)

@Knight of NI. I did everything you just shown. One of my problems was a 3d array instead of 2d array. So instead of using build array to combine those 3 arrays, I used insert into array at indexes 0,1 and 2. So that gave me a 2d array. But then when I try to plot it in graph by building array with graph history it still was making it 3d array. Thats when I checked your program and saw that there is an option to concatenate inputs in build array, i did that and i got the result like yours. But there is still a problem with your program. That is I am not seeing all 12 values, we can only see 3 values. I made a small change to show you that. 

govindsankar_1-1754842651873.png

This is not what i want. All 12 values are seperate. I can explain more in detail. I have 4 batteries and 3 values from those 4 batteries are coming that is msg counter, error 1 counter and error 2 counter. So each battery has these 3 values and I want to plot all the 3 values of each battery and total 4 batteries together. So in total it will be 12 values. And the number 4 can change, it can be 3 batteries or 2 or 1 or 5. But as a standard for us its 4 batteries and I need to see all 12 values. 

 

 

 

0 Kudos
Message 5 of 7
(388 Views)

You get three traces with four new values each per iteration (total=12). If you want to add a row with 12 values, reshape the 2D array to a 1D array before appending.

0 Kudos
Message 6 of 7
(371 Views)
Solution
Accepted by topic author govindsankar

you can create a sub-vi with loop with shift register. It will work as a "buffer. 

 

write ain iteration - with the iteration number of the main loop that is calling the subvi. 

The iteration = 0 will innitialize the buffer creating a 2D array with all the N postions wiht a copy of the 1D 12 position Array. 

Then at every iteration, the vi will replace the buffer element iwth the newest data . 

This way the vi will not run out of memory and will stay within the size of the buffer size. 

 

 

0 Kudos
Message 7 of 7
(307 Views)