Multilayer event-based distributed control system for DC microgrids with non-uniform delays and directional communication

Correspondence Ardavan Rahimian, School of Engineering, Ulster University, Newtownabbey BT37 0QB, UK. Email: a.rahimian@ulster.ac.uk Abstract The secondary control layer of microgrids is often modelled as a multi-agent distributed system, coordinated based on consensus protocols. Convergence time of consensus algorithm significantly affects transient stability of microgrids, due to changes in communication topology, switching of distributed generations (DGs), and uncertainty of intermittent energy sources. To minimise convergence time in consensus protocol, this work proposes a multilayer event-based consensus control framework, which is resilient to communication delays and supports plug-and-play (P&P) addition or removal of DGs in DC microgrids of cellular energy systems. A novel bi-layer optimisation algorithm minimises convergence time by selecting an optimal communication topology graph and then adjusts controllers’ parameters. Average consensus is achieved among distributed controllers using an eventbased consensus protocol, considering non-uniform delays between agents. A realisation method has also been introduced using the directional beamforming technique for topology assignment algorithm based on modern telecommunication technologies. Provided feasibility case study has been implemented on a real-time hardware-in-the-loop (HIL) experimental testbed, to validate the performance of the proposed framework for key purposes of voltage stabilisation and balanced power-sharing in DC microgrids.


INTRODUCTION
fulfil the following objectives (1) minimising network traffic, (2) increasing sensors' operating life, and (3) guaranteeing optimal or sub-optimal control performance under communication delays.
To effectively implement such distributed controllers, eventbased transmission mechanisms are suggested in the literature [3,9,10]. For instance, the proposed event-triggered controller [3] effectively reduces the number of network packets, leading to reduced traffic for DAC among agents with sparse and costly wireless communication links. However, event-based control systems are more prone to existing transmission delays and need to be further studied. To solve this problem, several approaches are suggested by other researchers. For instance, in [11], constant link delay was considered to be uniform among all controllers, and albeit theoretically attractive approach, there exist practical constraints, since communication link was assumed to be full-duplex with parallel bi-directional data transfer.
In the existing literature of consensus algorithms for multiagent systems, the asymptotic consensus is mainly achieved within infinite time. In [12], a consensus algorithm other than DAC was considered for linear time-invariant (LTI) systems with noise and delays. Switching and fixed typologies were studied in [13], and random topologies in [14]. In [15,16], external disturbance and input delays were studied. In [3], authors have designed an event-triggered Kalman consensus filter (KCF) for state estimation of distributed agents. The advantage of using event-triggered KCF is to separate the state estimator from the controller and to separate the controller's design from that of the state estimator. Despite the advantage of the easier design principle, this method introduced computational complexities with low convergence times.
In particular, convergence time is an important performance index for distributed controllers operating based on average consensus, and in this work, authors have proposed a novel bi-layer optimisation algorithm to minimise convergence time. Moreover, the proposed method is robust and less computationally expensive in P&P scenarios in comparison to recent works.
In [17], event-based communication was modelled as a selftriggered problem with packet dropouts and communication delays. The computational complexity of the self-triggered control system is nonetheless high, and self-triggered control systems are notably prone to robustness issues in highly uncertain systems, such as microgrids [18]. In [19], authors have proposed a finite time consensus protocol for frequency stabilisation of AC microgrids by adjusting graph gains. This solution works as long as communication topology is optimised in advance and communication delay is a low value. In [20], the central predictive gain scheduling strategy makes event-based, finite-time controllers prone to a single point of failure. A common problem with many other works in this area [21][22][23] is solving finite-time consensus problems in continuous mode rather than in discreteevent mode, which is the main characteristic of existing communication technologies.
There are several important results reported for distributed control of AC microgrids. In [24], authors achieved frequency restoration and active power allocation under time-varying delays with boundaries found via the Lyapunov function for the total system. In [25], a self-consistent method is proposed to maintain power balance from RES in event disconnections in the communication network. In [26], a nonlinear distributed cooperative control scheme is proposed that can regulate the power output of DGs to achieve efficient utilisation of renewable energy in AC microgrids, which ensures meansquare autonomous proportional power-sharing over a nonlinear microgrid system via a sparse cyber network subject to noisy disturbance and limited bandwidth constraints. Similar to [24], authors in [27] designed a cooperate asynchronous control system that excludes Zeno behaviour in the operation of eventtriggered communication. From robustness of mentioned control system to disturbances are analysed in the same authors in [28] and [29]. In [28], the effect of measurement noise is considered, and in [29], noise on communication channels was studied. Despite advances in distributed event-based control in AC microgrids, this subject is still not well established in DC microgrids.
This paper proposes a multilayer event-based consensus control with minimised convergence time, which is also resilient to communication delays, and further supports P&P addition or removal of DGs in DC microgrids. Exchanging information among components is only executed when an event is generated, which efficiently reduces the number of packets generated in sensor-controller-actuator loops. A novel bi-layer optimisation algorithm minimises convergence time by selecting an optimal communication topology graph and adjusts controllers' parameters.
Different datasets can be used for event detection; for example output signals [30,31] or state-feedback signals [32]. Outputbased event generation approach has been deployed in this work, as voltages and currents are only available measurements in DC microgrids. More importantly, communication delays among agents are considered to be non-uniform, which is realistic in a distributed communication scenario. Thus, the main contributions of this work can be summarised as follows: • A novel bi-layer optimisation algorithm to minimise the convergence time of distributed controllers based on event-based average consensus. • A secondary layer controller for DC microgrids, resilient to non-uniform network delays. The proposed control architecture results in fast-voltage recovery by only regulating the output voltage of converters installed on EESs. It is co-designed to tackle the problem of voltage stabilisation and powersharing together.
The remainder of this paper is structured as follows. Section 2 introduces the proposed multilayer control framework. Distributed event-triggered consensus protocol is described in Section 3. In Section 4, the proposed topology assignment algorithm for minimum time convergence is discussed and analysed. Then in Section 5, secondary control layer system for DC microgrids is designed. The provided case study has been implemented on a real-time HIL experimental testbed, to effectively validate the performance of the proposed architecture for voltage stabilisation and balanced power-sharing in the DC microgrids. Experimental results and analysis are discussed in Section 6, and the paper is concluded in Section 7.

