Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 385
Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8
File Sort (SRT)
The SRT instruction sorts a set of values in one dimension (Dim to vary) of the
Array into ascending order.
Operands:
Relay Ladder
Structured Text
The operands are the same as those for the relay ladder SRT instruction.
However, you specify the Length and Position values by accessing the .LEN and
.POS members of the CONTROL structure, rather than by including values in
the operand list.
CONTROL Structure
Operand Type Format Description
Array SINT
INT
DINT
REAL
Array tag Array to sort
Specify the first element of the group of elements
to sort
Do not use CONTROL.POS in the subscript
Dimension to
vary
DINT Immediate
(0, 1, 2)
Which dimension to use
Depending on the number of dimensions, the order
is:
array[dim_0,dim_1,dim_2]
array[dim_0,dim_1]
array[dim_0]
Control CONTROL Tag Control structure for the operation
Length DINT Immediate Number of elements of the array to sort
Position DINT Immediate Current element in the array
Initial value is typically 0
SRT(Array,Dimtovary,
Control);
Mnemonic Data Type Description
.EN BOOL The enable bit indicates that the SRT instruction is enabled.
.DN BOOL The done bit is set when the specified elements have been sorted.
.ER BOOL The error bit is set when either .LEN < 0 or .POS < 0. Either of these conditions also generates a major
fault.
.LEN DINT The length specifies the number of elements in the array on which the instruction
.POS DINT The position contains the position of the current element that the instruction is accessing.