Select program automatically on startup in AUT mode

  • I added CWRITE in sps, but the program does not select on startup. Can anyone help? Thanks


    &ACCESS RVO

    &COMMENT PLC on control

    DEF SPS ( )

    ;FOLD DECLARATIONS

    ;FOLD BASISTECH DECL

    ;Automatik extern

    DECL STATE_T STAT

    DECL MODUS_T MODE

    ;ENDFOLD (BASISTECH DECL)

    ;FOLD USER DECL

    ; Please insert user defined declarations


    ;ENDFOLD (USER DECL)

    ;ENDFOLD (DECLARATIONS)

    ;FOLD INI

    ;FOLD AUTOEXT INIT

    INTERRUPT DECL 91 WHEN $PRO_STATE1==#P_FREE DO RESET_OUT ()

    INTERRUPT ON 91

    INTERRUPT DECL 92 WHEN $PRO_MOVE==TRUE DO RESET_LINESEL()

    INTERRUPT ON 92

    $LOOP_MSG[]=" "

    MODE=#SYNC

    $H_POS=$H_POS

    ;Automatik extern

    IF $MODE_OP==#EX THEN

    CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")

    ENDIF

    CWRITE($CMD,STAT,MODE,"RUN /R1/Program/t()")


    LOOP

    WAIT FOR NOT($POWER_FAIL)


    CWRITE($CMD,STAT,MODE,"RUN /R1/Program/t()")


    ENDLOOP



    ;FOLD

    END

    ;ENDFOLD



    DEF RESET_OUT ( )

    INT N

    MsgLoop(" ")

    IF REFLECT_PROG_NR == 1 THEN

    FOR N = 0 TO PGNO_LENGTH - 1

    $OUT[PGNO_FBIT_REFL + N] = FALSE

    ENDFOR

    ENDIF

    IF (PGNO_REQ>0) THEN

    $OUT[PGNO_REQ]=FALSE

    ELSE

    IF (PGNO_REQ<0) THEN

    $OUT[-PGNO_REQ]=TRUE

    ENDIF

    ENDIF

    END


    DEF RESET_LINESEL()

    $LINE_SEL_OK=FALSE

    END

    ;FOLD USER SUBROUTINE

    ; Integrate your user defined subroutines


    ;ENDFOLD (USER SUBROUTINE)

    ;ENDFOLD

  • kwakisaki

    Approved the thread.
  • ;Automatik extern

    IF $MODE_OP==#EX THEN

    CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")

    ENDIF

    CWRITE($CMD,STAT,MODE,"RUN /R1/Program/t()")

    Unconditional CWRITE is a bad idea. You should have the second CWRITE inside an IF $MODE_OP==#AUT statement, like the #EX one above it.


    Is there another program selected before the robot is rebooted? And is it still selected after reboot is complete? Or is $PRO_STATE1==#P_FREE? I've never liked use CWRITE RUN without checking $PRO_STATE first and using CWRITE CANCEL beforehand.


    For example, this is from the Loop section of an SPS, designed to always Select CELL.SRC whenever the mode was changed to #EX, but the concept is the same:

    Code
                IF ($PRO_STATE1==#P_FREE) OR ($MODE_OP<>#EX) THEN
                   $FLAG[iProgramStarted]=FALSE
                ENDIF
                IF ($PRO_STATE1<>#P_FREE) AND ($MODE_OP==#EX) AND (NOT ($FLAG[iProgramStarted])) THEN
                   CWRITE($CMD, STAT, MODE, "CANCEL")
                ENDIF
                IF ($PRO_STATE1==#P_FREE) AND ($MODE_OP==#EX) THEN
                   CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()")
                   $FLAG[iProgramStarted]=TRUE
                ENDIF

    Since you're trying to run the CWRITE in the Init of the SPS, you could do away with the $FLAG, which was used to ensure the CWRITEs were one-shotted, not cyclical. But you can see that the Interpreter is Cancelled first, then the CWRITE RUN is only executed after $PRO_STATE1 is #P_FREE.

  • Thank you for your reply. I test the program in KUKA Office Lite 8.63, is this effect?

    As I checked $PRO_STATE1==#P_FREE,and R on the top of the screen is grey. I change the code as the following, but still takes no effect. flag[3] is twinkle,0.5s true,0.5s fales.

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