Mitsubishi Electronics FX Home Theater Server User Manual


 
FX Series Programmable Controlers Applied Instructions 5
5-48
5.5.9 SQR (FNC 48)
Operation1:
This instruction performs a square root operation
on source data (S) and stores the result at
destination device (D). The operation is conducted
entirel
y
in whole inte
g
ers renderin
g
the square root
answer rounded to the lowest whole number. For
example, if (S) = 154, then (D) is calculated as
bein
g
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 onl
y
activated when the mode settin
g
float fla
g
, M8023 is used.
This then allows the SQR instruction to process answers in floatin
g
point format. The source
data (S) must either be supplied in floatin
g
point format for data re
g
ister use, or it can be
supplied as a constant (K,H). When constants are used as a source, the
y
are automaticall
y
converted to floatin
g
point format. Operation 2 is onl
y
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
SD
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 usin
g
M8023 in float mode, onl
y
double word (32bit) data can be processed.
See pa
g
e 4- 46 for more details re
g
ardin
g
float-
in
g
point.
D= S
X3
D 2
[ S ] [ D ]
K5
SQR
X10
X7
M8023
M8000
M8023
D 30
D5
DSQR
General note:
Performin
g
an
y
square root operation (even on a calculator) on a ne
g
ative number will result
in an error. This will be identified b
y
special M coil M8067 bein
g
activated:
-168 = Error and M8067 will be set ON
This is true for both operatin
g
modes.