File Sort (SRT)

The SRT instruction sorts a set of values in one dimension (Dim to vary) of the array into ascending order.
IMPORTANT: You must test and confirm that the instruction does not change data that you don’t want it to change.
If you specify an array that is a member of a structure, and the length exceeds the size of that array you must test and confirm that the SRT instruction does not change data you do not want changed.
The data is constrained by the specified member.
In this transitional instruction, the relay ladder toggles the rung-condition-in from false to true for the instruction to execute.
Available Languages
Ladder Diagram
Ladder_File Sort(SRT)_v1
FactoryTalk Design Studio
DSL - Ladder Diagram
SRT(Array,Dimtovary,Control);
Operands
Ladder Diagram
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
Dimension to vary
DINT
Immediate
(0, 1, 2)
which dimension to use
the order of the dimensions is: array[0,1,2]
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
CONTROL Structure
Mnemonic
Data Type
Description
.EN
BOOL
The enable bit indicates the SRT instruction is enabled.
.DN
BOOL
The done bit is set when the instruction has operated on the last element in the Array.
.ER
BOOL
The error bit is set when either .LEN < 0 or .POS < 0. Either of these conditions also generates a major fault.
When .ER bit is set, the instruction does not execute.
.LEN
DINT
The length word specifies the number of elements in the array on which the instruction operates.
.POS
DINT
The position word identifies the current element that the instruction is accessing.
Affects Math Status Flags
No
Major/Minor Faults
A major fault will occur if:
Fault type
Fault code
.POS < 0 or .LEN < 0
4
21
Dimension to vary > number of dimensions
4
20
Length > end of array
4
20
See Common Attributes
for operand related faults.
Execution
Ladder Diagram
Condition / State
Action Taken
Prescan
N/A.
Rung-condition-in is false
.EN bit is cleared to false
.EN bit is cleared to false
.DN bit is cleared to false
Rung-condition-in is true
The instruction executes
Postscan
N/A.
Examples
Example 1
Sort DINT_array, which is DINT[4,5].
RSL5K_SRT Example 1
Ladder Diagram
FTStudio SRT EX1 V1
Example 2
Sort DINT_array, which is DINT[4,5].
File Sort (SRT) (10)
Ladder Diagram
FTStudio SRT EX2 V1
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.