TML Interrupts – TML Programming Details

In TML, you can monitor simultaneously up to 13 conditions. Each condition triggers a TML interrupt. When a TML interrupt occurs, the normal TML program execution is suspended to execute a TML function associated with the interrupt, called the interrupt service routine (in short ISR). The TML interrupt mechanism is the following:

The intelligent drive continuously monitors 12 conditions that may generate TML interrupts. The motion controller has an additional condition that triggers a TML interrupt when an error on the slaves occurs
When an interrupt condition occurs, a flag (bit) is set in the ISR (Interrupt Status Register)
If the interrupt is enabled e.g. the same bit (as position) is set in the ICR (Interrupt Control Register) and also if the interrupts are globally enabled (EINT instruction was executed), the interrupt condition is qualified and it generates a TML interrupt
The interrupt causes a jump to the associated interrupt service routine. On entry in this routine, the TML interrupts are globally disabled (DINT) and the interrupt flag is reset
The interrupt service routine must end with the TML instruction RETI, which returns to normal program execution and in the same time globally enables the TML interrupts

The 13 monitored conditions are:

 

1.Int0 – Enable input has changed: either transition of the Enable input sets the interrupt flag
2.Int1 – Short-circuit: when the drive/motor hardware protection for short-circuit is triggered
3.Int2 – Software protections: when any of the following protections is triggered:
a.Over current
b.I2t motor
c.I2t drive
d.Over temperature motor
e.Over temperature drive
f.Over voltage
g.Under voltage

 

4.Int3 – Control error: when the control error protection is triggered
5.Int4 – Communication error: when a communication error occurs
6.Int5 – Wrap around: when the target position computed by the reference generator wraps around because it bypasses the limit of the 32-bit long integer representation
7.Int6 – LSP programmed transition detected: when the programmed transition (low to high or high to low) is detected on the limit switch input for positive direction (LSP)
8.Int7 – LSN programmed transition detected: when the programmed transition (low to high or high to low) is detected on the limit switch input for negative direction (LSN)
9.Int8 – Capture input transition detected: when the programmed transition (low to high or high to low) is detected on the 1st capture / encoder index input or on the 2nd capture / encoder index input
10.Int9 – Motion is completed: in position control, when motion complete condition is set and in speed control when target speed reaches zero.
11.Int10 – Time period has elapsed: periodic time interrupt with a programmable time period set in the TML parameter TMLINTPER  
12.Int11 – Event set has occurred: when last defined event has been occurred
13.Int12 – Error on slave occurred: when a slave reports an error.

The interrupt service routines (ISR) of the TML interrupts are similar with the TML functions: the starting point is a label and the ending point is the TML instruction RETI (return from interrupt). When a TML interrupt occurs, the TML instruction pointer (IP) jumps to the start address of the associated ISR. This information is read from an interrupt table, which contains the values of the starting labels for all the ISR. The beginning of the interrupt table is pointed by the TML parameter INTTABLE. Like the TML functions, the interrupt table and the interrupt service routines must be positioned outside the main section of the TML program (see the programming example below).

At power-on, each drive/motor starts with a built-in interrupt table and a set of default ISR. The TML interrupts are globally enabled together with the first 4 interrupts: Int 0 to Int 3. For Int 2, all the protections are activated, except over temperature motor, which depends on the presence or not of a temperature sensor on the motor; hence this protection may or may not be activated. For each of these 4 interrupts there is a default ISR which is executed when the corresponding interrupt occurs.

Remark: A basic description of these defaults ISR is presented below. Their exact content is product dependent and can be seen using TML development platforms like EasyMotion Studio which include the possibility to view and/or modify the contents of the default ISR for each type of drive/motor.

If you intend to enable other TML interrupts or to modify the default ISR for the first 4 TML interrupts, you need to create another TML interrupt table which will point towards your own ISR. In this new interrupt table, put the starting labels for your ISR and use the global symbols: default_intx (x=0 to 11) as labels for those ISR you don’t want to change. These global symbols contain the start addresses of the default ISR.

Remark: Some of the drive/motor protections may not work properly if the TML Interrupts are handled incorrectly. In order to avoid this situation keep in mind the following rules:

The TML interrupts must be kept globally enabled to allow execution of the ISR for those TML interrupts triggered by protections. As during a TML interrupt execution, the TML interrupts are globally disabled, you should keep the ISR as short as possible, without waiting loops. If this is not possible, you must globally enable the interrupts with EINT command during your ISR execution.
If you modify the interrupt service routines for Int 0 to Int 4, make sure that you keep the original TML commands from the default ISR. Put in other words, you may add your own commands, but these should not interfere with the original TML commands. Moreover, the original TML commands must be present in all the ISR execution paths.

The interrupt flags are set independently of the activation or not of the TML interrupts. Therefore, as a general rule, before enabling an interrupt, reset the corresponding flag. This operation will avoid triggering an interrupt immediately after activation, due to an interrupt flag set in the past.

To summarize, in order to work with a TML interrupt, you need to:

Edit your own ISR or decide to use the default ISR.
Create your own interrupt table, and set the TML parameter INTTABLE equal with your interrupt table start address. Exception: if you use only default ISR
Reset the interrupt flag to avoid entering in an interrupt due to a flag set in the past
Enable the TML interrupt. As the TML interrupts must be globally enabled, the TML interrupt is now activated and your ISR will execute when the interrupt flag will be set.

Default ISR Description

ISR for Int0 – Enable input has changed: When enable input goes from disable to enable status, executes AXISON if ACR.1 = 1 (i.e. the drive/motor is set to start automatically after power-on with an external reference) or if ACR.3 = 1 (i.e. specific request to execute AXISON at recover from disable status). Before executing AXISON, if the drive/motor is set in electronic gearing slave mode, the motion mode is set again (followed by an update command – UPD) to force a re-initialization for smooth recouping with the master.

ISR for Int1 – Short-circuit: Set Ready output (if present) to not ready status and turn off the green led (if present). Set Error output (if present) to error status and turn on the red led (if present). Execute AXISOFF and set SRL.3 =1 to set the drive/motor into the FAULT condition.

ISR for Int2 – Software protections: Same as ISR for Int1

ISR for Int3 – Control error: Same as ISR for Int1

See also:

TML Interrupts – Related TML Instructions and Data

TML Description