Nigel, With the routine I gave you it decodes all 4 states of the encoder so what has to be done is a divide by 2 on the final variable. This can be accomplished by a shift statement ">> 1".

Dave Purola,
N8NTA