You could use "INTERRUPT ON CHANGE" which uses portB.4 to portB.7. You could connect Chan A of X axes to portB.4 and chan B of same axes to portB.5 while axes Y will use portB.6 and portB.7 in the same way.
In the interrupt routine you will increment a variable for X axes and one for Y axes. using the timer0 or timer1 overflow you will read the variable and extract the speed, once you have done that you will zero both variable for the next reading.
Since you will count both channels you will be able to detect also the direction setting a direction flag in function of the channel sequence.
As far as interrupt on change, is concerned you could take advantages from Darrel Taylor instant interrupt routine, simple to use and very relaible indeed.
Al.
All progress began with an idea
Bookmarks