Counting with a photoeye

lauu

Member
Join Date
Aug 2003
Posts
83
I'am trying to count parts with one photoeye but sometimes I get 2 counts for the same part. I have tried different ways to solve the problem but havent find the right one. Can anyone help me?

Thanks!
 
You're probably getting intermittent blips from the photoeye that the PLC is interpreting as an additional part. The simplest way to work around this is to just add short on and off delay timers to the photoeye input to filter out the blips.

| PHOTOEYE +-------+
|-----] [-----------------| TIM 1 |
| +-------+
|
| PHOTOEYE +-------+
|-----]/[-----------------| TIM 2 |
| +-------+
|
| TIM 1 TIM 2 EYE_ON
|-----] [---+---]/[---------( )
| |
| EYE_ON |
|-----] [---+


.
Use the EYE_ON bit in lieu of the PHOTOEYE bit as the input to your counter.

beerchug

-Eric
 
What type of photoeye are you using? Through-beam, diffuse, or retroreflective? Something in the product you're detecting or the way the photoeye is mounted is causing the signal from the eye to go TRUE-FALSE-TRUE-FALSE for a single pass of the product in front of the eye. There could be more TRUE_FALSE transitions that are happenening faster than the PLC can detect.

Put a scope on the signal to see what it looks like. Then adjust your mounting or your gain setting on the eye to get the cleanest signal.


If you can't fix it by these adjustments, then you could create a timer in ladder logic to ensure that a minimum time period elapses between successive counts.
 
If you are using bit shifting you can filter your eye by looking for 2 or 3 consecutive bits before counting it as an object. We do that where there is a lot of debris flying around causing single stray bits to end up in our data files. If we only looked for one bit we would get a ton of errors.
 
lauu said:
I'am trying to count parts with one photoeye but sometimes I get 2 counts for the same part. I have tried different ways to solve the problem but havent find the right one. Can anyone help me?

Thanks!

Hey guys

Thanks again for helping me, it seems to bee working now.
Hopefully one day I will have something to contribute.

beerchug

Jesper
 
Question

Is it common practice to program in a debounce when using a PE to count or just as needed?

Thanks,
Bob
 
Debouncing is very common for number of situations or
whenever signal might have noise but you expect one
good defined signal. It is common for PLC Input cards
to include debounce or filtering for 2-15mS.
This does the job for many cases but not always.
Ok here is one suggestion: Using PLC of you choice,
write simple rung that increments counter on every
rising edge of the signal from push button.
Press button say 10 times and see what counter says.
If the value is different (higher in counter) it means
that you should have debounce on this button.
 
You don't usually have to add debounce timers for simple discrete inputs. As Panic mentioned, the input filters usually suffice (and many are adjustable). I can't remember ever having to add debounce logic in my programs for switch/sensor inputs. Occasionally I'll add a 100ms filter for a customer's input just to avoid any headaches if their contact is noisy.

I regularly use the on/off delay logic I posted for lauu, just not for 'debouncing' purposes. This is my standard "Minimum Level" logic to determine when sufficient parts are on an infeed conveyor. The 'on-delay' is set to a value slightly higher than the time it takes for a part to pass a "Minimum Level" photoeye. The timer will only 'time-out' when a part is stationary on the conveyor (IOW, parts have built-up to the minimum level). The 'off-delay' gets set to a value just high enough to ignore any intermittent OFF signals that might occur. Parts may not accelerate as a group, so you might get a gap between parts that you need to ignore.

While I'm on this subject, here's a newbie tip regarding the use of thru-beam or retroreflective photoeyes to monitor levels... 👨🏻‍🏫

If parts have an inherent gap between when grouped, aim the photoeye at an angle across the parts to ignore the gap. The leading edge of the second part will block the eye before the trailing edge of the first part leaves the eye.

beerchug

-Eric
 
Sorry Eric, your right.

Here is the rest of the story!

I tried to adjust the PE, like Steve sad, but I stil got the "extra" count. So I put in some new "code" and it looks like this:


| //Counts when parts lives the PE (OSF)
|
| PE S:1/15 Out_PE
|---]/[---]ONS[---]/[---------------------(L)
|
| Out_PE PE Time_before_Next_Count
|---] [----] [---------------------------(Tim)
| |
| | Tim Out_PE
| |---] [----------(U)





I have a ON/OFF time for about 300 ms, so I put in 200ms for the timer`s timebase.


Jesper

Hej ghriver!
The S:1/15 is "first pass" bit for an AB-PLC.
I use it her to avoid counts when the PLC is powered up. The PE is NO-Type.

Jesper
 
Last edited:

Similar Topics

Hello I am looking for tips on how to count the duration of a given function and then how to display it on the hmi panel in the hh:mm:ss format...
Replies
4
Views
1,698
Guys, I know it will be silly but can't get my head around it. I have 3 conveyors, every one on a separate servo drive, and 2...
Replies
25
Views
3,496
The 1734-IB8 has no hardware counting function correct? I am trying to find something to substitute in for a 5069-IB16F (since lead times are...
Replies
3
Views
1,409
Been scratching my head at what I thought should be a relatively simple task. I need to count how many rows a .csv file has, so I can later read...
Replies
6
Views
2,538
Hi All, I need to count my Contactor switching times. There are lots of them so I created a template logic with local variables in FC2000. Now I...
Replies
10
Views
2,115
Back
Top Bottom