Hi all,
I'm communicating with a modbus device which sends data in 32 bits data.
You can see the structure in this example:
N7:4 MW810 swap: enter c_conv_index
N7:5 MW811 swap: enter c_conv_index
N7:6 MW812 swap: decimal c_conv_index
N7:7 MW813 swap: decimal c_conv_index
I read modbus words and I put it in N7 map. Then I move two N7 words (N7:5 to n7:54 and N7:4 to N7:55 to swap the integer part) and the same with (N7:7 to N7:56 and N7:6 to N7:57 to swap the fractional part).
Then with instruction CPW I convert the 2 integer words N7:54 and N7:55 to long L10:7 (integer part).
Also with instruction CPW I convert the 2 fractional words N7:56 and N7:57 to long L10:8 (fractional part).
The result:
Now I have the integer value on L10:7 (25) and the fractional value on L10:8 (23658016).
The problem is that I need a float value of (25,23658016). I have tried some things without success.
I have tried with a CPT to divide and add the integer part: L10:7+(L10:8|100000000) to a float F8 but I have an error saying that "Operand sizes do not match!".
Could you help me? Do you know how to solve this problem?
Thanks in advance.
Pau
I'm communicating with a modbus device which sends data in 32 bits data.
You can see the structure in this example:
N7:4 MW810 swap: enter c_conv_index
N7:5 MW811 swap: enter c_conv_index
N7:6 MW812 swap: decimal c_conv_index
N7:7 MW813 swap: decimal c_conv_index
I read modbus words and I put it in N7 map. Then I move two N7 words (N7:5 to n7:54 and N7:4 to N7:55 to swap the integer part) and the same with (N7:7 to N7:56 and N7:6 to N7:57 to swap the fractional part).
Then with instruction CPW I convert the 2 integer words N7:54 and N7:55 to long L10:7 (integer part).
Also with instruction CPW I convert the 2 fractional words N7:56 and N7:57 to long L10:8 (fractional part).
The result:
Now I have the integer value on L10:7 (25) and the fractional value on L10:8 (23658016).
The problem is that I need a float value of (25,23658016). I have tried some things without success.
I have tried with a CPT to divide and add the integer part: L10:7+(L10:8|100000000) to a float F8 but I have an error saying that "Operand sizes do not match!".
Could you help me? Do you know how to solve this problem?
Thanks in advance.
Pau