As more and more photovoltaic grid-connected power generation systems are connected to the grid, the power quality of the grid is getting more and more attention. For photovoltaic grid-connected power generation systems to achieve reliable grid connection without current impact, the filtered inverter output voltage must be consistent with the amplitude, phase, and frequency of the grid voltage. Otherwise, the grid harmonics will increase, the power quality will decrease, and the Grid-connected and circulating current may even cause damage to the photovoltaic power generation system. Therefore, phase lock control must be carried out in the process of grid connection to meet the requirements of grid connection. According to IEEE Std1547-2003, the maximum phase error is 20°, the instantaneous voltage error cannot exceed 10% of the grid voltage, and the maximum frequency error cannot exceed 0.3Hz.

**⑴Phase-locked loop principle**The phase-locked loop PLL (Phase-Locked Loop) is a phase tracking system. The basic characteristic of the phase-locked loop is to use the external input reference signal to control the frequency and phase of the oscillation signal inside the loop. Because the phase-locked loop can automatically track the frequency of the output signal to the frequency of the input signal, the phase-locked loop is usually used in a closed-loop tracking circuit. When the phase-locked loop is working, when the output signal frequency is equal to the input signal frequency, the output voltage and the input voltage maintain a fixed phase difference, that is, the phase of the output voltage and the input voltage are locked, which is the name of the phase-locked loop origin.

The basic structure of a typical phase-locked loop is shown in Figure 1. It consists of three parts: a phase detector PD (Phase Detector), a loop filter LF (Loop Filter) and a voltage-controlled oscillator VCO (Voltage-Controlled Oscillator). The phase detector in the phase-locked loop is also called the phase comparator. Its function is to detect the phase difference between the input signal and the output signal, and convert the detected phase difference signal into a VD voltage signal for output. The signal is low-pass filtered. The control voltage vC of the voltage-controlled oscillator is formed, and the frequency of the output signal of the oscillator is controlled. There are various forms of loops in practical applications, but they all evolved from this basic loop. The phase-locked loop is essentially a feedback control system, which is different from the conventional control system in that the conventional control system collects the voltage or current signal converted by the sensor or directly collected from the system, while the phase-locked loop collects the phase Signal.

The reference signal is equation (1), where VIm is the amplitude of the input voltage, ωi is the angular frequency of the input voltage, and φi is the initial phase angle. The output signal of the voltage-controlled oscillator is equation (2), Vom is the amplitude of the output voltage, and φo is the initial phase angle. It is assumed that the output voltage and the input voltage have the same angular frequency.

νi = Vimsin(ωi+φi(t)) (1)

νο= Vomcos(ωi+φο(t)) (2)

Assuming that the phase detector is an ideal analog multiplier, then

νD=VimVom{sin[2ωit＋φi(t)＋φο(t)]＋sin[φi(t)﹣φο(t)]}/2 (3)

The loop low-pass filter is a linear low-pass filter that filters out the high-frequency components in the output error voltage of the phase detector, and plays a filtering and smoothing effect to ensure the stability of the loop and improve the loop tracking performance and phase noise characteristics. It is a very important role and has an important impact on various performance indicators of the loop. Analog loop filters are divided into passive filters and active filters. Commonly used loop filters include RC integral filters, passive proportional integral filters and active proportional integral filters, as shown in Figure 2 ( a), (b), (c).

After filtering by the loop filter, the component containing 2 times the input frequency in the formula (3) is filtered out, and the formula (4) can be obtained.

νc = VimVom sin(φi(t)﹣φο(t))/2 = VimVom sin(φe(t)/2 (4)

The voltage-controlled oscillator is the link that converts the voltage into the phase, and its oscillation frequency changes linearly with the control voltage νc, as shown in equation (5).

ω(t)=ωo + Kvcoνc(t) (5)

The voltage-controlled oscillator integrates the frequency error signal so that the output signal follows the phase of the input signal to achieve the purpose of phase lock. The mathematical expression of the voltage-controlled oscillator is equation (6). The voltage-controlled oscillator is the inherent integral link in the phase-locked loop and plays a very important role in the loop.

φo(t)=Kvcoνc(t)/s (6)

Phase-locked loops can be divided into four categories according to different implementation methods: analog phase-locked loops, digital-analog hybrid phase-locked loops, all-digital circuit phase-locked loops and digital phase-locked loops.

①Analog phase-locked loop: All are realized by analog circuits. The analog multiplier is used as the phase detector, the analog loop filter is used for filtering, and the voltage-controlled oscillator is used for frequency output. The main disadvantage of analog phase-locked loop is that the voltage-controlled oscillator has nonlinearity, the operational amplifiers and transistors in the loop are prone to saturation, there is zero drift of operational amplifiers and phase detectors, and the temperature drift and aging of circuit components affect the phase-locked loop. Performance also has a certain impact.

②Digital-analog hybrid phase-locked loop: The phase detector adopts XOR gate and JK trigger digital logic circuit, while other modules are composed of analog circuits. The digital-analog hybrid phase-locked loop can achieve very high operating frequency and control accuracy. Its main disadvantage is that its center frequency is affected by the parasitic capacitance on the chip where it is located, and the range of variation is large. In strict applications, the center frequency must be adjusted. It has the shortcomings of analog phase-locked loop.

③All-digital circuit phase-locked loop: With the rapid development of digital circuits, an all-digital phase-locked loop has appeared. It does not include any passive components, such as resistors and capacitors, and has all the significant advantages unique to digital systems, that is, the circuit is completely digitized, and the use of logic gate circuits and flip-flop circuits reduces the possibility of interference from the outside world and power supply. The circuit is easy to integrate, and it is easy to make an integrated single-chip all-digital phase-locked loop circuit, and the reliability of the system is greatly improved. In addition, the all-digital phase-locked loop can also slow down or eliminate the effects of the nonlinearity of the voltage-controlled oscillator in the analog phase-locked loop, device saturation, and zero drift of the operational amplifier and phase detector on the loop performance. The disadvantage is that the realization of its hardware is limited by the logic speed of digital integrated circuits, and the all-digital circuit phase-locked loop is not widely used. At present, most of the phase-locked loops used in high-performance applications are digital-analog hybrid phase-locked loops.

④Digital phase-locked loop: also known as software phase-locked loop. With the rapid development of single-chip and DSP digital signal processors, their processing capabilities are getting stronger and stronger. Generally, the system no longer uses special hardware to realize the phase-locked loop, but software programs complete the sampling of the input signal and the phase-locked loop algorithm. . It can overcome some difficult hardware problems, such as DC zero drift, device saturation, and must initialize calibration. Its characteristics are higher intelligence, better performance, flexible control, convenient device upgrades, and even the control algorithm can be modified online without changing the hardware circuit. Therefore, the use of chips with high-speed data processing capabilities and simple analog circuits to study reliable digital phase-locked loop methods to solve the grid voltage phase-locking and frequency tracking problems in grid-connected systems is one of the current research hotspots.

**⑵Digital phase-locked loop design**So far, many literature studies have discussed digital phase-locked loop algorithms. Digital phase-locked loop algorithms with greater influence can be divided into three categories: PLL algorithms based on zero-crossing detection, PLL algorithms based on coordinate transformation, and PLL algorithms based on coordinate transformation. PLL algorithm of instantaneous power theory.

**⑶ PLL algorithm based on instantaneous power theory**The PLL algorithm based on instantaneous power theory is suitable for three-phase systems and single-phase systems.