08-11-2013 05:11 PM - edited 08-11-2013 05:12 PM
Hello,
I am trying to read two columns of data from the serial port.
Example:
52439 52430
52437 52440
52209 52214
51065 51070
52390 52206
I am using the Visa serial function and I can read the first column of data from the serial port, but I cannot figure out how to read the second column.
I want to graph both sets of data.
I have attached my VI.
Thank You For Your Help.
Solved! Go to Solution.
08-11-2013 05:15 PM
What do you mean by reading a column from serial data? Serial data is serial, it doesn't com in columns. Just a string of data.
How is the data actually arriving? Is it 2 values that are separated by a delimiter such as a tab character?
If so, use Read from string and set the format string to account for the 2 pieces of data.
08-11-2013 05:22 PM
Yes its two values that are separated by a tab character.
And could you please elaborate the "read from string" suggestion.
Thank You
08-11-2013 08:19 PM
The Scan from String function takes a "Format String" on the top (right-click the function and choose Help, which explains all the inputs). In particular, you can say "Give me two numbers separated by a tab" and the output will be two numbers (either integers or floats, depending on the format you choose). In particular, %d\t%d specifies Decimal Integer, <tab>, Decimal Integer.
08-11-2013 08:24 PM
Could you please run your VI until the "read string" indicator contains data. Now stop the VI and right-click the terminal of "read String" and select "create constant". Copy this newly created diagram constant to the diagram of a new VI, save the VI under a new name, and attach it here. Thanks!
08-11-2013 09:47 PM
@P_Dhaliwal wrote:
Hello,
I am trying to read two columns of data from the serial port.
Example:
52439 52430
52437 52440
52209 52214
51065 51070
52390 52206
I am using the Visa serial function and I can read the first column of data from the serial port, but I cannot figure out how to read the second column.
I want to graph both sets of data.
I have attached my VI.
Thank You For Your Help.
What other members are explaining to you, should look like this below snippet...
Code (saved in LabVIEW version 2010) is attached.
08-12-2013 10:01 AM
moderator1983 wrote: What other members are explaining to you, should look like this below snippet...
I don't think so, your code will most likely not work at all. He is reading 20 characters at a time, presumably coresponding to one row with two values. In the current data example, we have 5 digits, 7 spaces, and another five digits. This does not add up to 20 chars, so there might be other delimiters or we migh even have a frame shift that needs to be handled. That's why I wanted to see a typcal raw string before making any premature conclusions.
Looking at the original code, we have many issues that also need to be addressed.
In summary, the current code is higly flawed. It need to be cleaned up as well as adapted to two values per read as required. We need more information to continue helping.
08-20-2013 08:34 AM
Thanks for the help. 😃