Next Article in Journal
Interpretable State Estimation in Power Systems Based on the Kolmogorov–Arnold Networks
Previous Article in Journal
Advanced Distributed Control of Parallel Resonant CLLC DAB Converters
Previous Article in Special Issue
Busbar Design for High-Power SiC Converters
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Design and Practical Implementation of Microgrid Inverter Control Using TMS320F28335 Microcontroller with Improvement in Electrical Power Quality

by
Nicolás Magro
,
Jesús R. Vázquez
* and
Reyes Sánchez-Herrera
*
Department of Electrical Engineering, E.T.S.I., University of Huelva, 21004 Huelva, Spain
*
Authors to whom correspondence should be addressed.
Electronics 2025, 14(2), 319; https://doi.org/10.3390/electronics14020319
Submission received: 8 November 2024 / Revised: 3 January 2025 / Accepted: 13 January 2025 / Published: 15 January 2025
(This article belongs to the Special Issue Advances in Power Converter Design, Control and Applications)

Abstract

:
Nowadays, the proliferation of distributed renewable energy sources is a fact. A microgrid is a good solution to self-manage the energy generation and consumption of electrical loads and sources from the point of view of the consumer as well as the power system operator. To make a microgrid as versatile as necessary to carry that out, a flexible inverter is necessary. In this paper, an algorithm is presented to control an inverter and make it complete and versatile to work in grid-connected and in isolated modes, injecting or receiving power from the grid and always compensating the harmonics generated by the loads in the microgrid. With this inverter, the microgrid can work while optimizing its energy consumption or according to the power system operator instructions. The inverter proposed is tested in a designed Matlab/Simulink simulation platform. After that, an experimental platform designed and built ad hoc, including a DC source, AC linear and non-linear loads, and a Semikron power inverter, is used to test the proposed control strategies. The results corroborate the good system performance. The replicability of the system is guaranteed by the use of low-cost devices in the implementation of the control.

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.

2. Topology and Control Strategy of Proposed System

In this section, the microgrid scheme is shown through a block diagram developed in Matlab/Simulink (Figure 2). It includes a DC source connected to the DC side of a power inverter, which tracks the reference signal using PWM (pulse width modulation) techniques. The AC output is filtered to smooth the ripple due to electronic device switching, and is connected to the microgrid AC bus, where the loads are connected. There are linear and non-linear loads. This AC bus is connected through a breaker to the general power grid. Two operation modes are possible: a closed breaker imposes the grid-connected mode and an open breaker imposes the isolated mode. In the following subsections, the designed control is presented, and some simulation results are carried out to verify its adequate performance.
On the right side of Figure 2, the linear and non-linear AC loads can be observed. Regarding the last kind, rectifiers and power regulators, which work as voltage and current harmonic sources, are included. They allow the analysis of the quality improvement of the electric power when the designed control is used. A breaker (upper side of Figure 2) is used to change the microgrid work mode: grid-connected or isolated. The designed simulation platform is completed with the control block which generates the converter commutation signals (lower left part of Figure 2). The DC power sources are connected to the DC side of the inverter, and the AC output of the inverter is connected to the AC bus of the microgrid through a passive LC filter.

2.1. Inverter Control Algorithm

