Tested encoder reading algorithm