How to program RIO chip for capture counter in begin/end register?

[FONT=“Courier New”]Hello,

I want to know if it’s possible to program the RIO chip for quadrature decoding and capturing the counter value on begin and end event of an other pin for the same block?

Using the counter as free running, when the photo-detector event rise on PIN 2, I want to capture the counter value to the begin register and when the event fall, capture the counter value to the end register. Using interrupt on PIN 2, I can catch the photo-detector event and read the begin/end register with all precision. Is it possible?

Encoder -------- RIO PIN
A -------------> 0 (in-phase)
B -------------> 1 (quadrature)

Photo-detector
OUT -----------> 2 (event)

Thank you!

[/font]

The logic of the RIO block does not allow begin / end capture to be mixed with quadrature decoding. This is because Increment and Begin are tied to the same event logic. So is Decrement and End. This means you can’t mix Begin and End capture with any counter function that depends on external signals for incrementing or decrementing the counter. You could mix an external up only pulse counter with an End event, but quadrature is up/down. The capture function is really designed to work with an internal clock driven counter.

You could use a second RIO block to interrupt the processor on an external signal and accomplish this in an interrupt routine that reads the quadrature counter value on the interrupt. You could easily setup separate interrupts for the rising and falling edges of that signal which could accomplish what you explained, but it would have some possible interrupt latentcy. The only other signal that mixes directly with a quadrature decoder is an index signal, which can be setup to reset the quadrature count when detected.

Hi,

Thank you for your answer. I will measure this latency today.

Jean-Yves