7-92
7.5 Data Processing Instructions
7.5.12 Sorting 16-/32-bit data
SORT, DSORT
Function
SORT
(1) Sorts 16-bit BIN data n points from
in ascending or descending order.
Sort order is specified by the ON or OFF status of SM703.
• When SM703 is OFF : Sorts in ascending order
• When SM703 is ON : Sorts in descending order
(2) Several scans are required for sorts performed by the SORT instruction. The number of
scans executed until completion is the value obtained by dividing the maximum number of
times executed until the completion of the sort by the number of data blocks compared at
one execution specified for
. (Decimal fractions are rounded up.) When the value of
is
increased, the number of scans until completion of the sort is reduced, but the amount of
time per scan is lengthened.
(3) The maximum number of executions until completion of the sort should be calculated
according to the following equation.
Maximum number of executions until completion (n) (n 1) / 2 [times executed]
When n 10, the number of executions is obtained as 10 (10 1) / 2 45 [times executed].
If
2, then the number of scans until the completion of sort is calculated as
45/2 22.5 23 [scans].
(4) The device specified for
(the completion device) is turned OFF by the execution of the
SORT instruction, and turned ON when the sort is completed. Because the device specified
for
is retained in the ON state after the completion of the sort, the user must turn it OFF if
required.
(5) The 2 points from the device specified for
are used by the system during the execution of
the SORT instruction. These 2 points from the device specified for
should therefore not
be used by the user.
Changing these points may cause an error code to be returned.
(Error code: 4100)
(6) If the value of n is changed during the execution of the SORT instruction, the sort will be
performed in accordance with the number of sort data blocks after the change.
(7) If the execution command is turned OFF during the execution of the SORT instruction, the
sort is suspended. The sort resumes from the beginning when the execution command is
turned ON again.
(8) To execute another sort operation immediately after the completion of the previous sort, turn
OFF the execution command once, then turn it ON.
s
1
Data
b
efore
sort
-124
-10
500
35
W
hen
SM703 = OFF
W
hen
SM703 = ON
-124
35
-10
500
500
-10
35
-124
S
ort
i
n
the
ascen
di
ng
or
d
er
S
ort
i
n
the
d
escen
di
ng
or
d
er
s
s
s
s
s
s
s
s
s
s
s
s
+1
+2
+3
+1
+2
+3
+1
+2
+3
s
2
s
2
Example
s
2
d1
d1
d2
d2
Summary of Contents for MELSEC Q Series
Page 1: ...Structured Programming Manual Mitsubishi Programmable Controller QCPU Common Instructions ...
Page 2: ......
Page 14: ...A 12 MEMO ...
Page 340: ...6 178 MEMO MTR ...
Page 708: ...7 368 MEMO ...
Page 776: ...8 68 MEMO ...
Page 796: ...9 20 MEMO ...
Page 804: ...App 8 MEMO ...
Page 812: ...Index 8 MEMO ...
Page 815: ......