Handling encoder signal, compensation for light variation, stray light