1 Introduction

Microgrids consist of distributed generators (DG), storage devices, controllable loads and protection units, and they usually operate in low or medium voltage networks. Microgrids can operate interconnected to the power grid, or islanded, offering considerable control capabilities over the network operation [1, 2]. The transition between two modes may give rise to harmful transient overcurrents. In general, a smooth connection is achieved when the voltages of the systems to be connected coincide in magnitude, phase and the frequency. In microgrid applications, synchronization before reconnection is usually accomplished by detecting the voltage magnitude, phase and frequency difference between the main grid and the microgrid [3, 4].

This problem has been tackled in various papers in the past. In all these works, the importance of implementing a fast and accurate grid voltage synchronization algorithm has been highlighted. Reference [3] presents a control method based on the adaptation of a dual second order generalized integrator based on a frequency locked loop (DSOGI-FLL). The algorithm is implemented in a grid-connected power converter that acts as an intelligent connection agent (ICA). The presence of many voltage source converters, however, may deteriorate its effectiveness. Reference [4] proposes an active synchronizing control scheme that also adopts a central based coordinated control for multiple DGs. In [5], the synchronization control system sends remote compensator signals from the substation to the speed and voltage regulators of a hydro plant, achieving safe reconnection. The phase coincidence is addressed only by means of a synchronism check relay that blocks the reconnection until the phase difference is null. This may delay the transfer for undefined period of time. Reference [6] presents a transfer strategy based on droop control of local microsources providing good results. The algorithm moves the droop equations of the microsources to achieve frequency synchronization and in later stage phase synchronization. However, the second synchronization stage affects the frequency synchronization, while the voltage magnitude coincidence is not addressed. The synchronization system presented in [7] is based on two dual second order generalized integrators (DSOGI) and two stationary reference frames phase locked loop (SRF-PLL) for synchronizing the grid voltage with the capacitor voltage of the converter filter. Besides the requirement of rather complex components, the main consideration here is that during the synchronization process, the droop control is not employed and none of its functions are carried out.

Reference [8] presents the autonomous control for smooth transitioning between the two modes. The DGs operate as current controlled sources using proportional resonant (PR) regulators for frequency and phase angle regulation while a predictive voltage controller in each DG ensures voltage control across the microgrid. Reference [9] investigates the transient oscillation during the transition between modes and presents a modified PQ control method for their amelioration. Accordingly, the output of the PQ controller of the DGs synchronously tracks the output of a V/f controller of the DG voltage forming unit to pass from islanded to grid-connected mode. In both approaches [8, 9], constant communication between the islanded and the main grid is needed. In [10], transitioning is based on two separate synchronization compensators that immediately affect real and reactive power control loops. Inputs to these synchronization compensators are the magnitude and phase of the two voltage phasors of the microgrid and the main grid. The immediate effect on the droop loops may lead to instability, in case of large differences in angle and magnitude between the two systems. The technique of [11] follows the same reasoning by implementing the synchronization algorithm in the secondary control level that affects the set points of the droop control loops. Reference [12] describes the transition process of a real microgrid between modes. The voltage source unit gradually lowers the microgrid frequency, in order to reduce the phase difference. When the breaker closes, a frequency spike is observed.

In this paper, a control strategy based on local agents that are responsible for the seamless reconnection of the microgrid to the upstream grid is presented. The proposed scheme has the flexibility and reliability of distributed controller schemes. The agent of the microgrid central switch (MCS) manages the status of the switch, while exchanging information with the inverter agents of the microsources when needed. The inverter agents are responsible for the synchronization process and also manage the control strategy of the inverters depending on the microgrid operation state. In case of failure of an inverter delivering a signal to the MCS agent, synchronization is not jeopardized; it can only be slowed down. The synchronization process is based on employing two phase locked loops (PLLs) and three simple proportional-integral (PI) controllers, whose output are three compensator signals. These signals implement voltage, frequency and phase synchronization by adjusting the control signals of the pulse width modulation (PWM) of the microsource inverters. The proposed strategy is simple to implement, as it is based on the simple PI control without affecting the droop control of the inverters. After the synchronization criteria are met, the MCS closes at a zero-crossing of the voltage waveform, and at the same time, all the agents are informed for the new operating status to switch to the appropriate control strategy. All synchronization criteria are accurately met in a fast and efficient way, as shown by the numerical and laboratory simulations.

2 Agents control strategy

2.1 MCS agent

The MCS ties the point of connection between the microgrid and the upstream distribution system. The interconnection switches are designed to meet grid interconnection standards (IEEE 1547 and UL 1741 for North America) to minimize custom engineering and site-specific approval processes and lower cost [13].

The MCS switching conditions are the following.

1) Microgrid disconnection from the mains

The islanding operation mode can be intentional, e.g. scheduled maintenance, or unintentional, e.g. failure in the upstream network. In both cases, the microgrid switching to islanding operation ensures continuation of supply to critical loads.

2) Microgrid reconnection to the mains

Once islanded, the microgrid can be reconnected to the utility grid. Synchronization of the two grids is necessary before closing the central switch at a voltage zero crossing. Frequency, voltage magnitude and voltage phase need to be accurately matched to prevent transients.

