Mitigation of Voltage and Frequency Excursions in Low-Inertia Microgrids

Power systems proliferated by distributed generation sources are becoming increasingly prone to frequency and voltage disturbances. These problems are exacerbated in microgrids since they have fewer intrinsic disturbance-rejecting measures and features. To increase the reliability and stability of emerging power systems, the advanced control structures of the distributed generation sources based on power electronics devices must be deployed during suboptimal operating conditions. The aggravating circumstance is that both voltage and frequency excursion can be transient and long-lasting and consequently can occur simultaneously. The algorithm proposed in this paper integrates voltage support (nominal voltage restoration) and inertia emulation features with the comprehensive current references management scheme, thus securing improved grid operating conditions during several different faults and occurrences. The control algorithm is developed and tested in the context of a small microgrid, but it can be applied with minimal alterations in traditional grids, also. To prove that it is possible to decrease simultaneously voltage unbalances and frequency deviations, a test microgrid consisting of a synchronous generator, photovoltaic system, battery storage system, and controllable balanced and unbalanced loads was developed in a hardware-in-the-loop environment.


I. INTRODUCTION
Distributed generation sources (DGSs), while enabling the utilization of renewable energy sources, energy supply diversification, and other benefits, introduce several operational difficulties to otherwise rather stable power systems. Among other deficiencies, the power systems rich with DGS, and in particular distribution networks and microgrids, demonstrate increased voltage and frequency volatility.
Transient voltage deviations and unbalances appear during short circuit faults and when large loads are connected or disconnected. Long-lasting unbalances appear when unbalanced loads and power production facilities are present in the The associate editor coordinating the review of this manuscript and approving it for publication was Bin Zhou .
network. Frequency disturbances generally arise when there is a discrepancy between the active power production and consumption and when large load groups are connected or disconnected from the grid. They can be both transient and long-lasting, depending on what has caused the disturbance and on how primary and secondary frequency regulation structures are designed.
It is important to note that these phenomena can be more frequent and more severe in distribution networks and microgrids. Regarding the grid voltage conditions, this is the case because these networks are generally dislocated from large production facilities, that in this case do not provide close to infinite bus behavior (stable voltage), and because there is an increasing number of local generation units that by intermittently producing energy inevitably VOLUME 11, 2023 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ affect local voltage conditions. The frequency stability in modern power systems and microgrids is reduced because power is progressively more produced by DGS and less by the traditional generation units (grid-connected synchronous generators) that naturally damp frequency deviations. The consequences of voltage and frequency instabilities are diverse. Voltage unbalances complicate power flow calculations that are of great importance for the networks' operation optimization [1]. Both balanced and unbalanced voltage dips and swells can lead to equipment disconnection, which is particularly dangerous if the DGS is disconnected since this can lead to problem propagation and exacerbation. Voltage dips can cause excessive currents to be produced by DGS if power references are not altered. This also can cause DGS disconnection since overcurrent protection will react to save the converter from destruction. Frequency drifts and swings propagate throughout the whole network and the larger the network is the harder is to synchronously damp them and bring the frequency to the nominal value in a controlled fashion. If drifts and swings are not attenuated, the whole network can become unstable and could collapse. Moreover, it is hard to identify and disconnect problematic network areas, if there is one (it could be that the problem is network-wide). This is the reason why allowable frequency changes in traditional networks were so small (less than 0.1% of nominal frequency).
Although DGS usage can result in or worsen mentioned disturbances, they can also be utilized to alleviate them, if properly controlled and dispatched. The researchers have recognized this fact previously and a number of solutions, designed to mitigate various voltage and frequency excursions by using DGS, have been proposed, albeit with some shortcomings.
An important concept of positive and negative powers was introduced and applied in [2]. It was demonstrated that by carefully setting the ratio between positive and negative active and reactive powers, it is possible to decrease voltage unbalances in the point of common coupling (PCC). Unfortunately, the generalized and automated control structure was not provided. A similar approach was used in [3], with an additional goal to reduce active power oscillations, caused by the unbalanced sags. The problem with the proposed solution lies in the fact that optimal nominal voltage restoration conflicts with the goal to nullify active power oscillations, i.e. if active power oscillations were nullified, suboptimal voltage restoration could take place. Moreover, in this paper also generalized and automated control structures were not provided. Active power and active power oscillations were carefully addressed in [4] and [5], also. Again, the proposed solutions certainly do not provide optimal voltage support in the general case. On the other hand, several papers deal with purely inductive grids [6], [7], [8], [9]. Since distribution networks and microgrids can actually be more resistive, these solutions can be applied only in transmission grids. Moreover, the applicability of these solutions is further diminished if the stiffness of the transmission grids is taken into account. Maximization of voltage restoration in phase with the largest voltage dip was secured in [10]. Although this may be a useful feature, the algorithm does not provide flexible and comprehensive voltage support.
A comprehensive voltage support scheme was proposed in [11], but the solution relies on incremental changes in voltage amplitudes and phases. This could rely on slow and unreliable convergence toward the optimal operating point. Moreover, the scheme uses complex expressions to derive grid voltage amplitudes. The scheme proposed in [12] seems promising, however, it is lacking comprehensive voltage management features. In [13] output regulation theory-based approach was used, but the current, i.e. power, the limitation was not analyzed. The current amplitudes limitation, although analyzed in the paper, was not demonstrated in [14]. Flexible support, designed for general cases, was proposed in [15]. The main drawback of the paper is that the current amplitudes limitation was secured only through a proportional change in active and reactive power. In other words, active or reactive power prioritization was not provided. Power prioritization is an important feature if the grid is either dominantly inductive or resistive, which usually is the case. Extensive voltage regulation and current amplitudes control were proposed in [16] and in [17]. In the context of voltage support, the only drawback of these solutions is that they do not address arbitrary voltage profile generation, but only nominal voltage restoration in cases of unbalanced voltage sags. If the arbitrary, but within the defined limits, voltage profile generation was enabled, the control algorithm would be able to project its influence further away from PCC. For example, the grid operator could command DGS to generate slightly higher or lower voltages than nominal, in order to mitigate undervoltage or overvoltage deeper in the network. Overvoltage problems were generally not addressed. Big data analysis was used to gain deeper insight into how voltage unbalances can be mitigated in the context of a wider area network in [18]. Still, the phase current waveforms were not explicitly controlled, and correspondingly, current amplitudes were not properly managed. Reduction in microgrid current unbalances was provided in [19]. Although this should result in voltage unbalance reduction, neither voltage nor current amplitudes were regulated. In [20], voltage support was secured, but with non-sinusoidal limited current waveforms during unbalanced voltages.
How DGS can contribute to frequency regulation was also analyzed in recent papers. Generally, most proposals can be categorized into three groups -virtual synchronous machines (VSM) or synchronverters [21], [22], virtual inertia (VI) [23], [24], [25], [26], and droop methods [27], [28], [29]. VSM approach in many aspects is similar to the synchronverter construct and, as the name suggests, the overarching goal of the control structures, governing standard voltage-source inverters (VSI), is to mimic the behavior of synchronous machines and inherently realize frequency stabilization and regulation, as if the real synchronous machine was connected to a grid. Actually, VSM has an advantage over real synchronous machines since it can dispatch arbitrary amounts of power at a much faster pace -the dynamic behavior is artificially defined through loops' gains and parametrization. Different VSMs adopt different approaches to modeling certain subsystems. Some adopt fairly simple (first-order transfer functions), while others use high-order synchronous machine models. The former do not represent synchronous machine dynamics fully and later suffer from stability issues [30], [31]. The most important deficiency of these algorithms is that they usually do not implement classical current loops, which means that current limiting, and generally management, is hard to realize, i.e. the resulting control structures are quite complex. The virtual inertia approach essentially adds governor dynamics to otherwise standard vector control of the current-controlled VSI. It is quite an elegant and effective way to damp frequency oscillations and eliminate frequency deviations from nominal values by dispatching active power when necessary. Consequently, they are easy to embed into existing DGS control solutions. Droop-based methods offer distributed control of grid voltage and frequency. Depending on how much active and reactive power DGS is producing, voltage amplitudes and phase angles are modulated. They are applied to the islanded microgrid. Droop-based methods nowadays differ widely since many improvements were made to the original algorithms. Still, similarly to VSM, droopbased schemes either do not include current control loops or, if they do, are rather complicated and hard to optimize. For all three of the mentioned approaches can be said that there must be a significant energy storage present within DGS that can dispatch the desired power when necessary. This fact has been surprisingly seldom addressed [23], [26]. Finally, it is interesting to note that there can be found equivalence between these three, and in particular between VSM and droop-based, approaches [30], [31], [32], [33].
Recently, there were attempts to synthesize control algorithms addressing multiple variables relevant to microgrid operation. Namely, frequency and voltage disturbances rejection features were analyzed jointly. A modified synchronverter scheme was designed to reduce unbalances in generated currents, if grid voltages are unbalanced [34]. It is not clear from provided results whether the algorithm will help improve voltage conditions for a general case. Similar remarks can be given for the approach described in [35], with the difference that this solution is based on a virtual synchronous machine. The voltage and current unbalance were explicitly addressed in [36], in addition to inherent frequency excursions mitigation (the algorithm is based on the droop-controllers). The paper thoroughly derives a comprehensive, albeit complex, control scheme, but fails to provide compelling results proving the scheme's effectiveness (neither instantaneous currents nor voltages are depicted, the current/power maximization feature is not clearly demonstrated, etc.). The voltage and frequency disturbances were mitigated using the solution derived in [37], but the current/power limitation feature was not addressed at all.

A. SCOPE OF THE STUDY
Considering the remarks on previously proposed solutions and the fact that various voltage and frequency excursions are frequent and detrimental to the operation of both traditional distribution grids and microgrids (particularly islanded microgrids), the algorithm that enables simultaneous mitigation of these occurrences would be beneficial.
Hence, this study proposes the algorithm governing DGSs utilized in traditional networks or microgrids, with a major objective of mitigating various network disturbances. It should be emphasized that microgrids without inertia (synchronous generators), i.e. microgrids with only power electronics-based sources, were not considered. This is the case because such networks are yet to be technologically completely viable and are not close to wide commercial adoption. This is corroborated by the fact that German regulations forbid islanded microgrid formation altogether, at the moment [38]. Consequently, focusing on such networks would narrow the applicability of the derived algorithm. Still, the derived algorithm should be applicable to islanded microgrids with no natural inertia and simple to integrate into pertaining control structures. This will be further investigated in future studies.
Specifically, the study is placed in the context of a network outlined in Fig. 1. This network consists of a PV system, a diesel generator (although it can be any source based on grid-connected synchronous machines), a battery storage system, and passive loads. Switch SW2 is used to connect balanced (top position) or unbalanced load (bottom position) to PCC. The grid can be connected or disconnected from the infinite bus by activating or deactivating the switch SW1. If switch SW1 is closed, the traditional distribution network, or non-islanded microgrid, is constituted. Alternatively, if SW1 is opened, the islanded microgrid is formed. In that case, the diesel generator takes the role of a gridforming source. The PV system and battery storage system are always in the grid-following/supporting mode. During VOLUME 11, 2023 different test procedures, SW1 was kept open or closed depending on which phenomena were addressed in that particular test, as explicated in the chapter on experimental results.
The disturbance rejection and mitigation scheme is assigned to the battery storage system since it can rapidly dispatch significant amounts of active and reactive power. The scheme can be integrated into the control algorithm governing the PV system, or other DGSs, albeit with limited capacity since the PV system does not have an inherent significant energy storage element, i.e. active power reserve.

B. ADVANTAGES AND NOVELTIES OF THE PROPOSED SCHEME
The control algorithm derived in this paper was designed following shortcomings and deficiencies of the previously proposed solutions, described in previous paragraphs. Hence, although the context of the study is not unique, the paper provides a unique control scheme that comprehensively solves the problem of voltage and frequency excursions in low-inertia microgrids and brings the following advantageous features: • An arbitrary set of current/power waveforms can be produced, in accordance with the converter's current limits. Also, the algorithm manages current/power references so that the maximized power production is enabled at all times; • It can prioritize either active or reactive power production, depending on the nature of the grid to which the DGS is connected; • It secures controlled active and reactive power production during balanced and unbalanced voltage sags and swells; • It can mitigate balanced and unbalanced voltage sags and swells, i.e. restore nominal voltage amplitudes. Actually, arbitrary voltage amplitudes can be realized at the point of common coupling for arbitrary grid voltage amplitudes (taking into account only the converter's current limits); • The frequency deviations are damped by employing the virtual inertia paradigm; • Frequency deviations and voltage amplitudes management can be deployed simultaneously; • As such, the algorithm can be applied in traditional distribution (or transmission) networks and microgrids; • The algorithm is simple and easy to implement. The algorithm's novelty and importance are based on the fact that, to the best of the authors' knowledge, no other scheme demonstrates all of the listed features, although some have been reported in previous studies. The algorithm capable of demonstrating multiple features regarding disturbances and power management should be of great importance to emerging and rather volatile networks, such as microgrids. Moreover, the simultaneous mitigation of frequency and voltage deviations is a novel feature, not secured by earlier solutions. This is an important feature since these disturbances can occur simultaneously (e.g. disconnection of a large production plant whilst the unbalanced load is connected to the grid). Also, the overvoltage problems were not explicitly considered, even though the overvoltage conditions can follow or be caused by similar phenomena as the voltage sags (some short-circuit faults cause specific phase voltages to swell) and hence occur almost as frequently. It should be emphasized that the control scheme treats overvoltage and undervoltage conditions as the same phenomena (voltage excursions) and thus represents a uniform and unified solution. Furthermore, arbitrary voltage profile generation was not considered previously even though this is of fundamental importance for influencing the grid operating conditions further from the point of common coupling into the network. The possibility of using the algorithm both in grid-connected and islanded mode is novel, also. Hence, the generality and novelty of the solution are amplified by the fact that the control scheme can be used in various network types. The operation in microgrids based only on DGS connected to the grid via power electronics devices is not secured, but in the next studies, it will be examined whether the proposed algorithm can be integrated into droop-based control structures, much like in [36]. Finally, the algorithm simplicity enables easy implementation, but also upgrades and integration with other control structures.
The remainder of the paper is organized as follows. The second chapter introduces the algorithm and its main objectives and features. The third chapter provides the results obtained using real-time simulators (i.e. controller-hardwarein-the-loop, C-HIL, setup). The fourth chapter consists of a short discussion and concluding remarks. Fig. 2 depicts the organization of hardware and software units pertaining to the battery storage system. The hardware consists of the battery system, inverter, filtering impedance (Z f ), known and balanced grid impedance (Z g1 ), unknown balanced or unbalanced local load (Z ll ), unknown and balanced grid impedance (Z g2 , where Z g2 ≪ Z g1 ), unknown and balanced load at PCC (Z l ) and a grid voltage (U g ). Here, the U g does not have to be an infinite bus. It can also be a voltage generated, or imposed, by the synchronous generator, depending on the state of the switch SW1 in Fig. 1.

II. PROPOSED CONTROL SCHEME
Please note the position of PCC and the place where the voltage is measured. The voltage conditions are controlled at the PCC. The voltage conditions deeper in the grid (after impedance Z g1 ), if not available directly through measurement, could be reconstructed using various methods utilizing the measurements at PCC [39], [40], [41], [42]. A similar can be said for knowledge of Z g1 . Still, in a microgrid, it is meaningful to expect a good knowledge of impedances in the grid and many smart metering devices to be distributed throughout the grid.
The software has a standard form utilized in gridsupporting or grid-following grid-tied converter applications. The voltage and current measurements are transformed from natural (abc) into the stationary (αβ) reference frame. The αβ current components are used as feedback signals in the current control loop. Correspondingly, the proportional-resonant current controllers are used in the control scheme [43]. The αβ voltage components are used in the sequences extractor and phase-locked loop (PLL) unit. This unit is based on dual second-order generalized integrators, although it can be implemented using various other methods [44], [45]. The modulator, generating gate signals for the inverter, is based on the space vector modulation technique. The DC-link voltage control was turned off in this study since it is considered that the battery system has sufficient capacity so that the battery system voltage is not changing significantly during the system operation. Finally, the powers and current references management units generate current references. Inputs to the references management scheme are estimated grid voltage components (u dq pn ), estimated grid voltage angular frequency and angle (ω and θ), and initial active and reactive power references (p r d and q r d ). Initial active and reactive power references can be defined by outer control loops (e.g. DC-link voltage control loop), by the grid operator, etc. The powers and current references management units should secure that defined control objectives are fulfilled, provided that the remainder of the control algorithm operates properly. Namely, the references management units should define references such that the PCC voltage regulation is enabled, that timely dispatchment of active power (to mitigate frequency deviations) is secured and that current/power production is maximized.

A. REFERENCES SECURING FLEXIBLE PCC VOLTAGES CONTROL
Derivation of the power and current references that would contribute to voltage disturbances rejection, or that would alter PCC voltages in any manner desired by the grid operator, starts with the set of fairly simple equations (1)-(4). They are voltage balance equations in the synchronous reference frame, considering the positive and negative sequence components.
u dp pcc = r g1 · i dp − x g1 · i qp + u dp (1) In (1)-(4), r g1 and x g1 are normalized equivalent grid resistance and reactance, respectively. The voltage components u dq pn are estimated grid voltage components, while u dq pnpcc are voltage components at the PCC, i.e. controlled variables. The PCC voltages control is realized implicitly, using current references and current control loop, i.e. there are no voltage control loops. Once the system of equations (1)-(4) is solved, the expressions for necessary current references are obtained -(5)- (8).
The u dq pnpcc components can be controlled to arbitrary values and if it is set that {u dp pcc , u qp pcc , u dn pcc , u qn pcc } = {1, 0, 0, 0} (in relative units) if Z g1 and u dq pn are estimated or otherwise precisely known and if Z g2 is small (zero) and Z l , Z ll are large (infinite), ideal PCC voltage regulation could be realized and the nominal (and balanced) voltage profile would be measured at the PCC. The precision of PCC voltage control certainly depends on how precisely Z g1 , Z g2 , Z l , Z ll and u dq pn are known, but this fact will be addressed later in the paper.
It is worth noting that the expressions (1)-(8) are suitable for usage in any type of network (arbitrary r g1 and x g1 ) and to achieve arbitrary PCC voltage profile (arbitrary u dq pnpcc -balanced or unbalanced, under-or overvoltage profiles can be imposed) enabling full flexibility in controlling the PCC voltages and even in influencing the voltage conditions elsewhere in the network. Also, the current references can be used to calculate the active and reactive power references necessary for voltage support (p r vs and q r vs ), utilizing voltage components, if such information is necessary (e.g. in power/energy management schemes).

B. ACTIVE POWER REFERENCE SECURING VIRTUAL INERTIA FEATURE
Virtual inertia feature, or frequency deviation damping, is actualized by dispatching active power, which is in turn realized by defining adequate active power reference. The active power reference necessary to damp frequency deviations is found using the swing equation (9), characterizing simplified synchronous machine behavior [30].
In expression (9), J is emulated rotor inertia, ω is the angular frequency of the voltages generated by the inverter, ω g is grid angular frequency, T 0 is emulated mechanical torque (applied to the machine's shaft) and T el emulates developed electromagnetic torque. Parameter D represents the damping coefficient, associated with the dynamics of damping windings in a real synchronous machine. The expression (9) can be used in a more convenient form after it is multiplied by the nominal grid angular frequency and then normalized with respect to the nominal power. Also, the angular frequency should be expressed in per unit. Thus, expression (9) becomes expression (10), where d=D·ω gn 2 /S n . Additionally, inertia constant H can be introduced, where H=J·ω gn 2 /(2·S n ). In the Laplace domain, the expression (10) takes the form of expression (11).
Finally, in order to properly damp grid frequency deviations and contribute to the grid frequency regulation to a nominal value (in per unit), the expression for active power reference (p r vi ) necessary to realize virtual inertia capability becomes (all variables are in per unit): In expression (12), the ω r pu is the reference angular frequency (set to 1 p.u.), ω est is the estimated angular frequency (coming from PLL unit), also in per unit. It should be noted that expressions (9)-(12) should be regarded only as simplified approximations of how the synchronous machine would behave and that they are correct only for small excursions around the nominal grid angular frequency.

C. POWER AND CURRENT PRODUCTION MAXIMIZATION AND MANAGEMENT SCHEME
The voltage support and virtual inertia features must be enabled at all times and activated instantaneously with grid disturbance occurrence. Also, the DGS's protection mechanisms activation should be prevented, if possible. Moreover, the power and current producing capabilities must be optimized and maximized so that the disturbance rejection capabilities are fully utilized. Hence the scheme that manages the power and current references is of crucial importance. The scheme must be simple and flexible, taking into account the DGS's limitations (primarily current ratings of the converter) and corresponding protection mechanisms, and secure power and current production maximization. This scheme is based on the expression for apparent power (13), valid in threephase systems where positive and negative sequence current and voltage components are present, and there are no zero sequence components.
After expansion (13) becomes a set of equations (14)- (19). This set can be used to calculate necessary current references, which would result in the production of the desired active and reactive powers (p r and q r ). Since there are four current references i dq pnr , this set is redundant and there are several ways how this set can be used to find current references.
Power references p r and q r correspond to average active and reactive power references, p 1 and p 2 are active power oscillating components, and q 1 and q 2 are reactive power oscillating components. All six components can be set to arbitrary values (note that the relative units are used).
To calculate current references, any four out of six expressions (14)- (19), can be used. Still, the most meaningful sets of equations are (14)- (17) and (14), (15), (18), and (19). The first enables control over average active or average reactive power production and enables the complete elimination of active power oscillations. Similarly, the second enable control over average active or average reactive power production and enables the complete elimination of reactive power oscillations. Other sets of expressions would either leave average active or average reactive power uncontrolled or would not enable complete active or reactive power oscillations elimination.
The current references corresponding to the two mentioned sets of expressions are calculated using (20)-(23) and (24)-(27), respectively i dp r = P r · u dp u 2 where u 2 p = u 2 dp + u 2 qp and u 2 n = u 2 dn + u 2 qn . Expressions (20)- (23) and (24)-(27) can be used to enable the virtual inertia feature since (12) indeed defines only the average active power reference.
i dp r = P r · u dp u 2 The other three power references components (q r and p 1 and p 2 or q 1 and q 2 ) can be defined in accordance with other control goals.
Unfortunately, the sets of expressions suitable for the elimination of oscillations in active or reactive power cannot be also used to implement voltage support features -certainly not in the general case. For that, different expressions (28)-(31), derived from (14) and (15), must be used. p r+ = u dp · i dp r + u qp · i qp r · k p (28) q r+ = −u dp · i qp r + u qp · i dp r · k q (30) The parameters k p and k q can be set to values between 1 and 0. If k p and k q are set to 1, the active and reactive power will be produced utilizing only positive sequence components (currents). Alternatively, if k p and k q are set to 0, the active and reactive power will be produced utilizing only negative sequence components (currents). Also, active and reactive powers can be produced partially using positive and partially negative sequence components. Accordingly, the average active power reference can be realized using what is called positive active power (p r+ ) or negative active power (p r− ), and the average reactive power reference can be realized using what is called positive reactive power (q r+ ) or negative reactive power (q r− ) [46]. It can be proven that by properly choosing parameters k p and k q , arbitrary phase currents' profiles can be produced, with constraints that the phase currents will be sinusoidal and in accordance with power references. This corresponds perfectly with the necessity to produce different current profiles, during different grid voltage conditions (balanced and unbalanced, over-and undervoltage conditions) and to implement a flexible voltage support feature. Hence, for voltage support capability, the expressions (32)- (35), obtained after solving the system of equations (28)-(31), should be used.
i dp r = P r · u dp · k p u 2 The sets of expressions (20)- (23), (24)-(27), and (32)-(35) cumulatively can be used to produce not completely arbitrary, but certainly all power and current profiles of practical importance.
The expressions (32)- (35) should be equal to expressions (5)- (8), if the voltage support feature should be realized. Also, parameters k p and k q and power references p r and q r (i.e. p r+ , p r− , q r+ and q r− ) can be calculated using the i dq pnr , u dq pn and expressions (14)- (15) and (28)- (31). The values for k p and k q , i dq pnr , u dq pn , and corresponding power references, must be known in order to manage references further (e.g. for references maximization) without unnecessarily perturbing original control goals (e.g. voltage support and virtual inertia).
Once power and current references, that should secure virtual inertia and/or voltage support are known, they must be used to check whether the phase currents would be excessive if such references were to be realized for present grid voltage conditions. If the calculations indicate that the currents higher than the converter's limits would be produced, the power and current references must be recalculated. Unbalanced voltage conditions are of special importance since they are harder to manage than balanced voltage conditions and since during unbalanced grid voltages particularly excessive currents could be produced.

D. MAXIMAL PHASE CURRENTS AMPLITUDE IDENTIFICATION
The sole goal of the following scheme is to identify whether any of the phase currents would be larger than the converter ratings.
Also, if some of the phase currents' amplitudes would be larger than the limits, the scheme gives the information on which of the three currents has the highest amplitude.
Using this information, the remainder of the control algorithm then recalculates the power and current references. New references should be such that the power-producing capacities are maximized for the current operating conditions, VOLUME 11, 2023 which means that the largest phase current amplitude must be exactly at the converter limit.
Considering that the unbalanced voltage conditions imply the presence of both positive and negative voltage components, to secure the voltage support feature the converter must produce both positive and negative sequence current components, in the general case. Hence, the phase current waveform (in abc domain) is constituted of positive and negative sequences sinusoidal waveforms. In a stationary reference frame, the two components can be represented as two vectors rotating in opposing directions, as depicted in Fig. 3. The phase current reaches its amplitude when positive and negative current vectors align. This happens at the current phase angle ϕ. In Fig. 3 i dq pnr are current references in the synchronous reference frame, i p and in are the amplitude of the positive and negative phase currents respectively and Imax is the amplitude of the cumulative phase current.
The expressions (36)- (38) are used to find the phase ϕ at which the cumulative current vector reaches its maximum value Imax.
i p = i dp r 2 + i qp r 2 , i n = i dn r 2 + i qn r 2 (36) ϕ p = arctg i qp r i dp r , ϕ n = arctg i qn r i dn r (37) The phase current amplitudes are found by projecting the cumulative current vector (at phase ϕ) onto the pertaining axes. Note that the algorithm depicted in Fig. 4 is derived considering only the right half-plane (b and c axes are extended into the right half-plane) and that the power invariant Clarke transform is used throughout the paper. For example, for current references used in Fig. 3, the phase current a would have the highest amplitude.

E. POWER PRODUCTION MAXIMIZATION AND PRIORITIZATION
If the scheme for maximal phase currents amplitudes identification detects an overcurrent problem, the control algorithm must recalculate the power and current references. Indeed, it is possible to proportionally decrease both active and reactive powers following the ratio between the current limit and the phase current amplitude that would be generated if the old references are produced. This would bind the highest phase current amplitude to the defined limit. Still, this is seldom a meaningful and optimal approach. In most cases, it is beneficial to maximize either active or reactive power. For example, if the virtual inertial feature must be deployed, the reactive power production could be of secondary importance. Also, for dominantly inductive networks, the production of reactive power would result in more pronounced voltage support.
The new power and current references are calculated using active power-producing current amplitude i px and reactive power-producing current amplitude i qx and the expression (39) where I lim is the defined converter limit (here chosen to be one per unit), δ is the phase difference between the i px and i qx and x stands for suffix a, b, or c (depending on which phase current would be the highest). Also, the scheme for new references calculation is based on the expansion of the four expressions sets, initially used to find expressions for current references ((14)-(17), (14), (15), (18), and (19) or (28)-(31)) with an additional expression that imposes the necessity that the highest phase current amplitude is bound to the I lim . The results are sets of five expressions, instead of four, where the power that should be prioritized is considered as the fifth unknown, in addition to current references. The non-prioritized power reference is an initial estimate set to zero (i.e. it is assumed that there are no capacities left for the production of the non-prioritized power).
The fifth expression is found by applying the inverse Park and inverse Clarke transform onto the current references as in TABLE 1. New power references that secure maximized power production ( P=0 or Q=0). (40) and (41).
Angle θ x is set using one of the expressions (42) or (43), depending on which power should be prioritized and which phase current would be the highest. For example, if the reactive power should be prioritized and the phase current b would be the highest one, the second expressions in (43) should be used in (40) and (41).
Parameters k p and k q are defined by the voltage support scheme (using (28)-(31), for example), if such scheme is enabled, or are equal to one if the oscillations in active or reactive power should be minimized. It should be noted that θ + equals zero in the steady-state since the phase-locked loop is locked for the positive sequence voltage vector, and θ − = arctg(u qn /u dn ).
Once the system of equations (14)- (17), (14), (15), (18) and (19) or (28)-(31) plus additional expression coming from (40) and (41) (using the adequate expression for angle θ x ) is solved, expressions for new power and current references are obtained. Here, only new power references are given, since it is less computationally demanding to calculate only new power reference and use it in the original current reference to obtain updated current references (all particles in corresponding expressions have been previously calculated). Table 1 provides new power reference expressions that will secure that the amplitude of the highest phase current is exactly at the converter's limit and that either oscillations in active or reactive power are nullified.
Alternatively, if flexible voltage support is necessary, expressions in Table 2 should be used. These expressions will also secure that the highest phase currents are exactly at the converter's limit, albeit with power oscillations being uncontrolled.
Depending on which phase current would be the highest one, which power production should be prioritized, and which control goal must be realized (power oscillation nullification or voltage support), one expression from Table 1 or Table 2 should be used. It should be emphasized that these expressions were derived assuming that there are production capacities for the production of only one (prioritized) power, i.e. the non-prioritized power reference is set to zero. This is appropriate when deep grid voltage sag occurs, for example. Otherwise, assuming that the non-prioritized power reference should be set to zero is unjustified and the non-prioritized power reference should be curtailed only partially, while the prioritized power reference should keep its original value. Whether this is the case or not can be simply concluded by comparing the new prioritized power reference with the original prioritized power reference (p r ≶p r new or q r ≶q r new ). If the new power reference is smaller than the old one, the new power reference should be used and the non-prioritized power reference should be kept at zero and new current references should be found using these power references (inputting the power references in (20)-(23), (24)- (27) or (32)- (35)). Alternatively, if the new power reference is larger than the old one, the old power reference should be kept and a new non-prioritized power reference should be found.
In the latter case, active power-producing current amplitude i px and reactive power-producing current amplitude i qx and the expression (39) must be employed in the following fashion. Firstly, using the prioritized power reference, i px or VOLUME 11, 2023  i qx are calculated (depending on which power is prioritized) by using expressions in Table 1 and Table 2 -i px or i qx are used instead of I lim . For example, if reactive power should be prioritized, the phase current b would be the highest one and voltage support should be implemented, reactive powerproducing current amplitude i qx would be calculated using expression (44).
Next, the amplitude of the non-prioritized powerproducing current (in this example i px ) should be calculated, taking into account that the sum of the active powerproducing current and reactive power-producing current must equal I lim , i.e. using expression (39). The phase difference between the active power-producing current and reactive power-producing current δ is found as the difference θ px -θ qx .
Finally, once the non-prioritized power-producing current amplitude is found, the new reference for non-prioritized power can be found, again using expressions in Table 1 or  Table 2. In the addressed example, the new active power reference P r new is found using expression (45).
In Table 1 the following expressions stand: The complete control algorithm is shown in Fig. 5. As indicated in the figure, in addition to power references defined by the voltage support feature (p r vs and q r vs ) and virtual inertia (p r vi ), the grid operator can define power references (p r go and q r go ), also. As an initial strategy, the active and reactive power references are summed and then compared to the power references that would result in maximal voltage conditions at PCC. Although it is not very probable, it is possible that such cumulative power production could result in excessive PCC voltages and thus trigger overvoltage protection. Next, employing the power references, the current references are calculated, using one of the strategies previously presented -those that secure power oscillations nullification or one providing flexible voltage support. If voltage support is not necessary, nullification of active power is beneficial since oscillations in DC-link voltage are accordingly minimized. In this case, expressions in Table 1 are used in the algorithm. If voltage support is necessary, expressions in Table 2 are used in the algorithm. Please note that if voltage support is realized, parameters k p and k q, once defined by the voltage support scheme, are not changed later in the algorithm, i.e. only average positive and negative powers are changed/curtailed if necessary. If k p and k q values are not changed, the currents would be limited, the amplitudes of all phase voltages would be increased and the unbalance would be decreased. If they were changed during the reference recalculation procedure, various effects, both desirable and undesirable could be realized. For example, if curtailment is necessary, k p and k q values could be changed so that only the negative voltage sequence is nullified. In this case, the voltage unbalance reduction is maximized, but the cumulative voltage amplitude increase is limited. This could be desirable, but only if the unbalanced voltage sag is not too deep. Still, this is a different control goal -the initial control goal was a complete voltage recovery, not a negative sequence nullification. Alternatively, k p and k q values could be changed so that the voltage profile is actually worsened (e.g. highest phase voltage amplitude increase instead of the lowest voltage amplitude increase) [10], [15]. Hence, in this paper, for simplicity's sake, an approach in which k p and k q values are not changed is adopted. The next stage in the algorithm is to check if excessive currents would be produced. If not, the current references are preserved. If yes, new power references are found (again k p and k q are not changed even if power curtailment is necessary). The control algorithm shown in Fig. 5 is the one used when reactive power production is prioritized, but the algorithm for active power production prioritization would be completely analogous. Finally, once the new power references are found, the current references are found once more, using the same expressions used to calculate initial current references. Although this seems redundant and computationally unreasonable, it is necessary and not computationally demanding since essentially only the power reference is changed in the current references' expressions (voltage conditions are the same) and all particles in those expressions have been previously calculated.

III. RESULTS AND DISCUSSION
The behavior of the proposed control scheme was examined in the context of a microgrid, outlined in Fig. 1. The microgrid was implemented in hardware in the loop (HIL) environment. The setup is depicted in Fig. 6. Since the power stage is complex, four networked emulators were used.
The control codes for the battery system and PV system were implemented using Texas Instruments TMS320f28335 control cards, while the network coordination and configuration (synchronous machine control, local load connection, and disconnection, etc.) were realized using the emulators themselves and their capabilities for control schemes implementation. The PV system was driven by a standard vector control algorithm and was working at maximum power point at all times when activated. The battery system was driven by the proposed control scheme. The synchronous machine was producing the specified amount of power when the grid was in non-islanded mode. Once islanded mode was initiated, the synchronous machine was set up so that a seamless transition between the non-islanded and islanded mode was possible  (adequate power production was instantiated). In other words, grid-forming functionality was assigned to the synchronous generator. The battery system also could have been assigned this function, but such a scheme and approach are out of the scope of this paper.
Reconnection of the network to the infinite bus is done once the resynchronization process was finished (the network voltage vector was aligned with the infinite bus voltage vector by adjusting the synchronous machine operation). Table 3 contains the power stage data. It should be noted that transformers, used to connect the battery and PV systems, as well as passive loads, to the grid are not depicted in Fig. 1, but were used in the emulated model. Furthermore, for the impedances, Z g1 and Z g2 the same underground cables were used, albeit with different lengths -Z g1 cable had a length of three kilometers (so that significant voltage conditions alteration was possible), while Z g2 cable had a length of half a kilometer (so that the network at the place where voltages are measured is stiff).   Table 4 contains the power stage data related to the DGSs and synchronous generators. The grid-side converter has the same ratings as the battery and PV systems. For the synchronous generator, only the most relevant data is given. The rest of the necessary parameters are omitted for space considerations.
The most relevant data necessary for the battery and PV system control codes synthesis can be found in Table 5. The current control loops and the phase-locked loops, and corresponding data, are the same for the battery and PV systems. The DC-link voltage control was implemented only for the PV system. The DC-link voltage is considered to be constant for the battery system. Other details regarding PV system control and the synchronous machine control are omitted here since they are not relevant for discussion. Inertia constant (H) and parameter d from expression (12) were calculated considering that the peak (transient) apparent power is 250 kVA (nominal apparent power is 150 kVA) and that the maximal active power is dispatched when the frequency deviates for 4 Hz from the nominal value.
During testing, the maximum allowable current I lim was set to 174 A (which translates to one per unit since the base value is 174 A). In root mean square terms, this means that the maximal RMS value for phase currents is around 20% higher than the nominal phase current RMS value (which is 100 A). The given nominal converter voltages are again RMS values (line voltages), which means that the amplitude of the phase voltages should be around 1200 V, during nominal conditions.  The first set of tests was conducted in a non-islanded network regime. The non-islanded regime was activated so that arbitrary voltage conditions could be imposed, including significant voltage sags and swells, by setting the voltage profile generated by the infinite bus.
It would be hard to realize significant voltage, especially unbalanced, dips in the islanded regime. The first set of diagrams (Fig. 7 a)) was recorded when a significantly unbalanced voltage sag was initiated. The sag was successfully mitigated and nominal PCC voltages have been restored. Since the sag was not too deep, the currents are well within the limits (under 174 A). The next test was to see how the current limitation feature functions. Hence, a deeper unbalanced sag was imposed. As can be seen in Fig. 7 b), the currents are safely limited, but the PCC voltages, although improved in comparison to grid voltages, are neither balanced nor nominal. The third test was conducted simply to prove that the voltage disturbance imposed under the second test can be mitigated if the current limitation was turned off. Fig. 7 c) shows that the currents are higher than 174 A, but the PCC voltages are nominal. Also, on account of current waveforms, it can be said that the transient behavior, during this and other tests, is excellent. The fourth test was conducted when a switch SW2 (Fig. 1) was placed in the lower position. This has caused a balanced local load to become unbalanced. Specifically, one load phase had a 500 times smaller impedance than the rest of the two phases. From Fig. 7 d) it is evident that neither nominal PCC voltages have been measured nor current was limited.
Still, considering the topology of the addressed network, this is perfectly expected. It is not possible to restore nominal PCC voltages using only voltages as a medium (measured in the manner previously discussed). The unbalanced load drains unbalanced currents that cause an unbalanced voltage drop across impedances Z g1 and Z g2 . This voltage drop can not be simply neutralized, and consequently, nominal PCC voltages can not be simply restored, because voltages are measured at what can be called an unbalanced voltage divider -the smaller the Z g2 is, the harder is to improve the PCC voltage conditions since the grid is stiffer and the unbalanced load connection is ''less visible'' to the battery system. This problem can be solved by measuring the current profile consumed by the load and feed-forwarding this profile to the battery system, in form of p r go and q r go (note Fig. 2 and 5). In that case, the current would simply circulate between the battery system, and the load and nominal voltage conditions would be recorded. Even though this necessitates additional measurements, it is reasonable to expect that a smart meter would be installed at each node of such a network, and such measurements would be made anyway. Furthermore, small deviations from ideal voltages can be seen in Fig. 7 a) and c), but those are attributed to the grid voltage components estimation imprecisions (sequence extractor and PLL unit in Fig. 2). Moreover, the results shown in Fig. 7 show that both active and reactive powers had significant oscillations, during all tests. Active power oscillations could decrease the battery life cycle, albeit not significantly. Reactive power oscillations do not have any tangible adverse impacts.
Also, before the unbalanced voltage conditions were imposed or before the unbalanced load was connected, active and reactive power production was not zero. This is the consequence of the fact that the grid voltage amplitudes were not set to be exactly equal to nominal values, but were smaller than nominal by around 50 V. Additionally, the balanced voltage drop across Z g1 and Z g2 has caused slightly lower than nominal voltages to be measured. It should be noted that the voltage waveforms were measured and then filtered to remove high-frequency components, inherently present as a consequence of the DGSs operation.
The responses recorded during the second set of tests are shown in Fig. 8. These tests were also conducted in the non-islanded regime of the microgrid. The difference is that now overvoltage conditions were addressed. In Fig. 8a), the overvoltage conditions, imposed by the infinite bus, were partially reduced in the context of PCC voltages. Initially, there was a small unbalanced voltage sag, which was successfully mitigated. After that, unbalanced overvoltage conditions were enforced, but since the current had to be limited, nominal voltage conditions could not be restored. The goal of the next test was to prove that arbitrary voltage conditions could be imposed at PCC. The battery system has initially an unbalanced voltage sag. Then, the reference voltage components were changed from {u dp pcc , u qp pcc , u dn pcc , u qn pcc } = {1, 0, 0, 0} to {1.1, 0, 0, 0}. Consequently, PCC voltages were still balanced (even though the grid voltages were unbalanced), but the phase voltages' amplitudes were 10% larger than nominal, as depicted in Fig. 8 b). The following two tests were conducted to demonstrate that the nullification of active or reactive power oscillations is not compatible with voltage excursion mitigation. The responses shown in Fig. 8 c) and d) testify that the voltage profile was worsened while the oscillations were indeed eliminated either in active or reactive power. Also, all results (including those in Fig. 8 c)) were recorded while active power production was prioritized, except the results shown in Fig. 8 d), which were recorded while reactive power production was prioritized. Consequently, in the third test, active power was partially curtailed, while reactive power was stopped completely. In the fourth test, reactive power production was partially curtailed, while active power production ceased completely. It should be noted that the active and reactive production before the voltage disturbance occurred was a result of active and reactive power references being set to a particular value (0.8 p.u.) and was not a result of either voltage support or virtual inertia feature. The PCC voltage depicted in Fig. 8 c) and d) would cause overvoltage protection triggering and converter disconnection. The third set of tests was conducted in islanded microgrid regime.
The synchronous machine has taken the grid-forming function. The PV system was operating at the maximum power point, battery system's active and reactive power references were set to 0.2 p.u. Fig. 9 a) shows that slightly higher active and reactive powers were produced, since a voltage support feature necessitated additional active and reactive power for voltage conditions improvement. Once an additional balanced local load was connected, the battery system dispatched additional active power to mitigate the frequency drop caused by the load connection. The frequency has dropped to 0.9976 p.u. (59.856 Hz). If the installed power of the battery system was higher, the frequency deviation would be even smaller. After the transient, the reactive power production has slowly returned to the value it had before the load connection while the active power production has been increased in correspondence to frequency change and the parameters defined for the expression 12. In the next test, one unbalanced local load was connected to the network from the beginning of the test. The rest of the testing parameters were the same as in the previous test. Again, the battery system's voltage support feature has resulted in PCC voltage conditions improvement, but the nominal voltage conditions were not restored, for reasons previously explicated. The frequency has dropped to 0.9975 p.u. (59.85 Hz). Since the currents were not limited, the reason for this slightly deeper frequency dip probably lies in numerical inconsistencies. Moreover, it should be noted that the frequency oscillation (at twice the grid frequency) was the consequence of an unbalanced load being connected. Still, the amplitude of this oscillation was almost negligible, indicating that the network stability was not compromised. In the third test, higher active and reactive power production was demanded (0.6 p.u.), whilst the same unbalanced load was connected. In this case, when an additional balanced load was connected, the currents had to be limited, and power production had to be curtailed. Consequently, the frequency dip was more pronounced in this case -the frequency dropped to 0.9971 p.u. (59.826 Hz). Again, the currents, although unbalanced, have no overshoots nor low-order harmonics are present and are always within the defined limits. Fig. 10 gives the superimposed frequency responses for these three scenarios, with the addition of the frequency response when there is no virtual inertia activated (the battery system was disconnected). Expectedly, the frequency dip is the most significant when there is no active power dispatched during the local load connection.
The provided experimental results prove that the proposed control algorithm can: • Result in the production of various current and power profiles (securing different control goals); • Manage current and power references so that the maximized power production is enabled during all operating regimes (i.e. effective current limitation feature was presented); • Prioritize active or reactive power production; • Manage balanced and unbalanced under-and overvoltage conditions at PCC; • Deploy virtual inertia and damp frequency excursions caused by load connection; • Simultaneously alter PCC voltage conditions and provide virtual inertia feature.

IV. CONCLUSION
The stable operation of emerging power networks depends on how power-producing facilities are optimized and controlled. Various disturbances, most notably voltage and frequency disturbances, caused by various occurrences, jeopardize the safe and reliable operation of microgrids, and in particular of low-inertia microgrids. These networks have insufficient inherent disturbance mitigation features and distributed generation sources must, at least partially, contribute to disturbances rejection and grid operation normalization. This paper proposes a control scheme that governs distributed generation units, with a primary goal to contribute to the restoration of the nominal point of common coupling voltages and contributing to the frequency drift reduction. Balanced and unbalanced, overvoltage, and undervoltage disturbances are addressed. The frequency drifts are decreased by activating the virtual inertia feature. Moreover, the control scheme manages the power and current references so that several particular control goals are enabled while respecting converter power production limits. Consequently, the proposed control scheme secures both the safe operation of the distributed generation source itself and improved microgrid operation. All salient features of the proposed scheme have been demonstrated via tests that were conducted on the microgrid, consisting of a synchronous generator, battery system, PV system, and several balanced and unbalanced loads. The said microgrid was established in the hardware in the loop environment.  VOLUME 11, 2023