5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-70
API
Applicable model
20PM
48
D
D
SQR
P
P
Square root of a binary value
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
S
*
m
*
D
*
Note: All devices can not be modified by V devices and Z devices.
Please refer to specifications for more information about device
ranges.
16-bit instruction (7 steps)
SQR
Continuity
instruction
SQR P
Pulse
instruction
32-bit instruction
DSQR
Continuity
instruction
DSQRP
Pulse
instruction
Flags
Ox O100
M1808 M1968 Zero flag
M1809 M1969 Borrow flag
M1810 M1970 Carry flag
Please refer to the explanation below.
Explanation
The square root of the value in
S is calculated, and the result is stored in D.
S: Source device; D: Device in which a result is stored
The value in S can only be a positive value. If the value in S is a negative
value, an error will occur, and the instruction will not be executed.
The value stored in D is an integer. The fractional part of a square root
calculated is dropped. If the fractional part of a square root calculated is
dropped, a borrow flag will be ON.
If the value in D is 0, a zero flag will be ON.
Example
When X20 is ON, the square root of the value in D0 is calculated, and the
result is stored in D12.
X20
SQR D0 D12
D0 D12