RobotStudio event

How to mask a num value?

Options

Hi,

I have a number of 104 (example, changes depeding on what the number I get from the PLC is). I would like to read the two last digits of 104 (04) and read that into a new num, is this possible in RAPID? Shearched but can't find anything regarding that.

 

Best regards,

Alexander K

AlexK2008-8-6 10:56:13
Best regards
Alexander Källberg

Comments

  • Henrik Berlin
    Options

    Hi Alexander,

    Try this:

    m = your original integer

    n = the two last digits

    n = m - Trunc(m  / 100) * 100

    Example:

    m = 1234

    m / 100 = 1234 / 100 = 12.34

    Trunc(m / 100) = Trunc(12.34) = 12

    Trunc(m  / 100) * 100 = 12 * 100 = 1200

    n = m - Trunc(m  / 100) * 100 = 1234 - 1200 = 34

    Disclaimer: This algorithm was not tested in RAPID and needs to be validated before put into production.

    Henrik Berlin2008-8-6 16:49:40
    Henrik Berlin
    ABB
  • PerSvensson
    Options

    Or something like this

    image

    Per Svensson
    Robotics and Vision Specialist
    Consat Engineering
  • AlexK
    Options

    Thank you very much, need to put me into the above examples, I'm not a math genius, but I don't think it will be a problem, else I will bother the two of you again image

    Best regards,

    Alexander K

    Best regards
    Alexander Källberg