LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hexadecimal to Decimal Conversion

Solved!
Go to solution

Hi,

 

I would like to extract 040C from my frame and convert it to decimal. Currently, I’m able to extract it from the frame, but I can’t convert it to decimal. I tried using 'Hexadecimal String To Number', but without success. 

 

DATA :       0112 080F 0000 1B58 0200 0004 0C02 0100 0100 00D0 3E

 

Does anyone have an idea, please? 

0 Kudos
Message 1 of 13
(267 Views)

Try this: 

 

snip.png

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 2 of 13
(241 Views)

forgot to attach the vi, here it is

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 3 of 13
(240 Views)

for string controls you can view bytes as nonsense, byte strings, passwords? or Hex by right clicking the string control and selecting an option (see below). 

 

Jay14159265_0-1750347985241.png

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 4 of 13
(236 Views)

@Jay14159265 wrote:

for string controls you can view bytes as nonsense, byte strings, passwords? or Hex by right clicking the string control and selecting an option (see below). 

 

Jay14159265_0-1750347985241.png

 


Which is why you should make the display type visible if it isn't the default display type.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 13
(220 Views)

@billko wrote:

@Jay14159265 wrote:

for string controls you can view bytes as nonsense, byte strings, passwords? or Hex by right clicking the string control and selecting an option (see below). 

 

Jay14159265_0-1750347985241.png

 


Which is why you should make the display type visible if it isn't the default display type.


Jay14159265_0-1750351713142.png

Yes ... if you look very closely you can see the "n" for nonsense ; ) 

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 6 of 13
(157 Views)

Hi and thank you for your answers

 

I would like to extract 040C from my frame and convert it to decimal (040C = 1036). Your script extracts 4C from the frame (4C = 76). Maybe I didn’t express myself clearly.

0 Kudos
Message 7 of 13
(138 Views)

@Fredo123Danzel wrote:

Hi and thank you for your answers

 

I would like to extract 040C from my frame and convert it to decimal (040C = 1036). Your script extracts 4C from the frame (4C = 76). Maybe I didn’t express myself clearly.


I think you are missing a byte of data.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 13
(131 Views)

When I enter 040C as a constant, I’m able to convert it to decimal (040C = 1036): 

 

Fredo123Danzel_0-1750354101106.png

but when I extract 040C from my frame (0112 080F 0000 1B58 0200 0004 0C02 0100 0100 00D0 3E), I don’t get the correct conversion (I get 0).

 

Fredo123Danzel_1-1750354187822.png

 

 

0 Kudos
Message 9 of 13
(130 Views)
Solution
Accepted by topic author Fredo123Danzel

@Fredo123Danzel wrote:

I would like to extract 040C from my frame and convert it to decimal (040C = 1036). Your script extracts 4C from the frame (4C = 76). Maybe I didn’t express myself clearly.


You have a binate string and this has nothing to do with hex formatting.

 

You need to typecast or unflatten it to your required datatype (U16 or I16). You get 1036 if you assume big endian.

 

altenbach_0-1750354420676.png

 

0 Kudos
Message 10 of 13
(113 Views)