Hi,
Whenever you trigger a capture input pin it loads the value of Timer1 to the capture registers. So for your application you need to track Timer1 get difference values and do the calculation there after. Why not use an interrupt to increment a counter. Use an asm interrupt or if you are not so conversant with asm hunt for Darrel Taylor's instant interrupt thread. It lets processing the interrupts in basic with a little bit more code overhead. As for the distance measurement you can have some additional circuitry to get the direction of the rotation and use another pin to increment the counter. Albeit this can be done in software itself but may be complex with lots of noise on the encoder signals.
Regards
Sougata
Bookmarks