RS5000 how to search for all identical strings in an array

dwouters

Member
Join Date
Nov 2015
Location
NH
Posts
5
A customer is asking if I can do a check on his batch numbers and reject a batch from starting if the check fails. The setup is as follows:
I have an array of 20 batch numbers, representing trays of material that get loaded in a thermal oven.
A batch of material can be spread across several trays, so for example batchnumber_tray[1] = batchnumber_tray[2] = batchnumber_tray[3], then next batch, will be spread across the next trays :
batchnumber_tray[3] = batchnumber_tray[4] = batchnumber_tray[5] =batchnumber_tray[6] , etc, until all 20 trays are filled.
The number of trays used per batch varies, as well as the number of batches used per array.

He want a check that sets a bit if any of the batchnumbers are not in sequential trays, in other words if
batchnumber_tray[1] = batchnumber_tray[3] = batchnumber_tray[4], but batchnumber_tray[1] NOT equal to batchnumber_tray[2], then set an error flag.
The batches have to be loaded in sequential trays..., if it skips a tray and then occurs again, that can't happen..
I know I can compare the individual batchnumber_tray with each other using an FSC instruction or even EQU, but what is the most efficient way to do a cross search for all the different batch #'s used and flag if any batch numbers are not grouped together?
Thanks for any suggestions.
 
Its a bit hard to be Complete, lack of detail, but essentially if you index through an array, tray by tray, looking at the batch number then every time you find a new batch number the previous one should be complete and can me marked as such, preferably in a second array.
So Far so good...
Now if you mark a batch as complete, checked, the first time it isn't the current batch number but mark it bad should your batch complete code be triggered for a batch already marked complete you will have found any batch held on trays that are not sequential....
its just a simple loop and a common assignment statement with a single caveat.

Procedure...
Set all batches as unchecked.
set 'last tray' to 1
set 'current tray' to 1
Get 'current tray' batch number and place in 'Last Batch'

Top of loop - some exit strategy, perhaps a count
Increase tray number by 1
Get 'current tray' batch number

If 'current tray' batch number is not the same as Last Batch
Mark the batch...
as checked if its unchecked
as bad if its checked

Set 'Last Batch' to 'current tray' batch number
Go back to the top of the loop

hope that helps...
Al
 
Thanks Al, that is pretty much how i'm trying to do it. I put something together using the FSC function and cycling through all the trays, looking for a match from the "current" batchnumber with any other tray batchnumbers. If a matching batchnumber is found in the next tray, I end the FSC and restart FSC searching from that next position instead for the next occurance. If the next match is not in the next tray, but somewhere further, then I set an error flag for that position where the match is too far away.
Sorry if my explanation doesn't make much sense I know it's hard to convey all needed details..
In a few days I'll be able to test/simulate, hopefully it works and is not driving up scan time too much.
 
You are probably better not using loops within a single scan...
I know you can I am simply suggesting you probably shouldn't.

When I said loop I probably should have said 'pseudo loop'
I tend to set up a sequence count,
then do one operation, on a rung/s per sequence number.

When you decrees or reset the sequence number nothing more happens until the next scan...

That said if you are only checking 20 trays, heck even 200 trays, and only looking at each one once per check-sequence, which is what I was advocating, then scan time will not be an issue.

BTW if you ever do have a scan time issue, you can split code between scans using several methods. Generally you will not need to be doing everything at once.

Al
 
Appreciate the advice Al. I haven't used loops nor FSC much in ladder so don't know the effect on scan times.
Currently it is doing "one" FSC per scan, or one "match found" per scan, as I increase the index of the search tray by one only if the FSC is complete or it found an adjacent tray match. I think that is exactly how you mention doing it ..

I initially had the FSC in a FOR loop but didn't think that would work, and you're right, I don't need to have it all done at once, the data entry of the batch numbers will take time and as long as it's flagged by the time they're done it's fine.
 
"looking for a match from the "current" batchnumber with any other tray batchnumbers"

You don't need to do this, or restart the loop, you are thinking in human terms...

Turn the whole thing on its head and work out what indicates OK/Bad and how few questions you need to ask to determine that...

a good batch has sequential trays, ergo anything else isn't good.

When you step through trays a change of batch number indicates a good batch until you find that batch number again.

If you start your check with all batches set to unknown, finding a new batch number means the last one you checked was good if it is currently unknown and bad if it inst unknown.

You only need to check each tray once and and keep a temporary record of the last batch number you checked.

All the loop dose is step through the set of trays, however many there are, and it only needs to do that once to check all batches.

The key is to realise that not knowing the status until the check is complete is OK. If you set a batch OK and then find it actually isn't because there is a tray out of place, which you didn't find until 6 trays later, that's still fine.

A recursive check is harder, faster and much easier to test and thus get wrong.... simple is good.

Al
 

Similar Topics

We only have like 3 AB's in this plant that run RS 5000. Never really had any problem with them. Today an output went bad and we had to change...
Replies
19
Views
9,462
I have recently made a career change after 25 years of being an electrician. I am officially a junior automation controls programmer. I recently...
Replies
11
Views
366
Hi Guys, Hoping that someone could please confirm if the 1756-IF16/B is/isn't compatible with the 1756-L1 5550 processor(13.24). I'm sure I...
Replies
2
Views
103
Hello, I need help making a logic modification to a RS Logix 5000 program. I can email the program and give plenty of insight to it plus I have...
Replies
4
Views
2,201
Hey folks I was wondering how one puts shortcuts on the logic display for instructions. A few weeks back another programmer added them for me...
Replies
2
Views
971
Back
Top Bottom