LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to build an array using the data that I get through the serial port

I am reading data through the serial port, but I want to buffer these data. I have seen a function, but i think that i can use this if I am reading data from I/O intrument, so I don´t how can I fill an array, with the data that I am reading!!!
Thank you!!!
0 Kudos
Message 1 of 4
(2,856 Views)
Not sure exactly why you want to do this but you can keep the previously read data in a shift register and concatinate it with the new data as it arrives.

This can become costly (memory and speed-wise) if you read a lot of data and concatinate frequently. If you can avoid reading the data until it has all arrived (the serial port has a buffer...) that is a better solution.
Message 2 of 4
(2,856 Views)
I'll hazard a guess that you are reading data with VISA as a string. Then you want to convert that (probably with Scan From String) into a number. Then, you want to collect those numbers into an array.

We don't really have enough information to tell you the best way to do this. Here are some ideas.

If you are reading all the numbers from the instrument at once (e.g., a waveform from a scope), you might consider using "Spreadsheet string to array". Most scopes return the data as ASCII with commas between the values, so you'd wire a "," to the "delimiter" input of the "Spreadsheet string to array" function.

If, however, the instrument is returning a single point at a time, there are more questions. Do you want to do this continuously, or do you want t
o collect only a certain number of data points, and then process them as a block?

If the latter, then you'd just acquire each data point, convert it to a number, and then use output indexing on the for loop to create your array.

If the former, then you may want to store the data in a queue, and read it from the queue elsewhere in your program.

If you let us know what you want to do, we can probably provide more precise help.

Brian
0 Kudos
Message 3 of 4
(2,856 Views)
Hello
i have similar problems.
the serial ports will receive data continuously, but when ever i received 5 data, i would like to convert this 5 data to an array. how can i do that ?
0 Kudos
Message 4 of 4
(2,856 Views)