352
Floating-point Math Instructions
Section 5-24
1.
This section of the program converts the data from BCD to floating-point.
a) The data area from DM 0200 onwards is used as a work area.
b) First BIN(23) is used to temporarily convert the BCD data to binary da-
ta, and then FLT(––) is used to convert the binary data to floating-point
data.
c)
The value of x that has been converted to floating-point data is output
to DM 0203 and DM 0202.
d) The value of y that has been converted to floating-point data is output
to DM 0205 and DM 0204.
2.
In order to find the distance r, Floating-point Math Instructions are used to
calculate the square root of x
2
+y
2
. The result is then output to DM 0213
and DM 0212 as floating-point data.
3.
In order to find the angle
θ
, Floating-point Math Instructions are used to
calculate tan
–1
(y/x). ATAN(––) outputs the result in radians, so DEG(––) is
used to convert to degrees. The result is then output to DM 0219 and DM
0218 as floating-point data.
4.
The data is converted back from floating-point to BCD.
a) First FIX(––) is used to temporarily convert the floating-point data to bi-
nary data, and then BCD(024) is used to convert the binary data to
BCD data.
b) The distance r is output to DM 0100.
c)
The angle
θ
is output to DM 0101.
5-24-1 FLOATING TO 16-BIT: FIX(––)
Limitations
The content of S+1 and S must be floating-point data and the integer portion
must be in the range of –32,768 to 32,767.
DM 6144 to DM 6655 cannot be used for R.
100
100
Calculations
Distance r =
√
x
2
+
y
2
Angle = tan
–1
(
y
x
)
Example
Distance r =
√
100
2
+
100
2
= 141.4214
Angle = tan
–1
(
)
= 45.0
DM Contents
DM 0000
0100
DM 0001
0100
x
y
DM 0100 0 1 4 1
DM 0101 0 0 4 5
r
θ
(BCD)
(BCD)
S
:
First source word
R
: Result word
IR, SR, AR, DM, EM, HR, LR
Ladder Symbols
Operand Data Areas
IR, SR, AR, DM, EM, HR, TIM/CNT, LR
Third operand
:
Always 000
−−−
FIX(
−−
)
S
R
000
@FIX(
−−
)
S
R
000
Содержание SYSMAC CQM1H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 9: ......
Страница 11: ......
Страница 15: ...xvi...
Страница 87: ...62 Calculating with Signed Binary Data Section 1 7...
Страница 169: ...144 Serial Communications Board Section 2 6...
Страница 537: ......
Страница 565: ......
Страница 569: ......
Страница 573: ......
Страница 577: ......