The SOGI-FLL (second-order generalized-integrator frequency-locked-loop) is a well-known and simple adaptive filter that allows estimation of the parameters of the grid voltage with a small computational burden. However, this structure has shown to be sensitive to the events of voltage sags and swell faults, especially to voltage sags that deeply distort the estimated frequency. In this paper an algorithm is proposed to face the fault that modifies the SOGI-FLLs gains in order to achieve a better transient response with a reduced perturbation in the estimated frequency. The algorithm uses the SOGI’s instantaneous and absolute error to detect the fault and change the SOGI-FLL gains during the fault. Moreover, the average of the absolute error is used for returning to normal operating conditions. The average value is obtained by means of a single low pass filter (LPF). The approach is easy to implement and represents a low computational burden for being implemented into a digital processor. The performance is evaluated by using simulations and real-time Typhoon Hardware in the Loop (HIL) results.