This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sdk:castint2float [2017/06/14 12:48] – created juraschek | 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-" | + | Therfore we need to shift the Register 2 16bit to the right and perform an Bitwise-" |
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, | mputint(mem, | ||
tempfloat=mgetfloat(mem, | tempfloat=mgetfloat(mem, | ||
+ | free(mem); | ||
</ | </ |