Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sdk:castint2float [2017/06/14 12:48]
juraschek created
sdk:castint2float [2018/02/02 15:45] (current)
preisig
Line 1: Line 1:
-====== Cast  ======+====== Cast two integer into one float  ​======
  
 Sometime there are 32Bit Float Values stored in 2 16bit Modbus Register. ​ Sometime there are 32Bit Float Values stored in 2 16bit Modbus Register. ​
Line 7: Line 7:
  
 We are assuming that in Register 0x0002 are the MSB and in 0x0001 are the LSB. We are assuming that in Register 0x0002 are the MSB and in 0x0001 are the LSB.
-Therfore we need to shit the Register 2 16bit to the right  and perform an Bitwise-"​or"​ on the ofter Register 3. +Therfore we need to shift the Register 2 16bit to the right  and perform an Bitwise-"​or"​ on the ofter Register 3. 
 Afterthat we need to copy this integer value into a memory resoure and retrieve it as a float again. ​ Afterthat we need to copy this integer value into a memory resoure and retrieve it as a float again. ​
  
Line 23: Line 23:
 mputint(mem,​0,​tempint);​ mputint(mem,​0,​tempint);​
 tempfloat=mgetfloat(mem,​0);​ tempfloat=mgetfloat(mem,​0);​
 +free(mem);
  
  
 </​code>​ </​code>​