Newbie with Simple Sorting Conveyor

David,
I probably made a few errors. One I noticed after I posted is that on the last Rung 28, 4th input branch, the C406 address should be C306, because Divert Lane 3 is really your last photosensor. That branch is an attempt to catch the boxes that do not get diverted and remove them from the Counter 1 accumulator as they pass by the last photosensor. If this does not work, then you will have to add another set of rungs for a 4th bit-shift register.

The screen shot you posted of the instruction does not explicitly state that source and destination addresses cannot overlap so I'm ASSUMING that my initial move of n+1 to n+0 would work.
Doug, yes you could use overlapping addresses in the Block Copy Source and Destination, but the Length is always "1", not a variable. Probably you could use the For-Next instructions to create a loop to do the Block Copy enough times to get to the desired bit. That might save a couple of rungs in the program.
 
Last edited:
Doug and David,

I was wrong about the Block Copy. The CLICK does have a limited index "pointer" available. You must use only the DS file as the pointer. Using the DD (double integer word) file as the FIFO stack, I was able to MOVE the Counter value to the DS1 pointer, and reduce the number of rungs and also improve the reliability.

Now at each diverter, only a simple comparision is made for the First-In box DD1 = 1 for Lane 1, 2 for Lane 2, and so on through 4 for Lane 4. For Lane 4, nothing is done except decrement the Counter by 1. I think it will work better using this method.
 
Last edited:
Lancie,

I have only had a short time to play with your Rev 1 program so far, but it appears that the diverters are only comparing the data for the first box until it exits the conveyor.

For instance, if I select Lane 3 for the first box first then Lane 1 for a second box, the Lane 1 diverter won't fire until lane 3 has. Since new lanes will be selected before the first box reaches lane 3, the second box will pass by diverter 1.

I could be missing something so I'll keep playing with the program. I appreciate all of your help with this!
 
I will see if I can figure out why that is happening.

Some possibilities:

1. Did you use the same inputs for each lane as were in the program?

2. Are your inputs X001 to X007 connected to momentary-contact pushbuttons or switches. In other words, each one goes on then off again (not maintained ON)? The photoswitches must be off until a box reaches the photosensor.

3. Two of the input switches going on at the same time will create an error.

4. How long does each diverter need to stay ON? Right now they are ON for 1 second. Perhaps 0.5 second would be enough for most solenoid-operated air kickers. If a diverter stays on long enough for the next box to reach another photoswitch, I think that might cause an error.

5. For rungs 7, 10, and 13, you could try changing the Diverter Timer bits to the Y001, Y002, and Y003 output bits instead. That would move the FIFO Copy up by 1 second in each case, meaning that the FIFO would be re-positioned for the next box 1 second earlier than it is now. That might make all the difference, depending on how fast your boxes are traveling and how much space is between each one. EDIT: Also change the same 3 timer bits in Rung 15 to the Y output bits.
 
Last edited:
1. Did you use the same inputs for each lane as were in the program?
Right now, I'm just running your program on the CPU with no wiring connected. I have not changed any of the input addresses.

