A rotary optical encoder is described to provide the pole position of the rotor in a permanently magnetized motor. Using a simple opening design of code tracks and two light sensors along with a corresponding processing circuit, only one additional code track is required on the code wheel to output phase-changing signals. Thus the rotary optical encoder with phase-changing signal with low cost and small size is implemented.