Next Article in Journal / Special Issue
Optimization of the Pick-Up and Delivery Technology in a Selected Company: A Case Study
Previous Article in Journal
Accurate Numerical Treatment on a Stochastic SIR Epidemic Model with Optimal Control Strategy
Previous Article in Special Issue
Distribution Path Optimization by an Improved Genetic Algorithm Combined with a Divide-and-Conquer Strategy
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:

Demonstration of Resilient Microgrid with Real-Time Co-Simulation and Programmable Loads

Hossam A. Gabbar
Yasser Elsayed
Manir Isham
Abdalrahman Elshora
Abu Bakar Siddique
1 and
Otavio Lopes Alves Esteves
Faculty of Energy Systems and Nuclear Science, Ontario Tech University, 2000 Simcoe St. North, Oshawa, ON L1G0C5, Canada
Faculty of Engineering and Applied Science, Ontario Tech University, 2000 Simcoe St. North, Oshawa, ON L1G0C5, Canada
Author to whom correspondence should be addressed.
Technologies 2022, 10(4), 83;
Submission received: 22 May 2022 / Revised: 2 July 2022 / Accepted: 9 July 2022 / Published: 12 July 2022
(This article belongs to the Special Issue 10th Anniversary of Technologies—Recent Advances and Perspectives)


In recent years, the foment for sustainable and reliable micro energy grid (MEG) systems has increased significantly, aiming mainly to reduce the dependency on fossil fuels, provide low-cost clean energy, lighten the burden, and increase the stability and reliability of the regional electrical grid by having interconnected and centralized clean energy sources, and ensure energy resilience for the population. A resilient energy system typically consists of a system able to control the energy flow effectively by backing up the intermittent output of renewable sources, reducing the effects of the peak demand on the grid side, considering the impact on dispatch and reliability, and providing resilient features to ensure minimum operation interruptions. This paper aims to demonstrate a real-time simulation of a microgrid capable of predicting and ensuring energy lines run correctly to prevent or shorten outages on the grid when it is subject to different disturbances by using energy management with a fail-safe operation and redundant control. In addition, it presents optimized energy solutions to enhance the situational awareness of energy grid operators based on a graphical and interactive user interface. To expand the MEG’s capability, the setup integrates real implemented hardware components with the emulated components based on real-time simulation using OPAL-RT OP4510. Most hardware components are implemented in the lab to be modular, expandable, and flexible for various test scenarios, including fault imitation. They include but are not limited to the power converter, inverter, battery charger controller, relay drivers, programmable AC and DC loads, PLC, and microcontroller-based controller. In addition, the real-time simulation offers a great variety of power sources and energy storage such as wind turbine emulators and flywheels in addition to the physical sources such as solar panels, supercapacitors, and battery packs.

1. Introduction

