LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data conversion from "float" type

Solved!
Go to solution

In a wireless data logger I am collecting analog data with an 8 bit microcontroller and sending it as a UDP datagram. The data recieved in the LV application looks like this :

 

\r\n020.43\s002.14\s000.00\s000.02\s   ( "\'" Codes display )

 

0D0A 3032 302E 3433 2030 3032 2E31 3420 3030 302E 3030 2030 3030 2E30 3220 ( Hex display )

 

020.43 002.14 000.00 000.02 ( Normal display)

 

I want to strip and display the values 20.43, 2.14,0.0 and 0.02 in my LV App.  Trying with "Scan from String " and " Decimal Number to String" but with little success. Maybe I can "build" my data from the Hex ?? 

 

Any idea welcome. Thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 7
(3,000 Views)
Solution
Accepted by topic author MogaRaghu

Scan from string works just fine for me.

 

Message Edited by Ravens Fan on 04-15-2010 10:26 PM
Message 2 of 7
(2,996 Views)

There are innumerous ways of doing this; some elegant, others not so elegant.

 

Since this is a string, and a string of numbers separated by the space character, I would say that the scan from string Vi is the best way.  It can be difficult according to my experience to get that right.  You need to examine your format string and read the Help carefully.  Break your data up to test.  Start with only one number.  I'm not sure how scan from string will deal with zeroes at the front of numbers.

 

Another way is Match pattern VI (string pallette) in a For loop.  Search for your code separator (i.e. /s) and index Before substring output.  Use convert string to number VIs, again in For Loop.

0 Kudos
Message 3 of 7
(2,994 Views)
Ravens, what was your format string?
0 Kudos
Message 4 of 7
(2,993 Views)
I left it disconnected and it worked just fine.
0 Kudos
Message 5 of 7
(2,988 Views)

Ravens Fan wrote:
I left it disconnected and it worked just fine.

 

Amazing ! I did not even dream that I can leave out the format string and tied my self in knots trying to read thorugh the help and creating one !! Another instance where a LV function is something like an Easter egg and you need out-of-box thinking to use it effectively.

 

Anyway thanks Raven.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 7
(2,969 Views)
I figured I start without it, it would throw some errors, and I would change the format string until I got it working right.  It just so happens that it worked right away.
0 Kudos
Message 7 of 7
(2,946 Views)