if you need live speed a simple way to do it is like this:
Code:
int time;
int gearteeth;
int speed;
if(time<38)
{
gearteeth+=// put code in for gear tooth counter
time++;
}
else
{
speed = time;
time=0;
}
this will give you the amount of gear teeths over the given time since the default routine runs at roughly 38Hz that should give you a number fairly close to gear teeth count /sec