LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion from negative single to unsigned 16bit integer

Solved!
Go to solution

Hi there,

 

I want to convert a negative single to unsigned 16 bit integer. When I have a 0 in single data type, after the conversion I would like to have 32768 in unsigned 16bit integer datatype. Any suggestions?

 

PD.: When I try to convert a negative value of single I obtain a zero on the output.

 

Thank you.

0 Kudos
Message 1 of 16
(3,528 Views)

Hi Inigo,

 

I want to convert a negative single to unsigned 16 bit integer. When I have a 0 in single data type, after the conversion I would like to have 32768 in unsigned 16bit integer datatype.

Like this?

check.png

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(3,511 Views)

Hi Gerd,

 

Thank you! Yes that's it. Now I have another problem. In my application I'm communicating a siemens s7-1200 with a cRIO 9039. I'm using modbus TCP to write in the holding registers of the PLC, but the value I'm sending is not the one that it's being written in the holding registers. The PLC works with int datatype(signed 16 bit integer), but the functions reading/writing in labview work with unsigned 16 bit dataype.

 

Somehow I've managed to read the data of the PLC without problems, but writing it's a different thing. You can see the function I'm using with the values I'm writing on the attached image "writing". Also, I've attached the values in the PLC, as you see are different to the ones in labview.

 

Thank you in advance.

Best regards,

Iñigo.

 

 

Download All
0 Kudos
Message 3 of 16
(3,495 Views)
Solution
Accepted by IñigoP

Hi Inigo,

 

when you need I16 values you should work with I16 data in LabVIEW!

 

An U16 value of 33568 is the same (bitwise) as the I16 value of -31968!

So get rid of the conversion I suggested in my previous message and simple convert the SGL value into an I16 value. Wire this I16 value to your MODBus functions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 16
(3,492 Views)

Hello Gerd,

 

But the function accepts U16 as an input, if I do what you're suggesting, a coertion dot will convert the data to U16, won't it?

 

Best regards,

Iñigo.

0 Kudos
Message 5 of 16
(3,489 Views)

Hi Inigo,

 

if I do what you're suggesting, a coertion dot will convert the data to U16, won't it?

Yes.

What's the problem?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 16
(3,487 Views)

Hello Gerd,

 

Your solution is working. I thought that I would have the same problem, because of the coertion dot. This is not the case, my bad.

 

Thank you bery much.

Best regards,

Iñigo.

0 Kudos
Message 7 of 16
(3,474 Views)
Can u plz explain this one .I'm also facing same problem ..
Sravankumar Atla
CLD || CTD
0 Kudos
Message 8 of 16
(3,249 Views)

Hi Saisravan,

 

Can u plz explain this one .I'm also facing same problem ..

Which problem do you face? Who are you talking to?

(And what is "u" and "plz"?)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 16
(3,243 Views)
Same problem....! ie. I can't able to give the -ve values to modbus write function...I need to run motor in reverse direction. So I need to give -ve values to drive...IE ABB ACS880 drive. My modbus function is unsigned 16 bit...but need to give -ve values to write function...can you please help me on this.. thanks in advance...
Sravankumar Atla
CLD || CTD
0 Kudos
Message 10 of 16
(3,236 Views)