Colleagues,
Conversion is straigtforward and very simple.
Connect your string "3F7851EC" to "Hexadecimal String To Number"
function, leave the all inputs, except string, unwired.
You'll get U32 number. Then use "TypeCast" to convert this number to
"SGL" LabVIEW type. You'll get your 0,97 in a single float numeric
indicator.
This is all described in IEEE floating point numbers format standard,
and LabVIEW strictly follows it making the all conversions for you.
If you need more explanation, let me know.
Regards,
--
Sergey Krasnishov
____________________________________
Automated Control Systems
National Instruments Alliance Member
Moscow, Russia
sergey_acs@levsha.ru
http://acs.levsha.ru
Michael Ziegler wrote:
> "Pelle Soderberg"
erg@flir.com> schrieb im Newsbeitrag
> news:3a54f8aa@newsgroups.ni.com...
>
>> I'm reading data from an instrument that
>> sends the data in Hex (ASCII String)
>> and I need to convert the data to Float.
>> All labview Vi:s converts to integers and spoils all my attempts.
>> Anyone have an idea?
>>
>> Example (Motorola format)
>> "3F7851EC" convert to 0.97
>
>
> I think there is no possibility to convert it directly only with Labview.
> But you should be able to call a C function (see Code Interface Node)
>
> C-function to convert a hex-ASCII float value to numeric float
>
> float strg2float( char *stringval)
> {
> union {
> unsigned long ulong;
> float floatval;
> }conv;
>
> sscanf( stringval, "%X", &conv.ulong);
> return( conv.floatval);
> }
>
> Greetings Mike