how to swap 2 int value to real after doing bit swap on idint on CBM
How to swap dint to real after doing bit swap on dint in CBM
Do we have any inbuilt function block/CM to do , below example leading to more load.do we ahve better option other than this.
Example:
Input1 Int
Input2 Int
output real
Var1 boolean16
Var2 boolean16
Var3 boolean32
var4 dint
dinttobool16(int := input1,boolstruct => var1);
dinttobool16(int := input2,boolstruct => var2);
var3.B0 := var1.B0 ;
.
.
Var3.B16 := var2.B0;
.
.
Var3.B31 := var2.B15;
bool32todint(boolstruct := var3, int => var4);
output := dint_toreal(var4);
Do we have any inbuilt function block/CM to do , below example leading to more load.do we ahve better option other than this.
Example:
Input1 Int
Input2 Int
output real
Var1 boolean16
Var2 boolean16
Var3 boolean32
var4 dint
dinttobool16(int := input1,boolstruct => var1);
dinttobool16(int := input2,boolstruct => var2);
var3.B0 := var1.B0 ;
.
.
Var3.B16 := var2.B0;
.
.
Var3.B31 := var2.B15;
bool32todint(boolstruct := var3, int => var4);
output := dint_toreal(var4);
Answers
I am afraid not!
Why are your bits swapped in the first place ?
Are you reading them from a Hardware device ? Then you probably configured the device wrongly. Set the bit order in the hardware configuration or in the sending PLC.
Are you reading them from a Hardware device ? Then you probably configured the device wrongly. Set the bit order in the hardware configuration or in the sending PLC.
You don't do any bit swap only combine two int values to generate real value. Check function words_to_real in the System library.
Hi,
If your requirement is to convert two integer value to real, then you shall refer my previous answer in the below threads.
https://forum-controlsystems.abb.com/...
Two Integer values was converted to real using FBD
If your requirement is to convert two integer value to real, then you shall refer my previous answer in the below threads.
https://forum-controlsystems.abb.com/...
Two Integer values was converted to real using FBD
Add new comment