Stephen,
Regarding your first code posting
Code:
static long lec = 0; //lec = encoder count
Did someone explain that if you initialize "lec" every time this function is called, it will always be zerod? You could get rid of the 'lec = 0'...that way it would always remember the last value (which is what you were trying to do).
If you already figured this out or I missed this in the above response...just ignore what I said. :-)
Regards,
ChuckB