FRAMEWORK OVERVIEW
Microgrids consist of DGs such as microturbines and RES. The latter ones, such as photovoltaic (PV) panels and wind turbines, have intermittent availability due to variations of weather conditions. Hence, control systems in a microgrid are usually categorised into three layers to overcome the variations in the availability of DGs: • Primary Layer: This layer is also called the local layer, in which local control loops are operating. Droop control is a commonly used control function in this layer. Power electronic converter controllers are also grouped in this layer. • Secondary Layer: In this control layer, real-time synchronisation tasks between local controllers take place. Control systems in this layer are distributed with neighbouring communication. Consensus protocols, especially distributed average consensus controllers are designed in this layer. Control systems of this layer are mainly designed for voltage or frequency stabilisation, and balanced power-sharing. • Tertiary Layer: Energy management, demand response, and other microgrid management systems are designed in this layer. Usually, the operational speed of control systems in this layer is not real-time, and thus, human interaction for management decisions is considered.
In our proposed framework for DC microgrids, when a new DG is getting online, that is connecting to the network, secondary control systems of DG have to be initialised. Therefore, controllers first seek neighbouring DGs with the required link speed and shortest route. A synchronisation unit in the DG controller is responsible for this task. Then, the unit transmits information of available links to the tertiary layer control system, where a specific bi-layer optimisation algorithm defines the communication graph for all DGs in the microgrid.
This work assumes that each bus has an ESS installed on it and ESS is connected to a microgrid via a bi-directional DC-DC converter. ESS acts as an energy buffer for the corresponding DG installed on the bus, and thus, DG will not get connected to the microgrid directly. This forms the concept of virtual or abstracted DG as BESS on each bus hides (abstracts) dynamics of installed DG. It further simplifies distributed control system design as the dynamic interface of RES will be similar for all buses.
The main optimisation factor is a delay in the communication graph, which directly affects the convergence of consensus protocols. This topology change is critical for maintaining microgrid stability since microgrid power continuity and resiliency must be achieved by minimising communication delays.
After the new communication topology is determined, this information will be sent back to DG's synchronisation unit. For The structure of the tertiary layer topology assignment unit is shown in Figure 1. The process consists of two steps: (1) optimisation of graph topology algorithm based on communication link delays, and (2) computation of tuned parameters for DG controllers. In the next section, the proposed event-triggered consensus protocol is introduced, which forms the basis of the secondary control layer system. Then, the tertiary layer graph optimisation method is discussed, followed by the droop control strategy for mentioned control objectives of the DC microgrid.

