LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-Time data to array

Solved!
Go to solution

Hello Everyone,
I am trying to create a spreadsheet of 500 columns and 1000 rows.
My program consists of real-time data streaming through the com ports (VISA), running in a continuous while loop. I was hoping someone could help me with the following:
1) How do I convert point by point data into an array format?
2) How to I set up iterations and loops in order for the program to collect 1000 samples of data and then switching to the next column (switching columns 500 times)
3) How do i take my 1000x500 array and write it into a spreadsheet?

Most examples I find to create rows and columns of arrays use random number vi embedded INSIDE a for loop, then auto-indexing it. However how do I embedded my real-time data (present inside a while loop) into a for loop (that's why I am unable to follow those examples).

I am fairy new to LabView. I would be great if someone could help me out because I have tried countless ways to create my spreadsheet.

Thank you!

0 Kudos
Message 1 of 14
(2,158 Views)

at what baud rate you are receiving data on serial port. can you attach a snapshot of your vi block diagram. is there any hand shaking involved. 

if you needed i will send you a vi , check my logic if it works for you.

0 Kudos
Message 2 of 14
(2,131 Views)
Why does your single point acquisition have to be inside a while loop? Put it inside a for loop set to iterate 500 times. Put that inside another for loop set to iterate 1000 times. The output of the inner for loop is a row with 500 elements and the output of the outer loop is a 2D array with 1000 rows and 500 columns. Done.
0 Kudos
Message 3 of 14
(2,120 Views)
Sorry, got your counts backwards. The inner loop would be set to run 1000 times and the outer set for 500.
0 Kudos
Message 4 of 14
(2,118 Views)
Tirmizi,

How is baud rate or hand shaking at all relevant to the question?
0 Kudos
Message 5 of 14
(2,114 Views)
Solution
Accepted by hiba.nzm

Easiest would be to collect the data into a 1D array of size 500000 (=500x1000). Initialize a 1D array of that size and of the correct datatype and use it to initialize a shift register of you acquisition loop. With every new data point, use "replace array subset" to substitute real data based on the iteration terminal. When the acquisition is done, reshape the array to 500 rows|1000 columns and write it to file (e.g. using write to spreadsheet file).

 

Why are you using a while loop. Apparently you know the total number of iterations before the loop starts, so a FOR loop would be more appropriate (you can show the conditional terminal to stop early if needed)..

 

Be aware that formatting large arrays is expensive. Unless ihe file needs to be imported elsewhere, I recommend to use binary files.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 6 of 14
(2,111 Views)

I am attaching the vi as well as the snap shot of vi . i hope this will help you. give me your feedback.

 

regards

Download All
0 Kudos
Message 7 of 14
(2,097 Views)
Please don't use a flat sequence structure. It is totally unnecessary.
0 Kudos
Message 8 of 14
(2,086 Views)

it is good for clear understanding specially for new one. but as far as my understanding in programming where you want to run steps one after an other flat sequence is essentail. unlesss you complete the first step , second one will not be run.

 

for programs where a set of sequences need to be run again and again put the flat sequence in while loop.

0 Kudos
Message 9 of 14
(2,077 Views)

@Tirmizi wrote:

it is good for clear understanding specially for new one. but as far as my understanding in programming where you want to run steps one after an other flat sequence is essentail. unlesss you complete the first step , second one will not be run.


No! The flat sequence just add unecessary code and confuses the new programmer who might adapt the same bad habits. The diagram comments are for understanding the code, not the sequence.

 

In this particular case, the execution order is fully determined by dataflow and the sequence makes no difference. It just adds clutter to the diagram.


Tirmizi wrote:

for programs where a set of sequences need to be run again and again put the flat sequence in while loop.


Why would the argument change if you put the sequence inside a loop. Makes no sense!

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 10 of 14
(2,071 Views)