KRC4 $OV_PRO speed set using input from sensor

  • We have a KRC4 robot and would like to set the $OV_PRO speed to run at a slow speed when it sees an input from a sensor and then at a faster second speed if the input is not seen.
    The code that is written at the top of the sub routine at the moment is,


    IF I_SHELLS_OPENED_PIECE_ON THEN
    $OV_PRO=50


    ELSE
    $OV_PRO=100


    ENDIF


    I_SHELLS_OPENED_PIECE_ON is the input from the sensor.


    What is happening is that the robot runs at 100%, sees the input and then slows down to 50%. When we lose the input the robot stays at 50%.
    Is there a way to run at 50% when seeing the input and 100% if not?


    We have multiple programs being called so this change will be in not just one.


    Thanks

  • your code can work only if written in sps.sub, so you have cyclic execution. In subroutine like in your case,
    will work only once per call. Or if you want your code to work in subroutine too,you have to use interrupt.

    Edited once, last by spiral ().

Advertising from our partners