Increasingly, the world is becoming more dependent on electricity, directly and indirectly. Almost every sector in the globalized world has its process linked to the electric industry. In addition to the conventional use of electricity, an unreliable energy system negatively impacts sectors such as transportation, security, food, health, etc. [1]. For this reason, outages are more than an inconvenience; they seriously threaten community safety, economic stability, and national security [2]. Some factors can significantly impact an energy grid reliability, such as more frequent natural disasters, the current aged energy networks, the asynchrony between energy demand and supply, and the vulnerable energy control system [3].
The rise in the severity and frequency of power outages due to extreme weather conditions has made studying grid resilience crucial. Furthermore, weather events are expected to become more severe due to climate change and global warming in the following years [4]. Nowadays, several reliability indices are used to evaluate the power system performance, such as the System Average Interruption Duration Index (SAIDI), the System Average Interruption Frequency Index (SAIFI), and the Customer Average Interruption Index (CAIDI), among others [5,6]. However, these indices are not long enough to evaluate the whole system because they are focused only on high probability low impact disturbances, and the grid operates passively. They do not account for the primary power outages caused by extreme weather events; consequently, the recovery mechanism is limited to a specific point where the outage occurs [7]. The entire grid reliability is only analyzed when a considerable and broad disruption happens. For that reason, new studies are needed to encompass the grid reliability to deal with both the impact caused by extreme weather and the fact that the current energy grid is aging and overdue for an upgrade [8].
Additionally, with technological advances, smart grids are expected to spread in the following years, consequently resulting in intelligent homes. This scenario means that basically, everything in a house will need electricity, such as turning on or off the heating, cooling, doors, windows, everything, resulting in a society more connected and more dependent on electricity than ever [9]. The same happens with businesses and other buildings that have their daily activity linked directly to electricity use. This interconnectedness means that every sector is negatively affected when part of the grid needs to be repaired [10]. That is why it is important to design resilient energy systems; to prevent power disruptions or restore electricity quickly if an outage occurs [11]. Additionally, the increase in advanced energy loads, such as smart appliances and electric vehicles, leads to another concern in the electric sector: the volatility and the asynchrony between demand and load, resulting in a struggle to provide a stable energy flow. In most cases, the utility grid needs to be oversized to supply peak demand, even for a short period [12].
Research has shown that the way to improve the resiliency of the energy grid is to invest in microgrids integrated with renewable sources, especially by using a distributed system. Distributed generation has grown considerably all over the world, and this is basically due to the incentives for the use of renewable sources as the key to fighting climate change, as well as the advances in technologies and market expansion, which have increased the viability of the installation of small generators connected directly to the distribution network, as well as the advancement of new technologies and the need for the small power grid in remote places [12]. To be considered a microgrid, a system needs to consist of an energy load and generators with a control capability, which means it can disconnect from the traditional grid and operate autonomously [13]. In other words, a microgrid is generally connected to a utility grid; however, in the case of extreme weather and power outages, it can break off and operate on its own by using a local energy generation and, consequently, keep the load supplied.
According to the U.S. Department of Energy Microgrid Exchange Group, a microgrid can be defined as a group of interconnected loads and distributed energy resources within clearly defined electrical boundaries that act as a single controllable entity concerning the grid, which can be controlled as a grid-connected system or works in an off-grid mode. Different designs of microgrids are being developed to provide reliable energy using emissions-free sources integrated with energy storage systems, with a tendency to increase over time due to the falling cost of renewable energy sources associated with the efforts to replace fossil fuels and the frequent transmission line failures [14].
A lot of research has been conducted regarding the possible scenarios and microgrid benefits. In [15], the author states an overview of the integration of MEG with the existing utility grid and its main problems and points out the most relevant research, including distributed generation, applications with energy converters, management and control, protection, and communications. However, not much is found about the many challenges that must be dealt with. In [16], the author summarizes different approaches and technologies that have been studied to address the complexity and challenges of microgrids, mainly regarding the power quality, which includes energy flow balancing, real-time management, frequency control, efficiency, and economical operation, as well as highlights the importance of focusing on fail-safe control and fault tolerance systems to improve the resiliency in advanced microgrids. In [17], the paper identifies possible controller designs used in existing MEG, including the control system’s challenges, and proposes research systems with fault-tolerant control applied to a hierarchical architecture to enhance the smartness of control systems. More recently, many studies have focused on research and development in the area of fail-safe and resilience techniques for MG [18,19,20]. Due to its multiple functions and many possible solutions proposed in the literature, the design of control systems for MEG is a complex engagement [21].
Since microgrids are typically composed of different technologies and energy physics, power electronics converters are essential components that must be included in the MEG systems to integrate various energy networks, which consist of electronic devices able to convert electric energy from one form to another, such as alternating (AC) and direct current (DC), and also allowing the adjustment in energy voltage, current, and frequency [22]. Additionally, power converters can be used to increase maneuver abilities in hybrid systems, especially with renewable sources, by controlling the extracted power in each source and stabilizing the energy flows between components [23]. For these reasons, researchers are constantly exploring power converters technologies, and topologies to meet the more complex microgrid components integration [24]; however, most of them have some limitations in adapting different energy flows and technologies.
In [25] is presented a multi-input convert to be used in renewable energy applications; however, by using only a unidirectional power flow with limited components and a non-dispatchable current source. In [26], the load can be supplied by different voltage levels prevenient from two sources without circulating current, using the multi-input converter, but it lacks modularity. The proposed converter in [27] has fewer conduction losses, and the load supply can be performed individually or simultaneously from two different sources, which have different voltage–current characteristics with three power switches only; however, the proposed converter can be used only in DC microgrid applications, and the sources cannot transfer the power between them. For this paper, the proposed multi-input converter aims to work in bidirectional power flow capability and exchange the energy between the DC sources with minimum components parts. In addition, it has the modularity feature, so it can easily be adapted to different energy sources and consequently increase the microgrid reliability.
To develop reliable microgrids, it is crucial to focus on research and lab experiments and ensure that existing infrastructure adapts to new technologies. Lab experiments must simulate threats and responses and validate new technologies to help grid operators against outages. Performing experiments also help visualize the impact of climate change and the increasing of sophisticated cyber attackers to enhance the electric grid. One way to do this is by performing real-time simulations, which consists of testing computer modeling and small-scale energy system with real-life input and output. OPAL-RT Technologies is the leading developer of open real-time digital simulators and hardware in the loop testing equipment in the energy sector. OPAL-RT can be used to design, test, and optimize control and protection systems for power grids, power electronics, etc. In addition, the RT-LAB, core OPAL-RT software, enables users to develop models suitable for real-time simulation. RT-LAB models are fully integrated with MATLAB/Simulink [28]. Simulink, developed by MathWorks, is data-flow graphical programming software for modeling, simulating, and analyzing dynamic systems. It supports simulation, automatic code generation, continuous tests, and verification of embedded systems. Integrated with MATLAB, it can incorporate MATLAB algorithms into models and export simulation results to MATLAB for further analysis [29].
This paper aims to introduce an experimental platform for a micro energy grid with unique merits such as having sizable and extensible AC and DC loads, hybrid power and energy storage sources through real-time co-simulation, and a redundant control system for enabling the fail-safe and resilient control to the MEG. A sizeable load is considered the first merit and is developed through an array of relays to dynamically change the arrangement of series and parallel connections between loads to determine the designated load value, which is applicable for AC and DC loads, including capacitive, inductive, and resistive load types. The second merit is combining a real-time simulation to emulate power and energy sources that are impracticable to be considered in lab sizes, e.g., wind turbines as a power source and flywheels as energy storage. The real-time simulation is designed based on OPAL-RT simulator OP4510 to connect the real-time hardware signals with the Simulink models. The signals that could be manipulated and connected are input signals from sensors and switches, while output signals like relaying simulation output signals are used to activate and run actuators, e.g., motors. The third merit is the redundant control system which utilizes two controllers: the first is based on a microcontroller array, and the second is based on a PLC controller aiming to back up each other and maintain the system availability.
The paper is outlined starting with the introduction section, followed by Section 2 presenting the design and co-simulation of the microgrid, and introduces the proposed microgrid’s design and structure, highlighting the proposed system innovation. Section 3 demonstrates the testing and validation. Section 4 shows the resiliency, fail-safe control, and fault-tolerant capacity of the proposed microgrid. Finally, Section 5 concludes the work.

2. Design and Co-Simulation of Microgrid

The MEG consists of three main components: power sources, controllers, and energy loads. Therefore, it is possible to develop hybrid energy systems by combing different components technologies with hardware and emulators subsystems. The main features of the microgrid proposed in this paper consist of:
  • Resiliency technique based on redundant control between microcontroller and PLCs;
  • Hybrid energy sources, i.e., PV, utility grid, and energy storage system (battery bank);
  • Programmable DC load and AC load based on relay control and load management;
  • Hybrid power bus topologies, i.e., DC and AC networks;
  • Master–slave networking topology between master and slave PLCs (1211C and 1214C CPUs).
