# Trap routine is not called

**URL:** <https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164>\
**Category:** RobotStudio\
**Tags:** traps, trap\
**Created:** [March 28, 2018, 4:21pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164 "2018-03-28T16:21:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cerminek](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cerminek](https://tech-community.robotics.abb.com/u/cerminek)\
**Post date:** [March 28, 2018, 4:21pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164/1 "2018-03-28T16:21:21Z")

</div>

Hi all,

we need to make an update to control sensors during one movement. The controler has RobotWare ver.5 and it has no multitasking. So we used Trap routine to detect if the sensor switches on during movent.

Here is the definition of trap:  
CONNECT trpInsertionCheck WITH CheckInsSensorTrap;  
ISignalDI IN\_InsertionVirtualCheck,1,trpInsertionCheck;

the input IN\_InsertionVirualCheck is virtual cross connected signal. It was tested and it works OK.

The trap routine itself is:  
TRAP CheckInsSensorTrap  
IF ( bCheckInsertSens=TRUE ) AND  
( DI1= high OR DI1= high )  
THEN  
PulseDO \Plength:=0.5, Out\_100;  
ENDIF  
RETURN;  
ENDTRAP

Also here is the movement where the detection is needed:  
IWatch trpInsertionCheck;  
bCheckInsertSens:=TRUE;  
MoveL RelTool(…;  
bCheckInsertSens := FALSE;  
ISleep trpInsertionCheck;

Also there is no data in variable Trapdata in Program data/Used types. Trapdata is not shown in used variables…

So my question is: how can we detect the sensor during movement without TRAP or how can we setup the trap?

Thanks to all.

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [March 28, 2018, 4:50pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164/2 "2018-03-28T16:50:15Z")

</div>

You should be doing a search.

---

<div class="post-metadata">

**Author:** ![cerminek](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cerminek](https://tech-community.robotics.abb.com/u/cerminek)\
**Post date:** [April 7, 2018, 6:51pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164/3 "2018-04-07T18:51:20Z")

</div>

> [@lemster68](#):
>
> You should be doing a search.

But the SerchL instruction returs posititon. It useless for our purpose…

---

<div class="post-metadata">

**Author:** ![Knud\_E\_Lindberg](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/knud_e_lindberg/32/4450_2.png) [@Knud\_E\_Lindberg](https://tech-community.robotics.abb.com/u/Knud_E_Lindberg)\
**Post date:** [April 9, 2018, 12:37pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164/4 "2018-04-09T12:37:28Z")

</div>

Why ( DI1= high OR DI1= high ) in trap rutine ?

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [April 10, 2018, 7:13pm UTC](https://tech-community.robotics.abb.com/t/trap-routine-is-not-called/8164/5 "2018-04-10T19:13:28Z")

</div>

Probably the reason why the trap isn’t executed is that the program pointer is ahead of the motion so the ISleep and bCheckInsertSens:=FALSE are already executed even if the robot is still moving , so one way is to synchronize the motion and program pointer and one way to do that is to have a fine point in the move instruction.