The following sections focus on the microgrid reconnection to the upstream network. The main modules of the MCS agent are shown in Fig. 1. The term agent is used here to describe the software that functions autonomously and continuously, while it has the ability to communicate with other agents.

Fig. 1
figure 1

MCS agent structure

The operation mode detection module is enabled by an external signal that is driven by the microgrid central controller (MGCC), in case of intended islanding/reconnection or an islanding detection method (IDM) in case of unintended islanding and is beyond the scope of this paper.

The decision module provides transfer signals to the transfer module according to the signals exchanged with the islanding detection module and the microsource inverter agents. The transfer module initiates, if necessary, the transfer process by sending the appropriate signal to the MCS. It also sends the inverters of the microsources appropriate signals in order to change their control mode. Note that in case of reconnection, where the synchronization process should be enabled, the decision module exchanges also signals with the inverter agents. This process is described in the next section.

The events record module records the real time data during the transfer process and sends these data for further analysis. After the transfer is complete, a signal will be sent to the decision module, and the agent will prepare itself for the next transfer.

2.2 Microsource inverter agents

This section describes the synchronization process that the inverter agents undertake when a transition from islanded to interconnected mode is required.

Each inverter agent structure is shown in Fig. 2. Two PLLs for detecting phase and frequency of the main network and the microgrid at the point of common coupling (PCC) are employed. The proposed method is integrated into the inverter agents that undertake the synch process, when the appropriate signal from MCS agent is received. It should be noted that the frequency and voltage of a microgrid are determined by multiple generators and loads, so the following process is integrated in all microsource inverters.

Fig. 2
figure 2

Synchronization process that inverter agent undertakes

The proposed process is based on local measurements and consists of two steps. Firstly, the synchronization between frequency and voltage magnitude is achieved and secondly the phase synchronization is accomplished without affecting the first step. Then reclosing is allowed. More details are as follows.

When the microgrid operates in islanded mode, the inverters operate under the following conventional droop equations.