The system schematic proposed in this paper consists of a microgrid with an interconnected power system, including physical sources, such as the utility grid and a solar panel, and emulated power sources, such as a wind turbine, using a real-time simulator. In addition, the system includes energy storage systems, physically and simulated, such as battery bank and flywheel, respectively. Furthermore, the system has a redundant control system based on microcontrollers and PLCs, as well as a dynamic load system, which consists of an AC and DC relay controlled sizable load. The following subsections elaborate on the system structure, including system components and parameters and the co-simulator based on Opal-RT OP4510.

2.1. Microgrid Structure and Resources

The structure of the proposed microgrid is shown in Figure 1. The system consists of AC and DC load, controllers, and power sources, including PV panels, emulated wind turbines, and flywheels based on real-time simulation, battery bank, and supercapacitors. Due to the complexity of using actual wind turbine and flywheel systems on a small scale for laboratory purposes, both approaches are emulated by using real-time simulations, which mimic the actual behavior of these technologies. The wind turbine and flywheel emulators using MATLAB/Simulink and testing using an OPAL-RT real-time simulator.
Regarding the energy loads, the system includes AC and DC programmable loads by changing the series and parallel arrangement of the loads using a bank of relays controlled by microcontroller-based relay drivers. In addition, the controller can insert or withdraw some loads based on the system capacity limit or according to the user’s request. Figure 1 shows two types of power sources: physical power sources such as PV and the utility grid are highlighted in dark solid blue and emulated power sources such as wind emulators are highlighted in dark blue with a yellow border. Additionally, it shows two types of energy sources: physical energy sources such as supercapacitor and battery pack are highlighted in green and emulated energy sources such as emulated flywheel are highlighted in green and yellow border. The figure shows the bus and energy management controllers in the middle. In addition, the co-simulation based on OPAL-RT (OP4510) is connected between the hardware and simulation Simulink for cooperating between the emulated components, called emulated plant, e.g., flywheel or wind turbine, and the hardware components of the systems.
Table 1 lists the system components describing their types and parameters, stating the physical and emulated power sources, energy storage, AC and DC loads, converter, inverter, and real-time simulator. It shows each component’s capacity and limits, voltage, input, and output parameters.

2.2. Circuit Design

Figure 2 depicts the schematic of the MEG circuitry, including relay array and microcontrollers, PLCs, inverter, converter interfaces, and dynamic loads. Since the system has been designed in the lab and consists of modular sectors, i.e., controlling units, signal acquisition boards, inverter, and power converter circuits, it makes easy maintenance and upgrading flexibility possible. Regarding the schematic details, the system consists of relay driver boards for driving the variable DC and AC loads, a variable capacitor for power factor correction, a charging controller of the battery pack, sensor boards for adapting the sensors’ readings with the acceptable limits of microcontrollers, Arduino boards, communication devices for TCP ethernet connections, Modbus connectivity, pure sine wave inverter, bidirectional and multi-input power converter, and the PLC controllers in master-to-slave topology. Additionally, the system provides hybrid AC and DC bus systems that can feed different loads.

2.3. Fail-Safe and Resiliency Design of Microgrid

The concept of a resilient, intelligent, and effective microgrid brings forth promising enhancements for the current energy scenario without the necessity of redesigning the existed transmission lines, increasing the ability to integrate different types of energy demand with advanced energy storage systems, and with a high share of distributed power generation from renewable energy sources. However, as the diversity of distributed generators and energy load increases, the complexity of operating, controlling, and monitoring all the nodes within the system to maintain the power flow stability increases. Therefore, in addition to a myriad of benefits that a theoretical MEG can provide, there are some challenges that an effective energy management system needs to bear to become reliable [30].

2.3.1. Fail-Safe Algorithm

An essential factor that impacts the power quality is the ability to smoothly switch between energy sources and controllable loads that become undetectable for emergency loads. The necessity to change between the energy source surge for different reasons, mainly due to problems on the transmission side, such as climate destruction or utility grid maintenance, resulting in the necessity of switching between the grid-tied and islanded mode. This transition needs to be smooth enough to avoid or cause a less possible interruption in the energy supply. When it is necessary to change to an island mode, the energy management needs to identify a better scenario to meet the energy demands, activating the energy storage system and auxiliary generators.
This mechanism is commonly performed by using electric actuates, which require a constant energy source to operate and that can identify power loss in the system and drive actuators to a predetermined safe position to maintain the energy supply for the system [31,32]. Figure 3 charts the logic flow of the fail-safe algorithm that guarantees the balance between load demand and available power source capacity by monitoring the status of loads and sources. It calls for a fail-safe routine to detect a change in any contact’s position by calculating the load demand and source capacity smartly based on current statuses and checking the power availability to fulfil the request load demand. If there is plenty of power to satisfy the loads, it updates the system accordingly. However, if there is a power shortage, it calculates for emergence loads. Then, if the amount of available power sources can satisfy the emergency loads, it activates the emergency loads only. Or, it loads the previous safe settings of loads and sources.

2.3.2. The Resiliency of the Microgrid

Figure 4 demonstrates the resilient design of the microgrid by showing the remote access ability to monitor, control, and perform maintenance to the microgrid by using the modbus-based communication between two PLC controllers. This way, the microgrid can be accessed from anywhere without having operators on site. In addition, the redundant control topology between PLC and microcontrollers maintains the microgrid secured when one controller goes down. Thanks to the firm and safe control algorithm, the microgrid can simultaneously be commanded from both sides.

2.4. Fault-Tolerant Control of Microgrid

