Keeping track of bottles to be ejected

Dartrunner

Member
Join Date
Jul 2003
Location
Bluff City, TN
Posts
14
The perfunctory "I am new to this." ;)

Just getting started in PLC programming and am trying to write one for a Siemens S7-200 CPU 224.
The application is checking bottles for a UV coated label as they travel by on a conveyer and then blowing them off about 3ft down the line if there is no label. The bottles are spaced about 6in apart and traveling between 90 and 120 bottles a minute.
I am able to detect the presence of the bottle’s neck and trigger the UV cameras to find the bad ones with out a problem. The problem comes in tracking the bottle down the line and ejecting the correct one. I have a presence sensor at the blow off point and an eye verifying that the bottle was ejected. I have tried to do it with timers and such but keep running into problems because of speed variation and the bottles vibrating on the conveyer. I looked at using a shift register, but guess I am having a brain block on understanding how to apply it. Also tried using an up/down counter, which would work for a while, but seemed to start getting the wrong bottle after a while. Sometimes getting as much as 4 bottles off. The line is sometimes powered down and brought back up with the bottles wherever they were when the conveyer was stopped. Other equipment on the line can also stop the conveyer (I think this was the biggest problem with the counter idea, bottles stopping under the presence eye.) and this controller will also stop the conveyer if an ejected bottle is not seen in the chute. (I think I have that one programmed)

Any suggestion would be very welcome!
Thanks,

Bob Smith
 
Hey Dart,

I'll try and answer this, even though I know that there are much more qualified programmers that may have a better solution, but willing to impart what I do know about programming...

Also, I am not very familiar with the Siemens family of processors, but I'm thinking that your bit shift will be the 'code of choice' for your scenario. Simply, it's parts tracking, and adjusting the bits within the register as a bottle passes by the sensor. In the AB series, a bit shift is usually at the 'word' level (16 bits per command) and you can alter the output to meet a bit within the word. From what I understand with bit shifts, you have the bottle pass the eye, it enters information into the first bit of the word. Then, with little programming, you move that bit within the word either left or right, and set an output to a bit further down the line. Let's say that you know that at the entry of a bad bottle, it will meet the ejector 16 bottles down the line (or whatever distance). You set the bit register input (in AB sense, approx. B3:2/16) and have it send an output to your rejector. You would program the B3:2 to be your bit shift, then assign an output to the bit level. I'm hoping that this makes sense and you will be able to incorporate into Siemen's language...

Since you seem to have an issue with starting and stopping, the bit shift makes the most sense, but maybe another sensor further down the line? How about incorporating an encoder for the conveyor, a sensor just before the ejector as a comparator, etc... some sense of checks to make sure that your parts tracking is accurate given the fluctuations?

As for the powering down and up, you may have to research how the Siemens processor stores information during a power down. Most processors give the option to either do a memory dump during power down, or keep the last values stored in memory. Hopefully, someone with more Siemen's experience will be able to answer that question specifically.

Just some thoughts from an overworked mind... ;)

Hoot
 
Hootnholler said:
From what I understand with bit shifts, you have the bottle pass the eye, it enters information into the first bit of the word. Then, with little programming, you move that bit within the word either left or right, and set an output to a bit further down the line. Let's say that you know that at the entry of a bad bottle, it will meet the ejector 16 bottles down the line (or whatever distance). You set the bit register input (in AB sense, approx. B3:2/16) and have it send an output to your rejector. You would program the B3:2 to be your bit shift, then assign an output to the bit level. I'm hoping that this makes sense and you will be able to incorporate into Siemen's language...

I follow what your saying (I think), I have gone over the Shift Register Tutorial on this site, but I am not understanding how the register shifts, what would be the input to tell it to shift? I guess that is where I am being ignorant. If the register had 16 bits in it, it would have to shift 16 times before the bad bottle reached the ejection point. What is going to shift it that many times? If I do it with a timer, I don't see how it would deal with a change in speed. And if I just look at the bottles, what about a missing bottle, or the first or last bottle in a run. Or if a bottle was kicked off in the line before this system? Too many questions? :(