$$\left\{ {\begin{array}{*{20}l} {f = f_{\text{ref}} + k_{\text{p}} (P_{\text{ref}} - P)} \hfill \\ {V = V_{\text{ref}} + k_{\text{q}} (Q_{\text{ref}} - Q)} \hfill \\ \end{array} } \right.$$
(1)

where f ref, V ref, P ref, Q ref are the reference values of frequency, voltage magnitude, active power and reactive power; f, V, P, Q are the measured values of the corresponding electrical parameters; k p, k q are the droop coefficients.

It has to be noted that the reference values of the active and reactive powers are setpoints dictated by the control strategy of each DG or the MGCC.

When the MCS agent decides reclosing, its decision module sends a signal (1) to the inverter agents so that the first step of synchronization starts.

The difference between the microgrid and the grid frequency drives a simple PI controller. The output of the controller is the compensator signal S f that modifies the classical voltage reference of the PWM, as shown in Fig. 3. Similarly, the voltage difference drives a simple PI controller whose output modifies the same PWM sinusoidal signal (Fig. 3). When both the compensator signals reach a steady value and their derivative is zero, the second step of the synchronization process is triggered.

Fig. 3
figure 3

Modified control signals during synchronization

The difference between the microgrid phase and the main grid phase drives a simple PI controller. Its output is the compensator signal S p that changes the phase of the sinusoidal signal of the PWM, as shown in Fig. 3 without affecting the frequency of the microgrid that has been regulated in the previous step. When the compensator signal S p gets a constant value, the phase synchronization is completed. Note that the compensator signals are the same for all agents without immediately affecting the droops and thus the power sharing among the microsources.

Next, an appropriate signal is sent to the MCS agent to inform that the synchronization criteria is met. The decision module of the MCS agent sends simultaneously the appropriate signal (0) to stop the synchronization process and a transfer signal to the transfer module. When reconnection is achieved, the transfer module informs the inverter agents about the new operation status in order to change from voltage control mode to current control mode. The above procedure is shown in Fig. 4.

Fig. 4
figure 4

Transfer process between two operation modes

The opposite procedure can be followed in case of intentional transfer from interconnected to islanded mode. In this case, the P&Q setpoints of Fig. 4 should be first modified, so that there is no power exchange between the grid and the microgrid by means of generation rescheduling or load shedding. Then the transfer process can be activated and the inverter agents can switch control mode.

3 Simulation results

In order to evaluate the proposed scheme, the microgrid of Fig. 5 is used. Two DG interfaces are connected with an AC feeder through their inverters. An RL load and an induction motor are also connected at the same feeder. The MCS is responsible for the operational status of the microgrid. The PI controller gains have been specified by trial and error after extensive iterations in order to ensure the convergence of the controlled variables to the desired values.

Fig. 5
figure 5

Microgrid structure

The system parameters are as follows: DG nominal power is 30 kW; X and R of distribution lines are 0.268 Ω/km and 0.5652 Ω/km, respectively; voltage amplitude and frequency of the AC system are 380 V and 50 Hz; power and capacity of the PL load are 30 kW and 13 kVA; power, voltage amplitude and rotate speed of the induction motor are 4 kW, 400 V and 1450 r/min.

At initial steady state, the microgrid operates in islanded mode. The synchronization process begins at 2 s and is completed at 3.5 s. When the criteria are met, the MCS closes at 3.505 s, when the first zero crossing occurs. Some representative results are presented.

During the islanded operation, the inverter agents operate under droop control mode. Thus, the frequency and voltage of the microgrid may differ slightly from their nominal values. As shown in Fig. 6, the frequency lies at 49.93 Hz during the islanded mode. At 2 s, the inverter agents start the voltage and frequency synchronization after receiving the appropriate signal from the MCS agent. The frequency is restored within 1 s. In Fig. 7, the compensator S f signal is shown. When the compensator signal gets a constant value at 3 s, the frequency is restored as expected. In Fig. 8, the root mean square (RMS) value of the voltage is shown. The voltage during the whole synchronization process and the reconnection at 3.51 s does nοt experience any oscillations or transients and the compensator signal S v remains zero.

Fig. 6
figure 6

Microgrid frequency

Fig. 7
figure 7

Compensator signal S f

Fig. 8
figure 8

Voltage at PCC

The zero derivatives of the compensator signals trigger the second step of phase synchronization without affecting the signals of the first step.

The phase difference between the two voltages of the microgrid and the grid is shown in Fig. 9. At 2 s, the phase difference is around 9 degrees. At 3 s, the phase synch is triggered and the phase difference is eliminated at 3.5 s, as shown in Fig. 10. At 3.5 s, the phase synchronization is achieved and the compensator signal S p triggers (Fig. 11) the decision module of the MCS. At 3.51 s, the microgrid reconnects with the mains seamlessly.

Fig. 9
figure 9

Phase difference before phase synchronization

Fig. 10
figure 10

Phase difference after phase synchronization

Fig. 11
figure 11

Compensator signal S p

As expected, the loads do not experience any oscillations during both the synchronization and reconnection process (Fig. 12).

Fig. 12
figure 12

Absorbed active and reactive powers from loads

4 Hardware setup and results

In this section, the proposed control scheme is evaluated experimentally through control hardware in the loop (CHIL) simulation.

In a CHIL experiment, the hardware under test is a controller, in which the proposed control algorithm is studied while the network is still simulated. The real-time digital simulator (RTDS®) of the National Technical University of Athens (NTUA) laboratory is employed for implementing the control, while the same network topology of Fig. 5 is tested. It is clear that the use of an actual controller and the inherent time delays in the communication may impact the resulting waveforms, however the qualitative comparison between simulation and lab experiment is very satisfactory.

Figures 13 and 14 show the frequency and voltage of the microgrid and the main grid, respectively, during the synchronization process. At 1 s, the first step of the synchronization process begins. The frequency of the islanded microgrid is restored from 49.5 Hz to 50 Hz within 2.2 s, when the signal S f reaches a steady value. The voltage of the islanded microgrid is restored from 214 V to 230 V within 1 s, when the signal S v gets a steady value.

Fig. 13
figure 13

Frequencies during transition-proposed method

Fig. 14
figure 14

Voltage difference during synchronization-proposed method

At 3.2 s, the first step of synch is achieved and the regulation of the phase begins. Figure 15 presents the phase difference during the synchronization mode. At 5 s, the angle difference between the two systems is almost zero and the main breaker closes resulting in a seamless transition from islanded to grid-connected mode.

Fig. 15
figure 15

Phase difference during synchronization

Note that the frequency remains at the desired value even during the phase synchronization from 3 s to 5 s. This is one of the main differences between the proposed synchronization method and the one described in [12]. Reference [12] deals with the transition of a laboratory microgrid from islanded to grid-connected mode. For purposes of qualitative comparison with the previous results, the transition process of [12] is repeated in the next figures. The voltage source unit (this is a battery inverter in the laboratory) monitors the grid voltage waveform and gradually lowers the microgrid frequency at 10 s, in order to reduce the phase difference. It is obvious that the phase synchronization affects the frequency. When the phase difference is minimized, the breaker closes at 45 s resulting in a frequency jump (Figs. 16 and 17).

Fig. 16
figure 16

Frequencies during transition according to [12]

Fig. 17
figure 17

Voltage difference during synchronization in [12]

In [13], frequency and angle synchronization affect each other and during the breaker’s closure, frequency or angle slightly deviates from their desired values. As a result, oscillations or non-desired spikes may happen.

5 Conclusion

In this paper, a seamless transfer control strategy based on local agents is presented. The microgrid can switch from islanded to interconnected mode of operation fast without frequency and voltage oscillations. The agent system consists of the MCS agent and the inverter agents. The MCS agent supervises the operation mode of the microgrid and manages the operation of the switch. The inverter agents are responsible for their operation mode and the synchronization process during the reconnection. The agents exchange information so that the reconnection is seamless. The synchronization control achieves firstly voltage and frequency and then phase synchronization. The compensator signals modify the classical PWM reference signal of the inverters, so that the phase and magnitude difference between both microgrid and grid voltages is minimized by means of three simple PI controllers. The proposed control strategy is tested through simulation and a hardware setup proving satisfying performance.