Справочник Пользователя для Mitsubishi Electronics FX2NC

Скачать
Страница из 382
FX Series Programmable Controlers
Applied Instructions 5
5-48
5.5.9
SQR (FNC 48)
Operation1:
This instruction performs a square root operation
on  s ou rc e  data  (S)  a nd   s to res   t he   r es ult  a t
destination device (D). The operation is conducted
entirely in whole integers rendering the square root
answer rounded to the lowest whole number. For
example, if (S) = 154, then (D) is calculated as
being 12. M8020 is set ON when the square root
operation result is equal to zero. Answers with
rounded values will activate M8021.
Operation 2: This function is equivalent to FNC 127 ESQR This operation is similar to
Operation 1. However, it is only activated when the mode setting float flag, M8023 is used.
This then allows the SQR instruction to process answers in floating point format. The source
data (S) must either be supplied in floating point format for data register use, or it can be
supplied as a constant (K,H). When constants are used as a source, they are automatically
converted to floating point format. Operation 2 is only valid for double word (32 bit) operation,
hence both (S) and (D) will be 32 bit values and the SQR instruction will be entered as DSQR
or DSQRP.
Mnemonic
Function 
Operands
Program steps
S
D
SQR
FNC 48
(Square
root)
Performs a
mathematical
square root e.g.:
K,H,D
D
SQR, SQRP:
5 steps
DSQR,
DSQRP:
9 steps
When using M8023 in float mode, only 
double word (32bit) data can be processed. 
See page 4- 46 for more details regarding float-
ing point.
FX
0(S)
FX
0N
FX FX
(2C)
FX
2N(C)
D=     S
FX
(2C)
FX
FX
2N(C)
FX
0N
FX
0(s)
PULSE-P
FX
(2C)
FX
FX
2N(C)
FX
0N
FX
0(s)
16 BIT OPERATION
FX
FX
0N
FX
0(s)
FX
(2C)
FX
2N(C)
32 BIT OPERATION
FLAGS
Zero M8020
Borrow M8021
X3
D 2
[ S ]
[ D ]
K5
SQR
X10
X7
M8023
M8000
M8023
D 30
D5
DSQR
General note:
Performing any square root operation (even on a calculator) on a negative number will result
in an error. This will be identified by special M coil M8067 being activated: 
                                  -168 = Error and M8067 will be set ON
This is true for both operating modes.