Convert REAL to INT

  • Hi!


    I get a numerical value from the PLC in a REAL format but in order to use the value as index for a FOR/ENDFOR-loop the value must be an INTEGER.

    How can I convert the REAL-value to an INT-value in the robot (LR-MATE 200 with plus-controller)?


    Is it enough to move it to another [R] register or is there an instruction that must be used?


    Thank you!

  • Place your Ad here!
    • Helpful

    Try using the DIV command to convert the Real number to an Integer. The DIV command is for Integer division and will return only the quotient. R[1] is Real, R[2] is new Integer. R[2]=R[1] DIV 1 This will divide R[1] by 1 and will set R[2] to the Integer value of R[1].

  • Try using the DIV command to convert the Real number to an Integer. The DIV command is for Integer division and will return only the quotient. R[1] is Real, R[2] is new Integer. R[2]=R[1] DIV 1 This will divide R[1] by 1 and will set R[2] to the Integer value of R[1].

    This is a good suggestion.
    Also, adding before division +0.5 to positive value or -0.5 to negative one, will result in correctly rounded integer, instead of truncated.

  • The main reason is that we do not have the plc programmer in house. And we have a bunch of machines rolled out around the world.

    We have the knowledge and possibilities to adjust on the robot side of the application but not on the plc side. So even though it would be easier to change the plc program I really prefer how to do this on the robot side in case we need to do this on a machine on the other side of the world.

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 account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners