Online Parametric Estimation of Grid Impedance Under Unbalanced Grid Conditions

: Whereas power-electronics-based power systems are expected to enable more integration of renewable energy sources, they could pose crucial challenges including stability issues due to the Thévenin impedance seen by inverters. Such problems could be mitigated by enabling the inverters to estimate the grid impedance by including a grid impedance estimation technique into their control loop. However, one aspect which has been overlooked thus far is that the accuracy of such grid impedance estimation techniques is signiﬁcantly affected by various grid conditions. For instance, the unbalance in three-phase power systems causes unwanted oscillations at double the fundamental frequency in the inverters control loops. Therefore, this paper proposes a simple and reliable online estimation of the grid impedance under unbalanced conditions. The technique is based on wide-band impedance estimation incorporated into the control loop of the positive sequence of a three-phase grid-connected inverter equipped with a positive- and negative-sequence control (PNSC) strategy. Additionally, complex curve ﬁtting is utilized to obtain parametric models of the grid impedance. To demonstrate the efﬁcacy of the proposed grid impedance estimation technique, extensive case studies are performed. These include: (1) unbalanced operations of both resistive-inductive (RL) and resistive-inductive-capacitive (RLC) models of the grid, (2) background harmonics, and (3) asymmetrical impedances of the network.


Introduction
Potential stability issues [1,2] could be caused by a lack of grid impedance information in power-electronics-based power systems. Furthermore, there is a risk of negative impedance instability in converter-fed AC microgrids with high penetration of converter-interfaced loads because of strict power regulation [3]. The poor performance of the inverter-based distributed generation (DG) units due to variations of the grid impedance, especially the increase in the grid inductance, may also lead to unstable operation [4]. While the output impedance of inverters is determined by its design specifications [5], the major issue with the grid impedance is that it is a time-varying variable and it cannot be derived or measured directly at the the point of common coupling (PCC). Therefore, online estimation techniques should be adopted.
Recently, the online estimation of grid impedance by Photovoltaic (PV) inverters has become an appealing topic to many researchers for several reasons. Both active and passive grid impedance estimation techniques can be implemented into the control system of PV inverters [6]. This cost effective approach requires no extra hardware, such as a network impedance analyzer. The grid impedance information can be used to enhance the operation of grid-connected inverters, e.g., online stability analysis [7,8], voltage control [9], adaptive current controller [10], low voltage ride through [11], anti-islanding detection of grid-connected inverters [12][13][14][15], and analysis of multi-parallel inverters system [16][17][18].
A pseudo-random binary sequence (PRBS) has a spread-spectrum impedance estimation, and it has gained much interest as a nonparametric frequency response identification technique due to several advantages compared to other online wideband impedance estimation techniques implemented into the grid-connected inverters. It is a binary sequence with an optimal crest factor (equal to 1). It behaves as white noise, but it is generated easily using a deterministic algorithm. Moreover, it suits a practical implementation due to its small disturbance amplitude and immunity against background noise in the system [19,20]. Recently, the advantages of the PRBS have motivated researchers to adopt it for impedance estimation purpose while using power electronics converters [8,[21][22][23][24][25].
The implementation of the PRBS identification technique into 3-phase grid-connected inverters controlled in the synchronous reference frames (dq-axis) for grid impedance estimation purpose has been reported in several studies [8,[21][22][23]. The injection point of the PRBS in the control loop of the inverters differs between studies. For instance, it is injected into the carrier frequency of PWM [21], inner current controller references at dq-axis [22,23], and several locations (hybrid injection) simultaneously [8]. The second approach has the advantage of more control of the PRBS, and it provides more accurate results for a frequency range within the controller bandwidth. It is worth noting that all above studies on PRBS assumed balanced grid voltage conditions. Several control techniques of grid-connected inverters have been realized in the dq-axis due to its simplicity and the direct relation between dq-axis currents and the injected active and reactive power to the grid. Therefore, most of the previous studies used the PRBS estimation technique to obtain the grid impedance in the dq-axis, where a single control loop was deployed to control the dand qcomponents. However, the occurrence of an unbalanced grid voltage will produce an uncontrollable oscillation in the dq-axis at double the grid fundamental frequency [26]. In such a scenario, the grid impedance cannot be measured directly in the dq-axis unless indirect and more complicated techniques are utilized. Therefore, advanced control strategies should be adopted to ensure safe operation of the grid-connected inverters under unbalanced grid conditions [27]. Moreover, the implementation of the PRBS into the control loop of such advanced control strategies of grid-connected inverters for grid impedance estimation propose has not been reported in the literature.
Furthermore, background harmonics are usually presented in the grid voltage in the normal operation of low-voltage distribution network. The source of such harmonics are mainly nonlinear loads, power electronics converters, and variable-frequency drives [28]. Such harmonics may result in large estimation errors of the estimated grid impedance using grid-connected inverters. A common practice in overcoming this problem is to assume that the harmonic content in the grid voltage does not change in time. Therefore, pre-injection (unperturbed) measurements were subtracted from the captured (perturbed) measurements during signal injection (i.e., the PRBS) for the same window length [29,30]. However, if the background harmonics change during the estimation process (i.e., nonstationary harmonics and phase-shifted harmonics), the above procedure of subtraction of the unperturbed measurements from perturbed measurements will not be feasible. Hence, to consider more realistic scenarios for low-voltage distribution networks, more investigations are needed to explore the harmonics effects on the estimation accuracy based on the PRBS technique.
Although the grid impedance estimation based on the PRBS technique implemented in the dq-axis has been reported in the abovementioned works, all of them considered only inverters with single current loop. As a result, the overall estimation procedure of those approaches is either limited by the balanced operation of the network or need more complicated approaches to extract the impedance under unbalanced conditions, which tends to be impractical for online identification purposes. Therefore, it becomes necessary to explore online grid impedance estimation using grid-connected inverters in unbalanced low-voltage networks. Applications of the estimated impedance may include (1) online stability assessment based on generalised nyquist criteria to extend previous studies that considered the PRBS estimation technique only for balanced systems [7,[21][22][23] and (2) the use of the fundamental grid impedance to improve, for example, low-voltage ride-through capability of grid-connected inverters. In recent studies [11,31], it was shown that the fundamental grid impedance components (R g and L g ) are required to obtain optimal or suboptimal dq-axis current references of both the positive-and negative sequences' control loops. The work in the above studies assumed the information of the grid impedance is known and time-invariant, where this is not the case due to the dynamic properties of the power system, especially low-voltage distribution networks.
This paper proposes a robust and simple online wideband grid impedance estimation approach using the PRBS technique to include the operation of grid-connected inverters under unbalanced grid conditions. To do so, an advanced control strategy of grid-connected inverters called positive-and negative-sequence control (PNSC) strategy [32] is deployed. Further, its control loop is reconfigured to allow the PRBS injection on top of the d-axis current reference of the positive sequence. Finally, the impedance is estimated in the sequence domain based on the available voltage and current measurements at the PCC. Furthermore, complex curve fitting [33] is applied to obtain the parametric model of the grid impedance. The latter is important to overcome the challenge of frequency shift in the diagonal terms of the positive and negative sequences which are caused by the presence of the grid fundamental frequency [34]. This frequency shift causes substantial errors in the estimated fundamental grid impedance once it is performed in the sequence domain (or the natural reference frame (abc domain)). The proposed technique is summarized as follows: • estimates the parametric model of the grid impedance under both balanced and unbalanced systems. The estimation algorithm is implemented into the control loop of grid-connected inverter equipped with PNSC strategy; • takes into account both resistive-inductive (RL) and resistive-inductive-capacitive (RLC) models of the low-voltage distribution network; • considers asymmetrical line impedances of the distribution network; • assesses the estimation performance in the presence of background harmonics in the grid voltage; • evaluates the effects of the initialization parameters of the curve-fitting algorithm on the accuracy of the obtained parametric model. These parameters are the PRBS frequency resolution ( f res ), the number of selected data points (N), and the minimum frequency of selected data points to be fitted ( f min ).
The paper is organized as follows: Section 2 describes the system under consideration including the control structure of the PNSC strategy of grid-connected inverters. Section 3 elaborates on the methodology of wideband and complex curve fitting of the grid impedance estimation based on the PRBS. Section 4 presents selected simulation results. Finally, Section 5 concludes the paper.

System Description
The 3-phase 3-wire inverter system under investigation is described in Figure 1, and the system parameters are listed in Table 1. The grid-connected inverter is equipped with a DC power supply to emulate a PV array. The inverter is interfaced into the utility grid through a passively damped LCL filter with wye connected filter capacitors. Discrete-time control based on proportional-integral (PI) controllers is deployed to regulate the DC link voltage and the positive and negative sequences. All measurements (V abc , I abc , and V dc ) are passed to the discrete-time control system through zero-order holders (ZOH) to highlight the possible limitations of discrete-time implementation of the PRBS technique. Furthermore, inverter switches are controlled using gate signals generated by the sinusoidal pulse width modulation (SPWM) technique.
The utility grid is represented by an equivalent Thévenin model, with a line-to-line root-mean-square (RMS) voltage of 400 V. This model includes the grid voltage source V g and the equivalent grid impedance Z g . The work in this paper considers two different models of the Z g . In the first model, the Z g is represented as series RL model. However, the second model of the Z g considers the RLC model. It is represented by a series resistance and inductance (Z 1 = R g + sL g ) in parallel with a capacitance (Z 2 = 1/sC g ) [8].
( )  It is worth mentioning that only the RL model is shown in Figure 1. The equivalent transfer functions of the grid impedances for both the RL (Z g, RL (s)) and RLC (Z g, RLC (s)) models are given in Equations (1) and (2), respectively.
Z g, RLC (s) = Z 1 //Z 2 = R g + sL g 1 + R g C g s + L g C g s 2 (2) The PNSC strategy ensures safe operation of the inverter by injecting only positively balanced current to the grid in both cases of balanced and unbalanced grid voltage conditions. In this paper, the control scheme of the inverter is modified to allow online wideband grid impedance estimation. The operation of grid-connected under unbalanced grid voltage, symmetrical components extraction, and the inner current control loops of the PNSC strategy are highlighted in the following subsections.

Operation of Grid-Connected Inverters under Unbalanced Grid Voltage Equipped with PNSC Strategy
During the normal operation of the grid-connected inverters, only the positive components of the grid voltage will be present in the system. However, the negative sequence component will appear once the unbalanced grid voltage occurs. In this case, the inverter output apparent power (S), function of active power (P), and reactive power (Q) are given by Equation (3) based the instantaneous PCC voltage (v abc ) and the instantaneous inverter output current (i abc ). By neglecting the zero sequence due to the adopted 3-phase 3-wire system as shown in Figure 1, the inverter output apparent power is given in Equation (4) as a function of the dq-components of the positive voltage (v + dq ), the negative voltage (v − dq ), the positive current (i + dq ), and the negative current (i − dq ).
The instantaneous apparent power is further separated into active power P(t) and reactive power Q(t) by P(t) = P 0 + P c2 cos(2ωt) + P s2 sin(2ωt) (5) where P 0 and Q 0 are the average active and reactive injected by the inverter into the grid. It can be seen that the presence of the negative sequence caused by unbalanced occurrence resulted in oscillation at twice of the fundamental frequency 2ω in both the active (P s2 , P c2 ) and reactive power (Q s2 , Q c2 ). The power is given as a function to dq currents as follows [27]: For a grid-connected inverter equipped with the PNSC strategy implemented in the dq-axis, the current controller references can be obtained from Equation (8) based on the desired power (known values) to be injected to the grid by the inverter Equation (8) [35]: where, and K is included in Equations (8) and (9), which have three possible real values, [0, 1, or −1]. It is used to determine the control objective as follows: 1. K = 0: the inverter delivers a balanced current even under unbalanced voltage conditions. In this case, the negative current component references should be set to zero.

2.
K = 1: the inverter delivers active power free of oscillations.
It can be seen that the first step to realize the PNSC strategy in the dq-axis is to extract the positive and negative sequences of the measured voltage and current at the PCC. In the literature, two different approaches are distinguished. In the first approach [26,32], the measurements are directly locked to the dq-axis with ω s t and −ω s t. The second approach decomposes the measurements in the natural reference frame (abc domain) into their symmetrical sequences and then locks them to the dq-axis with ω s t and −ω s t. This task is achieved by a symmetrical component extractor. The first approach is simple but introduces oscillations in the dq-axis at 2ω s . Therefore, additional control approaches such as a notch filter and decoupling terms are reported to damp these oscillations. In contrast, the second approach will result in complete decoupling of the sequences in the dq-axis. However, the main drawback of the second approach is the introduced time delay that is required to decompose the sequences at the moment unbalance occurs. The authors of References [36,37] proposed fast techniques to extract the symmetrical components within one-fourth of the fundamental period, i.e., a 5-ms delay for a 50-Hz system. The second approach is used in our paper to extract the symmetrical components. Additionally, some modifications are applied, such as the implementation of a Synchronous Reference Frame Phase-locked loop (SRF-PLL).

Inner Current Control Loops of the PNSC Strategy
The PNSC is used to control the positive and negative sequences separately. Therefore, two control loops are used, namely a positive-sequence control loop and a negative-sequence control loop. Each control loop ensures that the inverter output current components follow their desired current references in the dq-axis. To enable the inverter to inject only balanced current, the dq-axis current references of the positive sequence (i + (8) and (9) by considering K = 0 (similar analysis can be explored for the other two cases for K = 1 and K = −1) and by setting Q re f = 0. In this case, both the dq-axis current references of the negative sequence (i − The dq-axis current references of the positive and negative control loops are given in Equations (10) and (11). Moreover, since there is no path for the zero sequence, it is not considered in the control loop.

Wideband Grid Impedance Estimation Under Unbalanced Grid Voltage
The methodology followed in this paper for the wideband estimation and parametric identification of grid impedance using a grid-connected inverter equipped with the PNSC strategy is presented as follows:

PRBS Disturbance Injection by the PNSC Strategy
The PRBS is a periodic wideband identification technique. Among PRBS signals, a maximum length binary sequence (MLBS) is the most commonly used due to the simple implementation using feedback shift registers [19]. The MLBS is used in our paper and it is implemented in MATLAB/Simulink based on a 10-bit generator using a unit delay. It has a frequency resolution F res = 1 Hz. Therefore, 1 s is the required time to inject one period of the PRBS to estimate the grid impedance. The PRBS parameters used are summarized in Table 2. To enable the inverter to estimate the grid impedance with an unbalanced grid voltage, the PNSC strategy is configured to allow the PRBS injection, as illustrated in Figure 1. The PRBS is added on top of the d-axis current reference of the positive sequence, calculated from Equation (10) based on the power reference generated by the outer voltage controller of the DC bus. To minimize its distortion effects on the inverter output waveforms and to obtain almost zero mean, the generated PRBS is scaled before it is added on top of the current reference [23].

Grid Impedance Estimation Based on PRBS Injection
Generally, the grid impedance estimation could be performed in different reference frames, namely dq domain, sequence domain, and/or abc domain. The first approach is preferred for balanced systems. For passive circuits, the d and q grid impedances are equal to each other. Therefore, it is sufficient for grid impedance estimation to measure d-impedance. However, the grid impedance estimation is no longer straightforward and it cannot be accurately identified due to the unbalanced conditions which, eventually, produces oscillations in the dq-axis signals at double the fundamental frequency. Hence, indirect and more complicated techniques could be used, such as the harmonic-transfer-function approach [38]. On the other hand, identifying the impedance in the sequence domain is simple and gives more reliable results under the unbalanced operation. The identification process is based on the analysis of the symmetrical components. Therefore, the second approach is implemented in this paper, where the online grid impedance estimation is performed in the sequence domain based on the voltage (v + abc ) and current ( i + abc ) measurements of the positive sequence. The grid impedance in the sequence domain (Z ± g ) is given based on Equation (12) [39].
where Z + g and Z − g are the positive and negative impedances. The equivalent grid impedance at the sequence domain is related to the adopted model of the grid impedance whether RL or RLC models are used, as shown below.
The RL model of the grid impedance is a common practice where the low-voltage distribution network is represented by an equivalent impedance consisting of R g and L g to simplify the study of the system. The equivalent grid impedance in the sequence domain (Z ± g, RL ) is expressed as follows: where ω s is the grid voltage angular frequency. For the RLC model presented in Equation (2), the equivalent grid impedance is expressed in sequence domain (Z ± g, RLC ) by where From Equations (13) and (14), it can be seen that the cross-coupling terms are always zero while the diagonal terms are equal to the grid impedance but with a frequency shift. Therefore, when estimating the grid impedance in the sequence domain, we expect to see a resonance peak at 50 Hz corresponding to the presence of ω s in the network. It is worth mentioning that the positive and negative impedances of the grid are identical (Z + g = Z − g ) for passive electrical components such as cables/lines, which are considered in this paper. Therefore, a straightforward approach to characterize the grid impedance is to apply what is called harmonic linearization [1] at every desired frequency (ω). Here, the impedance identification is performed based on the positive-sequence measurements (v + (ω), i + (ω)), as expressed in Equation (16).
Zg + (ω) = v + (ω)/i + (ω) (16) In this paper, the main steps to estimate the grid impedance followed by grid parametric identification are illustrated in Figure 2. The extracted symmetrical components of the inverter output current and the PCC voltage measurements are synchronized with the injected PRBS on top of i + d re f . The synchronization is done based on the phase angle of the positive sequence. Then, these measurements are filtered using a low-pass filter with a cut-off frequency of 5 kHz, half of the inverter switching frequency. Furthermore, the subtraction of fundamental frequency and other background harmonics in the system were applied to enhance the estimation accuracy. This was accomplished by subtracting the recorded voltage and current measurements before applying PRBS from the perturbed measurements with the PRBS for the same window [40]. Next, Discrete Fourier transform (DFT) is applied to both buffered current and voltage vectors measurements of any phase, here, phase A, independently. Finally, Equation (16) is applied to obtain the impedance frequency response of the Thévenin model of utility grid Z g over the desired frequency range.

Parametric Impedance Based on Complex Curve Fitting
It was shown in Equations (13) and (14) that it is not applicable to find accurate values of the grid impedance in the sequence domain at the fundamental frequency. Even though the approach of subtracting fundamental and its background harmonics in the pre-processing stage was followed, it was proved in References [29,30] that this procedure will not completely remove their effects on the impedance estimation results. Therefore, the curve-fitting approach is a useful solution that could be followed to construct the mathematical transfer function of the grid impedance from a chosen series of data points at different frequencies.
. The curve fitting for parametric grid impedance purpose was also adopted in References [8,39]. However, both studies have not considered the unbalanced operation of the power system. Besides, the implementation of the PNSC strategy for grid-connected inverters was not considered. Moreover, the authors of Reference [8] only deal with the RLC model of the grid impedance, where the complex curve-fitting technique was applied to dq impedances. Furthermore, it is not clear how the grid impedance components (R, L, and C) can be obtained from the fitted polynomial function. This paper utilizes the complex curve fitting in the sequence domain and abc domain. This enables a reliable, simple, and detailed parametric estimation of both RL and RLC models under both balanced and unbalanced grid conditions. The fitting technique relies on "the minimization of the weighted sum of the squares of the errors between the absolute magnitudes of the actual function and the polynomial ratio, taken at various values of frequency" according to Reference [33].

Synch measurments with PRBS injection
As shown in Figure 2, some initializations are required to use the complex curve-fitting algorithm. First is to define the used PRBS frequency resolution (F res ) and the frequency range of the data points to be fitted. The defined frequency range is between a minimum frequency ( f min ) and a maximum frequency ( f max ). The f max value should not exceed half of the inverter's switching frequency. Second is to select the number of the data points (N) to be processed for the curve fitting, where a small number could affect the accuracy of the estimated coefficients and a large number increases the computational burden. Table 3 shows the default setting values of F res , f min , and N that are being used for the Results section. It is worth mentioning that the setting value of F res should be the same as the injected PRBS. Moreover, detailed case studies of the trade-off between the abovementioned parameters and the accuracy of the obtained parametric impedance will be explored in the results; see Section 4.1.3. The third parameter required for the complex curve fitting is to define the chosen polynomial function for the curve fitting with respect to the equivalent grid impedance transfer functions in Equation (1) or Equation (2). For the RL model, the best candidate polynomial function for curve fitting (Z par g, RL (s)) is given in Equation (17).
where A 0 and A 1 are the transfer function coefficients that need to be identified. Then, the grid impedance components are obtained by comparing Equation (1) with Equation (17) as shown below.
Similarly, the parametric grid impedance of the RLC model (Z par g, RLC (s)) is obtained after curve fitting is applied. Unlike RL model, a second-order polynomial function is chosen here with respect to Equation (2) as shown in Equation (19) Z par g, RLC (s) = where A 0 , A 1 , B 1 , and B 2 are the transfer function coefficients that need to be estimated. Finally, the grid impedance components are obtained by comparing Equation (2) with Equation (19) as shown in Equation (20).

Results and Discussion
To verify the proposed grid impedance estimation technique for an unbalanced grid, extensive simulation case studies are carried out. Figure 1 shows the simulated 3-phase 3-wire inverter system. The simulation parameters of the system, the PRBS parameters, and the idealization values of the parametric impedance estimation algorithm are given in Tables 1-3, respectively. The simulation has been implemented in MATLAB/Simulink environment, where piecewise linear electrical circuit simulation (PLECS) toolbox components are used for accurate modeling of power electronics components. Furthermore, a discrete-time control and estimation model is used for the estimation results in order to consider real sample measurements and to highlight the limitations of implementing a grid impedance estimation technique using PRBS.
The presented results considering both the RL and RLC models of the equivalent grid impedance of the low-voltage distribution network seen at the PCC of the grid-connected inverter are presented as follows. Section 4.1 provides insight to the estimation performance of the RL model for several cases, namely (1) for balanced network, (2) for unbalanced grid voltage with/without background harmonics, (3) for effects of the initialization parameters of the parametric algorithm (F res , f min , and N) on the accuracy of parametric grid impedance estimation, and (4) for asymmetrical line impedances of the distribution network. Additionally, Section 4.2 explores the RLC model, where the system under unbalanced grid voltage and asymmetrical line impedances is considered.

RL Model of the Equivalent Impedance of Low-Voltage Distribution Network
The simulation are carried out for both balanced and unbalanced grid voltage conditions for a simulation time of 3 s (with an exception when the PRBS frequency resolution is studied). To estimate the grid impedance, an injection of two PRBS periods to the system is applied from the simulation time equal to 1 s, where each period has a duration of 1 s. Next, the grid impedance is estimated from the synchronous voltage and current measurements of the positive sequence during the injection of the second PRBS period, and measurements of the first period are neglected for better estimation results (to remove the PRBS transient). Moreover, to improve the estimation accuracy, the unperturbed measurements with the PRBS are subtracted from perpetrated measurements for the same window length of the PRBS period; here, it is equal to 1 s. Finally, curve fitting is applied to find the parametric model of the grid impedance.

Balanced Distribution Network
For the balanced grid voltage scenario, Figure 3a shows the nonparametric estimation results of the grid impedance up to half of the switching frequency, f sw = 10 kHz. It can be noticed that there is a peak at around 50 Hz as it is expected in Equation (12). Moreover, the estimation accuracy deteriorates beyond the PRBS generator's clock frequency, F gen = 1023 Hz, since PRBS signals provide very accurate identification results up to one-third of its F gen . Another constraint is f sw , where the estimation results is limited to half of f sw . Therefore, to obtain a continuous model of the grid impedance, complex curve fitting is applied based on the desired polynomial function to be fitted; see Equation (17). The estimated nonparametric impedance data points from DFT is forwarded as an input for the curve-fitting algorithm. The algorithm is provided with the initialization values presented in Table 3. The selection of certain data points (N = 500 samples) out of 20,000 samples is achieved within the defined frequency range. The selected data points for curve fitting are shown in Figure 3a. Finally, the obtained parametric impedance from curve fitting is given in Equation (21). Therefore, the grid resistance and inductance values can be obtained easily with the aid of Equation (18). To verify the accuracy of the results, the parametric estimation results are compared with the analytical (reference) impedance, Z g RL (s) = 0.5 + 0.5 × 10 −3 s, as shown in Figure 3b. The estimation errors in the grid impedance components are ∆R = −6.4%, ∆L = −1.67%.

Unbalanced Grid Voltage
The operation under unbalanced grid voltage conditions is investigated for two scenarios, without and with background harmonics in the grid voltage. Figure 4 shows the first scenario representing the unbalanced condition without background harmonics for a voltage sag with an amplitude of 50% V g in phase B. Figure 4b shows the inverter with the PNSC strategy injecting only a balanced current. It is found that the occurrence of an unbalance of 50% V g voltage sag in phase B increases the inverter output current from 7.3 A to around 8.83 A in order to maintain the output power equal to its reference of 5 kW. Limiting strategies of the inverter output current should be adopted to consider fault conditions. However, this is limited to 1.5 × I max since it is beyond the scope of this paper. Figure 4 also shows the PRBS injection effects on the PCC voltage, the inverter output current, the DC bus voltage, and the detected phase angle of the positive sequence. It is found that the PRBS injection causes an increase in the total harmonic distortion (THD%) of the inverter output current at the PCC by 3%. The THD is measured up to the 50th harmonics. Furthermore, the PRBS injection causes a slight ripple in the DC bus voltage, less than 1 V .   Unlike the first scenario, the second scenario examined the estimation accuracy of the grid impedance for unbalanced and polluted grid voltage source with harmonics. In this case, the processed voltage and current measurements for impedance identification contained the background harmonics. Figure 5a shows the simulated nonideal grid voltage source with unbalanced 50% V g voltage sag in phase B. It contains five different harmonics present with their maximum allowable amplitude according to the Australian harmonics standards [41]. The considered harmonics amplitudes are 5% for 3rd, 5th, and 7th; 1.5% for 9th; and 3.5% for 11th. The frequency harmonic spectrum of the equivalent Thévenin grid voltage at the PCC is shown in Figure 5b.  Figure 5.
Inverter operation under unbalanced grid voltage with background harmonics: (a) PCC voltage; (b) frequency harmonic spectrum of the grid voltage. Figure 6a,b presents the estimated grid impedance for the unbalanced case study (50% voltage sag in phase B) without background harmonics. Overall, the performance of the proposed technique successfully estimates the grid impedance. Also, Figure 6b compares the analytical solution with the fitted curve. It can be seen that the utilization of curve fitting for impedance estimation provides accurate results, as shown in Equation (22). The estimation errors in the grid impedance components are ∆R = 3.1%, ∆L = 5.5%. The above case studies of the obtained results of parametric grid impedance as a function of grid voltage conditions are summarized in Table 4. The first case represents the balanced grid voltage while the second and third cases represent unbalanced operation without background harmonics. In the second case, the applied voltage sag to phase B is 50%. Furthermore, an additional case study is considered, case 3. It represents a severe operation when a voltage sag of 50% was applied to both phase B and phase C. The severe estimation errors are larger for the third case, especially for the real part. On the other hand, Figure 6c,d show the estimated grid impedance case for a polluted grid voltage with background harmonics. Figure 6c shows the nonparametric impedance and the background harmonics which appear in the impedance spectrum at their corresponding frequencies. The parametric impedance shown in Figure 6d, is also given in Equation (23), where the estimation errors in the grid impedance components are ∆R = −0.8%, ∆L = 1.8%.
By comparing the parametric impedances given in Equations (22) and (23), it can be observed that more accurate estimation results are associated with the grid voltage with background harmonics. This finding could be explained from the working principle of the estimation technique. The PRBS energy/power spectral density (PSD) is distributed across a wide range of frequencies, as shown in Figure 7 for the PRBS used in this paper. Also, it can be seen that this energy is nearly zero at the PRBS generator's clock frequency (1023 Hz) and its multiple frequencies; the PRBS parameters are listed in Table 2. Furthermore, the presence of background harmonics acts as additional disturbances on top of the PRBS disturbance at their corresponding frequencies. Hence, the estimation results are improved slightly. Such improvements can be clearly noticed from the nonparametric impedances shown in Figure 6a,c. The interested reader is referred to [42] for more information on how the PRBS parameters affect the accuracy and the bandwidth of the estimated wideband grid impedance.  Table 2.

Effects of the Initialization Parameters of the Curve Fitting Algorithm
While the values of the initialization parameters for curve-fitting algorithm used in other parts of the paper are presented in Table 3, this section explores in details their effects on the estimation accuracy.
The parameters under consideration are f res , N and f min . Three case studies are investigated, in each case the other two parameters are kept constant to their values as presented in Table 3. Moreover, all the reported results in this subsection considered the unbalanced operation with the voltage sag of 50% in phase B. The PRBS frequency resolution is set to 1 Hz for all of these case studies: 1.
The PRBS frequency resolution ( f res ): it plays a vital role in the accuracy of the parametric identification of the grid impedance. Figure 8a shows the parametric results for three different values of f res , namely f res = 1 Hz, 5 Hz, and 10 Hz. Findings proved that more accurate results are obtained for smaller values of f res . It is a trade-off between the estimation accuracy and the injected disturbance period, which directly relates to the computational time burden. 2.
The number of selected data points (N): another factor playing a significant role in the accuracy of the parametric identification is N to be used for curve fitting. Figure 8b illustrates the effects of this parameter on the obtained results. Two different sets of data are considered: N = 50 data points and N = 500 data points. Less accurate results are associated with N = 50, especially the magnitude at the low-frequency range. Again, it is a trade-off between the estimation accuracy and computational time.

3.
The minimum frequency of selected data points to be fitted ( f min ).
To examine how f min could improve/deteriorate the accuracy of the parametric impedance, three different values of f min = 1, 100, and 1000 Hz are investigated beside its default value (10 Hz) that is used in the rest of the paper. The results are presented in Table 5. It can be seen that more accurate results are obtained for f min = 1 Hz compared to the case study of f min = 10 Hz. The errors were reduced to ∆R = 2.84% and ∆L = 1.81. The reason for this improvement is due to the extra information about the impedance behaviors between 1-10 Hz. Moreover, it can be seen that the most accurate results are obtained for f min = 100 Hz, with estimation errors of ∆R = 1.11 % and ∆L = 0.3 %. This improvement is because the non-smooth data points around 50 Hz are excluded. Finally, larger errors correspond to f min = 1000 Hz, where ∆R = 23.86 %. This is because the fitting algorithm does not have enough information about how exactly the impedance behaves in the low-frequency region where it is mainly determined by the resistance value.

Asymmetrical Line Impedances of the Distribution Network
The line impedances of three-phase systems could be nonidentical in realistic operation scenarios of distribution networks. The operation of such distribution networks will also result in an unbalanced grid voltage at the inverters terminal. Therefore, accurately characterizing the network impedances is required. The main challenge is the impedance of each phase which cannot be directly measured in the sequence domain or dq domain. For this reason, the estimation procedure here slightly differs from the rest of the case studies in this paper. The impedances identification in the performed in the abc domain according to Equation (24) instead of the positive sequence measurements.
To investigate the estimation accuracy, the impedances of phase A and phase B are set to the values listed in Table 1 for the RL model. However, the impedance of phase C is set to half of this value, Z c = 0.25 + 0.25× 10 −3 s. Then, curve fitting is applied to the estimated nonparametric impedances of each phase individually. The obtained results of the parametric impedances of the three lines are summarized in Table 6. Moreover, the nonparametric and parametric impedances of phase C are shown in Figure 9a,b, respectively.

RLC Equivalent Impedance Model of Low-Voltage Distribution Network
Two case studies considering the RLC equivalent impedance model of the low-voltage distribution network are presented as follows:

Unbalanced Grid Voltage
Similar to the above procedure for the RL model, the grid impedance estimation is performed in the sequence domain based on the voltage v + abc and current i + abc measurements of the positive sequence. The reference grid impedance components are set to R g = 2.5 Ω, L g = 1 mH, and C g = 3 µF [8]; see Table 1. Figure 10a shows the spectrum of the estimated grid impedance for the unbalanced system with 50% voltage sag in phase B. To obtain the parametric model of impedance, the objective function to be fitted was set using Equation (19). Then, the grid resistance, inductance, and capacitance values can be obtained by comparing the Equation (20) with the obtained parametric impedance shown in Equation (25). The estimation errors in the R g and L g are −0.08% and −3.1%, respectively. However, two values are obtained for the C g from two different terms, C g = B 1 /A 0 and C g = B 2 /A 1 , resulting in estimation errors of ∆C g = −1.22% and ∆C g = 1.79%. The slight difference between these results is due to the dependence of the first term upon the R g and to the dependence of the second term upon the L g , where both components (R g , L g ) have their own estimation errors. Figure 10b compares the analytical solution of the grid impedance with the parametric transfer function obtained in Equation (25).  Table 1. On the other hand, the impedance of phase C is set to 75% of this value, R g = 1.87 Ω, L g = 0.75 mH, and C g = 2.25 uF. Curve fitting is applied to the above-estimated nonparametric impedances to obtain the parametric model of each phase. The obtained results of the three lines are summarized in Table 7, where estimation errors in the C g are calculated based on the second term, C g = B 2 /A 1 . Moreover, the nonparametric and parametric impedances of phase C are shown in Figure 11a,b, respectively. It can be seen that the estimation errors in the impedance components increased significantly for phase C. This is due to the shift of its resonance peak towards high frequencies; here, it is around 4 kHz compared to 3 kHz for phase A and phase B.  The above investigated results proved the reliability of the proposed implementation of the PRBS technique into the control loop using the PNSC strategy. It is worth mentioning that the estimated parameters of the grid impedance either R and L (for the RL model) or R, L, and C (for the RLC model) using grid-connected inverters equipped with PNSC strategy could be used to enable advanced functionalities such as robust control, stability, and low voltage ride-through.

Conclusions
In this paper, a simple and reliable online grid impedance estimation technique that is robust under various grid scenarios is proposed. This technique relies on the implementation of the pseudo-random binary sequence (PRBS) into the control loop of a grid-connected inverter equipped with a positiveand negative-sequence control (PNSC) strategy. The grid impedance estimation is performed by injecting the binary sequence on top of the d-axis current reference of the positive sequence. This reconfiguration of the control structure allows grid impedance estimation while achieves safe operation of the inverter to deliver a balanced current under unbalanced grid conditions. Complex curve fitting was applied to obtain the parametric grid impedance of both equivalent RL and RLC models of the distribution network. The proposed technique was tested under unbalanced grid conditions caused either by voltage sag in the grid voltage or due to asymmetrical line impedances of the distribution network. The effects of the initialization parameters of the grid impedance curve-fitting algorithm were also investigated. The presented simulation results based on a discrete-time model of the inverter system which was implemented in MATLAB/Simulink confirmed the robustness of the proposed estimation technique for all case studies considered.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: