This work aims to investigate a problem with power quality and the exclusion of harmonics in the power system using a method called frequency estimation. This study aims to explore the performance of several strategies for estimating phase and frequency under a variety of less-than-ideal situations, such as voltage imbalance, harmonics, dc-offset, and so on. When the grid signals are characterized by dc-offset, it has been shown that most of the approaches are incapable of calculating the frequency of the grid signals. This article introduces a frequency estimation method known as Modified Dual Second Order Generalized Integrator (MDSOGI). This method accurately guesses the frequency under all of the unideal scenarios. Experiments have shown that the findings are accurate. In order to build a control scheme for a shunt active power filter that is able to function under such circumstances, the scheme is further integrated with the theory of instantaneous reactive power. In order to demonstrate enhanced performance, the experimental prototype is being created.