EVENT-TRIGGERED AVERAGE CONSENSUS WITH COMMUNICATION DELAYS
Controller agents are connected via a directed graph (,  ) with nodes  = (1, … ,  ), and edges  ⊂  × . (i, j ) ∈  holds if there is a connection from node i to node j . A = [a i j ] ∈ R N ×N is the graph adjacency matrix, where a i j > 0 if (i, j ) ∈ , and a i j = 0 otherwise. d i = ∑ N j =1 a i j represents the weighted degree of controller v i . D = diag{d i } is the degree matrix graph, and L = D − A is the Laplacian matrix graph. A directed graph is connected if there is an undirected path between any pair of vertices.
In this section, after presenting an overview of the proposed framework, some preliminaries on graph theory are given, followed by the proposed event-based consensus protocol for multi-agent systems. It is then shown that the system is inputto-state stable (ISS), by finding the maximum allowed delay.

Average consensus protocol
Considering a continuous-time system of N single integrator agents, classical distributed average consensus protocol in secondary control layer of microgrid architecture is given by: where x is value of interest to be shared among agents, and L i j is communication topology Laplacian matrix. Due to constraints of communication link to transmit continuous-time data streams, we hereby propose the following event-triggered consensus protocol, in which each controller shares its state information at specific event instances: where i j > 0 is communication delay from agent j to agent We assume delay only affects communication between two different agents, . Note that delays between agents are not uniform and can have different values. Increasing , are eventtriggering times and event interval of controller i, respectively. For notation simplicity, let The objective here is to find correct event generation conditions to guarantee the stability of the proposed protocol with time delay. To prove Theorem 3.1, first, it is shown that L has its second smallest eigenvalue at 2 , using Lemma 1: Lemma 1. [33] The Laplacian matrix L of a connected graph is positive semi-definite, that is z T Lz ≥ 0, ∀z ∈ ℝ n . Moreover, z T Lz = 0 if and only if z = a1 n , a ∈ ℝ, and 0 ≤ 2 (L)K n ≤ L, where 2 is the second smallest eigenvalue of L and K n = I n − 1 n 1 n 1 T n .
Now in the proposed Theorem below, we show that DAC protocol is converged to the average of agents' variables under non-uniform communication delays. Theorem 1. Assume a strongly connected directional graph with N agents and consensus protocol defined in (2). Let 0 < i < 1 be a constant design parameter. Given first event generation time at t i 1 = 0, nodes converge to consensus of the average of initial state values under the following event-triggering condition: with convergence rate upper bounded by: Proof. First (t ) is defined as agents disagreement vector using the following substitution ( [34]): . Input values to agents are then derived, using (5): To prove the stability of the proposed event-triggered DAC protocol in (2), the following Lyapunov energy function is employed: with its derivative along the dynamic trajectory (2) as: To simplify Equation (8), let: Therefore Equation (8) becomes: Since ab < a 2 + the following inequality holds: From (3) and (12), we have: where max = max{ 1 , … , n }. In addition, we have: (15) where (13) holds because L is a positive semi-definite matrix, 2a T Lb ≤ a T La + b T Lb, ∀a, b ∈ ℝ n , and a T La ≤ ||L|| ||a|| 2 , ∀a ∈ ℝ n . As a result we have: Considering Lemma 1, (16) holds, therefore: ) This confirms system (2) with triggering condition (3) exponentially gets stabilised because  is connected, and i j is finite. □

