Mitsubishi MELSEC-Q/L Programming Manual page 530

Table of Contents

Advertisement

SQR, SQRP
Function
(1) Returns the square root of the value designated at
.
D
S
+1
S
(
32-bit floating-point
real number
(2) Only positive values can be designated by
Operation Error
(1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into
SD0.
Error
code
The value specified in
4100
The specified device value is -0.
The specified device value is not within the following range:
-126
0, 2
| Specified device value | < 2
4140
The specified device value is -0, unnormalized number, nonnumeric, or
±
.
The operation result exceeds the following range (when an overflow
occurs):
4141
128
2
| Operation result |
*2:
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to Page 88, Section 3.2.4.
Program Example
(1) The following program seeks the square root of the value set by the 4 BCD digits from X20 to X2F, and stores the result
as a 32-bit floating decimal point type real number at D0 and D1.
[Ladder Mode]
[List Mode]
Step
Instruction
[Operations involved when value designated by X20 to X2F is 650]
Conversion
1
X2F
X20
to BIN
0
6 5 0
BCD value
BIN
528
, and stores the operation result in the device number designated at
S
D
+1
D
)
32-bit floating-point
real number
. (Operation cannot be performed on negative numbers.)
S
Error details
is negative.
S
*2
128
Inputs data used for
square root operation (
Converts the input data into a
32-bit floating-point real number (
Executes square root
operation (
Device
D20
2
Conversion to
b15
b0
floating-point
650
BIN value
FLT
Q00J/
Q00/
QnH
Q01
––
––
––
––
)
1
)
2
)
3
D11
D10
3
SQR operation
6 5 0
SQR
QnPH QnPRH
QnU
LCPU
––
––
––
––
––
––
––
D1
D0
2 5 . 4 9 5 1

Advertisement

Table of Contents
loading

Table of Contents