paulusB Posted May 4, 2020 Report Posted May 4, 2020 (edited) I'm building a function block to sum flow and production hous and calculate average flow based on a REAL input. For avering I use /L function. The Result R is a LWORD To get a more acurate result I want to convert the result to a REAL. The first two words of the LWORD is the Quatient in DINT The last two words of the LWORD is the Remainder in DINT How do I read out the remainder in a function block. A bit shift is nog working (NASR/NSRL) is only availabe to 32 bits,'. When not in a function block and using de D channel you simply pick the 3rd channel LWORD = D100 D100 = DINT for QuatientA D102 = DINT for remainder. m3_test.opt m3_test.bak m3_test.cxp Edited May 4, 2020 by paulusB attached function block
paulusB Posted May 4, 2020 Author Report Posted May 4, 2020 Figured it out. You have to work with arrays and move them (as discribed in the help ) 1
Crossbow Posted May 6, 2020 Report Posted May 6, 2020 Why do math on integers and then convert to real? That's not accurate. Convert the numbers to real before doing to math so decimals are not rounded off.
paulusB Posted May 6, 2020 Author Report Posted May 6, 2020 Because the total amounts can become big and real then les accurate
paulusB Posted May 6, 2020 Author Report Posted May 6, 2020 (edited) Thanks for the replies. I thought 64 bit real math wasn't available in CX-programmer. But it is. Edited May 6, 2020 by paulusB but help says only 32 bits...?
Crossbow Posted May 8, 2020 Report Posted May 8, 2020 Those are 32-bit real number commands. I think only NJ/NX have 64-bit floating point.
Michael Walsh Posted May 8, 2020 Report Posted May 8, 2020 I see you are using a CJ2M PLC. I have shown below how to use double real numbers in CXP with a CJ2M PLC. Symbol creation: Choose LREAL as the data type. Be aware that this data type uses 4 consecutive 16 bit addresses. So in this example, the variable would use D0, D1, D2 and D3. Here are some of the double floating point instructions: 2
paulusB Posted May 11, 2020 Author Report Posted May 11, 2020 I totally missed the "D" instructions. Thanks
Crossbow Posted May 13, 2020 Report Posted May 13, 2020 My bad... I am way behind on my knowledge of the legacy platforms, pretty much a Sysmac guy now...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now