Dealing with encoder rollover

capsuleguy

Member
Join Date
Sep 2019
Location
High Point
Posts
10
I have a single turn encoder controlling my motion project. It is controlling the speed of an elastic web. I have a sensor looking at marks on the web that triggers and captures the current encoder position. The encoder is configured to rollover so the capture will be between 1 and 262244 counts.
The sensor is triggered again and captures the encoder position approximately one revolution later. I subtract the second capture from the first and determine a position error that is used to change the servo ratio. It all works great unless the two captures are when the encoder rolls over.

For instance working correctly with a 20 count error: capture 1= 242240 and capture 2= 242260. Then 242240-242260=-20 error.

But if capture 1=262140 (then encoder rolls over)and capture 2= 16 then 262140-16= 262124 error when it should be -20 as well.

What is the best way for me to deal with this rollover situation?
 
First, determine the max count before it rolls over, and does it roll over to 0 or 1?

Do a compare of the first reading being close to the rollover count, then do a compare if the second reading to 1, and if it is determined to have rolled over MOV the reading to an integer, then ADD the max count above to that integer, and use your new integer instead of reading 2.
 
It partly depends on your platform and preferences. It also depends on what you expect the maximum magnitude of your delta to be.

If you can say that the delta will never be more than half an encoder revolution then any delta that is greater than 131122 must indicate that a rollover occurred. In that case, add 262244 to the delta to get the correct delta.

There is another way to do this if the plc handles integer rollovers correctly. If you bit shift the values left 14 bits to align the number with the 32-bit double word boundary, perform the delta, then shift the result back right 14 bits you will get the correct delta also.

Keith
 
Thanks for the ideas. I think we will move forward with your suggestions. I was hoping there was some magical rollover instruction that I didn't know about.
 
I made a mistake in my original post. If the delta is greater than half the rollover value, you need to SUBTRACT the rollover value from the calculated delta. Sorry for the confusion.

Keith
 

Similar Topics

Hello, I am attempting to tune a PID loop on a process. The process involves a valve with electronic actuator that has quite a high deadband...
Replies
10
Views
2,177
Good Morning , We had to change out a L61 with a L71 processor and it seems like our motion control is not the same . Have any of you run...
Replies
2
Views
1,833
I'm working myself into a bit of a lather. I'm in need of some assistance with programming an 'Hour Meter' in Codesys V3. I'm using a Wago...
Replies
5
Views
3,822
I have a washer/dryer machine coming from Europe which use 400v/50hz/177A. The machines has some heavy blower/vacumm motors that run on 400v, and...
Replies
23
Views
6,606
Hi to all. I have just graduated from college last May and now have a job in a large chemical plant. We are changing some electronic equipment out...
Replies
22
Views
6,351
Back
Top Bottom