Power quality is one of the major concerns in the present era. The problem of voltage sags and swells and its major impact on sensitive loads are well known. To solve this problem, custom power devices are used. One of those devices is the Dynamic Voltage Restorer (DVR), which is one of the most efficient and effective modern custom power devices used in power distribution networks. A new control algorithm for the DVR is proposed in this paper to regulate the load terminal voltage during sag, swell in the voltage at the point of common coupling (PCC). This new control algorithm is based on synchronous reference frame theory (SRF) along with PI controller is used for the generation of reference voltages for a dynamic voltage restorer (DVR). These voltages, when injected in series with a distribution feeder by a voltage source inverter (VSI) with PWM control, can regulate the voltage at the load terminals against any power quality problem in the source side. It first analyzes the power circuit of the system in order to come up with appropriate control limitations and control targets for the compensation voltage control through the DVR.