The concept of fault-tolerant power systems consists of a technique in which the energy system can ensure continuous and uninterrupted functionality. One of the requirements for a resilient system is to avoid outages. The system must be immune to single or multiple failures in the primary energy supply, which is made by developing architectures with backup and redundancy power sources.
Fault-tolerant control can be classified into active management and passive control. Passive control is widely used due to its robustness. Prior knowledge of possible faults is required for such control that may alter the system’s stability. Due to those faults, the elements installed, such as consumers and subsystem components, might affect their fundamental performance. Therefore, fault tolerance is required to provide the continuity of the microgrid functionality, and the following techniques can achieve it:
  • Fault detection: it consists of the appearance and detection of possible faults within the microgrid system.
  • Recovery: it means the replacement of the fault states with a particular state. It consists of two mechanisms:
    Fault management: fault state needs to be eliminated to clear the erroneous state of the microgrid.
    Fault handling: diagnosis, isolation, reconfiguration, and reset are required to resolve the fault.
This experimental work, stated in Figure 5, uses a fault tolerance algorithm based on PLC and relays logic control. PLC scans the loads, power sources, and energy storage statuses by reading the relays contacts statuses. Then, it checks the type of faults; if it is related to load, it isolates the faulty load(s), but if it is related to source(s), it isolates that source. Then, it calculates balanced load demands and power source generation. Ultimately, it activates and deactivates load(s) accordingly. In other words, it carries out a corrective action based on balancing the demanded load with the available power after isolating the faulty source(s) and or load. The main features of the proposed control are:
  • Regulating microgrid voltages considering faults within the supplies and loads.
  • The control strategy is robust against those faults, disturbances, and harmonics as changing the controller structure is not required like the existing controller. Therefore, even when some part of the system fails due to fault conditions, the proposed controller enables the continuity of the safe operation of the microgrid and thus increases the system’s reliability.
  • Finally, two case scenarios have been designed, the controller has been implemented in hardware to demonstrate its performance, and the results are described.

2.5. Microgrid Control

The redundant control technique has been designed based on three microcontrollers and two PLC controllers connected based on master-to-slave topology. Figure 6 shows the design of the microgrid control system that has been driven redundantly by microcontrollers and PLC, meaning when one controller is down, the other takes over the control to increase the reliability of the MEG. In addition, the system may receive commands from any of them to maintain a fail-safe system. Additionally, by applying master-to-slave control, one PLC works as a master controller (remote) that can send commands to the slave controller (local) to enable remote access to the system from anywhere. In addition to the remote access, the system can monitor all metrics, faults, and measurements of the system that can be used in analysis work for concluding and forecasting purposes. The figure also shows the interconnected system components, including the connection between the master PLC and slave PLC and the HMI screen connected to the master controller as a user interface to the control system. In addition, it shows the ethernet communication based on eight ports ethernet switch and how the two ways controllers, Arduino-based and PLC-based controllers can share the responsibility of controlling loads.

2.6. Co-Simulation Based on OPAL-RT

Real-time simulation is a technique used to mimic and analyze the system performance at the same rate as the actual physical system using computer modelling. Real-time simulations are used widely in several engineering fields and can be configured in hardware-in-the-loop simulations by testing controllers using real-life conditions.
OPAL-RT Technologies is the leading developer of open real-time digital simulators and hardware in the loop testing equipment in the energy sector. Figure 7 depicts the outstanding features of OPAL-RT (Model OP4510), which include 32 channels of digital inputs (DIs), 32 channels of digital outputs (DOs), and 16 channels of analog inputs (AIs), and 16 channels of analog outputs (AOs). These features allow the MEG system to emulate complex subsystems, such as flywheels, wind turbines, and nuclear reactors, which are unlikely to be hosted indoor, e.g., on a lab scale. In addition, OPAL-RT enables interfacing with external world devices, including switches, relays, motors, and sensors. So, these capabilities of OPAL-RT OP4510 have been utilized to process all the digital inputs from the user, such as the switches and feedback signals that relays’ contacts have relaid. Furthermore, analog inputs from measurement devices and sensors such as voltages and currents, and battery temperature, are transferred from hardware to the Simulink model by using OPAL-RT to be processed. Similarly, the generating outputs from the Simulink model are converted into physical signals to either be displayed on scopes or be used to switch actuators on and off or control signals that drive the power switches in controller and converter devices.

2.7. Experimental Setup of MEG

Based on the schematic design of the MEG circuitry described above, the experimental setup of the microgrid is pictured in Figure 8. It shows the integration of multiple power sources, including the grid, PV panels, battery pack, and supercapacitors in addition to the other emulated power and energy sources by OPAL-RT co-simulation. The figure also shows the redundant control system consists of a redundancy system including three microcontroller boards and two PLCs.
The setup provides two common power buses, AC and DC buses, for supplying different types of loads, which are sizable programmatically based on relay control logic. The load can be decided manually by switching on and off any load according to user demands. Additionally, it can be set automatically by selecting based on the total amount of load the user requested. It is important to highlight one crucial contribution that, for any load mode control, restrictions of balancing between the available power source and the requested loads can be selected by considering the priority of emergency loads according to a predefined plan.

2.8. Design of the Multi-Input Converter

The proposed multi-input converter is shown in Figure 9. The system is projected to charge the battery bank from DC-link or PV panel and discharge with the PV panel in the DC link to supply the AC and DC loads. The battery is used as an energy storage device with high energy density, and the PV is used as a renewable energy source that will reduce the supply from the grid. The converter consists of six MOSFETs, two inductors, and one capacitor, as shown in Figure 9. The design can be modular by adding two power switches and one inductor to combine the switching leg to add more renewable energy sources or energy storage devices with high power density such as supercapacitors. Table 2 shows the equations used to calculate the minimum values of inductors L1 and L2, and Table 3 shows the design specifications of the proposed converter.

2.8.1. Converter Control

