Using an Encoder to track part position

mahryanne

Member
Join Date
Jun 2007
Location
New York
Posts
6
Using an Encoder to track part position
Hi,
I have a Micrologix 1100 that I will use to add an inspection station on a line that processes 1000 ppm. The encoder I have is an AB that gives me 500 PPR. From previous postings I saw recomendations to use an HSC or a regular counter

1) can the Micrologix 1100 use an HSC mine is greyed out in RSLogix 500
2) since counters can only go up so high, so should I keep resetting my counter everytime I reach a part position. or how do I go about that

I have a part presence sensor that will trigger the Inspecting cameras and light, then I am counting on the encoder and my shift register to tell me when to reject.

Any input or code samples would be helpful.

Thanks,

Marianne
 
mahryanne said:
Using an Encoder to track part position
2) since counters can only go up so high, so should I keep resetting my counter everytime I reach a part position....

As a general rule, no, don't reset your raw counter.
If you reset the raw counter, you run the risk of missing pulses and hurting accuracy.

My advice: Each scan, calculate the distance traveled and adjust a separate register accordingly.

You can determine when the raw count rolls over when you get a value for distance traveled that is of the opposite polarity of the direction of travel and of a very high magnitude. When that happens, add (or subtract...depending on polarity) the PPR as well. For a bidirectional system, this requires that your PLC scan be at least twice as fast as a full rotation of the encoder.



Something like this:

'Note: on first scan, Old_count must be initialized (set equal to raw encoder value)
PPR=1000 'Pulses per revolution
Distance_Max = 500 'Maximum expected change per PLC scan
Distance = New_count - Old_count 'New Count is a snapshot from encoder register
Old_count = New_Count 'Update Old-Count Register
If Distance < -Distance_Max Then Distance = Distance + PPR
If Distance > Distance_Max Then Distance = Distance - PPR
Position = Position + Distance

If your system is not bidirectional, then you can remove some of this logic...

I would not use a shift register either...Just update the position of the part(s) in process like above, and when the position of the part is within the rejector window, operate the rejector if required.
 
Last edited:
OkiePC said:
As a general rule, no, don't reset your raw counter.
If you reset the raw counter, you run the risk of missing pulses and hurting accuracy.

My advice: Each scan, calculate the distance traveled and adjust a separate register accordingly.

You can determine when the raw count rolls over when you get a value for distance traveled that is of the opposite polarity of the direction of travel and of a very high magnitude. When that happens, add (or subtract...depending on polarity) the PPR as well. For a bidirectional system, this requires that your PLC scan be at least twice as fast as a full rotation of the encoder.
Here is where we disagree.

Code:
[font=Fixedsys]Something like this:[/font]
 
[font=Fixedsys]'Note: on first scan, Old_count must be initialized (set equal to raw encoder value) [/font]
[font=Fixedsys]PPR=1000 'Pulses per revolution[/font]
[font=Fixedsys]Distance_Max = 500 'Maximum expected change per PLC scan[/font]
[font=Fixedsys]Distance = New_count - Old_count 'New Count is a snapshot from encoder register[/font]
[font=Fixedsys]Old_count = New_Count 'Update Old-Count Register[/font]
[font=Fixedsys]If Distance < -Distance_Max Then Distance = Distance + PPR[/font]
[font=Fixedsys]If Distance > Distance_Max Then Distance = Distance - PPR[/font]
[font=Fixedsys]Position = Position + Distance[/font]
[font=Fixedsys][/quote][/font]
[font=Fixedsys]Forget about the PPR.  Think of this more as a unwind.   If you are counting pulses along a converyor then you don't care about PPR.[/font]
[font=Fixedsys][/font] 
[font=Fixedsys][code][/font]
[font=Fixedsys]DifCounts:=NewCounts-OldCounts;[/font]
[font=Fixedsys]SumCounts:=SumCounts+DifCounts;[/font]
[font=Fixedsys]
[/font]
DifCounts should be a 32 bit DINT and NewCounts and OldCounts will probably be 16 bit INTs. It is that simple. Well maybe not. It depends on the PLC and how easily it can sign extend 16 bit INTs to 32 bit DINTs. This should be easy enough on a PLC with L registers. The ML1200 does have L registers doesn't it? Don't worry about the overflow, just clear the over flow bits. Now you can count long distances. Don't reset the SumCounts! When you have many items on a conveyor that doesn't work unless you have a separate SumCounts for every part. Even then don't reset the SumCounts. Offset them. This way errors will not grow. I prefer to save away the SumCount and check to see when the required number of counts have gone by.

Code:
[font=Fixedsys]StartSumCount := SumCounts;[/font]
 
While ((SumCounts-StartCounts) < DelayCounts )
{
  Wait;
}
DO something;
Note the while check must be done as I show it otherwise there will be over flow problems.

Code:
While (SumCounts < (DelayCounts+DelayCounts) )
{
  Wait;
}
DO something;
This does not work!!!



 

Similar Topics

Studio 5000 & PF 525, Ethernet Comms, Encoder FB, Using Motor RPM as speed reference I'm trying to figure out how to send a speed reference in...
Replies
6
Views
936
Hi all, I have an application coming up where I have a motor that runs forward or backward to adjust the linear position of a machine component...
Replies
6
Views
1,299
A bit of background here: We use an incremental encoder with a counting module in our PLC configuration. Using dual phase / quadrature counting...
Replies
26
Views
8,950
Hello everyone. I'm new to the forum. I have a problem with the encoder and PID. We need to turn an encoder controlled rollover. I am using...
Replies
1
Views
1,399
Hello. I am working on a double sided labeling machine where is two parallel conveyors ,the bottles flows between them . The lower conveyor is...
Replies
0
Views
1,327
Back
Top Bottom