Chapter 5 Power Supply / CPU

1) Scan program

-. The scan program is executed regularly in every scan from 0 step to last step.

-. When interrupts has occurred, CPU pauses scan program and executes corresponding interrupt program first. -. When this interrupt program finished, scan program is to resume.

2) Interrupt program

-. When an interrupt occurs, the CPU module will stop the current operation and execute the corresponding interrupt routine first. After finish the interrupt routine, the CPU resume the sequence program from the stopped step.

-. MASTER-K102S series provides 3 types of interrupt.

The TDI (Time driven interrupt) occurs with the constant period

The PDI (Process driven interrupt) occurs with the status of external input.

The HSCDI(High speed counter driven interrupt) occur with comparison task signal from high speed counter. (Standard type only)

5.4.3Interrupt Programs

1)Usage of interrupt program

(1)Before to use interrupt function in sequence program, the parameter setting should be done properly. Then the corresponding interrupt routine should be written after END instruction. (Refer chapter 4 for details) If interrupt routines are not matched with parameter settings, an error occurs and the operation of CPU will be stopped.

(2)To execute an interrupt routine, use the EI instruction to enable the corresponding interrupt. The interrupt routine is not executed if an interrupt factor occurs before execution of an EI instruction. Once an interrupt is enabled with EI instruction.

(3)When multiple interrupt factors occur simultaneously, interrupt routines are executed according to the priority given to the each interrupt. If an interrupt factor that has higher priority occurs while other interrupt that has lower priority are executing, the interrupt routine of lower priority will be stopped and the interrupt of higher priority will be executed first.

Following figure show how CPU handles multiple interrupts

Scan Program

Interrupt routine 1

Interrupt routine 2

1

2

7

5

3

4

6

5-15

1Program starts

2Interrupt 2 occurs

3Stop main program and execute interrupt routine 2

4Interrupt 1 occurs (higher priority)

5Stop routine 2 and run routine 1

6Finish routine 1 and return to routine2

7Finish routine 2 and return to main program

Page 52
Image 52
LG Electronics 120S user manual Interrupt Programs, Scan program, Interrupt program, Usage of interrupt program