Once I see an example, I will probably understand it, at least I hope so!

Thanks,

Bob Smith
 
Last edited:
Using a counter to keep track of where the bottle is should be a workable solution. It sounds like the problem there could be with the sensor counting a bottle more than once. You could try adding a timer to the sensor for hysteresis. One question I have is there still power to the sensor when the line stops? If there is I don't think it would be a problem, if there isn't that could be the cause of the double counting. What if you incremented the counter when the sensor went off after it was on for a minimum of X amount of time?
 
You are asking the right questions... What tells the shift register to 'shift'? Ummm, nothing. Personally, I think you will drive yourself nuts trying to track the bottles with a shift register due to the distance between the inspection and the reject (the varying speed doesn't help the situation either)... banghead

One option would be to use the speed of the conveyor to reference how far a bottle has traveled once it is flagged as a reject. Keep in mind that this 'might' be a solution, provided the bottles never slip on the conveyor. If you want to be sure you'll catch the rejects, you really need to gain control of the bottles between the inspection and reject. One way might be to use a timing screw. See THIS LINK if you are unfamiliar with timing screws.

By the way, there isn't any chance you can reject AT the inspection point, is there? I didn't think so... ;)

If you can count on bottle speed not varying much, here's a 'generic' timer solution you might want to play with...