The inverter control system is designed to work while connected to or disconnected from the general power grid. If the grid does not supply an adequate AC voltage, the control system opens the breaker between the PS and the inverter output. Taking into account the fact that the grid nominal voltage is VN = 400 V, the breaker control acts when the RMS (root mean square) value of the voltage falls below 10%, that is, if VAC < VN * 0.9, or when it exceeds the nominal voltage by 10%. Figure 3 shows the content of the designed “source voltage OFF detection” block in Figure 2. The RMS values of the grid voltages are calculated and, if they are not in the indicated range, the control variable Out1_Breaker is set to 0. If the grid voltage is adequate, the variable is set to 1. This variable indicates the inverter operation mode: grid-connected if Out1_Breaker is 1 and isolated otherwise.
The variable Out1_Breaker is also used to establish the control strategy applied to the inverter. Thus, a value of 1 means that the breaker is closed and the inverter is connected to the PS. Thus, the microgrid voltage is imposed by the PS. In this case, the inverter must work as a current source injecting active power to the PS and compensating for the current harmonics. The proposed control strategy is presented in the upper part of Figure 4 and is explained below.
If the variable Out1_Breacker is null, the breaker is disconnected and the inverter has to impose the voltage in the microgrid. It has to work as a voltage source. The corresponding control strategy is presented in Figure 4 below. It consists of generating a sinusoidal balanced 400 V three-phase voltage and making the inverter track it.
In the upper-right of Figure 4, the control presented in Figure 3 is also represented to choose a current or voltage reference.
With respect to the control strategy applied when the inverter works while grid-connected, there are several compensation objectives, as presented in [19], from only compensating reactive power to compensating the current component which does not carry the active power required by the loads. From those control objectives, in this paper, the compensation of reactive power, harmonic power, and imbalanced power is chosen, in addition to providing the active power supplied by the distributed generators in the microgrid.
In addition, several frameworks have been published in the technical literature for applying these control objectives. The most relevant have been presented and compared in [20]. According to results obtained in [20], vectorial control is chosen to be applied in this work.
Applying the chosen control, the reactive, harmonic, and imbalanced current are not supplied by the grid and the microgrid is perceived to be a balanced linear load from the grid side. The power factor, the total harmonic distortion, and the imbalance are improved. If only active power P is interchanged between the grid and the microgrid, the current at the PCC will be sinusoidal, balanced, and in phase with the fundamental component of the voltage, and it should coincide with the active current indicated in Equation (1).
i a = P V 1 + 2 v 1 + = G 1 v 1 +
where v1+ is the fundamental direct sequence component of the voltage at the PCC and V 1 + 2 is the square of its rms value. To achieve this, the grid or source current (is) and the inverter current (called compensation current, iC) must be equal to load current, iL. The target or reference inverter current is indicated in Equation (2).
i C = i L i a = i L   G 1 v 1 +
If the active power from the renewable energy sources of the microgrid is considered, the inverter must provide a second component, iRS, according to Equation (3).
i R S = P R S v 1 + 2 v 1 + = G 2 v 1 +
where PRS is the active power generated by the DC sources of the microgrid.
Finally, the total inverter current, iT, is the sum of both components (that indicated in Equation (2) and that indicated in Equation (3)), as shown in Equation (4).
i T   = i R S   +   i C = i L     G 1       G 2 v 1 +   =   i L   G T v 1 +
Thus, iT is the reference current to be implemented in the power inverter.
This reference and the measured signals are compared to obtain the PWM control signals to be applied to the inverter, as shown in Figure 5. The signal from Figure 4 (In1_Vref in Figure 5) is compared with the actual value (In2_Vload), and the error, updated every 50 µs to limit the update frequency to 20 kHz, is the input of a “relay” block to obtain the trigger signals of the six switching devices of the three-phase inverter used in the simulation, which are IGBTs (Insulated Gate Bipolar Transistors). The “current comparator block” and the “voltage comparator block” shown in Figure 4 have the same structure, presented in Figure 5 for the voltage signals.
The right side of Figure 5 shows how to obtain the trigger signals of the six IGBTs of the three-phase inverter. If the error is positive, the comparator output is 1 and the upper switches of each branch of the three-phase inverter will be ON. The opposite signal, 0 in this case, puts the lower switches in the OFF position. It is necessary to reorder the signals which go to the inverter block in the simulated system (Figure 2).

2.2. Simulation Results

