How to create and sort list in PLC?

sarahc

Member
Join Date
Oct 2005
Location
Waikato, NZ
Posts
22
I have a client with a panel view + that shows a list of items. Currently the PV+ uses the piloted list selector with 10 items. The customer now wants to aphabetically sort the list, only display items with entries, and expand the list size to 100 items.
I figure if I can sort the items that'll take care of not displaying the empty field becuse I'll adjust the visible length of the list. Problem is I'm a bit stuck on how to sort the items as I've never done this sort of thing in a PLC before. I was thinking along the lines of using the decimal value of the 1st char in the string and move the items into a temp array before moving sorted list back?
Any ideas?
 
What sort of logic controller are you using ?

I have some code for a simple alphabetical bubble sort around here somewhere, done in a MicroLogix 1400 controller.
 
The ControlLogix ought to out-run the MicroLogix I used, and of course it's easier to manipulate strings in ControlLogix.

The attached ZIP file is an RSLogix 500 program in which I've stripped out all but the bubble sort.

N50:0-49 is an integer file with two ASCII characters in each element. These are the "color codes" you see mentioned in the comments.

N51:0-49 and N52:0-49 are integer files where each element contains a value related to the corresponding element in N50:0. These happen to be the power and speed of a laser etching system, so you'll see comments to that effect.

Convert this program to RSLogix 5000, or run it in an SLC (or Emulate 500, which I just did) and you'll see it bubble-sort the N50:0 alphabetical values, and move each related value to the appropriate location in the N51 and N52 tables.
 
Here is another version of a numerical bubble sort that will run on your ControlLogix PLC. I wrote it originally for a SLC 5/03, using Indirect Addressing. It also includes instructions and the math equations used, so that you can modifiy it as needed. To sort a character list, you would need logic to convert the first 2 or 3 characters to number values.
 
Last edited:
Thanks to previous posters I now have functionality to create and alphabetically sort a list of strings. Based on CLX emulator. I have sample PLC & HMI code if anyone wants.
 
Yes, this sorting question comes up here periodically. Please post your programs for future users. A PDF file-type print-out seems to be the best all-around method to allow the maximum number of people to read it.
 
Code can be merged into 1 routine if you're only sorting one list. I am intending to eventually sort multiple lists, so have split functions into subroutines.
 

Similar Topics

Hello, I've been trying to learn this a while now and still have not found out how this works. I have an Omron CJ2M PLC and an ABB ACS 355 VFD...
Replies
1
Views
237
Hello, I have to deal with iFix again and am looking at the most efficient way to create alarms to display in iFix, i.e. not creating an...
Replies
0
Views
153
Good morning to all, I have the following issue, I installed everything of intouch including the patch, it is the 2023 version. The...
Replies
0
Views
329
So, I finally got versioin 27 installed on my Windows 10 VM. However, now I can't upload a project from my lab controller. I have the above error...
Replies
0
Views
1,127
Hi all, I have few GB of logged data created by RS View 32 Works, it is all in .DBF format. At the moment, my company wants to shift all data to...
Replies
14
Views
1,445
Back
Top Bottom