1. Introduction
The concept of the microgrid [
1] was introduced as a building block of the smart grid of the future, being a solution for reliable interconnection of distributed energy resources (DERs, i.e., generating units, storage units, controllable loads). A microgrid is connected to the host grid through a point of common coupling (PCC) and can operate in both grid-connected mode and islanded mode, as well as switch between these two modes [
2]. In the former mode, the microgrid is a single controllable entity that provides the host grid power exchange and ancillary services. In the latter mode, in absence of the host grid, the microgrid must guarantee a reliable connection among DERs and loads. In this frame, microgrids are innovative entities in distribution networks. However, also existing industrial grids equipped with internal generating units can behave as microgrids if adequately controlled and operated.
In microgrid operation, a key point is the structure of the monitoring and control system, which is typically hierarchical and includes both distributed and centralized functions [
3]. The latter ones are assigned to the energy management system (EMS), which is capable of supervising and managing the microgrid in its various configurations and modes of operation, as well as of cooperating with the host grid [
2,
4]. The EMS pursues various objectives such as microgrid security operation, voltage profile and reactive power optimization, microgrid loss reduction, load balancing and minimization of costs in islanded operation, maximization of the economic profits from power exchange and ancillary services in grid-connected operation.
Validation of an EMS is typically performed by using hardware-in-the-loop (HIL) testing facilities, in which the real-time simulation of the microgrid is interfaced with the actual EMS under validation [
5]. An adequate level of detail in the representation of the microgrid is needed to ensure that simulation results are accurate enough for validation purposes. At the same time, the simulation of the microgrid should be computationally-efficient so as to ensure real-time simulation while avoiding the need for expensive computing machines. Another issue concerns the adoption of adequate tools for the data exchange between the EMS and the real-time simulator of the microgrid. In fact, the data exchange should reliably replicate the communication system and protocol between the EMS and the field (including distributed controllers of lower levels), so as to test the correct timing, response and coordination of all the functions of the EMS.
In this paper, a validation facility of the EMSs for microgrids is presented and used in a practical application. The main advantages of the proposed testing facility are:
the use of standard computers as PCs and the absence of dedicated interface modules, resulting in inexpensive hardware components;
the capability to validate both the control and communication functions of the EMS;
the applicability to microgrids of different types (industrial, commercial, residential), as well as of various dimensions, including large microgrids;
the easiness of changing the microgrid and the EMS under validation by only software modifications of the simulator tasks and of the exchange interface.
As drawbacks, the proposed testing facility presents the need to adapt the software interface between EMS and the field to the EMS under test and the possibility of testing only the EMS functions and not fast acting local controllers of the microgrid such as the protection systems.
The paper is organized as follows. In
Section 2, an overview of the HIL architecture is outlined according to the existing literature, and the peculiar characteristics of the proposed architecture are evidenced in comparison with other architectures. In
Section 3, an overview of the proposed HIL architecture and a description of each component of the validation setup are given, together with the description of the communication structure needed for data exchange between the real-time simulator and the EMS. In
Section 4, the validation facility is used to test a real EMS realized by Schneider Electric in the practical application of an industrial plant that can operate as a microgrid. The performance of the validation facility in terms of computation and communication times is analyzed. Finally, some test results are reported to show the fulfillment of the EMS requirements in monitoring and controlling the industrial microgrid in response to changes of the operating conditions.
2. The Hardware-in-the-Loop Architecture
Various papers in the literature propose HIL architectures to validate components and control systems for electric power systems and, in particular, for microgrids.
In [
5], a real-time development platform for simulation studies of the updated control and operation of power system functions was introduced. The paper focused on a laboratory setup with attention to the utilization of real-time simulation equipment in some typical reference applications. The scope of the setup was mainly the communication system, whereas the control system functions were simulated. In this case, an expensive real-time simulator of the microgrid is needed.
In [
6], an HIL integrated framework for testing operation and control of microgrids, as well as their individual components was proposed. Such an approach is suitable for testing the EMS and the hardware controllers at the signal level, as well as hardware devices like power converters at the power level. The proposed platform architecture is universal, but requires a microgrid real-time simulator with expensive dedicated hardware and software.
In [
7,
8], similar architectures, but with different costs of implementation were proposed for the validation of power electronics control hardware, firmware and software design. The schematic of the architecture is depicted in
Figure 1. The specific type of application requires dedicated real-time simulators with very small simulation time steps.
The works in [
9,
10,
11] presented a compendious summary of power HIL simulations that were used for designing, analyzing and testing of electrical power system components. The focus was mainly power system components and power electronic devices, and the analyzed HIL architectures adopted the general schematic shown in
Figure 2.
In [
12], a grid-tied micro-grid with a battery energy storage system was considered. The proposed energy management strategy was validated by the HIL experiments for real-time micro-grid operation. The HIL facility allowed the validation of a specific function of the EMS on a long-term horizon and did not include the replica of the communication system between the EMS and the field.
In [
13], a real-time energy management system (EMS) for small microgrids was considered. Indeed, a specific function concerning the economic optimization of the power exchange with the host grid was analyzed, which is a long-term horizon optimization. A hybrid exploration simulation framework that exchanges data over a real Ethernet network was developed to study the sensitivity of the system to networking issues such as transmission delays, data availability and reliability, among other factors. The microgrid was not simulated, but a PV system and loads were emulated from actual data.
Within the above frame, in the present paper, the microgrid to be controlled is modeled and simulated for testing the response of the actual EMS system under validation. Some simplifications are introduced in the microgrid model, such as neglecting fast electric transients, because EMS functions typically tackle medium- and long-term dynamics of the microgrid operation (such as frequency and voltage transients, power unbalances). Consequently, the simulation time step can be large enough, and soft real-time simulation [
14] can be used. This approach is different from the one followed in other real-time simulators (such as RTDS, RT-LAB, dSPACE), which are used in many HIL testing platforms, since they ensure a full and detailed simulation of the system under analysis with a small simulation time step. As a drawback, such simulators are expensive because of their dedicated hardware and software, and they are not required for all the EMS functions’ tests [
14].
The HIL architecture of the validation facility is depicted in
Figure 3 [
15]. It is based on a soft real-time digital simulator of the electric microgrid that is suitable for the EMS under validation. The task that implements the exchange interface between the real-time simulator and the actual EMS uses the same Ethernet protocol as the one adopted in the field. In this way, no specific hardware is needed, and the validation facility results in being inexpensive. At the same time, a reliable replica of the data exchange between the EMS and the field is guaranteed.
The proposed architecture for the testing facility presents the following features with respect to previous papers:
no specific and/or expensive hardware or software interface module is needed between the simulator and EMS system, as in [
5];
the peculiar communication protocol adopted by the EMS for data acquisition from the plant is actually implemented: this results in less flexibility, but higher fidelity to reality with respect to [
6,
16];
the microgrid is simulated in detail, including all the dynamic components (i.e., machines) and their local controls, the controllable loads, so as to analyze the response of the EMS functions to transients rather than only the optimization function performance on a long-term horizon, as in [
12,
13]; at the same, a soft real-time simulation can be used, because very fast electric transients are not modeled, differently from the applications to power electronic devices as in [
7,
8], which require hard real-time simulation with small sampling times;
no expensive linear power amplifier is needed as in the applications analyzed in [
9,
10,
11].
3. The Proposed Validation Facility
In principle, a validation facility should adequately represent the evolution of operating conditions of the microgrid and the actions of the EMS, as well as model and monitor their reciprocal interactions. Typical interactions concern, among others, the start and stop commands of controllable loads and of generating units, the frequency control and load-shedding in islanded operation, the voltage regulation and reactive power control and the power exchange in grid-connected operation.
In the proposed HIL architecture (
Figure 3), the soft real-time simulator of the microgrid and the actual EMS under test interact by the exchange interface, which is the key task. A more detailed block description of the architecture, including the subsystems and their assignments, is shown in
Figure 4.
The core of the setup consists of two subsystems: the power dynamic simulator (PDS) and the MATLAB Runtime Scheduler (MRS). The PDS is a dynamic-link library (dll) that is derived from a Simulink model simulating the microgrid, as explained in detail in the following. The MRS is a low level code script, which runs the linked PDS dll in real-time by timing its execution to preserve the coherence with the real-world clock.
The MRS realizes also the communication with the actual EMS, which is typically interfaced by a PLC. The EMS sends to MRS the control signals needed to manage the microgrid in the form of commands for the PDS and receives back the characterization of the microgrid. Since the MRS dialogues with the real EMS, the data exchange between MRS and EMS requires the same communication protocol as in the field. At present, the EMS adopts an Ethernet/Modbus TCP/IP protocol, but other protocols can easily be implemented.
Eventually, in
Figure 4, two additional subsystems are present, for monitoring/control functions on external PCs. The first one, named the PDS monitoring interface (PDSMI) is a separate, independent and asynchronous process with respect to the MRS. The PDSMI communicates with the MRS by a TCP/IP protocol: it acquires and visualizes the PDS variables and is also able to initialize and start/stop the simulation by a JAVA GUI. The adoption of PDSMI reduces the computation burden of the MRS/PDS, which does not need to take into account graphical issues. The second subsystem, named man-machine interface (MMI), allows the direct supervision by the human operator on the EMS. In the following, a detailed description of the subsystems of
Figure 4 is given.
3.1. Power Dynamic Simulator
The PDS emulates the response of the microgrid to the EMS’s control actions; in general, for the modeling of the electric system, a tradeoff must be arranged to match the opposite goals of ensuring a realistic behavior of the simulated microgrid, limiting in the meantime the complexity of the simulation so as to react in real time to the EMS’s actions. However, for the applications under study, it can be noticed that the EMS is characterized by sampling times with an order of magnitude of about 100 ms; this allows neglecting the short-term dynamics in the microgrid simulation (which correspond to pulses greater than 100 rad/s), by considering only medium- and long-term dynamics [
17]. Consequently, for an accurate digital simulation of the microgrid, a sampling time of the PDS equal to 1 ÷ 5 ms is adequate enough.
In the above assumption, the components of the microgrid such as rotating machines (generators and motors), static loads and electric network are modeled according to [
18] with phasorial representation of electrical quantities; the interaction among the models follows the reference scheme of
Figure 5 [
17]. For each simulation step, in this scheme, each component model exchanges the necessary information to interact with the other components; all data are adequately transformed to ensure that coherence is maintained when passing among the different reference systems of the models.
The exchanging variables in
Figure 5 mainly concern the interaction between the rotating machines and the static electric network; in particular, it is required that:
- -
the models of generators and motors provide their stator emfs, to the model of the electric network, so as to compute the electric network solution;
- -
the model of the electric network provides the stator voltage and current to each machine model in order to allow the computation of its stator emfs and of electromechanical quantities.
Particular attention to co-ordinate transformations is paid if the electric microgrid switches from islanded operation to operation in connection to a host grid and vice versa. In islanded operation, the system reference is a fixed co-ordinate frame rotating at nominal pulse; in connection to a host grid, the system reference is a co-ordinate frame synchronized with the phasor of the voltage at the PCC.
The frequency considered for the electric microgrid is evaluated as the one established by the speed of each generator in islanded operation or by the frequency of the host grid if connected. Two types of speed governor are implemented for generators: isochronous (ISO) and droop (DROOP). In the former, the speed is forced to be equal to its setpoint after a transient, and a full frequency error compensation is guaranteed; in the latter, the speed decreases by a fixed percentage when the generator varies from no-load to full load, and a stable working point can be found according to a predefined dispatch of power among generators and the host grid, if connected.
The dynamic model of the microgrid is firstly implemented in a Simulink environment and then converted into a linkable dll, invoked by the MRS (see
Figure 4). This converting procedure requires both the definition of the exchanging variable with the MRS and the declaration of the three internal MATLAB prototype functions (start, stop and single step of simulation) needed by the MRS for invoking and timing the PDS.
To allow the remote control management, the following data are made available by the PDS to MRS, which will care for their transmission to the EMS:
- -
the status of all the switches;
- -
the status of all controllable loads;
- -
the status of generators and their machine switches;
- -
the type of frequency control for the generators (ISO/DROOP);
- -
the active and reactive powers injected by the generators;
- -
the reserve of generation, evaluated on the basis of capability curves and the external temperature of all the group of generators;
- -
active and reactive powers, frequency, voltages, current for all loads and simulated switches;
- -
frequency and voltages on the main busbars.
The other way round, the data from the EMS are passed to the PDS by the MRS; their description is detailed in the following sections.
3.2. MATLAB Runtime Scheduler
The MRS is a MATLAB script that manages the execution of the PDS in soft real time and realizes also the communication with the actual EMS (see
Figure 4). The ‘soft real-time’ term means that the simulation is performed on commercial operating systems (e.g., Windows), which presents other active tasks that can introduce a delay in a simulation step, in contrast with the ‘hard real-time’ term, which means that it uses a hard interrupt to ensure that the system has fixed operation deadlines, from event to system response. The design of the PDS is conceived of so as to keep an adequate margin on the average computing times of the simulation steps; in this way, if a delay is introduced in a simulation step by other events in the operating system, the time margin allows recovering the delay in the subsequent simulation steps and maintains the soft real-time simulation. The recovery of the time delays is always monitored to check the validity of the real-time simulation.
The execution of the simulation is managed by three functions, internal to the PDS and invoked by MRS: start, stop and single step, which, as by name, permit starting and stopping the simulation or running a single simulation step. These functions can be invoked based on the delay time with the real-world clock. To ensure the results of a real-time simulation, an adaptive step of simulation is also adopted [
19]. The MRS adapts the simulation speed, by dynamically cycling the simulation steps, so as to maintain the delay between the simulation time and the real-world clock within an assigned boundary. The MRS cycle is defined according to the EMS sampling time, which is of an order of magnitude of 100 ms. According to
Section 3.1, since the sampling time of the PDS is about 1 ÷ 5 ms, in a single MRS cycle, multiple steps (N) of PDS simulation are performed.
In its cycle, the MRS handles also the information exchange with the EMS by a TCP/IP protocol (as a first application Modbus protocol). If the amount of data to be exchanged is very large, to guarantee the real-time simulation, the information exchange can be split into different sessions, which are assigned to subsequent MRS cycles. The communication with the PDSMI subsystem on an external PC is guaranteed by a TCP/IP protocol (
Figure 4).
The flowchart of the MRS is depicted in
Figure 6, in which the following tasks can be identified.
Task 1 (initialization): In this step, the initial status of the microgrid is established: all parameters of generators, motors, electric networks and static loads are set, as well as the status of all switches. A starting condition is also sent to the PLC(s) for initializing the EMS; similarly, the PDSMI receives a configuration, concerning the number and type of PDS variables that need to be monitored and visualized. All parameters are set, for the initial configuration, by customizable configuration files.
Task 2 (linking PDS dll): The PDS dll of the microgrid is loaded into the memory of MRS. A custom set of MATLAB functions (MATLAB prototype functions) grants the possible execution of the dll (by the internal functions of PDS: start, stop and single step) and creates the interface needed for the data exchange with the other subsystems (by the MRS) and to save and load the state of simulation. The structure of the Simulink dll is also invoked in the linking, so as to make accessible all the variables and states of the PDS’s simulation.
Task 3 (application of the user’s commands): According to the user’s choice, the state of the simulation can be loaded/saved/paused/stopped or started. A simple GUI, built internally by the MATLAB graphic user interface development environment (GUIDE) and invokable externally by the PDSMI, is used to pass commands to the MRS scheduler and manage the user’s events.
Task 4 (executing PDS single step function): If the simulation is started (start command), the single step function of the PDS is executed N times to simulate the response of the microgrid to the EMS commands and an updating of the PDS status results. The integer N represents the number of simulation steps of the PDS dll in the given time interval of the MRS cycle. For example, if the MRS cycles every 100 ms and the PDS simulation time step is 5 ms, then it is .
Task 5 (data to/from EMS): Every MRS cycle of assigned time interval (e.g., 100 ms), the PDS data are transferred to/from the EMS. The transfer is operated by a Modbus TCP/IP protocol, in which the opening of the sessions is commanded by the MRS that reads and writes on the data memory of the EMS.
Task 6 (data to PDMSI): Every MRS cycle of assigned time interval (e.g., 100 ms), the PDS data are transferred to PDMSI for monitoring and visualization.
Wait: In normal operation, since the average time to perform Tasks 4, 5 and 6 is smaller than the time reserved for an MRS cycle, a wait state interval is introduced, to preserve the correct match between the simulation time and the real clock time.
Stop of simulation: The whole procedure stops when the corresponding user command is given.
3.3. Energy Management System
The EMS ensures the monitoring, control and diagnosis of the microgrid, provides control and management of generators and prevents plant shut down in case of faults of the electrical network [
20,
21,
22]. Both the grid-connected and islanded operation have to be considered by the EMS. In the grid-connected mode, the voltage and frequency of the PCC can be assumed fixed by the host grid, assuming that the shortfall or the surplus of the microgrid power balance are compensated by the host grid. In this situation, a governor based on DROOP characteristics is widely used. In the islanded condition, a control strategy must regulate the voltage and frequency of the internal generation, so as to balance the net demand and generation of the microgrid; moreover, a load shedding function must be implemented to avoid a too rapid frequency drop in the case of consistent load surplus [
2]. In this case, a governor based on ISO characteristics is required to bring the frequency value back to the normal condition. Basically, the EMS function are assigned to three subsystems:
- -
SCADA system;
- -
Power management system (PMS);
- -
Load shedding system (LSS).
The first two subsystems operate in both grid-connected and islanded mode (with the different DROOP and ISO regulation for the second function); the third one is typical of islanded operation.
SCADA system The SCADA system performs the supervision and control of circuit breakers and disconnectors, gathers information from the protection relays and detects anomalies and events in chronological sequence to update the disturbance records.
Power management system (PMS): The PMS manages the control and regulation of the generators connected to the grid. Its main functions concern:
- -
supervising the internal electric power production and the consumption of the electrical system;
- -
maintaining the frequency of the electric system within assigned limits;
- -
maintaining the voltages of the electric system within assigned limits;
- -
maintaining the electric system in stable conditions in case of slow changes of the absorbed power;
- -
increasing the efficiency of the generating sets with load sharing;
- -
reducing the overloads of the generators.
- -
changing generator control mode (ISO/DROOP) when switching from host grid connected to islanded operation and vice versa.
These functions are typically performed by specific algorithms developed on a dedicated PLC.
Load shedding system (LSS): The LSS avoids the collapsing of the electric power supply under fast and abnormal perturbations of the operating conditions when the microgrid is in islanded operation. The load shedding function is automatically activated, as fast as possible, to disconnect specific loads and maintain the voltage and frequency within assigned limits. The LSS functions are performed by specific algorithms developed on a dedicated PLC.
To allow the remote control management, the following signals are sent from the EMS to the PDS:
- -
the open/close commands for all electric network switches;
- -
the commands for all controllable loads;
- -
the command of start and synchronize for the generators;
- -
the command of increasing/decreasing of speed, active/reactive power, voltages for secondary regulation;
- -
the setpoints for the governors.
- -
the type of frequency control for the generators (ISO or DROOP).
3.4. PDS Monitoring Interface
The PDSMI is a GUI written in Java that grants the monitoring, visualizing and plotting of PDS variables; the interface is linked to the stand-alone executable of MRS and allows also saving in files the time evolution of variables, as well as facilitating logging operations. The PDSMI invokes the stand-alone executable, to run the simulation in the PDSMI environment. The aim of the interface is to reduce the computation burden of the PDS, by leaving heavy graphical aspects to the PDSMI. This is possible thanks to the PDSMI process, which is separated, asynchronous and independent of the PDS.
3.5. Man-Machine Interface
The MMI allows a remote control of the EMS by a human operator; the communication with the EMS is established by an Ethernet protocol. A dedicated PLC interface, which is executed on an external PC, is used to pass the user commands.
5. Conclusions
In this paper, a test facility for the validation of the energy management systems (EMS) for microgrids is proposed; it is based on a real-time digital simulator and a hardware-in-the-loop architecture; specific details are provided concerning the framework of the test facility and the simulation times. The main advantages of the proposed testing facility are:
(i) the use of commercial PCs and the absence of dedicated interface modules, resulting in inexpensive hardware components;
(ii) the capability to validate both control and communication functions of the EMS;
(iii) the applicability to microgrids of different types (industrial, commercial, residential), as well as of various dimension, including large microgrids;
(iv) the easiness in changing the microgrid and the EMS under validation by only software modifications of the simulator tasks and of the exchange interface.
As drawbacks, the proposed testing facility presents the need to adapt the software interface between EMS and the field to the EMS under test, and the possibility of testing only the EMS functions and not fast acting local controllers of the microgrid such as the protection systems.
The results of the validation on an actual EMS for a industrial microgrid are reported to give evidence of the features of the validation facility.