SLC 5/05 HSCE Encoder Roll Over

I have a SLC 5/05 controller with a high speed counter encoder module 1746-HSCE installed. I have to track the leading edge of a unit on a
convyor over a large distance with high resolution. This means that the encoder eventually rolls over before I done tracking.

I have a few ideas about how to do this but Im not sure they are the most effecient and accurate methods. One is simply to increment a
counter every time the encoder counts X many pulses which equal an inch. The problem with that is the resolution sucks.

John Paley--Graphic Pkg Corp

There's another way. Try and "sense" the rollover. Every so often, depending on the rate of the counts, examine and store the accumulated
count in an integer address. The next sample, compare the previous accumulated count to the current one, then store the current count in the
same address for the next comparison. If at any sample, the current count is less than the stored, the counter has rolled over--increment a
rollover counter by one. (If I remember correctly, the counter rolls from 32767 to
-32768--or configurable to roll to zero--If it never goes minus, the math is easier.) Now, if rolling to zero, in a cpt instruction, with a
float address as a target, add the current acc count to (the number of rollovers times 32768). Now you have a total of all counts, rollovers
and all. If the counter rolls to -32768, it's a little different to deal with because it counts from -32768 toward zero first. In the cpt
instruction, you have to add 32768 to every sample to totalize correctly--and multiply by 65536.

From the something you might want to know dept--The accumulated count reported to the processor from the HSCE module is latent. That is, not
timely. For some reason, AB decided that it wasn't a high priority function. Bottom line is that the acc total you read from the processor
input image table can be as much as 35mS behind the actual count in the HSCE. If counts are rapid, this can cause great pain. Be careful!
Here's one way of doing it
Using two variables, a lower res count and a hi-res count, then use together to get distance and hi resolution count eg:
var1 = 18
var2 = 500
= 18.5 meters

set HSCE in to ring mode, on a count that adds up to some real measurement (eg 1 meter)
setup an HSCE output to inc a counter every revolution(var1)

then use the HSCE acc as the hi res count (Var2)
this one will loop around in ring mode

Then use ladder logic to check the 2 variables in series ie: EQU & GEQ

It will suffer from some scan time lag of the HSCE ACC count in a high speed application though.