LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Number

Hello All,

            I am trying to convert a string into numbers to be used for meters and numerical view and such. I have a string of numbers coming into the Labview Basic Serial Read & Write, this string of numbers is coming in from sensors on a microcontroller. I have 5 Analog and 4 Digital coming in,  I need to seperate all these numbers so that they can each be sent th their own graph. Any Ideas on how to get this done?

0 Kudos
Message 1 of 4
(2,561 Views)
There are many ways this can be done. Are the numbers separated by some character, like a comma? If so, you can use the Spreadsheet String To Array function to get an array of values. Or, you can use the Scan From String function. If you provide more information about the string then a more specific answer can be given.
Message 2 of 4
(2,552 Views)

The data is seperated by returns so if I am recieving from two analog and two digital sensors the data will look as followes:

 

125

33

0

1

 

0 Kudos
Message 3 of 4
(2,549 Views)

The data is coming continuously in that format or after you send a specific command to the micro? If it's continuous, what you have is a random number generator. Since your read of the data stream would start at some unknown point, you have no way to know what number represents what sensor.

 

Assuming you have control over the micro code, you have some options. Rewrite it to only send data from each sensor after you send a command. Then you could do x number of reads. Rewrite to send a complete scan with each value separated by something (i.e. a comma) and the whole string terminated by a return. Rewrite to prepend a channel identifier to each number (i.e. Ch1=x).

Message 4 of 4
(2,536 Views)