The control strategy was implemented using the proportional–integral (PI) controller; therefore, the system’s parameters can be adjusted easily by adjusting the PI gains. Flexibility and easy implementation are the main advantages of the PI controller. The error between the output voltage and the reference voltage is minimized using the PI controller, as shown in Figure 10, to generate the desired duty ratio for the pulses of the MOSFETs in the different operation modes. To make the system underdamped, the integral coefficient is regulated to be KI = 0.3, and the steady-state error and overshoot are minimized by controlling the proportional coefficient to be Kp = 0.001.

2.8.2. Operation Modes of the Converter

The proposed converter, presented in Figure 9, works in four different operation modes, as we will discuss later to transfer the power between the DC link and the battery bank, discharge from the PV panel and battery bank simultaneously, and exchange the energy between the PV panel and battery bank. The four operating modes of the converter are:

Mode 3: Battery Bank and PV Panel

In mode 3, the battery bank can be charged from the PV panel to extend the lifetime of the batteries during the peak hours and in sunny conditions. The PV panel work in buck operation mode to charge the battery bank, as shown in Equation (13), using the switches S3, S5, and S6.
V B T = T 1 T s   ×   V P V = D   ×   V P V
Where   T 1 = L 2 Δ I L V B t ,   and   D = T 1 T s
The switching sequence of the power switches in the three time intervals of the previous operation modes is summarized in Table 4.

3. Testing and Validation

Table 6 summarizes the system’s preliminary test and validation scenarios, which examine the proposed Microgrid’s capabilities, function, and features. These tests and validations have been certified in the lab, including grid control, and switching between standalone and grid-connected systems considering islanding mode. In addition, battery charging and discharging control have been tested, showing the safe and accurate battery disconnection at threshold voltage values for a full charge and discharge checkpoints.
The variable AC and DC load based on relay-based logic control has been tested for manual and automatic modes. Bus management control for AC and DC buses has been evaluated at normal and fault conditions. Additionally, protection functions for load, battery pack, and power sources have been validated successfully. The functions of the co-simulation have been validated, showing how OPAL-RT interfaces the hardware components with the Simulink components of the MEG. In addition, the remote access control and data logging for monitoring purposes have been tested. The listed functions below can be considered the whole set of tasks that can be carried out with the proposed MEG setup. However, only some key functions and potential works that have been listed as the merits of the proposed MEG are selected to be presented in this section.
Because the proposed MEG has a redundant control system based on PLCs and microcontrollers, two graphical user interfaces (GUI) have been approached to facilitate the system’s operation. Figure 11 shows the microcontroller-based GUI that includes a power source, battery charging, and load center control. The interface lets the user control the load, power sources, and energy storage. Figure 12 shows the HMI interface of PLC-based control that can carry out the load, power source, energy storage control, and battery charging control.

4. Co-Simulation Based on OPAL-RT

As mentioned above, the main objective of co-simulation is to interface the hardware with the simulation software, the Simulink. To enable a Simulink model, flywheel and wind turbine, to act out like a physical power source or energy storage, the study utilizes OPAL-RT OP4510 with the input mentioned above and output resources to link between the physical signals in the experimental world with the input and output (IOs) data in a Simulink model. In this test scenario, Figure 13 shows Simulink’s and OPAL-RT’s analog inputs and outputs (IOs) interface. It shows how the IOs are connected to tags and variables in the Simulink model. This test scenario shows how the OPAL-RT IOs tags are connected to the simulation.
Figure 14 shows the analogous signals received by OPAL-RT from sensors and measurement devices and generates switching pulses for driving the power switch elements, i.e., MOSFETS in power converters accordingly.

4.1. Testing Fail-Safe Logic

In this test case scenario, according to data listed in Table 7 that tabulates the collected statues of loads and power sources and their weights, the previous status of the loads and sources (On/Off), the total power of loads that were in ON status was 350 W (nodes 4, 5 and 6). Additionally, the full source power was 364 W (nodes 1, 2, and 3).
The fifth column, which represents the new requested statues, shows a total load of 800 w (nodes 4 to 7) when the available power of sources was reported from the previous status to be 264 W (nodes 1 and 3). Therefore, emergency loads are the only ones that be allowed to be energized. As a result, nodes number 4 and 5 that are highlighted in red will be expected to be energized, and node 6 will be turned off to keep the balance between load demand and available power. Figure 15 shows the microgrid setup before and after requesting changes. The supper capacitor has been disconnected due to either fault-tolerant or user request as in Table 7, as shown by the meter reading in Figure 15. Consequently, the intelligent fail-safe algorithms determine that the system can continue running with the emergency loads only that is why AC lamp 1 keeps switched on as an emergency load. However, AC lamp 2 has been switched off as it is a normal load. Finally, after having the supercapacitor removed out of the system, the remaining available power will be sufficient for the demanded power.

4.2. Fail-Safe Testing

4.2.1. Source out of Service

In this scenario, depicted in Figure 16, a fault condition has been considered within the power source to make an overload condition. In this condition, the controller will detect the faulty power source, calculate the total power generation, and compare it with the load demand. If the demand is high, the controller will disconnect some of the loads from the bus connector and only support the emergency load; thus, the system can achieve a continuation.

4.2.2. Short Circuit Condition

In this scenario, depicted in Figure 17, a short circuit condition has been applied within the system to make the system stop by force. A circuit breaker is used within the components and controlled by the PLC to bypass this fault. Whenever a component gets short-circuited, the controller will detect and activate the breaker to bypass this component, and the system will continue its safe operation.
Figure 18 shows the results of the fault-tolerant test on the microgrid experimental setup. The test scenario is that one of the power sources has gotten out of the system due to a breaker’s reaction to a fault. Without fault-tolerant considerations, the system will be totally down. However, the fault-tolerant feature enables the system to disconnect the faulty power source and maintain the system operation. Because the remaining amount of power decreased by losing one of the power sources, the fault-tolerant combines with a fail-safe algorithm to calculate the emergence load. Therefore, the emergency loads are only allowed to continue energized, as shown before and after the fault.

