Cancel Program and Send Pointer to Cell.

  • Hello I would like to have the possibiity of restart program of robot from any situation.


    In Cell I have a routine to send robot home acording to axis.


    I want to send a Signal from PLC to Robot. When Robot reads this signal in SPS makro, I would like to cancel any movement and program, and run cell again. Something similar to "PP to Main" signal in ABB robot.


    Thanks!!

  • The SPS (Level 0 interpreter) can manipulate the Level 1 Interpreter ("normal" programs) using CWRITE commands to the $CMD channel. The stock SPS already has some code that does this, and searching the manuals and the forum archives will turn up multiple examples. Basically, the SPS can perform STOP, CANCEL, and SELECT commands, emulating an operator using the FILE menu on the KCP.


    That having been said, what you are proposing to do is rather risky -- you can order the robot to cancel the current program stack, and start CELL from the beginning. But this will result in the robot attempting to move directly Home from wherever it is, which creates a serious collision risk. To make this work safely, you will need some sort of conditional safe path(s).

  • Don't try it with SPS.SUB and cwrite ..... It is much easier.
    Try something like that:



    I have done this in many applications and it works like a charm.


    Edit: corrected some faults (because typed it from scratch and by mind).

    Edited once, last by hermann ().

  • Thanks both:


    First, I'm not an expert with Robots, I'm a PLC programer (not too bad) and sometimes I have to integrate a Robot in my machines; so for every new task I have to study, read forums, and documentation to implement correctly.


    About sending robot directly to home. I don't do it. I have a routine that recognize actual possition of robot and sends it to home using a safe path. When I can't identify the correct path, Robot stops, and operator must send manually to home.


    * About Interrupt's solution, seems easier, but when I run it, a massage says that is not possible tu use when interruption is declared as global.


    * If finally I can't get it with interruptions, I will try sriting on the $CMD Channel


    Thanks!!

  • remove GLOBAL from interrupt declaration... cant use RESUME with global interrupt. also activate interrupt before calling sub

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • So to Clarify if to say the Cell looked like this.
    DEF cell( )
    INIT
    BASISTECH INI
    CHECK HOME
    PTP HOME
    Reset_IO()
    AUTOEXT INI


    ;RESTART INTERRUPT
    INTERRUPT DECL 1 WHEN bAbort_Program == TRUE DO Restart_Program()
    INTERRUPT OFF 1
    WAIT SEC 0.12


    INTERRUPT ON 1
    WAIT SEC 0.12




    LOOP

    P00 (#EXT_PGNO,#PGNO_GET,DMY[],0 )
    SWITCH PGNO ; Select with Program number


    CASE 1
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request

    IF $IN_HOME==FALSE THEN
    UnknownToHome()
    ENDIF

    IF $IN_HOME==TRUE THEN
    Reset_IO()
    endif


    CASE 4
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
    IF $IN_HOME==TRUE THEN
    Maintenance( )
    ENDIF

    CASE 7
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
    IF $IN_HOME==TRUE THEN
    MasterReference( )
    ENDIF

    CASE 8
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
    IF $IN_HOME==TRUE THEN
    BrakeTest( )
    ENDIF

    CASE 9
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
    IF $IN_HOME==TRUE THEN
    Reset_IO ( )
    ENDIF

    CASE 10
    P00 (#EXT_PGNO,#PGNO_ACKN,DMY[],0 ) ; Reset Progr.No.-Request
    IF $IN_HOME==TRUE THEN
    MAIN JOB
    ENDIF


    DEFAULT
    P00 (#EXT_PGNO,#PGNO_FAULT,DMY[],0 )
    ENDSWITCH
    ENDLOOP
    END



    GLOBAL DEF Restart_Program ()


    BRAKE
    INTERRUPT OFF 1
    Wait SEC 1


    END



    What would the out come be if the program was running a subroutine and i triggered the abort signal?

  • NO.
    The Cell should not look like that.


    More like this:


  • so that would send the program back to the "MainLoop" Correct?, i need to make sure that the home routine is only allowed after i push the home button, with unknown to home being triggered on the abort that defeats the purpose of the home button does it not?

    Edited once, last by Azermath ().

  • Hello:


    I found the solution in a Robot, unfortunately I had no choice to implement in my aplication as it was already delivered (finally I did with interruptions).


    Something like this should be implemented in SPS routine.


    In this case when PLC sets Input 180, robot sends feedback and cancels cell.
    With input 181 from PLC, Cell is started again



    IF $IN[180] THEN
    PULSE($OUT[180],TRUE,0.4)
    cwrite ($cmd,stat,mode,"cancel/R1/cell()")
    ENDIF


    IF $IN[181] THEN
    PULSE($OUT[181],TRUE,0.4)
    Cwrite ($cmd,stat,mode,"run/R1/cell()")
    ENDIF

  • NO.
    The Cell should not look like that.


    More like this:


    Hello guys!


    Hermann can I ask that why did you use GLOBAL DEF in cell.src?

    Is this the only way to write a program in cell.src?


    Moreover, what would happen, if i don't write the program "name" as you do, because i write the full program into case 4.


    Is that possible?


    I tell yout why is it important for me. I saw your code(which i respondod) and it helped me a lot, but i would like to modify it a little bit.

    -> Process is going in a loop cycle.

    -> the operator push a virtual button, when would like to modify the parameters.(interrupt off))

    -> The PLC got the information and waiting to the robot to end the last cycle.(in the last line interrupt on, and it trigger immediately)

    ->When the robot would like to start the cycle again, he won't because the program pointer went back here, and wait to the parameters and the start button:

    loop
    mainloop ()
    interrupt off 1
    UnknownToHome()
    endloop
    END

    Then it starts again.


    That's why i would like to write the full program into cell.src

    If i just write the program in case 4 like, Robot_program() and in that program i would like to make that interrupt what i mention upper, that wouldn't work.


    Any advice please?:)


    Thanks in advance!:)

  • Hermann can I ask that why did you use GLOBAL DEF in cell.src?

    Is this the only way to write a program in cell.src?

    Back before KSS 5(?), every .SRC file was limited to containing only one routine/function. This routine had the same name as the file. Hence, CELL.SRC starts with DEF CELL.


    Later, the ability to add multiple subroutines in a single SRC file was added. But these subroutines were purely "local" -- they could only be called by other routines inside the same .SRC file.


    Later still, GLOBAL DEF was added. This made it possible to make any subroutine in any .SRC file globally call-able, from any routine in any .SRC file. This made packaging programs easier.


    However, in order to maintain backward compatibility, the "filename routine" still has to be the first routine in the .SRC file, and cannot use GLOBAL DEF. This is because the "filename routine" (DEF CELL() in CELL.SRC, for example), is implicitly Global. Any subroutine in an .SRC file is implicitly local, unless it is explicitly made Global used GLOBAL DEF.


    Siimilarly, any variable in $CONFIG.DAT is implicitly Global (and so using DECL GLOBAL must be avoided), but it is now possible to make specific variables in other .DAT files global by explicitly declaring them so.

    Moreover, what would happen, if i don't write the program "name" as you do, because i write the full program into case 4.

    That is possible, but generally considered to be a poor practice. Generally, CELL.SRC is intended to have no motions (aside from Home), only calls to various motion routines. Placing motion paths inside a particular CASE inside CELL makes CELL harder to maintain, and less modular.

  • Wow SkyeFire I really appreciate your detailed informations what you give to me!:)


    Then i thought correctly, thanks for the confirmation:)


    If you don't mind i would like to ask one question about the upper program what i commented.


    Is it possible to write a declaration as GLOBAL INTERRUPT DECL 5 in cell. src like hermann did here:

    And after that, in the local .src i write in the lines an INTERRUPT ON 5?


    DEF ROBOT_MAIN_PRG()

    INI


    PTP XHOME
    PTP P1

    PTP P2

    and so on


    INTERRUPT ON 5


    END


    And in the cell.src:



    Is this fine then? :)

  • I think Hermann's code is okay, except that I don't think it's correct to use "GLOBAL" for an INTERRUPT OFF or INTERRUPT ON command -- IIRC, you only use GLOBAL on an Interrupt for the INTERRUPT DECL line.


    I could be wrong, though, it's been a while.


    Interrupts are "inherited", unless DECL'd GLOBALly. That is, an Interrupt DECL'd in one routine is "accessible" to any subroutine in the stack below the routine that DECL'd the Interrupt. But not accessible "laterally".

  • Ohh wow, thanks you.

    The end of the code is mine addition, hermann did everything correct!😊

    So, it looks like i can use it!

    Thank you very much guys!:)

  • NO.
    The Cell should not look like that.


    More like this:


    hermann I write this code to my KRC and i get error message 2350:

    "Runtime data of the main program cannot be used"


    Do you know what am i did wrong please?

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