## 1 Introduction  
The depletion of natural resources and environmental degradation are current research topics that have generated great concern today due to their accelerating impacts on climate change. Part of the issue is that the primary generation units that supply the increasing power demand are dependent on non-renewable resources, such as coal, oil, and natural gas. This is why the use of renewable energies close to the loads must be rapidly promoted in order to mitigate the effects of climate change. Microgrids have been proposed as a way to address this transformation by maximizing the efficiency and flexibility of renewable energy resources. A microgrid is an integrated energy system consisting of interconnected loads and energy resources that are distributed within clearly defined electrical limits, acting as a single controllable entity for the power grid [1, 2]. Microgrids are made up of different elements, and distributed generators are essential for their correct operation. These present a challenge in terms of interaction with the grid, where power electronics are vital for the proper operation. Furthermore, distributed generators are usually controlled and connected to the grid through electronic inverters and converters. Thus, the control loop for these devices must guarantee the stability of the system, satisfy the load of the microgrid, and maintain the power quality, such as by controlling the voltage magnitudes and active and reactive power. In the commercial environment, some microinverters only deliver active power to the electrical grid. However, loads demand active and reactive power, which is essential for some electrical devices, such as motors, as well as inductive and capacitive loads. Consequently, by not performing reactive power compensation, adverse effects are generated for the microgrid, such as high currents and voltage magnitude variations, which may require more electrical infrastructure. Therefore, distributed generators are needed to compensate these effects. Some examples of active and reactive power control using distributed generation have been proposed in the literature. For instance, in [3], the development of a two-stage control was presented. The first stage was the MPPT strategy, which was based on variable steps with predictive current control. The second stage was an active and reactive power control used to control an on-grid multilevel inverter, which was validated in MATLAB. In [4], an intelligent control algorithm with artificial neural networks was presented for an active and reactive power controller in a photovoltaic generation system connected to the grid. The system consisted of two devices: a DC-DC converter with a maximum power point tracking algorithm and a DC-AC hysteresis inverter; thus, independent control of the active and reactive power was required. An on-grid photovoltaic inverter installed on the low-voltage side of a distribution network was proposed in [5]. The architecture considered its operation and robustness against network faults. In addition, a two-stage predictive control for the DC link and the inverter was proposed. These controllers were evaluated with mathematical analyses and simulations. Another study related to active and reactive power control techniques for two-stage on-grid inverters in a photovoltaic system was presented in [6]. In this case, the DC link voltage, active power, and reactive power were successfully controlled with an adaptive-PI and adaptive-sliding-mode controller. The voltage magnitude, voltage phase, and frequency of the power grid were provided by a phase-locked loop (PLL) based on a second-order general integral (SOCI), which presented harmonic immunity, a fast tracking accuracy, and a fast dynamic response. Other research on power control is found in [7], where a structure was proposed for active and reactive power control in a multi-level modular converter. In this research, the current was decomposed into the \(dq\) axes using the Park transform.