LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read Floating valu

Hello
I'm using PIC18F microcontroller and using serial port to send a floating point value to labview.
whenever PIC sends te data it sends it in the form of strings.
Can anyone help me how to receive the floating point data into Labview , thus converting it into appropriate format of double precision. I'm using VISA protocol for read/write from labview.
I'm new to Labview...looking for help

0 Kudos
Message 1 of 6
(3,186 Views)
So, you just need to convert the string to double precision?  You need to use the Fract/Exp String to Number VI.  I have attached an example using it.  If I'm misinterpreting your question, you may want to clarify it.
0 Kudos
Message 2 of 6
(3,172 Views)
No no you misinterpreted it...actually I'm getting rubbish characters like ..."!@#$?<>>" as  a string and I want that to get changed to DBL so that I can process it further...
Regards,

0 Kudos
Message 3 of 6
(3,170 Views)
So the problem is that the data you are receiving from the microcontroller is actually bad then?  Hmmmm.  Not sure how to help you there, as I have not worked with that microcontroller before.  I didn't find any other posts from people using that particular one, but I did find and example that may be helpful.  Take a look at this and see if it helps, as I think it is doing something similar to what you are looking for.

http://zone.ni.com/devzone/cda/epd/p/id/4554
0 Kudos
Message 4 of 6
(3,160 Views)
Most likely, you need to typecast your string.
 
Do you know if the binary string is big endian or little endian? Do you know if it is SGL or DBL? Is it a single number or an array of numbers?
 
If the string is big endian, just typecast it (if it is 8 bytes, use a type of DBL, if it is 4 bytes, use a type of SGL, see image).
 
If the string is little endian, you can use unflatten from string which optionally does the endian conversion for you. (or simply reverse the string if it is a single number).
 
Can you attach a simple VI containing an actual string as a diagram constant?

Message Edited by altenbach on 06-15-2007 01:04 PM

Message 5 of 6
(3,156 Views)

OK, I did not see your second clarification:


@roiht wrote:
No no you misinterpreted it...actually I'm getting rubbish characters like ..."!@#$?<>>" as  a string and I want that to get changed to DBL so that I can process it further...

You obviously have 8 bytes in your string, so you need to typecast it to a DBL (Similar as shown in my other reply). See if the result looks right, else reverse the string. 😉

Message 6 of 6
(3,148 Views)