XMOVE with OR operator

  • Place your Ad here!
  • Hello,


    You can use a WHILE loop having that connditions or create a background program.

    For the WHILE loop, the robot will go to the final point and the motion it will be intrerupted by the conditions from the while.

    cond = 0

    LMOVE p1

    WHILE cond==0 DO

    IF SIG(1001) AND cond ==0 THEN

    BRAKE

    cond = 1

    END

    IF SIG(1002) AND cond==0 THEN

    BRAKE

    cond = 2

    END

    IF DISTANCE(HERE,DEST)<=5 AND cond==0 THEN

    cond = 3

    END

    END


    CASE cond OF

    VALUE 1:

    TYPE "Robot stopped by 1001 signal"

    VALUE 2:

    TYPE "Robot stopped by 1002 signal"

    VALUE 3:

    TYPE "Robot reached the final position"

    ANY :

    TYPE "State unkown"

    HALT

    END


    And for the backgroup program:


    .PROGRAM autostart.pc ()

    loop:

    IF SIG(1001) OR SIG(1002) THEN

    SIGNAL 2001

    ELSE

    SIGNAL -2001

    END

    TWAIT 0.1

    GOTO loop



    Use XMOVE TILL 2001


    I know that the XMOVE function had some bugs with the old AS version, make sure to have the lastest version from AS and SV. And also make sure to have a watchdog for the background program, If it is in stopped mode, the robot might collide or do other silly thing.

  • Welcome to the forum...………:beerchug:

    I have never tried using multiple signals, so cannot be sure if it will accept the syntax or not.

    However, I am pretty sure you can only detect on single signal as there are positive/trailing edge detection modes and also /ERR and /LVL options associated with the command. and these would not be possible across more than one signal.


    In which case, a background task to provide the detection signal would be an alternative.

    - but the background task must be running prior to the XMOVE instruction

  • Hello, thank you for reply


    I made like that yesterday.

    Today, I tested and everything working good with background logic. I put on the beginning program PCEXECUTE command with this logic and everything is OK.

  • Before the XMOVE function you can check if the autostart is still running:


    IF TASK(1003)<>1 THEN

    PCABORT 3:

    PCEXECUTE 3:

    END


    This code will check if the autostart3 is not running, it will execute again. If you have a different program name, you can put the name into after the pcexecute 3: program_name.

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