LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split a string and give there dat to 4 meters on by one

Solved!
Go to solution

I am using serial port for data acqusition with labview.

serial port is sending a string of decimal numbers like

203,200,210,230

now i want to split these strings. I have used ther termination character (Comma)  in Visa configure serial port vi

But now i want the Visa Read to split these number so that i will give them to 4 meters.

For example 203 to first meter, 200 to second meter,210 to 3rd and 230 to 4th meter

 

0 Kudos
Message 1 of 4
(3,042 Views)

the vi snap

 

new.png

0 Kudos
Message 2 of 4
(3,039 Views)
Solution
Accepted by topic author 444444

Hi number,

 

well, it's a colorful front panel. What should we do with that picture???

 

Use a SpreadsheetStringToArray function with "," as separator to transform your string into an array of numbers. Then use IndexArray to index the individual numbers from the array:

Numbers.png

Message Edited by GerdW on 06-07-2010 10:05 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(3,018 Views)

444444 wrote:
I have used ther termination character (Comma)  in Visa configure serial port vi

If you did this then the VISA Read will return only one number at a time since it will stop once it sees a comma.

 


But now i want the Visa Read to split these number so that i will give them to 4 meters.

For example 203 to first meter, 200 to second meter,210 to 3rd and 230 to 4th meter


VISA Read is not used to split anything. You would need to do that with the string returned by VISA Read. However, since you set the termination character to a comma, then that means you're only going to be reading one number at a time. This means you'd need to perform call VISA Read 4 times to get the 4 numbers. I would think that you'd want to use a different termination character so you read the whole 4 numbers. Do you get a linefeed or a carriage return character at the end of the string of 4 numbers? If so, that's what you should use as the termination character. Then you can use the Spreadsheet String to Array as Gerd shows, or you can use the Scan From String function.

Message Edited by smercurio_fc on 06-07-2010 04:21 PM
0 Kudos
Message 4 of 4
(3,002 Views)