From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add For Loop into XY Graph to update the graph display with new datasets

Solved!
Go to solution

Hello,

 

I have this data signal in csv file that contains 181 iteration of 128 data (rows) in each iteration and 14 channels (column). I want to incorporate a For Loop to update the XY Graph every 500ms, so in every 500ms, the new iteration of next data set is displayed in the graph. so that as if its receiving data in realtime. I have tried to display 1 complete iteration of data set in the graph without For Loop as shown in the screenshot(123).

 

I also tried adding the For Loop as in the vi, and read the 181cycles.csv but there graph is not appearing as expected; the graph is not showing different curves of signals every 5s instead shown all mixed signals at once. Can anyone please spot mistakes and suggest how can I achieve the aim above?

 

Any help would be greatly appreciated.

Download All
0 Kudos
Message 1 of 14
(3,714 Views)

All your FOR loop iterations are identical and display the same data. (You also have way too much duplicate code.)

To display 128 rows at a time, you need to take a subset based on the iteration terminal.

0 Kudos
Message 2 of 14
(3,688 Views)
Solution
Accepted by topic author quadratini26

See if this gives you some ideas. (there are probably more efficient ways, but this should point you in the right direction)

0 Kudos
Message 3 of 14
(3,685 Views)

yes, this gives me the idea of your previous reply. Btw I am still learning, can you explain to me the purpose of Transpose 2D array? what is the difference with the transpose on ReadfromSpreadsheet.vi?

 

also, I see there is another For Loop inside (nested loop) connected to XY graph, Why is it there? is it because the XY graph requires 2D array? 

0 Kudos
Message 4 of 14
(3,657 Views)

@nnhas wrote:

yes, this gives me the idea of your previous reply. Btw I am still learning, can you explain to me the purpose of Transpose 2D array? what is the difference with the transpose on ReadfromSpreadsheet.vi?

 


Well, If you are wondering why somethings is there, remove it and see what happens. 😄

Array elements of 2D arrays are arranged by rows in memory order and autoindexing slices out rows, so it is more natural to process this way. Without the transpose, the subsequent code would look slightly uglier. As I said there are plenty other ways to do it, so find some. 😄

 


@nnhas wrote:

 

also, I see there is another For Loop inside (nested loop) connected to XY graph, Why is it there? is it because the XY graph requires 2D array? 


Look at all the duplicate code you had, indexing out each column separately (You know that "index array" is resizeable, right?), building all these clusters N different times, and building the array of clusters. The FOR loop replaces all that with much simpler code. Takes 10% of the time to write, limits accidental errors and makes the code smaller, easier to read and debug.

 

0 Kudos
Message 5 of 14
(3,647 Views)

Noted on that.

 

Can you explain to me how do I add shift register to the solution you suggested above?

0 Kudos
Message 6 of 14
(3,606 Views)

@quadratini26 wrote:

 

Can you explain to me how do I add shift register to the solution you suggested above?


What solution? Shift register to do what? Are you referring to any particular post?

0 Kudos
Message 7 of 14
(3,603 Views)

I am referring to the .vi you posted in this thread and the shift register to store data on completion of each iteration display in the XY graph. 

 

0 Kudos
Message 8 of 14
(3,582 Views)

There is no shift register in my VI. The VI currently shows new data with every update as specified in your original post. If you want to show all data, just graph it all at once instead of taking subsets. Still not sure what you want.

Message 9 of 14
(3,577 Views)

@quadratini26 wrote:

I am referring to the .vi you posted in this thread and the shift register to store data on completion of each iteration display in the XY graph. 

 


If you also want to keep showing the previous data with each update, just make the following small change. No shift register needed:

 

KeepAll.png

0 Kudos
Message 10 of 14
(3,568 Views)