LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert signed 16-bit to decimal

Solved!
Go to solution

Hello,

 

I have to convert integer signed 16 bytes to is decimal value.

 

For example the lower byte has xCC and the high has xFF who do in decimal -52.

 

The string that come from the instrument is xFFCC. What I can use with Labview ?

 

Labview 6.1

 

Windows XP

0 Kudos
Message 1 of 9
(8,080 Views)

Each character is a U8 use join to meke it a U16 then cast to I16.

FF join CC produces xFFCC or 65485 convert to I62 =-52

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 9
(8,070 Views)
Sorry I16 not I62
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 9
(8,068 Views)
Solution
Accepted by topic author Rigide

I think a type cast from string to I16 shall solve it.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(8,061 Views)

Don't work

 

I16.gif

 

 

0 Kudos
Message 5 of 9
(8,047 Views)
It works if you set your string constant to Hex display and enter FFCC.  Right now it is in Normal Display.
0 Kudos
Message 6 of 9
(8,041 Views)
Yes it's wok. But how I do it with a string who come from a RS232 reading ?
0 Kudos
Message 7 of 9
(8,029 Views)

You don't do anything differently.

 

If it is xFF and xCC, it will look like this in normal display.

 

 

 

Your issue was that you typed in FFCC in normal display which is 4 bytes consisting of x46 x46 x43 x43  (the ASCII values of "F" and "C")

Message Edited by Ravens Fan on 05-11-2010 04:08 PM
0 Kudos
Message 8 of 9
(8,021 Views)

My reading of the question is that the OP receives a string of 5 ascii characters from an instrument via RS-232 and would like to convert the hex number into an I16.  I assume you receive 'xFFCC' from the instrument (5 characters).  I am fairly certain this function was around in LV6.

 

HexStringToI16.png

0 Kudos
Message 9 of 9
(8,007 Views)