The PLL calculates the frequency of the grid voltage by synchronizing the internal phase angle with measured voltage phasor. q-component of internal voltage phasor is therefore controlled to be zero.
Following relationship is used to calculate internal voltage phasor q-component:
uqPu = uiPu * cos(phi) - urPu * sin(phi);
If uqPu is zero, the internal phasor is locked with the measured phasor and rotates with the same frequency.