The system described in Section 2.1 is simulated with a sinusoidal three-phase voltage imposed by the grid (Figure 6). While the voltage rms value is in the appropriate range, before 1 s and after 2 s in Figure 6, the inverter works like a current source and the current control strategy is applied. From 1 to 2 s, the voltage rms value falls (for example, due to a voltage sag), and the voltage control is imposed to keep the microgrid voltage at the adequate values.
In addition to the inverter operation mode, the availability of active power from the distributed generators present in the microgrid can be studied. In this way, to observe the effect of distributed generators in the microgrid, the load, inverter, and grid currents are presented in Figure 7, Figure 8 and Figure 9, respectively, from 0.7 to 0.8 s. That range is chosen because at 0.75 s, the distributed generators are connected.
Thus, Figure 7 shows the current demanded by the load between 0.7 and 0.8 s. The load is a combination of a linear load and two types of non-linear loads, a rectifier and an AC regulator. As expected, the load current does not vary regardless of the supply source.
While the current control is imposed in the inverter, it supplies the active power from the DC microgrid sources as well as the harmonic and imbalanced power demanded by the loads. In this way, the source current becomes 50 Hz sinusoidal and balanced, in phase with the grid voltage. The next figures summarize the main results of connecting DC sources at a time of 0.75 s. Before that moment, the power grid supplies all the active power required by the load through a balanced sinusoidal current in phase with voltage, according to the designed control. The inverter supplies the rest of the needed load current, which does not contain an active component. After the DC source connection at a time of 0.75 s, the inverter current continues compensating the non-active components of the load and starts to provide the active power available from the DC source. Thus, the active power required from the grid is reduced. Figure 8 shows the current supplied by the inverter, after a passive filter, while Figure 9 shows the grid current, which is presented together with the grid voltage as a reference. The switching frequency used in this simulation is 20 kHz.
With respect to the compensation performance, Figure 10 and Figure 11 present the spectra of the grid current before and after implementing the compensation strategy into the inverter. As can be seen, before the implementation, the grid current presents a total harmonic distortion (TDH) of 6.33% and the spectrum is shown in Figure 10. After implementing the compensation control in the inverter, the THD is reduced by 43% to 3.63% and the spectrum shown in Figure 11 is obtained.

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 +VDC. If the error is negative, the trigger signals of thyristors T2 and T3 will be ON, the inverter output voltage will be negative −VDC, 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.

Author Contributions

Conceptualization, J.R.V.; Software, N.M.; Validation, N.M.; Investigation, N.M., J.R.V. and R.S.-H.; Writing—original draft, J.R.V.; Writing—review & editing, R.S.-H.; Supervision, J.R.V. and R.S.-H. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Ministry of Science, Innovation and Universities, Spain (National Database Identifier of Subsidies: 532399), through the project “Comprehensive Control System to optimize the energy demand of electrical microgrids (SOSGED)”, reference number: PID2020-117828RB-100.

Data Availability Statement

