The proper operation of single-phase and three-phase grid-connected power converters depends on the synchronization with utility networks. The major challenge of the synchronization is how to quickly and precisely extract the ac signal and fundamental positive sequence in single- and three-phase power systems, respectively. This paper proposes a new detection technique based on a modified Kalman filter and the generalized averaging method. The method has an open-loop structure, and uses the orthogonal signals which are obtained directly from the Kalman filter. The resulted detection system is very simple and robust even in the presence of power quality disturbances, such as voltage imbalance, harmonics, and voltage fluctuations. The proposed technique can detect the fundamental and harmonics frequencies within or less than half a cycle in all situations, such as small and considerable frequency variations. Meanwhile, the method guarantees the zero steady-state error in complicated harmonic scenarios, including all typical single-phase and three-phase harmonics. Various case studies are assessed and the performance of the proposed detection method is verified by experiments.