LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple hex right shift operation

I think this is a fairly simple question, I am trying to translate the following code into LV:

unsigned short crc = 0;
unsigned char b = 0x7d;
crc = crc ^ (unsigned char) b << 8;
if (crc & 0x8000)
crc = crc << 1 ^ 0x1021;

The only requirement is that 'b' should be the string variable in the 'hex' format and not the 'normal' format.

Another question is how a string variable in 'hex' format can be converted into 'normal' format?

Thanks in advance.
0 Kudos
Message 1 of 6
(4,362 Views)
1. If you are using LV 7.0 and above the functions that deal with that kind of code are the: "Data Manipulation". Try there first for all.

2. Try to connect a string that is display as "HEX Display" to a String Indicator that is at Normal Display. It Works for me....

Hope it helps....
0 Kudos
Message 2 of 6
(4,362 Views)
see the image, use integer(U8) for the unsigned char b

-Joe
0 Kudos
Message 3 of 6
(4,362 Views)
Thanks for the first answer. I have attached the VI that does the manipulation.

However your second answer did not work for me. Hence is it possible for you to modify my code with this change. Probably I am wrong, so I have included a second control by the name of StringInput(HexDisplay) that may be of help.

Thanks in advance.
0 Kudos
Message 4 of 6
(4,362 Views)
Thanks Joe,

I have attached the code in LV. Using the second control "StringInput(HexDisplay)" is bothering me. I wish to perform the same operation as being done presently but with the new control.

Any help would be greatly appreciated.
Thanks
0 Kudos
Message 5 of 6
(4,362 Views)
Hi,

try this vi to tranform hex (it's called ASCII) to normal...

Hope it Helps ....
0 Kudos
Message 6 of 6
(4,362 Views)