2. Are your inputs X001 to X007 connected to momentary-contact pushbuttons or switches. In other words, each one goes on then off again (not maintained ON)? The photoswitches must be off until a box reaches the photosensor.
Since I'm just running the program and monitoring with the data view, I'm just toggling the input bits manually (and making sure they're only on momentarily)

5. For rungs 7, 10, and 13, you could try changing the Diverter Timer bits to the Y001, Y002, and Y003 output bits instead. That would move the FIFO Copy up by 1 second in each case, meaning that the FIFO would be re-positioned for the next box 1 second earlier than it is now. That might make all the difference, depending on how fast your boxes are traveling and how much space is between each one.
I'll give that a try and see what happens.
 
Okay, hang in there. We will figure it out. I think it will be hard to turn toggle inputs on and off at the correct times.

My assumption was that X005 is the first photoswitch/diverter on the conveyor, followed by some distance downstream for X006, followed by some distance downstream for X007, followed by a straight section for the Lane 4 non-diversion. If the conveyor is different, then there might need to be some program changes.

Don't miss this change that I added later:
EDIT: Also change the same 3 timer bits in Rung 15 to the Y output bits.
 
My assumption was that X005 is the first photoswitch/diverter on the conveyor, followed by some distance downstream for X006, followed by some distance downstream for X007, followed by a straight section for the Lane 4 non-diversion.

That is exactly how the conveyor is laid out. It moves fairly slowly, so it is likely that additional boxes will be added before the first box is diverted.

Diverter 1 (X005) is close to the loading (and manual pushbutton) point, so the boxes will likely make it past that point before another is loaded.
 
I'm watching the FIFO positions (with data view) as I simulate the conveyor operation and the values are changing like I would expect (based on my understanding anyway).

Looking at rungs 6, 9, and 12 on column C, the comparison is only based on the value in FIFO position 1 (DD1). Don't we need to compare based on different positions for other boxes?
 
I think I see one problem with Revision 1. On rung 15, the bits that trigger the counter to count down (remove a box) need to be ON for only 1 scan. If each bit is ON for 1 second or the time for the diverter operation, then the next box may hit its photoswitch before the other diverter is done. That will cause the count-down bit C3 to miss one or more on-to-off transitions, and creates a bad error in the program.

A One-Shot bit must be used for the Outputs. I think each of the Y bits could be changed to a one-shot by checking the One Shot for that Output. However I chose to check the "Immediate" box so that each will go on mid-scan (as early as possible), and then added 4 new rungs before rung 15. Each of these rungs goes ON for only 1 scan when each Y output goes on. This will count-down the counter as quickly and as early as possible, preventing overlaps between the count-down triggers. So obvious now that I think about it! Oh, well, party on!

Here is Revision 3 with the above changes.
 
Looking at rungs 6, 9, and 12 on column C, the comparison is only based on the value in FIFO position 1 (DD1). Don't we need to compare based on different positions for other boxes?
Well, that is why it is called a "FIFO" (First In, First Out) operation. The first box IN to the FIFO stack always needs to be the first box OUT. So as a box hits each photoswitch, we only need to see if the number in the current FIRST box (which is always memory location "DD1" in this program) in the stack (which is shifted down each time a box is removed) is equal to the Lane Number. If it is, we divert the box. If not, the box passes and moves on to the next diverter.

When there is a box diverted, then we must immediately shift the FIFO stack so that the next box's lane number moves to the FIRST positon (DD1) in the stack. That little word immediately was what Revision 2 (see above) was about.

Hmmm...It occurs to me that there may be another error. If the FIRST box does not arrive at its lane until the SECOND box has already arrived at its lane, then possibly it will not work correctlly. We may have to add a FIFO memory stack for each lane. Let me think about this some more.

Does Revision 2 divert correctly if you put in boxes to Lanes 1, 2, 3, and 4 in sequence. If so, then there definitley needs to be more changes.
 
Last edited:
When there is a box diverted, then we must immediately shift the FIFO stack so that the next box's lane number moves to the FIRST positon (DD1) in the stack. That little word immediately was what Revision 2 (see above) was about.
That makes sense, but what happens when box 1 is on its way to lane 3 and a second box is added (for lane 1) before box 1 reaches lane 3? Box 2 will pass the diverter at lane 1 since the comparison is only looking for position 1 (which is currently lane 3). It sounds like we need to have multiple FIFOs (one for each lane?).

Thank you for being patient with me!
 
It sounds like we need to have multiple FIFOs (one for each lane)?
Yes, but each FIFO has to be synchronized so that it has a "0" entry for when the box Lane Number is not equal to the FIRST number.

That means it may be easier to go back to the old bit-shift method, which did have separate memory stacks for each lane, and they were automatically synchronized by the timing bit.
 
That means it may be easier to go back to the old bit-shift method, which did have separate memory stacks for each lane, and they were automatically synchronized by the timing bit.

Ok, I can try running your original program from post 8 again.
 
Ok, I can try running your original program from post 8 again.
Except it had the same timing errors with counting down the counter. Try tthe attached "back to square 1" Revison 0. I made a few other changes (removed the unnecessary FOR-NEXT loops) in an attempt to make it better.

EDIT: I forgot to change the Y bits on Rung 26 to the C4 to C6 bits. Those changes are now in Rev 0.

I am hanging up for tonight. I probably will be back tomorrow. Catch you later.
 
Last edited:
After thinking about it overnight, for a conveyor of unknown length and speed and without encoder position tracking, and packages that divert at different sequential points, there must be a new FIFO for each zone. FIFO #1 and #2 passes undiverted boxes on to the next FIFO, as must happen to keep up with the sequence of boxes. In this case the areas should be divided as follows:

FIFO #1: from START to Lane 1 Diverter
FIFO #2: from Lane 1 to Lane 2 Diverter
FIFO #3: from Lane 2 to Lane 3 Diverter

The non-diverted Lane 4 only needs to cause FIFO #3 to shift down one position and decrement Counter #3 by 1. Using sequential FIFOs is much easier in PLC software that has dedicated FIFO Load and FIFO Unload instructions. Rolling your own using a sack full of copy and counter instructions is not pretty.

Here is Revision 3 using 3 FIFO stacks, set for a maximum of 5 boxes in each zone. If there could be more, I left room between FIFO stacks to expand to 10 boxes.
 
Last edited:

Similar Topics

Hi All, I've just recently completed a basic training course on PLCs. I've been playing around with Step7 from Siemens and I'm trying to...
Replies
7
Views
1,830
I have surfed this board for a while and have learned much, but mechanics are my real forte so please forgive my ignorance of a solution for what...
Replies
7
Views
4,457
Hello all, I'm a new member here. I've joined as I want to learn about PLC programming. I've got a few questions to begin with. To get me...
Replies
37
Views
4,586
Howdy folks. Been doing PLC programming for like 15 years now in LD and ST, but I'm trying to learn SFC now and have a kind of dumb question... I...
Replies
4
Views
1,422
Hello. New to Unity and had a couple quick questions. Can a Modicon M340 output to a small multiline LCD screen and not a full HMI?
Replies
4
Views
968
Back
Top Bottom