beautypg.com

Delta Electronics Programmable Logic Controller DVP-PLC User Manual

Page 281

background image

6 Application Instructions API 00-49

DVP-PLC Application Manual

6-69

API Mnemonic

Operands

Function

48

D SQR P

Square Root

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

* *

*

D

*

SQR, SQRP: 5 steps

DSQR, DSQRP: 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

: Source device D: Device for storing the result

Explanations:

1.

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

2.

Flags: M1020 (zero flag); M1021 (borrow flag); M1067 (instruction operation error)

3.

This instruction performs a square root operation on S and stores the result in D.

4.

S

can only be a positive value. If S is negative, PLC will regard it as an “instruction operation error” and will not

execute this instruction. M1067 and M1068 = On and D1067 records the error code 0E1B (hex).

5.

The operation result D should be integer only, and the decimal will be left out. Borrow flag M1021 = On.

6.

When the operation result D = 0, zero flag M1020 = On.

Program Example:

When X10 = On, the instruction performs a square root on D0 and stores the result in D12.

X10

SQR

D0

D12

D0

D12