beautypg.com

Delta Electronics Programmable Logic Controller DVP-PLC User Manual

Page 537

background image

9 Application Instructions API 150-199

DVP-PLC Application Manual

9-65

API Mnemonic

Operands

Function

185

MCMP P

Matrix Compare

Controllers

ES/EX/SS SA/SX/SC EH/SV

Bit Devices

Word Devices

Program Steps

Type

OP

X Y M S K H

KnX KnY KnM KnS T

C

D

E

F

S

1

*

*

*

*

*

*

*

S

2

*

*

*

*

*

*

*

n

*

*

*

D

*

*

*

*

*

*

*

*

MCMP, MCMPP: 9 steps

PULSE 16-bit 32-bit

ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV ES EX SS SA SX SC EH SV

Operands:

S

1

: Matrix source device 1 S

2

: Matrix source device 2 n: Array length

D: Pointer (Pr), for storing the value of target location

Explanations:

1. Range

of

n: K1 ~ K256

2.

S

1

, and S

2

designate KnX, KnY, KnM and KnS; D designates KnY, KnM and KnS.

3.

SA/SX/SC can designate n = 4. EH/EH2/SV can designate n

4

≦ .

4.

See the specifications of each model for their range of use.

5.

Flags: M1088 ~ M1092. See remarks for more details.

6.

This instruction compares every bit in S

1

with every bit in S

2

starting from location D and finds out the location

of different bits. The location will be stored in D.

7.

The matrix comparison flag (M1088) decides to compare between equivalent values (M1088 = 1) or different

values (M1088 = 0). When the comparison is completed, it will stop immediately and the matrix bit search flag

will turn “On” (M1091 = 1). When the comparison progresses to the last bit, the matrix search end flag (M1089)

will turn “On” and the No. where the comparison is completed is stored in D. The comparison will start from the

0

th

bit in the next scan period and the matrix search start flag will turn “On” (M1090 = 1). When D exceeds the

range, the pointer error flag will turn “On” (M1092 = 1).

8.

The matrix operation will need a 16-bit register to designate a point among the 16n points in the matrix for the

operation. The register is the Pointer (Pr) of the matrix, designated by the user in the instruction. The vaild

range of Pr is 0 ~ 16n -1, corresponding to b0 ~ b16n-1 in the matrix. Please avoid changing the Pr value

during the operation in case the comparing and searching will not ne correct. If the Pr value exceeds its range,

M1092 will be On and the instruction will not be executed.

9.

When M1089 and M1091 take place at the same time, both flags will be “1” at the same time.

Program Example:

1.

When X0 goes from Off to On, the matrix search start falg M1090 = 0. The searching will start from the bit

marked with “*” (current Pr value +1) for bits of different status (M1088 = 0).

2.

Set the Pr value D20 = 2. When X0 goes from Off to On for 4 times, we can obtain the 4 execution results

n, o,

p, q.

n D20 = 5, M1091 = 1, M1089 = 0.

o D20 = 45, M1091 = 1, M1089 = 0.