# New to Interrupts

**URL:** <https://tech-community.robotics.abb.com/t/new-to-interrupts/7253>\
**Category:** RobotStudio\
**Created:** [July 6, 2016, 7:56am UTC](https://tech-community.robotics.abb.com/t/new-to-interrupts/7253 "2016-07-06T07:56:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khewes](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@khewes](https://tech-community.robotics.abb.com/u/khewes)\
**Post date:** [July 6, 2016, 7:56am UTC](https://tech-community.robotics.abb.com/t/new-to-interrupts/7253/1 "2016-07-06T07:56:43Z")

</div>

Goodmorning All,  
I am trying to implement an interrupt that is tied to a toggle switch input. I want this interrupt to stop the robot in place when toggled high, and resume movement when toggled back to low. I have gotten this operation to work, however, I want this operation to be repeatable…which it is not. If the interrupt is used once, it cannot be activated again, until I restart the program. I am in teach pendant mode. Any suggestions?

Thank you,  
Kris

---

<div class="post-metadata">

**Author:** ![kioog](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kioog](https://tech-community.robotics.abb.com/u/kioog)\
**Post date:** [July 6, 2016, 8:18am UTC](https://tech-community.robotics.abb.com/t/new-to-interrupts/7253/2 "2016-07-06T08:18:08Z")

</div>

Hello,  
what error do you get, that the interrupt is already declared?  
best use is that you define your interrupts at the beginning of your program, before your main loop  
and that you use Iwatch en Isleep in your program to put them active or inactive when you want.  
best use is also to put an Isleep in the beginning of your trap routine for your interrupt, otherwise you can nest down your interrupts when you have fast multiple flanks of your interrupt signal.  
also when you declare your interrupt, put Idelete just the line before, so when the interrupt is declared, it is deleted and you can redefine the interrupt, otherwise you get an error that the interrupt already exist.  
when you do “PP at main” all interrupt are deleted, that is probably why it always works only 1 time.

BR  
Peter

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [July 6, 2016, 8:07pm UTC](https://tech-community.robotics.abb.com/t/new-to-interrupts/7253/3 "2016-07-06T20:07:06Z")

</div>

In the routine called by your interrupt:

- stop the robot motion

-WaitDI for the input to go low

then the program will carry on from where it got interrupted.

Will this for your situation?

---

<div class="post-metadata">

**Author:** ![Pavel\_Riabichev](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@Pavel\_Riabichev](https://tech-community.robotics.abb.com/u/Pavel_Riabichev)\
**Post date:** [July 14, 2016, 5:27am UTC](https://tech-community.robotics.abb.com/t/new-to-interrupts/7253/4 "2016-07-14T05:27:39Z")

</div>

It is important to delete your interrupt declaration at the beginning of each cycle as in the example below:

PROC main()  
IDelete sig1int;

CONNECT sig1int WITH iroutine1;  
ISignalDI diInput,1,sig1int;

WHILE TRUE DO

!continious program here

ENDWHILE  
ENDPROC

/Pavel
