Electric motors are important in many fields such as industrial automation, electric vehicles, and other advanced devices. The increasing popularity of applications related to electric motors, especially in the transition from depleting non-reusable energy sources to electric power, has raised a demand for research and development in motor control. In operation mode, the sensor fault can affect the safety of users. Therefore, this paper presents an operation that considers two modes. Firstly, the motor is controlled using a field-oriented control strategy with an absolute encoder. Second, assuming a sensor fault occurs during operation, fault detection and switching commands are used to change the signal source. The key contribution of this work lies in the design of an effective observer and fault detection algorithm, which accurately estimates the motor's state variables and identifies sensor faults in real-time. By seamlessly transitioning between the two control modes, the proposed approach guarantees the continued operation of the PMSM drive system even under sensor failure conditions. The feasibility of the algorithm is validated through MATLAB/Simulink simulation environment.