5. Conclusions

This study introduces an experimental platform for a microgrid with distinct features, such as enabling extensible and sizable AC and DC load and combining physical and emulated power sources and storage systems, aiming to increase the system flexibility by utilizing real-time simulation OPAL-RT OP4515. In addition, the design includes fail-safe and resiliency features by developing a redundant control system based on microcontrollers and PLCs. Furthermore, PLC and relay logic control enable the sizing control of the load demand.
The system combines physical and emulated power sources and energy storage, aiming to increase flexibility and diminish the limitations of including different types and sizes of power and energy sources. For example, the wind turbine as a power source and flywheel as energy storages are impractical to incorporate within an indoor experimentation setup. Using co-simulation based on interfacing hardware components with Simulink based on OPAL-RT real-time simulation opened the door to include simulated components to act on the system the way the physical sources acts. Utilizing PLC combined with relay logic control successfully shows the ability to take the system from total failure and shutdown to fail-safe with balanced load demands and power generation. Applying the redundant control by utilizing PLC and microcontrollers increased the system reliability because controllers can cover each other. It only reinforces the benefits that microgrids integrate physical and emulated energy sources with energy management and storage systems to pursue resiliency, fail-safe, and fault-tolerant capabilities.
Furthermore, a complex and long-term transition is necessary to achieve a resilient and reliable energy system, primarily based on renewable energy and high energy efficiency, aiming for sustainability, robustness, and adaptiveness. The paper presents the design of a proposed microgrid that is enriched with various power sources and energy storage along with variable AC and DC loads. This paper demonstrates a complete scenario of real-time simulation based on emulated energy sources to be integrated with the physical sources to complement the ecosystem of the proposed microgrid. Additionally, a novel fault-tolerant and fail-safe algorithm have been implemented and tested. In addition, a redundant control system based on a microcontroller array and PLC has been implemented and employed to provide the proposed microgrid’s resiliency. Testing and validation of the claimed key features and potential merits of the implemented MEG platform yield results that prove the capabilities of reliability based on the redundant control system, fail-safe operation, fault tolerance, and resiliency of the proposed system.

Author Contributions

Conceptualization, All; methodology, H.A.G., Y.E. and M.I.; software, All; validation, All; formal analysis, All; investigation, H.A.G.; resources, All; data curation, All; writing—original draft preparation, All; writing—review and editing, All; visualization, All; supervision, H.A.G.; funding acquisition, H.A.G. All authors have read and agreed to the published version of the manuscript.


This research was funded by NSERC grant number [210320].

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The study did not report any data.


This research is supported by NSERC Discovery Grant. The authors would like to thank members of the Smart Energy Systems Lab (SESL) at Ontario Tech University, Canada for their support.

Conflicts of Interest

