An optical encoder provided with an origin detecting unit, comprising: a scale having an optical grating portion provided with an optically discontinuous portion; light receiving means for receiving a light beam reflected from the scale, arranged to include a plurality of units of light receiving elements, each of the units of the light receiving elements having the same number of light receiving elements (14a-14d) and having a length that corresponds to a length of a light-and-shade cycle of the scale that is formed on the light receiving means when said light beam is reflected by the scale and incident on the light receiving means, the light receiving means being provided in association with a pitch of the optical grating, movable relative to the scale and configured to provide an output signal (Fig. 4: A) indicative of a received light amount; and calculation means arranged to detect a change of the output signal from the light receiving means that occurs when said light beam illuminates the discontinuous portion of the scale, is reflected thereon and is incident on the light receiving means, to perform calculation based on the change and to detect an original scale position based on the result of the calculation; characterized in that said calculation means is adapted to obtain a middle voltage signal (Figs. 6, 11, 14) from said output signal by calculating, every time when the scale moves by one pitch, middle voltages from maximum values (Amax) and minimum values (Amin) of said output signal, to obtain a difference signal (Figs. 7, 12, 15) from the middle voltage signal based on middle voltages having a predetermined interval therebetween which is determined based on a number of units of the light receiving elements in the light receiving means and a size of the discontinuous portion of the scale, and to set the original scale position as a position at which the value of the difference signal falls within a target range (LV1, LV2). a scale having an optical grating portion provided with an optically discontinuous portion; light receiving means for receiving a light beam reflected from the scale, arranged to include a plurality of units of light receiving elements, each of the units of the light receiving elements having the same number of light receiving elements (14a-14d) and having a length that corresponds to a length of a light-and-shade cycle of the scale that is formed on the light receiving means when said light beam is reflected by the scale and incident on the light receiving means, the light receiving means being provided in association with a pitch of the optical grating, movable relative to the scale and configured to provide an output signal (Fig. 4: A) indicative of a received light amount; and calculation means arranged to detect a change of the output signal from the light receiving means that occurs when said light beam illuminates the discontinuous portion of the scale, is reflected thereon and is incident on the light receiving means, to perform calculation based on the change and to detect an original scale position based on the result of the calculation; characterized in that said calculation means is adapted to obtain a middle voltage signal (Figs. 6, 11, 14) from said output signal by calculating, every time when the scale moves by one pitch, middle voltages from maximum values (Amax) and minimum values (Amin) of said output signal, to obtain a difference signal (Figs. 7, 12, 15) from the middle voltage signal based on middle voltages having a predetermined interval therebetween which is determined based on a number of units of the light receiving elements in the light receiving means and a size of the discontinuous portion of the scale, and to set the original scale position as a position at which the value of the difference signal falls within a target range (LV1, LV2). to obtain a middle voltage signal (Figs. 6, 11, 14) from said output signal by calculating, every time when the scale moves by one pitch, middle voltages from maximum values (Amax) and minimum values (Amin) of said output signal, to obtain a difference signal (Figs. 7, 12, 15) from the middle voltage signal based on middle voltages having a predetermined interval therebetween which is determined based on a number of units of the light receiving elements in the light receiving means and a size of the discontinuous portion of the scale, and to set the original scale position as a position at which the value of the difference signal falls within a target range (LV1, LV2).