Chapter 4. Ladder Diagram (LD) Programming
186
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
4.9.8
Sort
When it receives power flow, the SORT function sorts the elements of the
memory block 'IN' in ascending order. The output memory block Q
contains integers that give the index that the sorted elements had in the
original memory block or list. Q is exactly the same size as IN. It also has a
specification (LEN) of the number of elements to be sorted.
Mnemonics:
SORT_INT
SORT_UINT
SORT_WORD
SORT operates on memory blocks of no more than 64 elements. When EN is ON, all of the elements
of IN are sorted into ascending order, based on their data type. The array Q is also created, giving the
original position that each sorted element held in the unsorted array. OK is always set ON.
Notes:
The SORT function is executed each scan it is enabled.
Do not use the SORT function in a timed or triggered input program block.
Operands
Note:
For each mnemonic, use the corresponding data type for the IN and Q operands. For
example, SORT_INT requires IN and Q to be INT variables.
Parameter
Description
Allowed Operands
Optional
Length (??)
The number (1
—
64) of elements that make
up the memory block to sort.
Constants
No
IN
The memory block that contains the
elements to sort. After the sort, IN contains
the elements in the sorted order.
All except data flow, S,
constants. SA
–
SC valid
only for WORD type
No
Q (must be the same type
as IN)
An array of indexes that gives the position
of the sorted elements in the original
memory block
All except S - SC and
constants
No
Example
New part numbers (%I00017 - %I00032) are
pushed onto a parts array PLIST every time
%Q00014 is ON. When the array is filled, it is
sorted and the output %Q00025 is turned on. The
array PPOSN then contains the original position
that the now-sorted elements held before the
sort was done on PLIST.
If PLIST were an array of five elements and
contained the values 25, 67, 12, 35, 14 before the
sort, then after the sort it would contain the
values 12, 14, 25, 35, 67. PPOSN would contain
the values 3, 5, 1, 4, 2.
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...