The authors declare no conflict of interest.


  1. Bostan, I.; Gheorghe, A.; Dulgheru, V.; Sobor, I.; Bostan, V.; Sochirean, A. Resilient Energy Systems: Wind, Solar, Hydro; Springer: Berlin/Heidelberg, Germany, 2012. [Google Scholar]
  2. Jesse, B.-J.; Heinrichs, H.U.; Kuckshinrichs, W. Adapting the theory of resilience to energy. Energy Sustain. Socie 2019, 9, 27. [Google Scholar] [CrossRef]
  3. Energy Weekly News. EEI Statement on the U.S. Department of Energy’s Energy Grid Reliability Study. Gale Acad. OneFile 2017, 87. Available online: (accessed on 15 April 2022).
  4. Abi-Samra, N.C. One Year Later: Superstorm Sandy Underscores Need for a Resilient Grid. IEEE Spectrum, 4 November 2013. Available online: (accessed on 2 April 2022).
  5. IEEE Std 1366–2003; 1366–2012—IEEE Guide for Electric Power Distribution Reliability Indices. IEEE: Piscataway Township, NJ, USA, 2012.
  6. Roege, P.E.; Collier, Z.A.; Mancillas, J.; McDonagh, J.A.; Linkov, I. Metrics for energy resilience. Energy Policy 2014, 72, 249–256. [Google Scholar] [CrossRef]
  7. Fox, J. Sustainable Electricity—Case Study from Electric Power Companies in North America; Springer: Berlin/Heidelberg, Germany, 2016. [Google Scholar]
  8. Oh, S.; Heo, K.; Jufri, F.H.; Choi, M.; Jung, J. Storm-Induced Power Grid Damage Forecasting Method for Solving Low Probability Event Data. IEEE Access 2021, 9, 20521–20530. [Google Scholar] [CrossRef]
  9. Hatti, M. Smart Energy Empowerment in Smart and Resilient Cities; ICAIRES: Taghit-Bechar, Algeria, 2019. [Google Scholar]
  10. Jasiūnas, P.D.J.M.J. Energy system resilience—A review. Renew. Sustain. Energy Rev. 2021, 150, 111476. [Google Scholar] [CrossRef]
  11. Egert, R.; Daubert, J.; Marsh, S.; Muhlhauser, M. Exploring energy grid resilience: The impact of data, prosumer awareness, and action. Patterns 2021, 2, 100258. [Google Scholar] [CrossRef] [PubMed]
  12. Borlase, S. Smart Grids—Advanced Technologies and Solutions; CRC Press: Boca Raton, FL, USA, 2017. [Google Scholar]
  13. Lantero, A. Department of Energy— Available online: (accessed on 15 April 2022).
  14. Berkeley Lab. Optimizing Energy Resources on the Grid. Grid Integration Group. 2019. Available online: (accessed on 17 June 2014).
  15. Parhizi, S.; Lotfi, H.; Khodaei, A.; Bahramirad, S. State of the Art in Research on Microgrids: A review. IEEE Access 2015, 3, 890–925. [Google Scholar] [CrossRef]
  16. Ortiz, L.; Gonzalez, J.W.; Gutierrez, L.B.; Llanes-Santiago, O. A review on control and fault-tolerant control systems of AC/DC microgrids. Heliyon 2020, 6, e04799. [Google Scholar] [CrossRef] [PubMed]
  17. Estefania, P.; Asier, G.-d.-M.; Andreu, J.; Kortabarria, I.; de Alegria, I.M. General aspects, hierarchical controls and droop methods in microgrids: A review. Renew. Sustain. Energy Rev. 2013, 17, 147–159. [Google Scholar]
  18. Hare, J.; Shi, X.; Gupta, S.; Bazzi, A. Fault diagnostics in smart micro-grids: A survey. Renew. Sustain. Energy Rev. 2016, 60, 1114–1124. [Google Scholar] [CrossRef]
  19. Simani, S.; Castaldi, P. Active actuator fault-tolerant control of a wind turbine. Int. J. Robust Nonlinear Control 2013, 24, 1283–1303. [Google Scholar] [CrossRef] [Green Version]
  20. Aldeen, M.; Saha, S.; Gholami, S. Fault tolerant control of electronically coupled distributed energy. Electr. Power Energy Syst. 2018, 95, 327–340. [Google Scholar]
  21. Bevrani, H.; François, B.; Ise, T. Microgrid Dynamics and Control; Wiley: Hoboken, NJ, USA, 2017. [Google Scholar]
  22. Alvarez-Diazcomas, A.; Lopez, H.; Carrillo-Serrano, R.V.; Rodríguez-Reséndiz, J.; Vazquez, N.; Herrera-Ruiz, G. ANovelIntegrated Topology to Interface Electric Vehicles and Renewable Energies with the Grid. Energies 2019, 12, 4091. [Google Scholar] [CrossRef] [Green Version]
  23. Kumar, G.V.B.; Sarojini, R.K.; Palanisamy, K.; Padmanaban, S.; Holm-Nielsen, J.B. Large Scale Renewable Energy Integration: Issues and Solutions. Energies 2019, 12, 1996. [Google Scholar] [CrossRef] [Green Version]
  24. Ming, W. Power Electronic Converters for Microgrids; IntechOpen: Sankt Veit am Flaum, Croatia, 2021. [Google Scholar]
  25. Dhananjaya, M.; Pattnaik, S. Design and implementation of a multi-input single-output DC-DC covnerter. In Proceedings of the 2019 IEEE International Conference on Sustainable Energy Technologies and Systems, Bhubaneswar, India, 26 February–1 March 2019; pp. 194–199. [Google Scholar]
  26. Athikkal, A.; Sundaramoorthy, K.; Sankar, A. Development and performance analysis of dual-input DC-DC converters for DC microgrid application. IEEJ Trans. Electr. Electron. Eng. 2018, 13, 1034–1043. [Google Scholar] [CrossRef]
  27. Jeong, Y.; Park, J.; Rorrer, R.; Kim, K.; Lee, B. A Novel multi-input and single-output DC/DC converter for small unmanned aerial vehicle. In Proceedings of the IEEE Applied Power Electronics Conference and Exposition (APEC), New Orleans, LA, USA, 15–19 March 2020; pp. 1302–1308. [Google Scholar]
  28. OPAL-RT Technologies. Professional Real Time Digital Simulation Software. OPAL-RT. Available online: (accessed on 5 May 2022).
  29. Sailer, R.; Oliver, H.; Budzisz, Ł. NMLab: A Co-Simulation Framework for Matlab. In Proceedings of the 2010 Second International Conference on Advances in System Simulation (SIMUL), Nice, France, 22–27 August 2010; pp. 152–157. [Google Scholar]
  30. Sabzehgar, R. Overview of Technical Challenges, Available Technologies and Ongoing Developments of AC/DC Microgrids. In Development and Integration of Microgrids; IntechOpen: Sankt Veit am Flaum, Croatia, 2016. [Google Scholar]
  31. Wang, J.; Feng, T.; Wang, B.Q. Fault Tolerant Control of Sensor Faults in Microgrid Inverter Control System. J. Phys. Conf. Ser. 2021, 1993, 012003. [Google Scholar] [CrossRef]
  32. Fields, S. What Are Microgrids and How do They Work? Energysage—Smart Enegy Decidions. Available online: (accessed on 17 January 2019).
