KEYENCE Visual KV Series User Manual

Page 199

Advertising
background image

2.4 Instruction Details

1

2

3-175

Chapter 2 Instructions

Coding

Programming technique
Two kinds of instructions can be used for the counting operation: a C (counter)
instruction and an INC instruction with data memory.
The following examples show how to program the total count with each instruction.

As the example of the INC instruction shows, using different instructions sometimes
simplifies the program even for the same control.
Simpler programming reduces the time for debugging.
It is convenient to use the CMP instruction for comparator outputs.

OR instruction
Compare the following two programs.
With program 1), input relays 0000 through 0004 are individually counted even when
they turn ON simultaneously.
With program 2), when some input relays 0000 through 0004 turn ON simulta-
neously, duplicated inputs are ignored.
Use the appropriate program according to your application.

Line No.

Instruction

Operand

Line No.

Instruction

Operand

0000

LD

0000

0011

DW

#00000 DM0000

0001

@INC

DM0000

0012

LD

2002

0002

LD

0001

0013

LDA

DM0000

0003

@INC

DM0000

0014

CON

0004

LD

0002

0015

CMP

#00100

0005

@INC

DM0000

0016

CON

0006

LD

0003

0017

ANB

2009

0007

@INC

DM0000

0018

OUT

0500

0008

LD

0004

0019

END

0009

@INC

DM0000

0020

ENDH

0010

LD

0005

0005

DM0001

STA

C001

LDA

#09999

0000

C001

DM0002

STA

C002

LDA

#09999

0001

C002

DM0003

STA

C003

LDA

#09999

0002

C003

DM0004

STA

C004

LDA

#09999

0003

C004

DM0005

STA

C005

LDA

#09999

0004

C005

DM0000

STA

DM0005

ADD

DM0004

ADD

DM0003

ADD

DM0002

ADD

DM0001

LDA

2002

$0000

DW

0005

0000

0001

0002

0003

0004

DM0000

INC

DM0000

INC

DM0000

INC

DM0000

INC

DM0000

INC

DM0000

Programming with the INC instruction
with data memory

Programming with the C instruction

0000

DM0000

INC

0001

DM0000

INC

0002

DM0000

INC

0003

DM0000

INC

0004

DM0000

INC

0000

DM0000

INC

0001

0002

0003

0004

1)

2)

INC / @INC / DEC / @DEC

KVNKA Chap 02_4dP.p65

08.3.11, 0:03 PM

175

Advertising