Applications of inc/dec instructions – KEYENCE Visual KV Series User Manual

Page 197

Advertising
background image

2.4 Instruction Details

1

2

3-173

Chapter 2 Instructions

Key operation

Arithmetic flag

2009

Turns ON when the result is "0" after an INC operation, or when the
result is "$FFFF (#65535)" after DEC operation. Turns OFF at other
times.

2010

Turns ON when the internal register is "0" after an INC or DEC opera-
tion. Turns OFF at other times.

2011, 2012 No change

Note: When an every-scan type INC/DEC instruction is used, INC (+1) or DEC (-1)
instruction is executed every scan time while input relay 0000 is ON.

Use a differentiation type instruction (@INC or @DEC) to execute the instruction
only once when input relay 0000 turns ON, as shown in the example.

Tips

When using DM0000 as an UP/DOWN counter
Performs an UP count (addition) when input relay 0000 turns ON.
Performs a DOWN count (subtraction) when input relay 0001 turns ON.

Applications of INC/DEC instructions

UP/DOWN count
Performs an UP count when input relay 0000 turns ON.
Performs a DOWN count when input relay 0001 turns ON.
Writes the count value into DM0000.
Reset input relay is 0005.

Coding

0000

DM0000

INC

0001

DM0000

DEC

#00000

LDA

2008

0000

DM0000

STA

0005

#00000

DW

DM0000

INC

0001

DM0000

DEC

DM0000

0000

DM0000

INC

0000

DM0000

INC

Clears DM0000 to #00000 when 0005
turns ON.

Sets #00000 to DM0000 at startup.

Increments DM0000 by 1 at UP edge
of input relay 0000.

Decrements DM0000 by 1 at UP edge
of input relay 0001.

@

#,$

FUN

FUN

@

#,$

FUN

FUN

SET

1

O R

9

L D

7

RES

0

ENT

R-SRCH

ENT

R-SRCH

Operand

ENT

R-SRCH

ENT

R-SRCH

Operand

Line No.

Instruction

Operand

Line No.

Instruction

Operand

0000

LD

2008

0005

@INC

DM0000

0001

LDA

#00000

0006

LD

0001

0002

CON

0007

@DEC

DM0000

0003

STA

DM0000

0008

LD

0005

0004

LD

0000

0009

DW

#00000 DM0000

INC / @INC / DEC / @DEC

KVNKA Chap 02_4dP.p65

08.3.11, 0:03 PM

173

Advertising