in an optical encoder , a plurality of light sources is controlled on and off so as to use light rays to irradiate an optical grating of a scale from a plurality of different directions . the light rays are received by a plurality of photoreceptor elements . operations are performed using signals output from the photoreceptor elements . accordingly , the relative position between the photoreceptor elements and the scale is detected precisely .