04-05-2014 04:36 AM
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!
Solved! Go to Solution.
04-05-2014 11:53 AM
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.
04-05-2014 12:13 PM
04-05-2014 12:15 PM
04-05-2014 12:19 PM
04-05-2014 12:23 PM
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.
04-05-2014 12:51 PM
I am attaching the vi as well as the snap shot of vi . i hope this will help you. give me your feedback.
regards
04-05-2014 01:29 PM
04-05-2014 01:41 PM
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.
04-05-2014 01:45 PM - edited 04-05-2014 01:50 PM
@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!