Remark:
The proposed event-triggering function is entirely distributed as convergence law is only dependant on the information of the agent's neighbours. Thus, agents do not need any information for global parameters. However, under this condition, communication delay between the agent and its neighbours should be estimated in advance.

Communication delay effect on average consensus
In this section, analysis for the effect of communication delay is provided, where maximum allowable time delay for nodeto-node communication will be derived. Effect of delay with continuous feedback is treated in literature; for example in [13,35]. Here, it is shown the proposed event-based strategy stabilises the average consensus with respect to ISS, assuming the maximum allowed delay is Δ ≥ 0, and the control law will be Following the change of variables in (5): where a is the average of initial state values, a = 1 N ∑ x i (t ). Then we obtain:̇( From the extension of ISS for time-delay systems in [36], we use the following Lemma from [9] to find the attraction region under bounded delay: Time-delay consensus problem of (19) is ISS with regarding to e(t − Δ), then there exists functions ∈ and ∈ such that for all t > 0 and 0 ≤ Δ ≤ From Lemma 2, there exists ∈ and ∈ such that (20) holds. Since an upper bound is enforced for ||e|| by event generation mechanism (3), || (t )|| converges to a ball around origin as long as the maximum allowed delay is 0 It can be shown that size of the ball increases with bound on ||e(t )||, defined by i .

Algebraic connectivity optimisation principles
In the previous section, the necessary event-triggering condition for exponential stability of average consensus protocol has been thoroughly described. However, as mentioned, convergence time can significantly degrade the performance of the controller or destabilise the microgrid. In this section, convergence time is minimised using an optimisation problem for controller agents to achieve consensus in minimal finite time.
As stated in Lemma 1, 2 is the second smallest eigenvalue of L. Besides, Theorem 3.1 has shown in Equation (17) that 2 directly affects the convergence rate of average consensus among agents. Hence, 2 is a very important parameter of the graph among all eigenvalues of the Laplacian matrix, which is also called algebraic connectivity.
The aim of this work is to optimise the communication graph to decrease consensus convergence time. Based on Equation (17), this occurs if the value of algebraic connectivity increases. The following two theorems state the effect of adding and removing a node on algebraic connectivity:

Theorem 2. Let G be a graph with N vertices. Let G + e be an augmented graph obtained by adding an edge e between two vertices in G.
Then eigenvalues of G and G + e are intertwined as follows [37]: If 2 (G ) is a multiple eigenvalue such that 2 (G ) = 2 (G + e), the result of adding an edge does not improve algebraic connectivity. Given that the trace Additionally, we deduce that given a graph with N vertices, the magnitude of i for i ∈ N tends to increase as |E| increases.
Theorem 3. Let G be a graph with N vertices. Let G − e be an augmented graph obtained by removing an edge e between two vertices in G such that removal of an edge does not disconnect the graph. Then eigenvalues of G and G − e are intertwined as follows [38]: We can also deduce that: This implies that 0 ⩽ 2 (G ) − 2 (G − e) ⩽ 2 and that given a graph with N vertices, the magnitude of i for i ∈ N tends to increase as |E| increases.
According to Equation (4), the proposed Lyapunov function V (x) reaches to origin in a finite time, less than the settling time of exponential term (exp(− In [39], the settling time is defined as "the time required for the response curve to reach and stay within a range of certain percentage (usually 5% or 2%) of the final value". For exponentially stable systems, the settling time maps to 4T and 5T , respectively [40], where T is: Equation (26) shows elements of the communication graph that are affecting settling time convergence, that is (1) algebraic connectivity of the graph, and (2) event generator parameter max . To minimise T , a bi-layer optimisation approach is proposed via: 1. Online topology assignment algorithm, which decides optimal communication graph based on highest algebraic connectivity. 2. Distributed tuning of controlling agents by adjusting optimal value for max in Equation (26).
The proposed two-level optimisation approach results in a minimum time event-triggered consensus, which drastically improves the transient response of microgrid in different operational scenarios, such as disconnection of DGs, or contingencies in transmission lines. The following sections describe details of each level of optimisation.

Level 1 online topology optimisation algorithm
Whena new DG is ready to operate, it should first negotiate with servers of the utility company to receive updated communication topology. This requires that the DG controller first obtains the geographical location of DG in the microgrid based on global positioning system (GPS) data, then communicate a new topology. After establishing communication to form a new topology, DG can be connected to a microgrid using circuit breakers. Here, the following cost function is proposed for the tertiary control layer to decide the optimal communication graph:  where || is the cardinality of graph edge set , and i j is the maximum measured delay on a specific communication edge. According to presented consensus stability requirements (i.e. being a connected graph and exposing a stable gain matrix), the topology assignment algorithm must fulfil the following constraints during switching between updated graphs: • There must be a spanning tree in the communication graph after plugging a DG; • DGs must be plugged sequentially to satisfy the uniform boundedness of switching time intervals (i.e. one DG at any time interval). • Non-zero elements of the adjacency matrix A must be bounded by positive constants at each interval.
Implementation details of the proposed topology assignment for tertiary layer control are provided in Algorithm 1. It searches through all feasible topologies with the maximum nodal degree of d max and finds an optimal solution.

Level 2 consensus controller tuning
In the second level of optimisation, the objective is to find the optimal value for max to minimise convergence time defined in Equation (26), and to provide a feasible event-triggered condition in Equation (3). Up to this level, a cost-effective communication graph is selected, and only controllers need to be tuned for parameter i . According to Theorem 3.1, 0 < i < 1, and it directly affects event generation rate, which is limited by the activation time of the medium access control (MAC) layer. Hence, by knowing the maximum allowed value for i , no further optimisation of individual i is required, because they are equal due to accessing the same medium via the same MAC layer. Thus, it is assumed that all controllers share the same i = max . Feasibility of event triggering condition is related to inter-event time, which is lower bounded by access rate of the communication channel. In this regard, we propose a new variable, events per second E ps , which affects max , max i j (i.e. maximum nodeto-node communication delay) and p (i.e. model-related design parameter): where E ps can simply be equal to maximum transferable packets per second for the communication link, assuming the event's data fits the size of one packet. This abstraction for event-packet relation separates the design of the control system from the speed of communication link, which is commonly defined in bits per second (bps). For example, for a 1 kbps channel with a maximum transmission unit (MTU) size of 100 bits, 10 events can be transmitted per second, forcing a data size of 100 bits for each event. Therefore, in this example, E ps = 10. Equations (28) and (26), form a second-level optimisation problem to find the optimal value for max . In the following section, the dynamics of the DC microgrid are modelled according to the proposed event-based control strategy.
The objective of the minimisation process is to find a solution that provides a faster convergence time. It might not be able to find the global solution as there might be several local minimum answers due to the reason that this is a mixed-integer optimisation problem defined both in secondary and tertiary layers of microgrid control. However, based on fact that the bi-layer optimisation algorithm finds graph topology with the lowest algebraic connectivity by having only two neighbour connections, it results in an acceptable optimised solution. Moreover, the scalability requirements of microgrids require a non-exponential computation complexity for any type of optimisation problem, which our proposed algorithm complies with.

SECONDARY CONTROL LAYER CONSENSUS
In this section, the mathematical model of the secondary control layer for the DC microgrid is developed. First, voltage correction terms for control objectives, voltage regulation, and SoC balancing, are introduced, along with related SoC dynamics for batteries. An average consensus protocol for bus voltage regulation is developed, followed by cooperative control for SoC balancing, where a small-signal stability analysis is described.

Modified droop control for battery systems
DC-DC converters operate at a high pulse width modulation (PWM) switching frequency, with at least one switching interval delay (i.e. T s ) in the current control (CC) mode. In Figure 2 Hence, the closed-loop transfer function of local bus voltage of DC microgrid is given by: A first-order model is used for battery per-unit energy level charging and discharging:Ṡ where E max i is the battery charge capacity of the ESS, v i is the bus voltage, and i i is the converter current. It is assumed that converter loss is negligible.
In the secondary control layer, voltage reference (v re f ) for DC-DC converter is set by modified droop control with two correction terms for each bus controller for battery systems, as follows: where v soc i is SoC balancing correction term, and v v i is the bus voltage regulating correction term.
The average consensus protocol of each battery local bus voltage through graph  is: (33) wherev i is local bus voltage estimation. Thus, {v i } are exchanged in the communication network between battery controllers for the local bus voltage average consensus protocol. Global dynamics of distributed average consensus protocol can be given as:̇v =v − Lv (34) which can be realised using the event-based consensus protocol defined in Theorem 3.1.
Applying Laplace transform yields the following transfer function matrix for the average consensus protocol [3]: where V and V are the Laplace transforms of v and v, respectively. For a balanced communication graph with a spanning tree, steady-state gain of average consensus protocol is given by averaging matrix: Final value theorem shows that for a vector of step inputs, elements of x(t ) converge to the global average of steady-state values v ss : To maintain the average local bus voltage of the battery at rated value v mg " a conventional proportional-integral (PI) controller is utilised. Local bus voltage correction term in (32) is then computed as: where H i is PI controller, k̄v Pi and k̄v Ii are proportional and integral PI gains, respectively. This PI controller regulates the average value of local bus voltages of DC-DC converter output of the battery to rated microgrid voltage. Hence, bus voltage offset from primary droop control is compensated. Another consensus control balances the SoC level among batteries. Data of {SoC i } are exchanged between neighbouring ESSs. Correction term v b 2i in (5) is defined as: where k SoC Pi is the control gain of SoC cooperative balancing control.

Small signal stability analysis
Output currents of ES converters are derived from multiplying bus voltages with bus admittance matrix, constructed based on line and load impedance values: Total SoC level dynamics can be summarised in vector form based on (31): Based on Equations (32), (38), (39), and (41), the total multivariable form of closed-loop secondary and primary control system dynamics can be described as follows: where G avg is the transfer function of voltage average consensus protocol, v mg is the nominal voltage, Y net is the admittance matrix, and I N is an N × N identity matrix.
To analyse the stability of the dynamics in (42), it is assumed that the reference voltage is given as: where 1 N ∈ ℝ N ×1 is the vector with all the elements equal to one. Using the final value theorem of Laplace transform, steady-state values of total microgrid dynamics are derived. By defining the steady-state total bus voltage vector, v ss , the final value is:  Based on the work in [6], it can be shown that: The final steady state value ∶ ⟨v ss ⟩ = v mg (47)

EXPERIMENTAL RESULTS: ANALYSIS AND DISCUSSION
A feasibility case study for DC microgrid, based on IEEE 5 Bus reference, has been appropriately selected for performance evaluation of consensus-based controller, and P&P topology switching algorithm. Values of interest for a consensus problem in the microgrid are (1) average bus voltage, and (2) average SoC level of ESSs (per-unit). The developed experimental setup is shown in Figure 3. It consists of dSPACE SCALEXIO real-time simulator for HIL simulation of DC microgrid, dSPACE MicroLabBox for real-time simulation of communication links using TrueTime network modelling framework, and developed multi-agent embedded controllers based on Arduino boards with corresponding signal conditioning interface circuits. Controllers that support WiFi communication protocol, have also been connected to the real-time microgrid simulator, dSPACE SCALEXIO. Moreover, the proposed strategy has been developed using digital signal processing (DSP) instructions of ARM Cortex-M0+, and model-based implementation and measurements have been carried out using MAT-LAB/Simulink and publish/subscribe communication model, respectively.
Multiple subscribers can listen for a predetermined topic, and also multiple publishers can publish new data on certain topics. In Table 1, the proposed controller has also been compared with   Figure 4 presents the DC microgrid structure employed in the deployed case study. The microgrid includes one storage on each bus. The nominal operating voltage of the microgrid is 380 V±5%, as most industrial microgrids use this nominal DC voltage, especially data centers [45]. 30 kWh (78.947 Ah) batteries are installed at all buses as ESSs of the microgrid. Constant power loads are assumed in the experiment. Thus, there is an internal controller to assure constant power is absorbed from the microgrid. Values for constant power loads are 150 W for buses 1 to 3, and 50 W for buses 4 and 5, leading to the total power consumption of 550 W. The initial energy level of storage systems is 50% of their capacity. Other parameters used in the experimental analysis, such as controller gains, are shown in Table 2. DG dynamics are abstracted by the corresponding ESS that buffers generated energy. With this assumption, the proposed distributed controller becomes agnostic to the size and dynamics of installed DGs on buses.

DC microgrid configuration
As reference in the experimental setup, DGs have a nominal rating of 100 W, which supplies 500 W to the microgrid in total.

Microgrid operation analysis
The experiment has been conducted for 80 s to show the dynamic response of the whole system in a short time frame in two scenarios. In the first scenario, Scenario A, load on all buses switches from 0% to 100% in steps of 20% every 20 s. The average communication delay between distributed controllers is 100 ms. In the second scenario, Scenario B, there are time-varying loads installed on buses, and the average communication delay between controllers is 200 ms. Communication graph also switches from graph according to Figure 4 every 20 s. Communication delay between agents is a random Gaussian process. In Table 3, the value for communication delay in both simulation scenarios are provided. Figures 5 and 10 show bus voltages are stabilised with less than 2% deviation, and consensus controllers are further converged in each step, along with the average consensus value shown in Figures 6 and 11 for both scenarios. It can be seen that voltage is stabilised around nominal 380 V of microgrid, and destabilising effect of addition or removal of DGs is mitigated. A balanced per-unit energy level is also achieved, as shown in Figures 7 and 8 for scenario A and Figures 12 and 13 for scenario B in each step. When DG is in a disconnected state,   When DG is in the disconnected state, consensus voltage is reset to the nominal voltage of the microgrid; however, after DG is added into the microgrid, the corresponding ESS controller cooperatively works with other controllers to reach an average voltage consensus value.  Proposal for topology assignment realisation: Beamforming networks for microgrids In this section, after analysing experimental results, a technique for the effective realisation of the topology assignment algorithm is briefly introduced, which has the potential to be deployed further in a microgrid with distributed controllers. This concept is based on directional communication links and beamforming techniques, developed for next-generation wireless and telecommunication infrastructures. Directional links can be summarised as a group of communication technologies, operating based on directional antennas and feeding subsystems. There are many advantages associated with the utilisation of such radio links over omnidirectional systems, including (1) lower interference with other nodes, (2) improved spatial reuse and spectrum efficiency, (3) longer transmission range allowing DGs far from each other to communicate, and (4) lower power requirement and consumption, due to the inverse proportion of minimum transmission power to antenna gains.
In this regard, beamforming methods, as an effective approach to introduce an extra layer of control over transmission and propagation of signals, can be further employed to generate distinct radio beams with significant gains, to accommodate desired directional transmission in wireless sensor networks (WSNs), and to realise proposed topology assignment algorithm [46,47]. This would result in transmission being only carried out in desired directions, which could significantly reduce contention and traffic in the channel. Once the decision is made on network topology, the beamforming-aided system updates the communication core in the microgrid among DG controllers.
The recently proposed IEEE 802.11ac wireless local area network (WLAN) standard has adopted beamforming technology for the implementation of directional radio links. This can be further integrated as part of practical system design and performance evaluation of studied DC microgrid. In the following, three different beamforming methods are discussed and compared in terms of transmission gain. In particular, the gain parameter is chosen for comparison, as it has a direct effect on link capacity. Increased capacity obtained by directional links reduces transmission delay to a great extent. Different types of beamforming methods can be briefly described as [48]: • Switched-beam systems: A fixed and pre-defined set of weights are applied to different antenna elements, to generate a uniform set of radio beams in terms of magnitude and phase values, to have control over electrical properties at each element of the array, and to further conduct electronic beam steering for the realisation of directional transmission. Moreover, when both transmitter (Tx) and receiver (Rx) are aware of the direction of transmission towards each other, transmission gain can be modelled by G d = G t × G r = K 2 , where G t and G r are directional gains of Tx and Rx, respectively, and K is the number of elements at either end of the radio link [49].
• Adaptive array systems: Unlike the previous case, they adapt their weights to maximise the resulting signal-to-noise ratio (SNR), which helps to cope with multipath phenomena by adaptively changing radiation patterns. Although this comes at expense of added cost and complexity. Transmission gain can also be expressed as G a = (2 [48]. • MIMO links: A multiple-input multiple-output (MIMO) link utilises digital adaptive arrays at both ends of the radio link, to provide spatial multiplexing and diversity, to increase the capacity of the link, and to further generate multiple independent data streams. Besides, produced gain provides an increase in Shannon link capacity C, which is given by Equation [48]: ( is the average SNR at any receiver antenna).
Hence, deployment of beamforming technology for event transmission will: (1) reduce transmission delay, as radio link is only established when the event is generated; (2) establish a deterministic communication behavior (rather than a stochastic one) that significantly increases the reliability of NCS; (3) increase stability region of an event-triggered control strategy that is typically prone to event transmission delay.

CONCLUSION
This work has proposed a multilayer cooperative event-based control for DC microgrids, which is resilient to communication delays, and further supports P&P addition or removal of DGs. It has been shown that convergence time is reduced using the bi-layer optimisation approach. Average consensus is achieved among distributed controllers using the developed event-based protocol, considering non-uniform delays. Moreover, a practical case study using the HIL simulation testbed has validated the performance of the proposed controller for voltage stabilisation, as well as balanced power-sharing in DC microgrids. Besides, the feasibility of beamforming technology and its potential for future integration in IoT-centric aspects of microgrids have been discussed. Experimental results confirmed that microgrid could be stabilised although communication network has large delays and data are transmitted in an event-based approach. Moreover, the proposed topology assignment algorithm was able to maintain connectivity of distributed controllers in event of addition or removal of DGs from the microgrid. This is very important as it forms the basis for the P&P operation of the microgrid due to the intermittent nature of RES.
For future extension of this work, artificial intelligence (AI)driven control systems can be employed to improve the efficiency of the proposed bi-layer topology assignment framework, along with its coordination with the real-time secondary control model. Graph optimisation problems can also be solved using machine learning methods. Furthermore, it is recom-mended to use a switching model for a bi-directional DC-DC converter, which provides more realistic results compared to the simplified average model.

CONFLICT OF INTEREST
No conflict of interest has been declared by the authors.

DATA AVAILABILITY STATEMENT
The data that support the findings of this study are available from the corresponding author upon reasonable request.

NOMENCLATURE
L i j Elements of the Laplacian matrix for communication graph.
i ith eigenvalue of the Laplacian matrix. max Maximum value of distributed event generators.