1. Introduction
The use of renewable energy sources is an adequate response to environmental and energy dependence problems. Electrical microgrids allow the local management of renewable production and, thus, the promotion of distributed generation, which is essential for increasing renewable penetration into the grid [
1].
A standard AC (alternating current) microgrid is generally composed of renewable energy sources such as photovoltaics or wind to generate DC (direct current) power, a storage system such as electrical batteries, a power inverter to convert the DC power to AC power, and DC/AC electrical loads [
2,
3].
Figure 1 shows a general diagram of an AC microgrid. It is connected to the power system, PS, through a breaker. Generally, the microgrid works while connected to the grid. However, with an appropriate inverter, the microgrid could work while connected to the grid or in isolated mode. If so, when the power system fails, the breaker opens and the microgrid works in isolated mode until the grid recovers. With the batteries properly charged, an adequate voltage control applied to the power inverter will supply AC loads in this case [
4,
5]. When the PS recovers, the breaker closes and the microgrid works while connected to the general grid, again. In this case, the power system guarantees AC voltage to the microgrid, and the inverter can work by injecting active power into the power system when an adequate current control is applied. This kind of inverter is called a denominated hybrid. The decision of working while grid-connected or isolated can also be made according to the PS requirements, among others.
In addition, the current strategy can be improved to compensate for harmonics and imbalanced and other limits of power quality in the current at the point of common connection (PCC), besides injecting active power to the PS., i.e., the inverter could work like an active power filter as well as injecting power into the grid [
6,
7,
8,
9].
There are several works in the technical literature that address the inverter control strategy to optimize the microgrid operation, also acting as an active power filter. In [
7], the authors provide an overview of control strategies to solve power quality issues in microgrids. A review of some control techniques and algorithms for addressing issues related to power quality and reactive and active power sharing is presented. However, in the work, the inverter only works while grid-connected and no own experiments are carried out. Reference [
8] studies the influence of distributed generation sources on power quality at the consumer bus. The authors present an overview of PQ issues in microgrids, covering various types of PQ disturbances, their key features, and the most relevant PQ standards and apply them to different kinds of microgrids. Again, this paper presents an inverter always working as a current source in grid-connected mode and without real experiments. Reference [
9] focuses on the control of active and reactive power injection from photovoltaic sources to the PS. The proposed control algorithms are tested with Matlab simulations using the IEEE 13-bus in different conditions, like the presence of multiple PV generators, imbalance, harmonics, and faults. The PV sources always work while grid-connected. The authors of [
10] present a control strategy for achieving maximum benefit from the grid-interfacing inverters of a microgrid. The inverter injects the active power generated from the renewable power sources into the grid through an inverter, which also works as a shunt active power filter to compensate for current imbalance, current harmonics, and reactive power. The microgrid only works while grid-connected. The proposed algorithm is tested using MATLAB/Simulink simulations, and it is validated through laboratory experimental results. However, the microprocessor used in the experimental platform is the dSPACE DS1104 DSP (digital signal processor), much more expensive than that proposed in the work presented in this paper, and the grid is emulated with an electrical source working at 30 V, much lower than that achieved in this paper. Reference [
11] presents a control method for grid-connected PWM inverters to reduce the output current harmonic distortion in a wide range of grid-connected distributed generation applications. The proposed control is based on the advanced synchronous reference frame method (ASRF). The present work achieves good simulation results in a microgrid connected to the power system. As other works have previously shown, the inverter only works as a current source and no experimental tests are presented. In [
12], the authors propose a multilevel inverter for enhancing power quality and a seven-level inverter for lowering harmonic distortion. The inverter only works while grid-connected and the algorithm is only tested through MATLAB simulations.
Other works focus on real-time control of the power inverter [
13,
14,
15]. In [
13], the authors present a microgrid simulation using Matlab/Simulink and the control algorithm is developed in the Java Agent Developing Environment. The inverter proposed can work while grid-connected or isolated. However, it does not consider the power quality. In [
14], a Matlab microgrid is presented for fault current analysis. The simulation system presented is used to analyze the fault currents in grid-connected and isolated operation mode. However, the harmonic compensation is not considered and the tests are only carried out at the simulation level. Finally, ref. [
15] presents a microgrid laboratory for educational and research purposes. An experimental system based on hardware-in-the-loop is presented, suitable for educational purposes but not applicable to real microgrids.
In the present work, a novel control strategy for a microgrid inverter is proposed to optimize the microgrid operation with the following characteristics:
- -
The control strategy allows the microgrid to work while grid-connected or isolated depending on the power system voltage quality. In addition, the control can be changed by the microgrid manager. To achieve this, the inverter acts as a voltage source or as a current source as appropriate.
- -
The inverter works both by injecting active power into the grid and by compensating for the current harmonics at the PCC. It works as an active power filter, also injecting into the grid the power generated by the renewable sources.
- -
The control strategy is implemented in a real inverter module.
- -
The microprocessor used to implement the control strategy is the TMS320F28335 model of the Texas Instruments (TI) boards [
16,
17,
18], which is commercial and non-expensive, which makes the proposed system easily replicable.
- -
The control strategy proposed is tested both in simulation and in experimental platforms built in the laboratory. The results prove the good performance of the proposed system.
- -
The inverter proposed also allows the battery of the microgrid to be charged from the grid when necessary. In this way, the microgrid can be connected to/disconnected from the PS according to the PS operator’s necessities.
In the technical literature, there are inverters that work as a voltage source or as a current source as appropriate. There are also inverters that work as active filters besides injecting active power into the grid. However, there are none which implement both functions. In addition, most of the papers in the technical literature present the control strategies implemented at simulation levels, and those which present experimental implementations use dSPACE boards to control the inverter (much more expensive than the TI), and the voltage used to emulate the grid is lower than 50 V. Thus, this work presents the first complete system to work as a hybrid inverter, which also acts as an active filter, and which is replicable because of the use of a non-expensive microprocessor.
Therefore, the inverter proposed in this paper makes the microgrid function completely versatile. In fact, it may work in isolated mode with the inverter imposing a voltage and in grid-connected mode by injecting power to the grid or receiving power from the microgrid when necessary, as well as always compensating the load harmonics. With the proposed inverter, a microgrid can optimize the power management from the point of view of the consumer as well as of the PS operator.
The rest of this paper is organized as follows: in
Section 2, the proposed control and its performance in a Matlab/Simulink simulation platform is presented. In
Section 3, the proposed experimental microgrid, including a DC source, an AC load, a power inverter, and the necessary devices to implement the control, is described. In this section, the DSP hardware and the software requirements to build the proposed microgrid inverter program to be executed in real time are also described. The Embedded Coder Simulink within MATLAB will allow the automatic generation of a C code for the Texas Instruments microcontroller, and the complementary Coder Composer Studio software will generate the executable program. In
Section 4, the complete process to make a real-time executable control program is shown and applied to some practical cases. The results are analyzed to also test the performance of the proposed system presented in
Section 4. Finally, some conclusions are depicted in
Section 5.
3. Experimental Inverter: Power Devices and Control System
Once the control strategy has been designed and tested in the simulation platform, the next step is to build an experimental system to validate the inverter real performance. In this section, a single-phase experimental microgrid built in the power laboratory of the Electrical Engineering Department at Huelva University, Spain, is presented. Note that the inverter implemented in the simulation platform is three-phase and the one implemented in the experimental platforms is single-phase like in the previous step to implement the three-phase inverter. A single-phase inverter is suitable for making a domestic microgrid able to self-manage the energy or work according to the PS operator instructions.
The experimental microgrid includes a programmable DC source to emulate the DC electrical battery, a Semikron power inverter, and some AC linear and non-linear loads to check the performance of the proposed control. The inverter can be connected to or disconnected from the grid through a controlled breaker. The inverter control is executed in a Texas Instruments DSP board, the TMS320F28335 model. To carry this out, required voltages and current signals are sensed using LEM sensors and a voltage conditioning stage is designed and implemented in the laboratory. This DSP board is programmed within Matlab/Simulink Embedded Code, which executes the control program in real-time. The DSP outputs are the trigger signals sent to the inverter switching devices to execute the control and the breaker control signal to connect/disconnect the microgrid to/from the power system.
3.1. Experimental Platform
The implemented experimental platform is shown in
Figure 12. An AC single-phase microgrid is implemented with a 150 V DC bus, a full bridge inverter with an LC filter at the output, and an AC transformer to connect two loads, a linear and resistive load of 1 kW and a non-linear load, an AC regulator, to check the compensation strategy performance. The inverter (power stage and acquisition and control board) and the load, including the inverter output LC filter, are highlighted in
Figure 12. To execute a closed-loop control, a measurement block is built. Hall Effect voltage and current sensors register AC and DC signals, and a conditioning block is used to connect the sensors’ output to the control board.
Figure 13 shows different details of the experimental microgrid.
For more detail,
Figure 13a shows the programmable DC source used to emulate the electrical battery and the junction box designed to connect the distributed generators to the DC bus.
Figure 13b shows the breaker which connects the microgrid to the power system when appropriate, including the box used to connect the different AC loads. In this paper, an AC transformer is used to connect the microgrid (100 V) to the power system (230 V). Finally,
Figure 13c presents the non-linear load used in this work, an AC regulator with an RL load at the output. The linear and resistive load of 1 kW used is shown and highlighted in
Figure 12.
3.2. Inverter Control: The Texas Instruments Digital Signal Processor TMS320F28335
In this section, the physical device chosen to perform inverter real-time control is presented, as well as the software necessary to implement the corresponding control program. The board chosen in this work is the TMS320F28335, a general-purpose and low-cost acquisition and control board. This board can be programmed within the Matlab/Simulink environment. The TMS320 series of processors is the most economical of the C2000 family from the manufacturer Texas Instruments, and it is suitable for executing complex algorithms such as the control system proposed in this work.
Once the control program is designed, adjusted, and validated through simulation tests implemented in the experimental platform, version 11.0.0, it is possible to build the executable program and install it in the DSP microprocessor (in this case, with the help of the CCStudio software, version 11.0.0). This real-time acquisition and control board can work with frequencies higher than 20 KHz as needed to control the electronic switching devices of a power inverter. To build the control program to be executed on the chosen board, it is necessary to have, in addition to the Matlab software (Matlab, Simulink and Embedded coder, version R2022b), the Embedded Coder Support Package for Texas Instruments C2000 Processors (version 22.2.0). With this software, it is possible to create and simulate the control program. The Matlab program is translated to C and compiled, and an executable program is built and installed in the DSP microprocessor. It is necessary to install additional software that does this process automatically. To carry this out, Code Composer Studio (CCStudio) is installed. Once the designed control program is installed in the physical system, the required calculations are accelerated by the DSP special architecture so they can be executed in real-time. In summary, a real-time acquisition and control board is implemented, which can work with frequencies much higher than 20 kHz, which is the value needed in this work to control the electronic switches of the power inverter.
The system must be completed with the physical sensors necessary to measure the input signals. In this case, the LEM voltage and current sensors (LV25-P and LA55-P) have positive and negative outputs (since they measure alternating voltage and current), and the range of board inputs is 0–3 V. Therefore, a circuit is necessary to condition the signals, including a change in scale to −1.5/1.5 V and the sum of DC voltages of 1.5 V to ensure positive outputs.
Figure 14 presents the designed circuit to condition the current sensor signals, including the midpoint reference voltage.
Figure 15 shows details of the sensor block connected to the system. The DSP inputs are the conditioned signals from the sensors and the outputs are the IGBT signal trigger and the breaker control signal. Remember that the breaker connects the microgrid to the power system when appropriate. The DSP is connected by USB to the PC to supervise the experiments.
4. Practical Cases: Isolated and Grid-Connected Microgrid Performance
This section describes how to build and execute the control program in the experimental platform introduced in
Section 3. To carry this out, some practical cases are presented.
4.1. Matlab Control Program
The control program is carried out within Matlab/Simulink helped by Embedded Coder as described in
Section 3.2.
Figure 16 presents a general view of the programmed code.
The necessary signals to control the inverter are measured through an ADC (analog digital converter) block (left bottom in
Figure 16), that is, load and voltage current, inverter current, power system voltage, and DC voltage. Other measures such as source current allow the supervision of the system performance. The first block re-scales the measured signals and the next one calculates each RMS value.
Some of these instantaneous and RMS values are necessary to calculate the inverter current reference (right bottom block in
Figure 16) when a current control is applied, as described in
Section 2.1.
The upper left block in
Figure 16 (power system voltage check) compares the measured power system voltage and its reference (sinusoidal created in Matlab). If the RMS value of the grid voltage is between the 90% and 110% of the nominal value, the block output will be 0. This output is used to select the adequate inverter control, a current control in this case.
Figure 17 shows details of this block, which corresponds to the central block in
Figure 16.
The output of the block detailed in
Figure 17 is the signal which establishes the inverter work mode and, in the presented case, switches ON a board output pin (selected in an output block GPIO, pin 10 in this work) to close the controlled breaker which connects the microgrid to the power system.
When the current control is selected, the calculated inverter current reference is compared with the measured inverter current. The error, positive or negative, is the input of a trigger block, which calculates the trigger signals sent to the electronics devices. The Simulink GPIO block sends these signals to the board output pins (30, 31, 32, and 33 in this work).
If the power network voltage is not within the proper limits,, the output of the power system voltage check will be 1, and this signal is used to select a voltage control at the central block. A reference sinusoidal voltage is compared with the real voltage and its error signal imposes the trigger signals.
In the experimental implementation of this work, a single-phase full bridge inverter is used, whose power stage is shown in
Figure 18. These kinds of inverters have two shunt branches with two thyristors in each one (T1–T2 and T3–T4). The middle points of these branches are the inverter AC output. The T1 and T4 thyristor trigger signals must be the same, as well as those corresponding to T2–T3. The second one must be opposite to the first one. If the reference signal is greater than the measured one, the difference is positive. This error imposes an ON trigger signal to thyristors T1 and T4 (
Figure 18). In this way, the inverter output current increases because the output voltage will be the input voltage +V
DC. If the error is negative, the trigger signals of thyristors T2 and T3 will be ON, the inverter output voltage will be negative −V
DC, and the output current will decrease.
The PWM control generates the voltage reference if the microgrid works in isolated mode and the current reference if the microgrid works in grid-connected mode.
4.2. Real-Time Implementation
To carry out the control program to be implemented in the DSP, it is required to specify the DSP that is going to be used in Matlab/Simulink by means of the “Modelling Setting” option, TMS32028335 in this work.
Once the program has been carried out in Simulink as described in
Section 4.1, the “Hardware/Build, Deploy&Start” option generates the C code automatically and the executable program is built. Then, the program is exported to the microcontroller via USB connection and automatically executed. Another option is to create and execute the program through the “Hardware/Monitor&Tune” option.
In this case, it is possible to supervise and interact with the experiment in real-time from the screen of Simulink, visualizing the desired signals using the Scope blocks or even changing the program parameters while the executable program is running. To carry this out, a virtual control desk is developed in this work, as presented in
Figure 19. The upper selector in
Figure 19 allows automatic or manual connection of the microgrid to the power system, and there are some indicators of voltage, current, and powers to supervise the experiments.
4.3. Practical Cases
The performance of the proposed control is validated in this section in two use cases, with linear and non-linear loads. The DC voltage is 150 V and the grid AC voltage is 100 V (a transformer is used to connect to the grid). The inverter output reactance is 25 mH. In the first case, the microgrid works in grid-connected mode with a resistive load of 50 Ω. In these conditions, the load active power is about 200 W. Firstly, a null active power from the DC sources is considered, which is then increased to 250 W and, after that, goes to 150 W.
Figure 20 shows the main waveforms in the three situations. Voltage is the violet graph (common to all the currents), blue is the current at the grid side, green is the load current, and red is the current corresponding to the inverter. As can be seen, in
Figure 20a, the inverter does not inject power, and all the power required by the load is supplied by the grid. In
Figure 20b, all the load power is supplied by the inverter and the surplus is injected to the grid, and so the blue graph is in antiphase to the voltage. Finally, in the case presented in
Figure 20c, both the inverter and the grid supply part of the power required by the load.
In the second case, the microgrid works in grid-connected mode and there is a load constituted by an AC regulator with an RL load of 10 mH and 50 Ω on the DC side, which is non-linear.
Figure 21 shows the main waveforms in the same three situations as in the previous case. In
Figure 21a, the inverter does not inject active power, but it supplies the load current harmonics. Thus, the grid current is sinusoidal like in
Figure 21c. In
Figure 21b, the grid current is also sinusoidal, although it is in antiphase with the voltage because the inverter injects power to the grid. These results confirm the adequate performance of the proposed current control.
Figure 22 presents the transient period corresponding to the connection of the DC sources. The load is linear in this case. As can be seen, the transient lasts a few milliseconds.
Figure 23 presents another transient period. In this case, the DC source power changes in an instant. The transient performance is like the previous one.
If the grid voltage is out of the allowed range (10% of nominal range), the control system detects it automatically and the inverter control changes to a voltage control. The reference voltage is generated by software and the real-time control allows this voltage to supply the load.
Figure 24 shows the main waveforms in this situation.
Finally, in
Figure 25, the results of the active power flux with different inverter operating modes are shown. These results are obtained from Matlab scopes using the developed control interface. The active power of the load, the power system, and the inverter are presented from top to bottom.
Initially, the load is disconnected, and the three powers in the figure are null. When the load is connected, the power system voltage is out of range, and the inverter voltage control fixes the voltage to the load and supplies all the power required. At a time of 30 s, the grid voltage is restored and the current control is imposed. In this case, the microgrid voltage is set by the power system. All the load active power is supplied by the power system because the DC sources are not available (inverter active power is null in the range from 30 to 39 s). At a time of 39 s the DC sources are connected. From 39 to 49 s, the DC source power is less than that of the load. As can be seen in
Figure 24, the power system reduces the power supplied. From 49 s to the end, the power from the DC sources is higher than the load, so the excess power is injected into the power system, resulting in a negative power system active power.
5. Discussion
Microgrids constitute a preferential way of achieving two objectives necessary to increase the penetration of renewable energy into the power system. On one hand, they are useful in managing the power supply and demand into the microgrid and, on the other hand, they can participate in demand response programs managed by the power system operator. To carry this out, the microgrid must be able to operate in grid-connected and isolated modes. In addition, the ability of the microgrid to not inject harmonics and other power quality non-conformities from the microgrid to the power system is valuable. The inverter presented in this paper has the necessary characteristics to make microgrids work as indicated. Moreover, the inverter is replicable because of the use of non-expensive and low-cost devices. With an inverter like that proposed in this work, the microgrid can work while generally connected to the grid with the support of the possibility of working while isolated when necessary, or it can work with a programmable schedule of connection to/disconnection from the grid according to the tariffs or the demand response programs, among other decision parameters. In this way, the proposed inverter turns a normal microgrid into a completely versatile one from the point of view of its operation and from the point of view of the power system operator.
The control system proposed has been tested at the simulation level and at the experimental level. In both cases, the necessary platform has been designed and built ad hoc. The experimental platform implementation is based on the use of non-expensive DSP and its use in low-cost electric/electronic devices. This is a novelty by itself because the works previously published in the technical literature do not present the experimental results or they present simpler and more expensive platforms than those presented in this work. The control strategies proposed are the result of the earlier experience of the authors. The results obtained in both platforms corroborate the good performance of the system and endorse the capability of the inverter to make the microgrid able to work in a versatile way.
6. Conclusions
In this work, an inverter has been proposed that optimizes the electrical microgrid performance and operation. With the inverter, the microgrid can manage the interchange of power with the power system whenever, making the interchanged power the only active power. The inverter can work in grid-connected or in isolated mode when appropriate. In addition, working in grid-connected mode, the inverter can inject or receive power to the grid while compensating the harmonic components of the load in the microgrid, improving the quality of the electric power at the point of common connection. If the control detects a non-adequate grid voltage, the microgrid and the grid are automatically disconnected, and the inverter imposes the appropriate voltage on the microgrid loads.
The control strategy has been tested within a Matlab/Simulink simulation platform. In addition, the control has been implemented in the laboratory and tested in an experimental microgrid designed and built ad hoc. The control was executed in a low-cost acquisition and control board, model TMS320F28335 of Texas Instruments. The results obtained and presented in this paper show the good performance of the proposed system. Taking into account the fact that the experimental inverter is single-phase, future work consists of implementing the three-phase inverter. In addition, additional tests are needed to assess the current versality of the complete microgrid, including different loads and distributed generators.