LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert to Signed Decimal

Solved!
Go to solution

Hello All,

 

I am receiving the following delimited string over GPIB.

 

ST4;TA246;TD252;AF15;ME3;SP1850;SP2250;SP365136;MS     2

 

 

The instructions to interpret this string tell me convert to Signed Decimal when dealing with negative temperatures. The value I am trying to convert is 65136 which I supposed to be -40 Degrees C.

 

How can I do this in Labivew?

 

Can anyone point me in the right direction.

 

Thanks

0 Kudos
Message 1 of 6
(2,618 Views)

Hi Andy,

 

convert the string to an U16 value, then convert that U16 to an I16…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(2,605 Views)
Solution
Accepted by topic author AndyTT

In addition to the convert to a U16 and then type cast to I16, it also looks like you will need to divide by 10 to get your actual temperature.


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 3 of 6
(2,600 Views)

Isn't it enough to parse the string to I16 instead of parse U16 and type cast? Or it'll 'safe out' at +32k instead?

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(2,557 Views)

@Yamaeda wrote:

Isn't it enough to parse the string to I16 instead of parse U16 and type cast? Or it'll 'safe out' at +32k instead?


It will "safe out" to +32k (just tested to make sure).


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
0 Kudos
Message 5 of 6
(2,549 Views)

But as Gerd already suggested, converting to I16 is the same as the typecast to I16, but simpler and less code (works for all integers if the number of bits does not change, of course).

 

U16I16.png

 

(And if you only need the blue indicator, setting the indicator to I16 would even be sufficient, but you get a pretty coercion dot :D))

0 Kudos
Message 6 of 6
(2,512 Views)