Voltage sags are one of the most important power quality problems in electrical systems. Dynamic voltage restorer (DVR) is known as the most common custom power device to compensate these power quality problems. DVR is an electronic based device in series to system, and the detection of voltage sags plays an important role for these devices. In electrical grids, different methods are used to detect voltage sags for DVR structures. These problems must be compensated fast and accurately. In this study, second order generalized integrator phase locked loop (SOGI-PLL) is improved to obtain voltage magnitude in addition to phase information in conventional SOGI-PLL. In this paper, the design of a novel controller design is proposed by using voltage magnitude and phase information through improved SOGI-PLL. Balanced/unbalanced voltage sags are compensated by using phase and voltage magnitude information obtained with improved SOGI-PLL in DVR. The simulation results of improved SOGI-PLL based controller are presented through PSCAD/EMDTC program. Proposed detection method shows fast and effective results for compensation of voltage disturbances.