LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting Information From a Hexadecimal String and Converting it into Decimal

Solved!
Go to solution

Hi Everyone!

I progressed now able to communicate with my inverter, I would like to represent the data that is received from the inverter in decimals. The strings that will be received would be in this format(more or less), for example "0203 0400 1800 0049 34". I want to omit the first 6 digits and last 4 digits which I had done it by using the string subset function twice(omitting the beginning, inverting and omitting and inverting again) which leaves the "00 18 00 00" part so here I want to represent the things that are not 00 in decimals. 18 in hex supposed to be 24 need to make a VI somehow.

 

First 6 and last 4 digits needs to be omitted can be done by only one "string subset" function if the mid part is a certain length which can be done because the length of the data part is in the hex message where( 02 is the address in hex, 03 is the function in hex and 04 is the amount of bytes which means 00 18 00 00 would be the data part and the last 4 digits/2 bytes is crc16 error check. So I can extract 04 in hex but can not convert it to an integer. below I'm attaching my VI which I tried couple of different things which no one had worked.

Thanks for help in advance

0 Kudos
Message 1 of 3
(2,169 Views)
Solution
Accepted by topic author ardahatunoglu

You are getting caught up in what a string is.  The Hexadecimal String To Number is for strings that are encoded in an ASCII format.  You have raw data.  So all you really need to do is use the String To Byte Array and then it is simple array manipulations to get what you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(2,147 Views)

Beautiful=)

0 Kudos
Message 3 of 3
(2,137 Views)