Data are contained within the article.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Saeed, M.H.; Fangzong, W.; Kalwar, B.A.; Iqbal, S. A Review on Microgrids’ Challenges & Perspectives. IEEE Access 2021, 9, 166502–166517. [Google Scholar] [CrossRef]
  2. Momoh, J. Smart Grid: Fundamentals of Design and Analysis; John Wiley & Sons: Hoboken, NJ, USA, 2012; Volume 63. [Google Scholar]
  3. Justo, J.J.; Mwasilu, F.; Lee, J.; Jung, J.-W. AC-microgrids versus DC-microgrids with distributed energy resources: A review. Renew. Sustain. Energy Rev. 2013, 24, 387–405. [Google Scholar] [CrossRef]
  4. Olivares, D.E.; Mehrizi-Sani, A.; Etemadi, A.H.; Cañizares, C.A.; Iravani, R.; Kazerani, M.; Hajimiragha, A.H.; Gomis-Bellmunt, O.; Saeedifard, M.; Palma-Behnke, R.; et al. Trends in Microgrid Control. IEEE Trans. Smart Grid 2014, 5, 1905–1919. [Google Scholar] [CrossRef]
  5. Paikray, P.; Swain, S.C.; Dash, R.; Panda, P.C. A review on current control techniques for inverter for three-phase grid-connected renewable sources. In Proceedings of the 2017 Innovations in Power and Advanced Computing Technologies (i-PACT), Vellore, India, 21–22 April 2017; pp. 1–6. [Google Scholar] [CrossRef]
  6. Barva, A.V.; Joshi, S. A Comprehensive Survey on Hybrid Active Power Filter Topologies & Controller and Application in Microgrid. In Proceedings of the 2022 IEEE Region 10 Symposium (TENSYMP), Mumbai, India, 1–3 July 2022; pp. 1–6. [Google Scholar] [CrossRef]
  7. Hassan, S.U.; Abi, Z.U.; Izhar, T. Advanced control techniques for micro-grids power quality improvement. In Proceedings of the 2017 Asian Conference on Energy, Power and Transportation Electrification (ACEPT), Singapore, 24–26 October 2017; pp. 1–6. [Google Scholar] [CrossRef]
  8. Shalukho, A.V.; Lipuzhin, I.A.; Voroshilov, A.A. Power Quality in Microgrids with Distributed Generation. In Proceedings of the 2019 International Ural Conference on Electrical Power Engineering (UralCon), Chelyabinsk, Russia, 1–3 October 2019; pp. 54–58. [Google Scholar] [CrossRef]
  9. Adhikari, S.; Li, F.; Li, H. P-Q and P-V Control of Photovoltaic Generators in Distribution Systems. IEEE Trans. Smart Grid 2015, 6, 2929–2941. [Google Scholar] [CrossRef]
  10. Singh, M.; Khadkikar, V.; Chandra, A.; Varma, R.K. Grid Interconnection of Renewable Energy Sources at the Distribution Level With Power-Quality Improvement Features. IEEE Trans. Power Deliv. 2011, 26, 307–315. [Google Scholar] [CrossRef]
  11. Naderipour, A.; Abdul-Malek, Z.; Afrouzi, H.N.; Ramachandaramurthy, V.K.; Guerrero, J.M. A Novel Compensation Current Control Method for Grid-Connected PV Inverter to Improve Power Quality in Micro-Grid. In Proceedings of the 2018 IEEE PES Asia-Pacific Power and Energy Engineering Conference (APPEEC), Kota Kinabalu, Malaysia, 7–10 October 2018; pp. 143–148. [Google Scholar] [CrossRef]
  12. Narendhiran, S.; Ragul, P.; Sakthivel, S.; Sathish, R.; Hariprabhu, M. An Enhancing Power Quality Improvement of Micro Grid System Using H Bridge Multilevel Inverter. In Proceedings of the 2024 10th International Conference on Advanced Computing and Communication Systems (ICACCS), Coimbatore, India, 14–15 March 2024; pp. 567–573. [Google Scholar] [CrossRef]
  13. El-Rahim, A.M.A.; Abd-El-Geliel, M.; Helal, A. Micro grid energy management using multi-agent systems. In Proceedings of the 2016 Eighteenth International Middle East Power Systems Conference (MEPCON), Cairo, Egypt, 27–29 December 2016; pp. 772–779. [Google Scholar] [CrossRef]
  14. Kaur, G.; Associate, A.P.; Rao, K.U. Design and Implementation of Hybrid Microgrid in MATLAB for Fault Current Analysis in Different Modes of Microgrid Operations. In Proceedings of the 2019 3rd International Conference on Recent Developments in Control, Automation & Power Engineering (RDCAPE), Noida, India, 10–11 October 2019; pp. 368–372. [Google Scholar] [CrossRef]
  15. Patrascu, C.; Muntean, N.; Cornea, O.; Hedes, A. Microgrid laboratory for educational and research purposes. In Proceedings of the 2016 IEEE 16th International Conference on Environment and Electrical Engineering (EEEIC), Florence, Italy, 7–10 June 2016; pp. 1–6. [Google Scholar] [CrossRef]
  16. Wu, Q.; Qiu, J.; Zhu, C.; Wang, Y. Automatic Fast Experiment System Design Based on Matlab Embedded Code. In Proceedings of the 2021 China Automation Congress (CAC), Beijing, China, 22–24 October 2021; pp. 7360–7363. [Google Scholar] [CrossRef]
  17. Elrajoubi, A.; Ang, S.S.; Abushaiba, A. TMS320F28335 DSP programming using MATLAB Simulink embedded coder: Techniques and advancements. In Proceedings of the 2017 IEEE 18th Workshop on Control and Modeling for Power Electronics (COMPEL), Stanford, CA, USA, 9–12 July 2017; pp. 1–7. [Google Scholar] [CrossRef]
  18. Mohammad Noor, S.Z.; Bin Omar, A.M.; Mohd Radzi, M.A.; Faranadia, A.H. Design of closed-loop algorithm of single-stage grid inverter using Digital Signal Processor (DSP) TMS320F28335 processors evaluation board. In Proceedings of the 2019 IEEE Conference on Sustainable Utilization and Development in Engineering and Technologies (CSUDET), Penang, Malaysia, 7–9 November 2019; pp. 290–294. [Google Scholar] [CrossRef]
  19. Salmeron, P.; Herrera, R.S.; Vazquez, J.R. Mapping matrices against vectorial frame in the instantaneous reactive power compensation. IET Electr. Power Appl. 2007, 1, 727–736. [Google Scholar] [CrossRef]
  20. Herrera, R.S.; Salmerón, P.; Kim, H. Instantaneous Reactive Power Theory Applied to Active Power Filter Compensation: Different Approaches, Assessment, and Experimental Results. IEEE Trans. Ind. Electron. 2008, 55, 184–196. [Google Scholar] [CrossRef]
