RSlogix 5000 Array sorting

I have 3 values that are being sent to an array that are continuously being updated. I want to sort this array and do actions on it (i.e find the middle value, take differences between them). Intuitively I would think to sort the array and then do the calculations on the sorted array. The SRT function has .EN and .DN bits, which leads me to believe that the next rung will be executed before the array is done sorting. My initial thoughts are to execute the SRT with a ONS and then use the .DN bit to trigger the calculations. Basically I want to make sure I’m doing the calculations on the sorted array and not the raw values. Let me know if there is a clean solution for this
 
The SRT instruction executes (performs the sort) when it detects the rising edge of its input rung (the .EN bit is the memory bit for the edge detection). So if the array is sorted on one scan cycle, because
  • on the previous scan cycle the input rung state was False which wrote a value of 1 to the .EN bit, and
  • on the current scan cycle the input rung state is True,
    • which coupled with the .EN bit value being 1 causes the instruction detect a rising edge
    • and to also sort the array, and
  • that sorting the array causes the .DN bit value to change to 1
and then on the next scan the input rung is still True, then nothing happens on that next scan cycle because the .EN bit value is 1 so there is no rising edge to detect so nothing is changed.

The description of the instruction* says nothing to suggest the sorting takes more than one execution of the instruction on one scan cycle.

Changing the input rung state would take two scan cycles to re-sort the array if the array data changed; placing the SRT instruction on an unconditionally True feed rung and writing a 0 to the .EN bit when the array data change would ensure the data in the array are always sorted after the rung executes.

* see here; that is a link to a big PDF file
 

Similar Topics

I have created a UDT, and then made it an array of 10 It contains time and some information all the tags within are DINTS when a bit enables i...
26
Replies
2,372
Views
Hello! I'm looking for advice how to convert an array of SINT[5] into the Decimal value. Since the total value of the array is 40 bits, it's too...
19
Replies
4,413
Views
Hey all, I am trying to figure out how to import some alarm messages without having to type them all in by hand. They are in the format of an...
4
Replies
2,671
Views
Hello i have been trying to figure out a good way to take hex and convert it to an array of SINT[]. Here is what my failed attempt looks like.
5
Replies
2,645
Views
I have a subroutine that gets called to copy a UDT In an array to a tag. This subroutine will be called around once per minute and has been...
4
Replies
3,591
Views
Top