LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2’complement hex convert

Solved!
Go to solution

The data is in16bit, little-endian, 2’complement format.

 

Eg. “60 02” is a little-endian notation, it equals to 0x0260, 608 in decimal.

Also “FF FB” means -1025.

 

May I know how to do the convert in LV, the volumn is big.

 

Any suggestion, thanks.

 

0 Kudos
Message 1 of 40
(9,512 Views)

Use the Swap Bytes VI under the "Numeric...Data Manipulation...palette. It will swap the upper and lower 8 bits of your word or array of words. You can then display it in whatever format you like.

Message 2 of 40
(9,506 Views)

Thanks, the  “60 02” is a string, and after swap, may I know how to convert further, thanks.

0 Kudos
Message 3 of 40
(9,498 Views)

@alex. wrote:

Thanks, the  “60 02” is a string, and after swap, may I know how to convert further, thanks.


Sorry, thought you wanted to convert "endianess"....Swap Bytes doesn't work on strings.

 

Can you give an example of more than just two values so I can see more of the input formatting?

Message 4 of 40
(9,494 Views)

It is a string array displayed by '\' Code as attached.

0 Kudos
Message 5 of 40
(9,492 Views)

Use string subset Vi to get lower and upper bytes.

Use concanet string to swap upper and lower bytes.

Use hexadecimal string to number conversion to convert it in decimal.

check the condition if it is greater than 65535 then subtract no. with this value to get negative no.

Labview user
Message 6 of 40
(9,491 Views)

Tried but cannot find 'concanet string', where is it, any suggestion, thanks.

0 Kudos
Message 7 of 40
(9,484 Views)

@alex. wrote:

It is a string array displayed by '\' Code as attached.


That is your raw data - all the numeric values are there.  All you need to do is typecast the string to an array of U16 and then swap bytes (as previously), as shown below.  If you don't know where to find a certain function, search the palette using the search box (or search the help).

hex bytes.png

Message 8 of 40
(9,472 Views)

Sorry It was Concatenate Strings

Every function is under strings pallete

Labview user
Message 9 of 40
(9,467 Views)

Hi Natahand,

I think  typecasting would not show negative numbers.

Labview user
Message 10 of 40
(9,466 Views)