04-15-2010 09:16 PM
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.
Solved! Go to Solution.
04-15-2010 09:25 PM - edited 04-15-2010 09:26 PM
Scan from string works just fine for me.
04-15-2010 09:31 PM
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.
04-15-2010 09:33 PM
04-15-2010 09:42 PM
04-15-2010 11:47 PM
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.
04-16-2010 08:34 AM