11-08-2010 06:56 AM
Hello,
I am in internship and I have a problem with my system.
I send information between a PCB to my computer. I send in my frame, a float in string format and I would like to make the conversion in LabView to show the good value.
For example, there are something like that in my buffer : 3E94C2DC and I would like to convert that in decimal format.
Could you help me please.
Thanks in advanced.
Quentin
Solved! Go to Solution.
11-08-2010 07:46 AM - edited 11-08-2010 07:46 AM
Not clear to me:
Source: '3E94C2DC' in what format? 2 words in Hex , or 8 bytes from serial coded in ASCII?
Output format: single float?(0,290549)
11-08-2010 08:05 AM - edited 11-08-2010 08:06 AM
It is 8 bytes from serial coded in ASCII. And I would like to convert this 8 bytes of my float string to decimal number. Then I could show the real value in LabView.
My output that I would like to have is around 0.30
11-08-2010 08:11 AM
Hi Quentine
Maybe you can use Hexadecimal String To Number Function (http://zone.ni.com/reference/en-XX/help/371361G-01/glang/hex_string_to_number). I attached an example.
Regards
Greg
11-08-2010 08:16 AM - edited 11-08-2010 08:24 AM
Did you see the number in my question ??
What LV version do you have ?
Just save and paste the snippet from my previous post 🙂
However, here as a vi in LV2009
11-08-2010 08:22 AM - edited 11-08-2010 08:23 AM
Sorry Henrik,
When I started creating post, there was no answer yet. After I send my post I saw your post. Maybe next time I will be faster 😉
regards
Greg
11-08-2010 08:23 AM
I am sure it is not clear taht I have.
I have a float number, I send the float number in my buffer with C code with printf instruction like that :
printf ("%x", numberthatIhave);
In labview I read my buffer, so it is a string format. And I would like to convert the message (hex value in string format) to a decimal number to show the number.
But I do not know how I can do that...
11-08-2010 08:32 AM
The snippet /vi should solve your problem.
The string is converted to a binary 32bit respensentation and then converted to a single float (also 32bit)
To check the result it would have been usefull to post an exact input / output pair 😉
Have fun 🙂
11-08-2010 08:42 AM
When I make the test with you solution, I have 1.049. Whereas I would like to have 0.30
11-08-2010 08:49 AM - edited 11-08-2010 08:54 AM
Do you see the minor but important difference ?
I used the typecast to convert U32 to SGL 😉
And you get 0,290549
(U32 displayed in Hex)