Figure 1. Microgrid structure.
Figure 1. Microgrid structure.
Technologies 10 00083 g001
Figure 2. Circuit design.
Figure 2. Circuit design.
Technologies 10 00083 g002
Figure 3. Fail-safe algorithm of the microgrid.
Figure 3. Fail-safe algorithm of the microgrid.
Technologies 10 00083 g003
Figure 4. The resilient design of the microgrid.
Figure 4. The resilient design of the microgrid.
Technologies 10 00083 g004
Figure 5. Fault tolerance algorithm based on PLC and relay control.
Figure 5. Fault tolerance algorithm based on PLC and relay control.
Technologies 10 00083 g005
Figure 6. Microgrid control.
Figure 6. Microgrid control.
Technologies 10 00083 g006
Figure 7. Real-time co-simulation for microgrid applications.
Figure 7. Real-time co-simulation for microgrid applications.
Technologies 10 00083 g007
Figure 8. Microgrid experimental setup.
Figure 8. Microgrid experimental setup.
Technologies 10 00083 g008
Figure 9. The configuration of the multi-input converter with MEG DC sources.
Figure 9. The configuration of the multi-input converter with MEG DC sources.
Technologies 10 00083 g009
Figure 10. Converter controller.
Figure 10. Converter controller.
Technologies 10 00083 g010
Figure 11. Microcontroller control user interface.
Figure 11. Microcontroller control user interface.
Technologies 10 00083 g011
Figure 12. HMI of PLC controller interface.
Figure 12. HMI of PLC controller interface.
Technologies 10 00083 g012
Figure 13. The interfacing between SM-OPAL and the analog IOs of OPAL-RT.
Figure 13. The interfacing between SM-OPAL and the analog IOs of OPAL-RT.
Technologies 10 00083 g013
Figure 14. Input and output analog channels signals in OPAL-RT.
Figure 14. Input and output analog channels signals in OPAL-RT.
Technologies 10 00083 g014
Figure 15. Fail-safe test scenario results on microgrid setup.
Figure 15. Fail-safe test scenario results on microgrid setup.
Technologies 10 00083 g015
Figure 16. (a) Normal operation; (b) operation during fault condition.
Figure 16. (a) Normal operation; (b) operation during fault condition.
Technologies 10 00083 g016
Figure 17. (a) Short circuit fault without FTC; (b) short circuit fault with FTC.
Figure 17. (a) Short circuit fault without FTC; (b) short circuit fault with FTC.
Technologies 10 00083 g017
Figure 18. Fault tolerance test results of the microgrid.
Figure 18. Fault tolerance test results of the microgrid.
Technologies 10 00083 g018
Table 1. MEG system components and parameters.
Table 1. MEG system components and parameters.
ComponentsTypeCapacity (kW)
Utility Gridphysical power sourceunlimited
PVphysical power source1
Wind Turbineemulated power source1
Battery Packphysical energy storage0.576
Supercapacitorphysical energy storage0.5
FlywheelEmulated energy storage1
ConverterDC-DC multi-input3
Inverterpure sine wave1
DC Loadresistive loadup to 3
AC Loadinductive and capacitiveup to 1
Real-Time Co-SimulatorOpal-RT4510
AC Bus110 AC/60 HZ
Relay Array50 SPDT relays 12VDC 10A
Microcontrollers3 Arduino uno R3
PLC controllers2 PLCs S7-1200
CPU 1211C and 1214C
ConverterDC-DC multi-input converter 12VDC-300VDC1
Inverterpure sine wave inverter1
Table 2. Inductance equations for different operation modes.
Table 2. Inductance equations for different operation modes.
L 1 , min ( 1 D ) T s Δ I L 1 V D C - D T s 2 Δ I L V B t V D C ( 1 d 2 ) T s Δ I L
L 2 ,   min - ( 1 D ) T s Δ I L 2 V D C D T s 2 Δ I L V B t V D C ( 1 d 2 ) T s Δ I L
Table 3. Design specifications of the proposed converter.
Table 3. Design specifications of the proposed converter.
Bank Voltage ( V B T )
PV Panel Voltage ( V P V ) DC Link Voltage ( V D C ) Switching Frequency (fs)Inductors ( L 1   and   L 2 ) Capacitor ( C ) Power
Values48 V12 V30 V30 kHz2 mH and
2 mH
100 μF1 kW
Table 4. Modes (1), (2), and (3) switching states.
Table 4. Modes (1), (2), and (3) switching states.
Mode 1 (a)Mode 1 (b)Mode 2Mode 3
T 1 S 2   ,   S 3 S 1   ,   S 4 S 2   ,   S 5 S 3   ,   S 6
T 2 D 4   ,   D 1 D 2   ,   D 3 D 6   ,   D 1 S 3 ,   D 5
T 3 S 1   ,   S 4 S 2   ,   S 3 S 6   ,   S 1 S 3   ,   S 5
Table 5. Switching states in modes (4).
Table 5. Switching states in modes (4).
T 1 T 2 T 3 T 4 T 5
Mode 4 S 2 ,   S 3 ,   S 5 S 2 ,   D 4   ,   S 5 S 2 ,   S 4 ,   S 5 D 1 ,   S 4 ,   D 6 S 1 ,   S 4 ,   S 6
Table 6. Testing and validation parameters.
Table 6. Testing and validation parameters.
Grid side controlGrid control
Islanding control
Load managementAC load control
DC Load control
Power factor correctionPF capacitor control
Battery managementBattery charging
Battery discharging
Bus managementAC bus control
DC bus control
Collecting feedback signals and monitoringReading DC bus data
Reading AC bus data
Reading battery data
PV power source controlMaximum power tracking (PV)
Connection mode
ProtectionBattery protection
DC side Faults
AC side faults
Battery protection
Remote access and monitoringRemote access
Monitoring and data logging
Table 7. Collected status of load and power sources.
Table 7. Collected status of load and power sources.
Node IDTypeDescriptionStatus
1: Connected,
0: Disconnected
1DC sourceBattery pack11144
2DC sourceSupercapacitor10100
3DC sourceConverter from grid11120
4Resistive loadBank of resistors11150
5AC loadAC lamp 111100
6AC loadAC lamp 211100
7AC loadAC inductive load01450
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Gabbar, H.A.; Elsayed, Y.; Isham, M.; Elshora, A.; Siddique, A.B.; Esteves, O.L.A. Demonstration of Resilient Microgrid with Real-Time Co-Simulation and Programmable Loads. Technologies 2022, 10, 83.

AMA Style

Gabbar HA, Elsayed Y, Isham M, Elshora A, Siddique AB, Esteves OLA. Demonstration of Resilient Microgrid with Real-Time Co-Simulation and Programmable Loads. Technologies. 2022; 10(4):83.

Chicago/Turabian Style

Gabbar, Hossam A., Yasser Elsayed, Manir Isham, Abdalrahman Elshora, Abu Bakar Siddique, and Otavio Lopes Alves Esteves. 2022. "Demonstration of Resilient Microgrid with Real-Time Co-Simulation and Programmable Loads" Technologies 10, no. 4: 83.

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop