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.
Solved! Go to Solution.
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.
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…
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?
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.
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"?)