Embodiment 1. A grid-connected control method based on a virtual synchronous generator. Combine below Figure 1 to Figure 6 The method provided in this embodiment is described in detail.
 see Figure 1 to Figure 6 , S1, using the instantaneous power calculation method to calculate the active power and reactive power according to the collected instantaneous values of the inverter output voltage and current.
 S2, using the VSG control algorithm to calculate the active power and reactive power to obtain a reference signal of the inverter output voltage.
 Specifically, as image 3 As shown, the virtual synchronous machine control algorithm draws on the second-order classical equation of the synchronous generator and the governor and excitation controller, so the VSG control algorithm is designed, and its mathematical equations are shown in formulas (1) to (3):
 Among them, T set , T e For the given torque and electromagnetic torque; P set , Q set For active and reactive power given; D p , D q is the active-frequency and reactive-voltage droop coefficients; θ is the electrical angle; Δω is the electrical angular velocity difference, Δω=ω n -ω;ω n , ω is the rated electrical angular velocity and the actual electrical angular velocity; Δu is the output voltage difference, Δu=u n -u o;u n , u o is the rms value of the rated voltage and the rms value of the output voltage; J is the moment of inertia; K is the inertia coefficient; among them, the instantaneous electromagnetic power P output by the synchronous inverter e and Q e It can be obtained from formula (4):
 where, u α , i α , u β , i β are the voltage and current u output by the inverter respectively ok , i ok It is obtained by abc-dq0 transformation.
 S3. The reference input signal is calculated by comparing the reference signal of the output voltage of the inverter with the voltage signal output by the synchronous impedance module, and the voltage signal is calculated by the synchronous impedance module according to the output current of the inverter.
 Specifically, the synchronous impedance module is specifically a synchronous impedance module based on a third-order generalized integrator, and more optimally, the synchronous impedance module is specifically based on a reduced-order resonator (ROR) and a third-order generalized integrator (TOGI) stage connected synchronous impedance module.
 like Figure 4 As shown, the synchronous impedance realization method based on the cascade of reduced-order resonator and third-order generalized integrator (ROR-TOGI) is based on the third-order generalized integrator-based quadrature signal generator (TOGI-OSG) capable of suppressing the input The influence of the DC component in the signal on the system is obtained by generating a two-phase quadrature signal with the same frequency and amplitude as the input fundamental component of the system.
 The closed-loop transfer function of TOGI is shown in formula (5):
 Among them, v(t), ω s are the input signal and the input frequency value respectively, and there are 3 output signals, which are v 1 (t), v 2 (t), v 3 (t), k is the closed-loop system gain.
 Assume that the input signal of TOGI contains a DC component A 0 , the AC signal whose amplitude is A, its expression is shown in formula (6):
 v(t)=A 0 +Asin(ωt) (6)
 From this, the TOGI steady-state outputs are respectively shown in formula (7):
 From this it can be seen that v 1 (t) Does not contain DC components and has the same frequency and amplitude as the AC components of the input signal; v 2 (t) contains a DC component and has the same amplitude as the input signal, with a phase lag of 90°; v 3 (t) with DC component only.
 In order to eliminate the DC component in the input signal and generate a quadrature AC output signal, the reconstructed v d (t)=v 1 (t), v q (t)=v 3 (t)-v 2 (t), where the value of k determines the dynamic response speed and harmonic suppression capability of the TOGI quadrature signal generator: the larger k is, the faster the dynamic response is, and the weaker the corresponding harmonic suppression capability; the smaller k is , the slower the dynamic response, the stronger the corresponding harmonic suppression ability.
 In order to avoid the influence of unbalanced components and take into account better dynamic response performance and harmonic suppression capability, a reduced order generalized integrator (ROGI) can be cascaded before TOGI to combine the positive and negative sequences of the same frequency. The components are separated, and the transfer function of the ROR regulator is shown in Equation (8):
 It can be seen from the above formula that the ROR regulator has frequency and polarity selectivity, and can directly separate the positive and negative sequences, complete the static tracking of the positive and negative sequence components of a specific frequency, and finally obtain the positive, negative sequence and harmonics of the input signal. weight.
 Based on the virtual impedance of the ROR-TOGI cascade, the output signal v through the d of TOGI d is a signal with the same amplitude and frequency as the fundamental component of the input signal, and its q output signal v q is with v d A signal with the same amplitude and a phase lag of 90 degrees, assuming that the expression for the two outputs is Equation (9):
 v d (t)=Asin(ωt)
 v q (t)=-Acos(ωt) (9)
 where A and ω are the amplitude and frequency of the input signal, respectively.
 taking into account v d expression, its virtual inductance value is:
 It can be obtained from the formula, and its virtual inductance value can be obtained by v q Multiply by ω and the inductance value L v to achieve, namely:
 Z v =-ωL v v q (t) (11)
 Similarly, if the required virtual impedance is a resistor, it is also very easy to implement, and output the signal v through the d of TOGI d Multiply by a resistance value, the expression is as follows:
 Z v =R v v d (t) (12)
 It can be concluded that the calculation formula of complex virtual impedance is as follows:
 Z v =R v v d (t)-ωL v v q (t) (13)
 In the above formula, Rv is the virtual resistance, and Lv is the virtual inductance;
 S4. The quasi-proportional resonance controller calculates and obtains an output voltage signal according to the reference input signal, the voltage output by the inverter and the inductor current, and uses the voltage signal as the reference voltage signal of the PWM modulator.
 Specifically, the quasi-proportional resonance controller determines the frequency fluctuation bandwidth of the grid-connected control system of the virtual synchronous generator during stable operation by setting the resonance frequency point.
 The quasi-proportional resonant controller is used to suppress the unbalance and harmonic components of the output voltage of the synchronous inverter. The quasi-PR controller can effectively suppress harmonics with high gain at the resonant frequency point, that is, when the grid frequency is offset. The transfer function of the quasi-proportional resonant (PR) controller is given by equation (14):
 Among them, K p is the proportional coefficient; K r is the resonance coefficient; ω o is the resonant frequency; where ω c is related to the bandwidth of the resonant frequency, ω c =π·Δf; Δf is the allowable fluctuation range of the grid frequency.
 S5. The PWM modulator obtains the inverter modulation signal according to the reference voltage signal of the PWM modulator, and outputs it to the inverter.
 More preferably, a quasi-synchronized parallel control algorithm based on a phase-locked loop of a reduced-order resonator is used to detect and control the pressure difference and to detect and control the frequency difference. The reduced-order resonator phase-locked loop specifically includes a Clack transformation matrix, a positive-negative sequence reduced-order resonant regulator, and a PLL phase-locked loop.
 like Figure 5As shown in the figure, based on the quasi-synchronous parallel control algorithm of the phase-locked loop of the reduced-order resonator, and referring to the working principle of the quasi-synchronous parallel device of the synchronous generator, the automatic quasi-synchronous device of the synchronous inverter is designed, which includes three steps: differential pressure detection And control, frequency difference detection and control, phase angle difference detection and control and parallel closing control, the control principle is shown in formula (15):
 In the above formula: Δu syn , Δω syn , Δθ syn respectively superimposed on u o , ω o and θ o Amplitude, frequency and phase angle synchronization signal on ; k mp , k mi are proportional and integral coefficients (m=u, ω, θ).
 Since the virtual synchronous generator technology has the drooping characteristics of the synchronous generator, its output frequency and voltage amplitude change with the change of the active and reactive power of the load.
 like Image 6 As shown, the phase-locked loop based on the reduced-order resonant regulator is mainly composed of three parts: the Clack transformation matrix, the positive and negative sequence ROR regulator and the PLL phase-locked loop. First, the three-phase voltage is transformed from the three-phase abc static coordinate system to the two-phase αβ static coordinate system, and then the U α , U β As a given command, make a difference with the output value of the ROR regulator, and use the error amount as the input of the ROR regulator to form a closed-loop feedback. Finally, the ROR regulator completes no static error tracking and outputs positive and negative sequence voltage components. where ω of the ROR regulator o It is obtained by the traditional phase-locked loop SRF-PLL in the two-phase synchronous rotating coordinate system, and the adaptive detection is realized.
 Grid voltage u measured by ROR-PLL g information, compare it with the synchronous inverter output voltage u o Compare the information to determine whether the absolute value of the pressure difference and frequency difference is less than the allowable error, and the allowable error of pressure difference ε u =5%u g , the allowable range of frequency difference is ε ω =0.3%ω g; If it is not satisfied, increase (decrease) ΔQ and ΔP through the pre-synchronization regulator to continue voltage regulation and frequency regulation until the allowable error is satisfied.
 Specifically, using the quasi-synchronized parallel control algorithm based on the reduced-order resonator phase-locked loop to detect the voltage difference includes: g and the inverter output voltage u o Compare and judge whether the absolute value of the voltage difference is less than the voltage allowable error, the pressure difference allowable error ε u =5%u g; If the voltage difference signal is not satisfied, increase or decrease the reactive power change value ΔQ through the pre-synchronization regulator to adjust the voltage until the voltage difference is less than the voltage allowable error.
 Using the quasi-synchronous parallel control algorithm based on the phase-locked loop of the reduced-order resonator to detect the frequency difference specifically includes: g and the frequency ω of the inverter output o Compare and judge whether the absolute value of the frequency difference is less than the allowable error of the frequency, and the allowable range of the frequency difference is ε ω =0.3%ω g; If it is not satisfied, increase or decrease the active power change value ΔP through the pre-synchronization regulator to adjust the voltage until the frequency difference is less than the frequency allowable error.
 When the inverter is connected to the grid, the phase angle difference is what really hurts the inverter, while the pressure difference and frequency difference have little influence, so the phase angle difference should be strictly controlled. If the phase lag between the inverter output voltage and the grid voltage, the output of the pre-synchronizing regulator is positive, which causes the output of the pre-synchronizing regulator to increase, the phase difference between the two voltages decreases, and the final phase difference is adjusted to zero . Considering the inherent action time of the closing circuit controller and the circuit breaker closing, the closing command should be issued at an angle before the two voltage phasors overlap, so as to ensure that the inverter is integrated into the system when the phase angle difference is the smallest. Usually we call this leading angle the leading angle.
 Specifically, when the inverter is connected to the grid, if the phase of the output voltage of the inverter lags behind the phase of the grid voltage, the output of the pre-synchronizing regulator is a positive value, resulting in an increase in the output of the pre-synchronizing regulator. The phase difference is reduced until the phase difference is zero; before the phase difference is zero, a closing command is issued with a preset leading angle in advance, and the inverter is merged into the power grid system, wherein the calculation formula of the leading angle is the formula (16):
 In the formula, ω d is the angular frequency difference; t dq is the lead time.