Kv -300 – KEYENCE Visual KV Series User Manual

Page 298

Advertising
background image

6.1 Interrupt Instructions

KV

-300

KV-10/80

3-274

6

Chapter 6 Interrupts, High-speed Counters, Positioning Control

INT / RETI

2008

1

EI

2203

2002

2002

CTH1

0005

END

INT

CTC2

RETI

2

4

0000

5

3

CTH1

#05000

CTC2

SET

2813

0501

0501

SET

RES

SET

RES

ENDH

Initial setting

When the operation is started, EI instruction enables interrupts.

Special utility relays No. 2200 through 2215 are turned OFF. Turning OFF 2203
disables CTC2 from resetting the CTH1 current value to 0.

Turning OFF 2206 allows interrupt to be generated at the rising edge of INT0003.

The value of DM0000 is reset to "0".

Turning ON special utility relay 2813 changes the input time constant to 10 µs.

1.0-µs internal clock pulses are counted using CTH1.

INT instruction with 0003 as the operand allows interrupts to be executed.

When interrupt is generated for the first time, 2206 is OFF. Therefore, program in
rung (a) is executed. Then, KEEP turns 2206 ON.

When interrupt is generated for the second time, 2206 is ON. Therefore, program
in rung (b) is executed to calculate the following:

(TM30 at 2nd execution) - (TM30 at 1st execution) = pulse width (unit: 1.0 µs)

The result is stored in DM0000.

Example 3

Interrupt by CTC

Pulses input to 0005 are counted. 0501 is turned ON when the number of pulses
reaches 5,000.

Coding

Line No.

Instruction

Operand

Line No.

Instruction

Operand

0000

LD

2008

0010

LD

2002

0001

EI

0011

CTH

1 0005

0002

CON

0012

LD

0000

0003

SET

2203

0013

RES

0501

0004

CON

0014

END

0005

RES

CTH1

0015

INT

CTC2

0006

CON

0016

LD

2002

0007

CTC

2 #05000

0017

SET

0501

0008

CON

0018

RETI

0009

SET

2813

0019

ENDH

KVNKA Chap 06.p65

08.3.11, 0:10 PM

274

Advertising