Latching quadrature encoder count with trigger input


We have an application requiring width measurement of an object moving on a conveyor system. The system is outfitted with an encoder and a photodector. The width measurement is simply the encoder count when the object passes the beam minus the encoder count when the object first breaks the beam.

The GRV-IDCIFQ-12 module appears to be the part we would want to use for interfacing the quadrature encoder to including index. Is there a way to configure one of the digital inputs to latch the encoder counts to a register on the falling and rising edge of the beam presence? Effectively, there would be a latched encoder count when the beam breaks and a second latched encoder count when the beam is restored.

We’re concerned with latencies introduced by reading the encoder count directly with PAC Control. There is ample time between object measurements so two latched count registers would be sufficient.
Thank you!

You can do this in your code. You would need to use either the scheduler subroutine if you are using PAC Control, or event driven task if you are looking to use Codesys. These will provide you with a way to interrupt and jump directly to the routine to capture the encoder counts on the rising or falling edge of a digital input.

Hi Garrick,

I’m new to the PAC Control environment, I did look at the scheduler subroutine. If I’m understanding the logic properly, the scheduler still needs to poll for the trigger and delay to allow other tasks to run introducing latency. Is that correct?