Figure 1. General microgrid scheme.
Figure 1. General microgrid scheme.
Electronics 14 00319 g001
Figure 2. Simulink simulation platform.
Figure 2. Simulink simulation platform.
Electronics 14 00319 g002
Figure 3. Power system voltage detection block to establish the inverter operation mode: grid-connected or isolated.
Figure 3. Power system voltage detection block to establish the inverter operation mode: grid-connected or isolated.
Electronics 14 00319 g003
Figure 4. Control algorithm when the inverter works as a current source (upper) and as a voltage source (down). The control to choose the appropriate one is also presented in Figure 3.
Figure 4. Control algorithm when the inverter works as a current source (upper) and as a voltage source (down). The control to choose the appropriate one is also presented in Figure 3.
Electronics 14 00319 g004
Figure 5. Comparison between measured and reference signals to generate the inverter PWM signal.
Figure 5. Comparison between measured and reference signals to generate the inverter PWM signal.
Electronics 14 00319 g005
Figure 6. Power system voltage (V) vs. time (s).
Figure 6. Power system voltage (V) vs. time (s).
Electronics 14 00319 g006
Figure 7. Load currents (A) vs. time (s). Phases 1, 2 and 3 in blue, red and yellow.
Figure 7. Load currents (A) vs. time (s). Phases 1, 2 and 3 in blue, red and yellow.
Electronics 14 00319 g007
Figure 8. Inverter compensation currents (A) vs. time (s).
Figure 8. Inverter compensation currents (A) vs. time (s).
Electronics 14 00319 g008
Figure 9. Grid voltages (V, left) and currents (A, right) vs. time (s).
Figure 9. Grid voltages (V, left) and currents (A, right) vs. time (s).
Electronics 14 00319 g009
Figure 10. Harmonic spectrum of the grid current before the compensation strategy is implemented in the inverter.
Figure 10. Harmonic spectrum of the grid current before the compensation strategy is implemented in the inverter.
Electronics 14 00319 g010
Figure 11. Harmonic spectrum of the grid current after the compensation strategy is implemented in the inverter.
Figure 11. Harmonic spectrum of the grid current after the compensation strategy is implemented in the inverter.
Electronics 14 00319 g011
Figure 12. Experimental platform.
Figure 12. Experimental platform.
Electronics 14 00319 g012
Figure 13. (a) Programmable DC source to emulate electrical battery and DC bus connections; (b) breakers to connect the microgrid with the PS and the loads to the AC bus; and (c) the non-linear load and an AC regulator with an RL load on the right side.
Figure 13. (a) Programmable DC source to emulate electrical battery and DC bus connections; (b) breakers to connect the microgrid with the PS and the loads to the AC bus; and (c) the non-linear load and an AC regulator with an RL load on the right side.
Electronics 14 00319 g013
Figure 14. Signal conditioning circuit: (a) current sensor, (b) midpoint reference voltage, and (c) power supply.
Figure 14. Signal conditioning circuit: (a) current sensor, (b) midpoint reference voltage, and (c) power supply.
Electronics 14 00319 g014
Figure 15. Sensor block and DSP board.
Figure 15. Sensor block and DSP board.
Electronics 14 00319 g015
Figure 16. General view of the control program in Simulink to be implemented in the DSP.
Figure 16. General view of the control program in Simulink to be implemented in the DSP.
Electronics 14 00319 g016
Figure 17. General view of the control program in Simulink to choose the inverter working mode.
Figure 17. General view of the control program in Simulink to choose the inverter working mode.
Electronics 14 00319 g017
Figure 18. Scheme of a single-phase full bridge inverter.
Figure 18. Scheme of a single-phase full bridge inverter.
Electronics 14 00319 g018
Figure 19. The interface designed to choose the connection/disconnection with the PS and thus the inverter work mode (in automatic and/or manual way).
Figure 19. The interface designed to choose the connection/disconnection with the PS and thus the inverter work mode (in automatic and/or manual way).
Electronics 14 00319 g019
Figure 20. From top to bottom: power system voltage (violet graph, 200 V/div), grid current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current with linear load (red graph, 1 A/div); (a) PDC = 0 W, (b) PDC > P_load, (c) PDC < P_load.
Figure 20. From top to bottom: power system voltage (violet graph, 200 V/div), grid current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current with linear load (red graph, 1 A/div); (a) PDC = 0 W, (b) PDC > P_load, (c) PDC < P_load.
Electronics 14 00319 g020aElectronics 14 00319 g020b
Figure 21. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current with non-linear load (red graph, 1 A/div); (a) PDC = 0 W, (b) PDC > P_load, (c) PDC < P_load.
Figure 21. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current with non-linear load (red graph, 1 A/div); (a) PDC = 0 W, (b) PDC > P_load, (c) PDC < P_load.
Electronics 14 00319 g021aElectronics 14 00319 g021b
Figure 22. Transient response after DC source connection, with linear load. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current (red graph, 1 A/div).
Figure 22. Transient response after DC source connection, with linear load. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current (red graph, 1 A/div).
Electronics 14 00319 g022
Figure 23. Transient response after 100% instant increase in DC source, with linear load. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current (red graph, 1 A/div).
Figure 23. Transient response after 100% instant increase in DC source, with linear load. From top to bottom: power system voltage (violet graph, 200 V/div), power system current (blue graph, 1 A/div), load current (green graph, 1 A/div), and inverter current (red graph, 1 A/div).
Electronics 14 00319 g023
Figure 24. Voltage and currents with inverter voltage control. Top to bottom: power system voltage, grid current, load current, and inverter current.
Figure 24. Voltage and currents with inverter voltage control. Top to bottom: power system voltage, grid current, load current, and inverter current.
Electronics 14 00319 g024
Figure 25. Active power fluxes (W) vs. time (s) in different operating modes. Top to bottom: load active power, inverter active power, and power system active power.
Figure 25. Active power fluxes (W) vs. time (s) in different operating modes. Top to bottom: load active power, inverter active power, and power system active power.
Electronics 14 00319 g025
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Magro, N.; Vázquez, J.R.; Sánchez-Herrera, R. Design and Practical Implementation of Microgrid Inverter Control Using TMS320F28335 Microcontroller with Improvement in Electrical Power Quality. Electronics 2025, 14, 319. https://doi.org/10.3390/electronics14020319

AMA Style

Magro N, Vázquez JR, Sánchez-Herrera R. Design and Practical Implementation of Microgrid Inverter Control Using TMS320F28335 Microcontroller with Improvement in Electrical Power Quality. Electronics. 2025; 14(2):319. https://doi.org/10.3390/electronics14020319

Chicago/Turabian Style

Magro, Nicolás, Jesús R. Vázquez, and Reyes Sánchez-Herrera. 2025. "Design and Practical Implementation of Microgrid Inverter Control Using TMS320F28335 Microcontroller with Improvement in Electrical Power Quality" Electronics 14, no. 2: 319. https://doi.org/10.3390/electronics14020319

APA Style

Magro, N., Vázquez, J. R., & Sánchez-Herrera, R. (2025). Design and Practical Implementation of Microgrid Inverter Control Using TMS320F28335 Microcontroller with Improvement in Electrical Power Quality. Electronics, 14(2), 319. https://doi.org/10.3390/electronics14020319

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