LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

converting string of hexadecimals to numbers

Hello all, i am trying to convert a string of hexadecimal numbers to decimal numbers. the problem is, the string i get is hexadecimal under hex display. under normal display it's bunch of weird stuff. for example: under hexadcimal display of string indicator, i get 01 86A0 which is 16^4*1+16^3*8+16^2*6+16^1*10+16^0*0=100000 in decimal. but the normal display of this string shows a squarebox and a cross . †  something like that. so when i tried to simply convert hexadecimal string to number, it obviously didn't work. one possible cause to this problem is because string '1' has hex value of 31, instead of 01. and so on for the other numbers.

a normal displayed version of string 186A0 can easily be converted to 100000. how do i convert such in my case?

thank you for all your help!
0 Kudos
Message 1 of 7
(3,154 Views)
Hi northPIG87,
use the "Hexadecimal String to Number" conversion. The strings you see in the indicators are ascii signs, so it is normal that 1 is not 1.
 
 
Mike


Message Edited by MikeS81 on 06-19-2008 11:14 AM
0 Kudos
Message 2 of 7
(3,152 Views)
Hi mike, thanks for the reply! but i have tried that but it  doesn't work. it works for 0186A0 if you type it in normal display mode. but the string i get is 0186 A0 under hexadecimal display. attached is a picture of both cases. hope you can see the difference.
0 Kudos
Message 3 of 7
(3,148 Views)
Hi northPIG87,
why do you want to insert your string in hex display. The conversion works with the normal display, if you insert a hex number there then labview can convert it to a hex nnumber, but if you insert your number in hex display, then it is "nothing" in normal display.
Mike
0 Kudos
Message 4 of 7
(3,143 Views)
Hi northPIG,

that's a typical use case for TypeCast, see attachment or this picture:

You only have to make sure you always typecast 4 bytes from string to U32 to get correct numbers...


Message Edited by GerdW on 06-19-2008 12:20 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 5 of 7
(3,134 Views)
Hello mike, it's not that i want to insert them as hexdisplay. this value iwant to convert is obtained from a instrument via serieal port.  the out put string of this instrument comes as a string that only makes sense if you hexdisplay it. hope that made sense to you.
0 Kudos
Message 6 of 7
(3,130 Views)
Oh my thank you so much!!! Yes it works!
thank you!!!
0 Kudos
Message 7 of 7
(3,128 Views)