Sample program
0.00
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Calculations
(1)
D0
D200
D01
D201
D200
D202
D201
D204
(2)
D202
D202
D206
D204
DM Contents
D204
D208
D206
D208
D210
D210
D212
(1) This section of the program converts the data from
BCD to floating-point.
(3)
D204
• The data area from D200 onwards is used as a
D202
D214
• First BIN(023) is used to temporarily convert the
D214
D216
D216
D218
• The value of x that has been converted to floating-
(4)
D212
D220
• The value of y that has been converted to floating-
D218
D221
(2) In order to find the distance r, Floating-point Math
Instructions are used to calculate the square root of
D220
2
x
D100
as floating-point data.
D221
(3) In order to find the angle
D101
Instructions are used to calculate tan
ATAN(465) outputs the result in radians, so
DEG(459) is used to convert to degrees. The result
is then output to D219 and D218 as floating-point
data.
(4) The data is converted back from floating-point to
BCD.
• First FIX(450) is used to temporarily convert the
• The distance r is output to D100.
• The angle
2
2
Distance r =
x
+
y
y
-- -
1
Angle
= tan
x
Example: Given the coordinates (100, 100),
the distance r and the angle
be calculated from the above
equation.
2
Distance r =
100
+
100
1
100
Angle
= tan
--------- -
100
x
D0 #0100
(BCD)
y
D1 #0100
(BCD)
work area.
BCD data to binary data, and then FLT(452) is
used to convert the binary data to floating-point
data.
point data is output to D203 and D202.
point data is output to D205 and D204.
2
+y
. The result is then output to D213 and D212
floating-point data to binary data, and then
BCD(024) is used to convert the binary data to
BCD data.
is output to D101.
3. Instructions
can
2
=
141.4214
180
=
45.0
D100
#0141
r
(BCD)
D101
#0045
(BCD)
, Floating-point Math
–1
(y/x).
463
3
Need help?
Do you have a question about the CJ - INSTRUCTIONS REFERENCE MANUAL 07-2009 and is the answer not in the manual?
Questions and answers