| --- RUNG 1 ---
|
| FAIL LATCH 1 LATCH 2 LATCH 3 +-------+
|---]^[------] [------] [------]/[----+------------------| TIM 3 |
| | +-------+
| LATCH 3 | TIM 3
|---] [-------------------------------+----]/[-----------( LATCH 3 )
|
| --- RUNG 2 ---
|
| FAIL LATCH 1 LATCH 2 +-------+
|---]^[------] [------]/[-------------+------------------| TIM 2 |
| | +-------+
| LATCH 2 | TIM 2
|---] [-------------------------------+----]/[-----------( LATCH 2 )
|
| --- RUNG 3 ---
|
| FAIL LATCH 1 +-------+
|---]^[------]/[----------------------+------------------| TIM 1 |
| | +-------+
| LATCH 1 | TIM 1
|---] [-------------------------------+----]/[-----------( LATCH 1 )
|
| --- RUNG 4 ---
|
| TIM 1 TIM 0 +-------+
|---] [----+----]/[-------------------------------+------| TIM 0 |
| | | +-------+
| TIM 2 | |
|---] [----+ +------( REJECT )
| |
| TIM 3 |
|---] [----+
| |
| REJECT |
|---] [----+


.
TIM 0 is set to how long you want the air jet to turn on to reject a bottle.

TIM 1,2,and 3 are set to the same preset value. This value is the time it takes for a bottle to travel from the inspection station to the reject station.

Note that the FAIL bit turns on for 1 scan when the inspection sees a failure

Now I'll try to explain it...

Let's see what happens with ONE failed bottle...

RUNG 1 gets skipped because neither LATCH 1 nor LATCH 2 is ON
RUNG 2 gets skipped because LATCH 1 is NOT ON
When we get to RUNG 3, LATCH 1 gets SET, and TIM 1 starts timing
When TIM 1 expires (bottle has reached reject station), it starts TIM 0 (RUNG 4), which actuates the REJECT for the specified time

Now, what happens if you have ANOTHER failure while you're 'tracking' THIS one? Let's see... Remember, LATCH 1 will be ON if we're currently tracking one failed bottle

RUNG 1 gets skipped because LATCH 2 is NOT ON
When we get to RUNG 2, LATCH 2 gets SET (because LATCH 1 is ON, remember?), and TIM 2 starts timing
RUNG 3 gets skipped because LATCH 1 is ON (it's 'busy')
Keep in mind that the first failed bottle gets blown off when TIM 1 expires
When TIM 2 expires (2nd bottle has reached reject station), it starts TIM 0 (RUNG 4), which actuates the REJECT for the specified time.

But what if you have YET ANOTHER failure while tracking these two? Now RUNG 1 will start TIM 3 to track this 3rd bottle... You know the rest. Basically, the timers/latches just come on board automatically as needed

You can add as many timers and latches as needed to track more bottles, just remember to add them AHEAD of the rest, and to use the appropriate quantities of --] [-- and ---]/[--- to fire off the next 'tracking latch' in the sequence.

Confused yet?... :D

beerchug

-Eric

Note to Terry... Didn't you write something (quite) a while back about something similar? I remember you talking about adding and removing items while a machine was stopped... :unsure:
 
Dead set easiest way is to use a shift register. You can use a PE to detect the necks of the bottles and use this input to pulse the shift register. Also use an output from the register to operate your reject solenoid.
I use Omron PLCs normally and they have a shift register where you can specify the length of the register. The longest one I have used was 10 words or 160 bits or 160 postions.
The only issues you should have to watch out for is if the PEs and or PLC are powered down. If the PLC is powered down you will have to use the first scan flag to reset the shift register and put up with a few bad bottles or use words that are meory retentive when it is powered down. If the PEs are powered down they will give a signal when they are powered up again and pulse the register so that you eject a good bottle and pass a bad bottle.
Have used this method before with great success.
beerchug
 
Say What????

Sorry Bob, I disagree. Remember that Deer said 3 F-E-E-T (that's just under 1 meter in Ozz :p)... That's a lotta room for random spacing of bottles (unless they're huge bottles! ;)). Where do you suggest he put the photoeye? The ONLY place would be immediately after the inspection point. You HAVE TO advance the shift register between inspections, otherwise it's useless. You might as well let the inspection trigger the shift. If you place it more than one bottle width downstream, the shift register won't start advancing until the first bottle reaches it. Now, what about the other bottles that have been inspected BEFORE that first bottle reaches the photoeye? Or do you figure the conveyor will always have bottles on it? And that no one will ever add or remove bottles from this space? Highly doubtful... :rolleyes:

I will say that my timer idea is pretty 'half-a$$ed', but at least it can (attempt to) keep track of EVERY failure that occurs, no matter how randomly spaced the bottles are. It's biggest drawback is that it relies on consistent bottle travel time from inspection to reject, which I doubt exists in Deer's application. If he doesn't have a lot of failures, a 'quick-fix' might be to decrease the delay times (TIM1-3) and increase the reject time (TIM0) to blowoff 3 bottles. The failed bottle SHOULD be the middle one, but if the speed varied slightly, it may be the leading or lagging bottle, but at least you'd have a better chance of catching it... :D

beerchug

-Eric
 
Fair comment Eric. It should be something constant such as a flag on the conveyor to a prox or a prox reading a bolt on a roller. That would be a better option and speed would not matter.
I suppose if the bottle size varied, there is another source of confusion. It would affect either option.
beerchug
 
That's a good one.
That one too.
Bad.
Not Bad
Ooooo, Really Bad!
Good one.
.
.
.

Offset
Pointer Words containing status
DEC
. +----------------------+
. | | Base Address + 0
. +----------------------+
. ==> | | Base Address + 1
. +----------------------+
. | OK | Base Address + 2
. +----------------------+
. | NFG | Base Address + 3
. +----------------------+
. | OK | Base Address + 4
. +----------------------+
. | NFG | Base Address + 5
. +----------------------+
. | OK | Base Address + 6
. +----------------------+
. | OK | Base Address + 7
. +----------------------+
INC


.
Use a Word Shift Register. The number of words in the shift register is equal to the maximum number of bottles that can fit between the Inspection and Ejection points.

The scheme is to have the Inspection Station write the evaluation directly to the "current" memory word in the shift register. The location of the "current" word is identified by "Base Address + Offset". The value of "Offset", in this case, ranges from 0 to 7.

At the beginning, the initial "Offset" value is 7. When the inspection station evaluates a bottle, the judgment is written to the location identified by Base Address + Offset.

The Ejector station ALWAYS reads at Base Address + 7.

When the Words in the shift register are shifted, the word at Base Address + 7 is discarded. The remaining words are shifted one place toward Base Address + 7.

Inspect evaluates a bottle and writes to Base + Offset. Then, Offset is DECREMENTED by one.
Inspect continues to evaluate bottles, writing to Base + Offset and DECREMENTING the Offset value.

Since the number of words is equal to the maximum number of bottles that can fit, there won't be a problem about over-fill, or decrementing below zero.

Meanwhile, the ejection station is waiting to "see" a bottle.

When the ejection station "sees" a bottle, the ejector looks to Base Address + 7. If "OK", then the bottle is passed. If "NFG", then the bottle is ejected. In either case, the ejector then causes the shift register to shift toward Base + 7. The value at Base + 7 is shifted out of the register. It then INCREMENTS the Offset for the next write by the inspection station.

You might want to "buffer" the inspection station actions. That is, if it happens to be that both stations try to manipulate the register at the same time, then you should probably let the ejector station have priority - "buffer" the inspection station result. Then when the ejector is done, update the register with the inspection data.
 
Not sure if Siemens has it ...

What about some form of fifo?

good bootle = 1, bad bottle =2

load bottle value at first photosensor

unload at the second
 
Yes, S7-200 has a FIFO structure, or better a FIFO instruction. This instruction shifts the first entry of a table to a destination. To enter a new value in the table you have to use the ATT instruction (Add To Table). The table consists of words (16-bits), the first entry being the table length, the second being the Entry Count (EC).
These instruction are available with S7-214, -215 and -216. Since the S7-224 is younger than these, I figure it goes for this CPU too. You should check the manual.

Kind regards,
 
Ok, some answers to questions I have seen,

Yes the bottle sizes do very from small 50 gram bottles to large 250 gram bottles. (Powder weight, liquid is added at the pharmacy so the bottle is only about 1/8 full of powder) The small bottles are round, about 1 inch diameter, the large are more rectangular, about 1.5 x 2.5 at the base. The bottles for any given batch are all the same and the line cleared between batches, so only one size being looked at during a run. However we are going through a set-up reduction program and don't thing they would like me adding another thing to change before every line change over. :)

The operator can change the speed of the line at any time from 90 bottles per minute up to 120 bottles per minute. (Mostly for correcting excessive fill weight errors, run as fast as you can with no more than a 2% rejection rate.)

The bottles do vibrate on the conveyer and can move slightly from the position it was at when inspected, which was why I put a presence eye at the ejection point. When I started out using timers I would look for the bottle within a band of time and eject it when it was in front of the eye. I found that the time varied too much with speed changes in the conveyer to accomplish this.

The bottles have just come through a screw driven labeler and are evenly spaced apart at about 6". The screw can and does run empty sometimes though, so there is not always a bottle every 6 inches.

The FIFO idea was what I was trying to do with the up/down counter. It would work for about 5 – 10 minutes but then would start to get further off the longer it ran, and would be about 4 bottles off after 30 minutes. (Probably bad programming on my part. :( ) I will look for the FIFO function jvdcande mentioned and see if I can get it to work better than the hacked up counter idea.

This is the closest the ejection chute can be to the checking station because of other equipment and the design of the ejection chute to be able to see if the ejected bottle is actualy ejected.

I had thought to just eject everything off on power-up until I reached the first bottle that I checked, but could not get that to work right either. I think I am a little (or maybe a lot :( ) over my head, but will probably learn a lot from this experience.

Thanks for the help and suggestions!

Bob Smith
 
Last edited:
Dartrunner,

The guys have come up with some excellent suggestions, but I gather that you think that no individual one of them will do the job. So, let us combine three of them!

The reason I think that a combination of the suggestions will work is that I was involved in a similar situation and it took a combination of techniques to solve the problem.

The suggestions I am talking about are these: (1) Use a shift register controlled by a pulse switch; and (2) Use a second photosensor (in addition to the initial bottle sensor), positioned as close as possible to the ejector point, call it the EJECTOR PHOTOSWITCH; and (3) Use a Counter TO ONLY TRACK THE DISTANCE BETWEEN THE EJECTOR PHOTOSWITCH AND THE EJECTOR. The idea is to minimize the slip error and other errors. Now combine these three things in the right way.

Shift registers are ideal for tracking individual parts, but you have to make sure that when the bit is shifted, the part has actually moved an equivalent distance. (For your small distance of 3 feet, you can also substitute a counter for the Bit Shift if you are not familiar with Bit Shift commands.) Here is the most common method:

STEP 1: You attach a pulse generator (or Encoder but much more expensive) to the conveyor, usually to the main conveyor head shaft. The pulser is calibrated to generate an "on" bit every time the conveyor moves a certain distance. I usually use 1 inch. Note that the pulser can be nothing more than a proximity switch with a target attached to the conveyor shaft at the right length. Now when your photosensor detects a bottle passing, you insert the first "1" bit into your shift register, BUT EACH SUBSEQUENT SHIFT IS PERFORMED IF AND ONLY IF A PULSE IS RECEIVED FROM THE CONVEYOR PULSE SWITCH. This way, you can measure with a tape (only 1 time) how far it is from the bottle sensor to the EJECTOR PHOTOSWITCH. Your bit (representing an individual bottle) shifts up to a number that equals the MEASURED DISTANCE MINUS SOME ERROR FACTOR (a known constant number). The error factor is set so that no matter if the bottles slip a little, that the next bottle down the line will the one being tracked. In other words, if your bottles are spaced about 6 inches apart, your error factor could be as large as 6 inches. The idea is to bracket the bottle within a certain range.

STEP 2: When the calculated Bit-Shift number is reached by the conveyor position pulser, you then enable a photoswitch which is located a known distance from the ejector. When this photoswitch sees the next bottle AFTER IT HAS BEEN ENABLED (which should be the one your are tracking, even considering slip errors AND EVEN IF THE CONVEYOR HAS BEEN STOPPED AND THEN RESTARTED, because your position pulse has also stopped), then you start a Counter.

STEP 3: The counter (which is doing the same job as the Bit Shift, except for a smaller distance) is advanced each time the Conveyor pulser is triggered, so that stops and starts will not matter. The Counter Preset Value is set to allow the conveyor to move the exact distance from the Ejector Photoswitch to the ejector. When the Counter is DONE, you trigger the ejector. With this method, the only slip error that is unaccounted for is any that happens in the small distance between the Ejector Photoswitch and the Ejector. Usually there is enough width or span in the ejector to allow for this small error.

Maybe this will get you on the right track. Remember that you need to actually sense how far the conveyor has moved in order to eliminate tracking errors.
 
Last edited:

Similar Topics

Good Morning , I have a Panelview Plus application that I would like see in my CompactLogix which screens are presently displayed on the...
Replies
9
Views
3,950
EDIT: Sorry for the typo in the title, it should say "via MSG" Hi guys, I've come up against something that is likely simple to take care of...
Replies
12
Views
1,863
Does anybody have a sample plc program for a micrologix 1400 using an encoder to keep up with multiple parts? The part hits a part present...
Replies
4
Views
2,426
Hey guys I am new to these forums and I am relearning PLC's after a 10 year break from it. What I am trying to do is keep track of cans that get...
Replies
8
Views
2,308
I have a Micro830, but I imagine my problem is just locical and probably applicable to most any PLC I have a conveyor with a photocell at one...
Replies
12
Views
3,006
Back
Top Bottom