Motion stop

  • Hello, I'm quite new in kuka programing. I need a little help.


    I have lin motion from A point to B point. I need to stop robot between A and B when some output gets true. Immediatelly after that go to point C, not matter I didn't reach B point.

    Could you advise how to do that?


    Thank you

  • Look into interrupts inside expert programming part of the manual. Inside your interrupt you will need BRAKE and at the end- RESUME.

    Edited once, last by Mentat: BREAK changed to BRAKE, because the former is incorrect, thanks SkyeFire :) ().

  • BRAKE, not BREAK. But, aside from that, Mentat is correct.


    You want to pay special attention to the program structure -- when the RESUME command is used, the program pointer jumps to the stack level where the Interrupt was declared. This will drive your subroutine -- usually I use a three-level stack: the "main" routine where the Interrupt is declared, and which calls a motion subroutine which contains just the INTERRUPT ON command, and calls the motion routine which contains just the INTERRUPT ON command, and the motion from A to B, and the Interrupt Service Routine (ISR), which the Interrupt calls. Inside the ISR, BRAKE halts the robot motion, but the RESUME command (which is badly named) is what cancels the active motion -- without the RESUME command, the robot will simply resume the interrupted motion where it left off. If the RESUME command is executed (RESUME is only allowed inside ISRs), the program pointer will jump back to the main routine, one line after the call to the motion routine. This happens even regardless of how deep the calling stack is, which is why it's so important to be careful at what level you declare the Interrupt, and at what level you use it.


    The "motion" routine also needs to end with some command to break the Advance Run Pointer, like a WAIT FOR TRUE. Otherwise, the ARP can get back to the Main routine before the Interrupt is triggered, which will cause errors. This does mean that you can't end an interruptable routine with a smooth approximated "flow" into the next move, which is another constraint to keep in mind.

  • Oh, quite complicated for me. Would you be so generous and send me your common three-level stack? Just for example. Thank you very much

  • VERY bare-bones example.

    Code
    DEF SearchMotion
      INTERRUPT ON 10 ; arm interrupt.  ISR will be called on the rising edge of $IN[1]
      $OUT[1] = False ; indicator that ISR was called
      LIN P2 ; search motion to be interrupted
      WAIT FOR TRUE ; break advance run pointer.  Without this, the advance run pointer can get back to Main before the Interrupt triggers, and cause a fault
    END
    Code
    DEF ISR()
    ; Interrupt Service Routine
    INTERRUPT OFF 10 ; protect against double-triggering
    BRAKE ; stop active motion
    $OUT[1] = TRUE ; indicate that ISR was called
    RESUME ; cancel all pending motion, jump main run pointer back to Main()
    END
  • please add in main program, directly after SearchMotion()

    INTERRUPT OFF 10


    this ensures that interrupt is no longer active. failure to do so will lead to surprises when you add more things into program such as motions and other subprogram calls after search.

    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

Advertising from our partners