LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transform 32-bit FLOAT number to 16-bit UNSIGNED

Solved!
Go to solution

Hi there,

 

I am trying to write 32-bit single precision number to two 16-bit unsigned modbus regsiters. Any ideas how could that be done? 

 

thanks in advance!

0 Kudos
Message 1 of 7
(6,141 Views)

How much precision do you need, and how do you want to use the value later?


GCentral
0 Kudos
Message 2 of 7
(6,137 Views)
Solution
Accepted by zde92

Hallo zde,

 

maybe this is an inspiration to you:

check.png

Best regards,
GerdW


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

splitJoinSgl.png

I got this far, but yours is much nicer. I didn't realise before looking into this how miserable single-precision is...


GCentral
Message 4 of 7
(6,125 Views)

For now, I don't have specific requirement for precision. I'am trying to do the modbus master/slave simulator. The SGL value will be written in input register of slave, then read with Read from input registers function on master. Since the modbus functions accepts the U16 format, the conversion is needed. 

0 Kudos
Message 5 of 7
(6,110 Views)

Hi there, I tried something similar using type cast to transform to U32 and the used Split Number. But probably, I would need to create the opposite conversion on master where I read the values from register? 

 

 

 

0 Kudos
Message 6 of 7
(6,104 Views)

Hi zde,

 

I tried something similar using type cast to transform to U32 and the used Split Number.

So you get the same result using more functions!? 😄

 

But probably, I would need to create the opposite conversion on master where I read the values from register? 

Yes, when you want to "simulate" this master too…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(6,096 Views)