Interrupts

Interrupts

Interrupts are program-defined events, identified by interrupt numbers. An interrupt occurs when an interrupt condition is true. Unlike errors, the occurrence of an interrupt is not directly related to (synchronous with) a specific code position. The occurrence of an interrupt causes suspension of the normal program execution and control is passed to a trap routine.Even though the robot immediately recognizes the occurrence of an interrupt (only delayed by the speed of the hardware), its response – calling the corresponding trap routine – can only take place at specific program positions, namely:

- when the next instruction is entered,

- any time during the execution of a waiting instruction, e.g. WaitUntil,

- any time during the execution of a movement instruction, e.g. MoveL.

This normally results in a delay of 5-120 ms between interrupt recognition and response, depending on what type of movement is being performed at the time of the interrupt.The raising of interrupts may be disabled and enabled. If interrupts are disabled, any interrupt that occurs is queued and not raised until interrupts are enabled again. Note that the interrupt queue may contain more than one waiting interrupt. Queued interrupts are raised in FIFO order. Interrupts are always disabled during the execution of a trap routine. When running stepwise and when the program has been stopped, no interrupts will be handled. Interrupts that are generated under these circumstances are not dealt with.The maximum number of defined interrupts at any one time is limited to 70 per program task. The total limitation set by the I/O CPU is 100 interrupts.

Interrupt manipulation

Defining an interrupt makes it known to the robot. The definition specifies the interrupt condition and activates and enables the interrupt.

Example: VAR intnum sig1int;

.

ISignalDI di1, high, sig1int;

An activated interrupt may in turn be deactivated (and vice versa).

During the deactivation time, any generated interrupts of the specified type are thrown away without any trap execution.

Example: ISleep sig1int; deactivate

.

IWatch sig1int; activate

An enabled interrupt may in turn be disabled (and vice versa).

During the disable time, any generated interrupts of the specified type are queued and raised first when the interrupts are enabled again.

Example: IDisable sig1int; disable

.

IEnable sig1int; enable

Deleting an interrupt removes its definition. It is not necessary to explicitly remove an interrupt definition, but a new interrupt cannot be defined to an interrupt variable until the previous definition has been deleted.

Example: IDelete sig1int;

Trap routines

Trap routines provide a means of dealing with interrupts. A trap routine can be connected to a particular interrupt using the CONNECT instruction. When an interrupt occurs, control is immediately transferred to the associated trap routine (if any). If an interrupt occurs, that does not have any connected trap routine, this is treated as a fatal error, i.e. causes immediate termination of program execution.

Several interrupts may be connected to the same trap routine. The system variable

INTNO contains the interrupt number and can be used by a trap routine to identify an interrupt. After the necessary action has been taken, a trap routine can be terminated using the RETURN instruction or when the end (ENDTRAP or ERROR) of the trap routine is reached. Execution continues from the place where the interrupt occurred.