Grid-Connected Inverter for a PV-Powered Electric Vehicle Charging Station to Enhance the Stability of a Microgrid

: This study proposes a grid-connected inverter for photovoltaic (PV)-powered electric vehicle (EV) charging stations. The signiﬁcant function of the proposed inverter is to enhance the stability of a microgrid. The proposed inverter can stabilize its grid voltage and frequency by supplying or absorbing active or reactive power to or from a microgrid using EVs and PV generation. Moreover, the proposed inverter can automatically detect an abnormal condition of the grid, such as a blackout, and operate in the islanding mode, which can provide continuous power to local loads using EV vehicle-to-grid service and PV generation. These inverter functions can satisfy the requirements of the grid codes, such as IEEE Standard 1547–2018 and UL 1741 SA. In addition, the proposed inverter can not only enhance the microgrid stability but also charge EVs in an appropriate mode according to the condition of the PV array and EVs. The proposed inverter was veriﬁed through experimental results with four scenarios in a lab-scale testbed. These four scenarios include grid normal conditions, grid voltage ﬂuctuations, grid frequency ﬂuctuations, and a power blackout. The experimental results demonstrated that the proposed inverter could enhance the microgrid stability against grid abnormal conditions, ﬂuctuations of grid frequency and voltage, and charge EVs in an appropriate mode.


Introduction
Recently, renewable energy sources (RES), such as photovoltaic (PV) and wind turbine generation (WTG), have been increasing in the grid to replace conventional synchronous generators [1]. These RESs are connected to the grid through power converters such as grid-connected inverters, which can weaken the microgrid by reducing the inertia of the grid [2]. Because the weak grid has low inertia, it is difficult to cope with the grid voltage and frequency fluctuations, leading to a deterioration of grid stability and power quality [3][4][5][6]. Various grid codes, such as IEEE Standard 1547-2018 and UL 1741 SA, were established to solve these problems [7,8]. These grid codes are guidelines for gridconnected inverters to maintain grid stability. According to the IEEE Standard 1547-2018 requirements, grid-connected inverters should be able to maintain grid stability and power quality by regulating the grid voltage and frequency through absorbing and supplying active or reactive power to the grid. Moreover, the grid-connected inverter should be able to detect abnormal conditions, such as a grid blackout, and operate in the islanding mode.
In addition to the increase in RESs, the penetration rate of electric vehicles (EVs) has increased to replace conventional fossil fuel vehicles. Therefore, the EV charging stations within the microgrid have also been increasing, as shown in Figure 1 [9][10][11]. Depending In addition to the increase in RESs, the penetration rate of electric vehicles (EVs) has increased to replace conventional fossil fuel vehicles. Therefore, the EV charging stations within the microgrid have also been increasing, as shown in Figure 1 [9][10][11]. Depending on the applications, each source and load can be connected to the microgrid through single or multi-stage power converters [12][13][14]. If many EVs are charged simultaneously from the microgrid, a power imbalance in the supply and demand may occur in the microgrid [15][16][17][18]. This makes the microgrid weak, decreasing its stability [19]. Unstable voltage and frequency in the microgrid can affect the power quality for charging EVs and may reduce the lifetime of an EV battery. To enhance the stability of the microgrid connected with an EV charging station, many studies [20][21][22][23][24] integrating PV generation and a charging station to the microgrid have been conducted. In [20][21][22], the optimized operation of gridconnected PV-based EV charging stations was studied. However, these studies mainly analyzed the economic improvement of the operation of PV-powered EV charging stations. In [23], it was proved that the grid stability could be improved through the total harmonic distortion (THD) of voltages using PV-powered EV charging stations. Moreover, researchers [24] studied that grid stabilization, including power gap balancing, peak shaving, valley filling of generated power, and voltage sag compensation, can be enhanced by utilizing PV-connected EV charging stations. Researchers [25,26] have also studied improving the microgrid stability in an EV charging station by using a vehicle-to-grid service (V2G). A V2G is defined as providing power and other necessary support from an EV to the grid [27][28][29][30]. Other researchers [25] proved that EV charging stations could be used to compensate for instantaneous grid voltage fluctuations and improve the power quality. In [26], a new control method was proposed to compensate for the grid frequency by utilizing the EV charging station. These studies proved that the deterioration of the grid stability could be mitigated using a V2G. Nevertheless, these studies have not considered the compensation of voltage and frequency fluctuations simultaneously. These studies are not enough to satisfy the requirements of the grid codes, such as IEEE Standard 15247-2018 and UL 1741 SA. These studies have also not considered an islanding mode for abnormal conditions of the grid, such as a blackout.
This study proposes a grid-connected inverter for PV-powered EV charging stations, enhancing microgrid stability using a V2G and PV generation. When the microgrid voltage and frequency fluctuate, the proposed inverter can stabilize the microgrid voltage and frequency by supplying active or reactive power to the microgrid or absorbing it from the microgrid. Moreover, the proposed inverter can automatically detect abnormal conditions of the microgrid, such as a blackout, and operate in the islanding mode. Researchers [25,26] have also studied improving the microgrid stability in an EV charging station by using a vehicle-to-grid service (V2G). A V2G is defined as providing power and other necessary support from an EV to the grid [27][28][29][30]. Other researchers [25] proved that EV charging stations could be used to compensate for instantaneous grid voltage fluctuations and improve the power quality. In [26], a new control method was proposed to compensate for the grid frequency by utilizing the EV charging station. These studies proved that the deterioration of the grid stability could be mitigated using a V2G. Nevertheless, these studies have not considered the compensation of voltage and frequency fluctuations simultaneously. These studies are not enough to satisfy the requirements of the grid codes, such as IEEE Standard 15247-2018 and UL 1741 SA. These studies have also not considered an islanding mode for abnormal conditions of the grid, such as a blackout.
This study proposes a grid-connected inverter for PV-powered EV charging stations, enhancing microgrid stability using a V2G and PV generation. When the microgrid voltage and frequency fluctuate, the proposed inverter can stabilize the microgrid voltage and frequency by supplying active or reactive power to the microgrid or absorbing it from the microgrid. Moreover, the proposed inverter can automatically detect abnormal conditions of the microgrid, such as a blackout, and operate in the islanding mode.
When the proposed inverter operates in the islanding mode, it is also possible to continuously supply power to local loads. In addition, the proposed inverter can not only enhance the stability of the microgrid but also charge EVs in the appropriate mode according to the conditions of EVs and PV generation. The superiority of the proposed inverter was verified and analyzed through experiments in a lab-scale testbed to mimic the operation of a PV-powered EV charging station in a microgrid. The main contributions of this study can be summarized as follows: (1) The proposed inverter can stabilize the microgrid voltage and frequency by supplying active or reactive power to the microgrid or absorbing it from the microgrid by using V2G and PV generation. These proposed inverter functions can satisfy the requirements of the grid codes, such as IEEE Standard 1547-2018 and UL 1741 SA. (2) The proposed inverter can automatically detect abnormal conditions of the microgrid, such as a blackout, and operate in the islanding mode. At this time, it can provide continuous power to local loads by using V2G and PV generation.
This paper is organized into the following five sections: Section 2 describes the configuration of the PV-powered EV charging station. Section 3 introduces the control method for the proposed inverter to improve microgrid stability. Section 4 presents the experimental setup and results for validating the proposed inverter control method. Finally, the conclusions are summarized in Section 5.

PV-Powered EV Charging Station Description
A PV-powered EV charging station charges EVs using PV generation as another available power source, which can reduce carbon emissions from fossil-fueled power plants. In other words, EVs can be charged using PV generation when the grid cannot supply power. It can also reduce the peak load or improve the microgrid stability by using PV generation and V2G [31]. However, EVs differ from an energy storage system because of their mobility characteristics. For example, a V2G may not be performed if there are not enough available EVs in the charging station, although a V2G is required to reduce the peak power demand or improve the stability of the microgrid. Therefore, it is crucial to consider these characteristics of a PV-powered EV charging station to use it as a stability enhancement method for the microgrid. Figure 2 shows the configuration of the PV-powered EV charging station [32]. The PVpowered EV charging station consists of PV arrays, DC/DC converters, EVs, bidirectional EV chargers, and bidirectional inverters. The charging station is connected to the microgrid through the bidirectional inverter. The bidirectional inverter controls power flow between the charging station and the grid. The local load is connected in parallel between the bidirectional inverter and the microgrid. The PV array generates power for charging EVs or supplying the grid and local loads. A DC/DC converter is used to harvest maximum power from a PV array by performing maximum power point tracking (MPPT). The bidirectional EV charger is used to control the charge and discharge of EVs. The bidirectional inverter and the bidirectional EV charger enable a V2G between EVs and the microgrid.  Figure 3 shows the operational strategy flowchart of the proposed grid-connected inverter. The significant function of the proposed inverter is to enhance the microgrid stability. In this study, the microgrid stability is defined as the grid voltage stability, the grid   Figure 3 shows the operational strategy flowchart of the proposed grid-connected inverter. The significant function of the proposed inverter is to enhance the microgrid stability. In this study, the microgrid stability is defined as the grid voltage stability, the grid frequency stability, and the grid stability from grid abnormal conditions. In addition, the microgrid in this study is considered a weak grid, because it is usually connected with various renewable energy sources (RES) and loads. In a weak grid, the grid voltage can be regulated by active power, and the grid frequency can be controlled by reactive power. Therefore, when the microgrid voltage fluctuations occur, the proposed inverter can stabilize the microgrid voltage by supplying or absorbing active power to the microgrid by using V2G and PV generation. In addition, when the microgrid frequency varies, the proposed inverter can also stabilize the microgrid frequency by supplying or absorbing reactive power to the microgrid.  If the islanding detection condition is not occurring in the microgrid, the proposed inverter is connected to the grid and operates in the grid-connected mode. In the gridconnected mode, the inverter detects the voltage and frequency of the microgrid. At this time, if the grid voltage or frequency fluctuation exists, the inverter operates in the voltage  The grid abnormal conditions considered in this study are grid blackout events, which can be judged through an islanding detection condition. The islanding detection condition occurs when power in the microgrid is totally cut off from the utility grid. Therefore, when power is absolutely cut off from the utility grid, the proposed inverter can stabilize the microgrid by operating in the islanding mode and continuously providing power to the local loads using V2G and PV generation. The islanding detection condition in the microgrid is distinguished from other events such as temporary faults because it occurs only when power is completely cut off from the utility grid. The islanding detection condition can be varied by the grid codes such as IEEE Standard 1547-2018 and UL 1741 SA.

The Proposed Grid-Connected Inverter
According to the proposed operational strategy, the proposed inverter determines the appropriate mode for charging EVs according to EVs and PV generation conditions. The operation modes according to the operational strategy are shown in Figure 4. In Figure 4, red arrows represent the direction of power flow among the PV array, EVs, and the grid. For example, the bidirectional inverter in Figure 4b can achieve bidirectional power flow, which is caused by the voltage and frequency compensation modes. First, the proposed inverter begins receiving data from the grid, EVs, and the PV array. Then, the inverter detects whether EVs are available in the EV charging station to enhance microgrid stability. If EVs are not available, the inverter operates in mode one. In mode one, the inverter supplies the power generated from the PV array to the grid and the local load, as shown in Figure 4c. If EVs are available, the inverter judges whether the islanding detection condition occurs in the microgrid. If the islanding detection condition exists, the inverter is disconnected from the grid and operates in the islanding mode, as shown in Figure 4a. At this time, the inverter can provide continuous power to local loads using EVs and the PV array in the islanding mode. compensation mode or the frequency compensation mode, as shown in Figure 4b. In these modes, the inverter stabilizes the microgrid voltage and frequency using a V2G and PV generation. If the grid voltage fluctuation exists, the proposed inverter operates in the voltage compensation mode for reducing the grid voltage fluctuation. On the other hand, if the grid voltage fluctuation does not exist, the proposed inverter detects the grid frequency condition. If the grid frequency fluctuation exists, the proposed inverter operates in the frequency compensation mode for reducing the grid frequency fluctuation. If the grid voltage or frequency fluctuation does not exist in the grid-connected mode, the proposed inverter monitors the condition of EVs and the PV array for charging EVs in the appropriate mode. The proposed inverter detects whether EVs need charging and whether a PV array generates power. If EVs need charging and a PV array does not generate power, the proposed inverter operates in mode two, as shown in Figure 4d. In mode two, EVs are charged only from the grid. If EVs need charging and a PV array generates power, the proposed inverter detects whether the energy of the PV array (EPV) is greater than the energy required for charging EVs (EEV). If EPV is greater than EEV, the inverter operates in mode three, as shown in Figure 4e. In mode three, EVs are charged only from the PV array, and the proposed inverter supplies the surplus EPV to the grid. If EPV is less than EEV, the proposed inverter operates in mode four, as shown in Figure 4f. In mode four, EVs are charged from the PV array and the grid. If EVs do not need charging, the proposed inverter operates in mode one.

Grid-Connected Mode
The proposed inverter generally operates in the grid-connected mode because the islanding detection condition does not often occur. Thus, to realize the operating strategy of the proposed inverter in the grid-connected mode, the following three control schemes are introduced: main control scheme, voltage compensation control scheme, and frequency compensation control scheme.
3.1.1. Main Control Scheme Figures 5 and 6a show the circuit and main control scheme of the proposed inverter. As shown in Figure 5, the proposed inverter includes four metal-oxide-semiconductor If the islanding detection condition is not occurring in the microgrid, the proposed inverter is connected to the grid and operates in the grid-connected mode. In the gridconnected mode, the inverter detects the voltage and frequency of the microgrid. At this time, if the grid voltage or frequency fluctuation exists, the inverter operates in the voltage compensation mode or the frequency compensation mode, as shown in Figure 4b. In these modes, the inverter stabilizes the microgrid voltage and frequency using a V2G and PV generation. If the grid voltage fluctuation exists, the proposed inverter operates in the voltage compensation mode for reducing the grid voltage fluctuation. On the other hand, if the grid voltage fluctuation does not exist, the proposed inverter detects the grid frequency condition. If the grid frequency fluctuation exists, the proposed inverter operates in the frequency compensation mode for reducing the grid frequency fluctuation. If the grid voltage or frequency fluctuation does not exist in the grid-connected mode, the proposed inverter monitors the condition of EVs and the PV array for charging EVs in the appropriate mode. The proposed inverter detects whether EVs need charging and whether a PV array generates power. If EVs need charging and a PV array does not generate power, the proposed inverter operates in mode two, as shown in Figure 4d. In mode two, EVs are charged only from the grid. If EVs need charging and a PV array generates power, the proposed inverter detects whether the energy of the PV array (E PV ) is greater than the energy required for charging EVs (E EV ). If E PV is greater than E EV , the inverter operates in mode three, as shown in Figure 4e. In mode three, EVs are charged only from the PV array, and the proposed inverter supplies the surplus E PV to the grid. If E PV is less than E EV , the proposed inverter operates in mode four, as shown in Figure 4f. In mode four, EVs are charged from the PV array and the grid. If EVs do not need charging, the proposed inverter operates in mode one.

Grid-Connected Mode
The proposed inverter generally operates in the grid-connected mode because the islanding detection condition does not often occur. Thus, to realize the operating strategy of the proposed inverter in the grid-connected mode, the following three control schemes are introduced: main control scheme, voltage compensation control scheme, and frequency compensation control scheme.

Main Control Scheme
Figures 5 and 6a show the circuit and main control scheme of the proposed inverter. As shown in Figure 5, the proposed inverter includes four metal-oxide-semiconductor field-effect transistors (i.e., MOSFETs) with body diodes (i.e., Q 1 , Q 2 , Q 3 , and Q 4 ), two inductors (i.e., L 1 and L 2 ), and a capacitor (i.e., C 1 ) and z g (i.e., the line impedance of the grid). Q 1 , Q 2 , Q 3 , and Q 4 are controlled by the gate control signals (i.e., g 1 , g 2 , g 3 , and g 4 ). L 1 , L 2 , and C 1 consist of an LCL filter for suppressing the harmonic of the proposed inverter output. The synchronous reference frame phase-locked loop (SRF-PLL) is used to synchronize the proposed inverter with the grid to achieve grid synchronization. Based on the SRF-PLL, the grid information, such as amplitude, frequency, and phase, can be determined. The closed-loop transfer function of the SRF-PLL is obtained as follows [33]: where ζ donates the damping factor, and ω n donates the natural frequency. mined. The closed-loop transfer function of the SRF-PLL is obtained as follows [33]: where ζ donates the damping factor, and ωn donates the natural frequency. Then, the output of the SRF-PLL (ωgrid and θgrid) is used for the second-order generalized integrator phase-locked loop (SOGI-PLL) [34]. The SOGI-PLL is used to create twophase orthogonal components in the α-β stationary reference frame for power calculations.
The grid voltage (vgrid), inverter output voltage (vinv), and current (iinv) are selected as the α-axis components of the fictitious two-phase system in α-β stationary reference frame as follows: where vα and iα are the α-axis voltage and current, respectively, and vβ and iβ are the β-axis voltage and current, respectively. The closed-loop transfer functions (Hd(s) and Hq(s)) of the SOGI-PLL are determined as follows [35]: where k affects the bandwidth of the closed-loop system, and ω donates the grid frequency. The inverter currents (iinv_d and iinv_q) are transformed by the Park transformation to synchronize the proposed inverter with the grid, as follows:  where θgrid is the grid phase, and iinv_d and iinv_q are compared with the inverter reference current values (iref_d and iref_q). The errors are used to calculate the reference voltage (vref_d and vref_q) by the proportional-integral (PI) controller. The duty cycle of the proposed inverter can be determined by vref_d and vref_q using the inverse Park transformation as follows: 3.

Voltage Compensation Control Scheme
The voltage compensation control scheme is used in the proposed inverter to reduce the voltage fluctuation, as shown in Figure 6b. The output voltage of the proposed inverter (vinv) is controlled by comparing the inverter reference voltage (vinv_ref). iref_q can be determined by a PI controller. After calculating iref_q, the voltage compensation scheme uses the same control scheme as the proposed grid-connected inverter control scheme for controlling the proposed inverter. Therefore, the inverter can reduce the fluctuation of the grid voltage.

Frequency Compensation Control Scheme
The frequency compensation control scheme is used in the proposed inverter to reduce frequency fluctuation, as shown in Figure 6c. The output frequency of the proposed inverter (finv) is controlled by comparing the inverter reference frequency (finv_ref). iref_d can Then, the output of the SRF-PLL (ω grid and θ grid ) is used for the second-order generalized integrator phase-locked loop (SOGI-PLL) [34]. The SOGI-PLL is used to create two-phase orthogonal components in the α-β stationary reference frame for power calculations.
The grid voltage (v grid ), inverter output voltage (v inv ), and current (i inv ) are selected as the α-axis components of the fictitious two-phase system in α-β stationary reference frame as follows: where v α and i α are the α-axis voltage and current, respectively, and v β and i β are the β-axis voltage and current, respectively. The closed-loop transfer functions (H d (s) and H q (s)) of the SOGI-PLL are determined as follows [35]: where k affects the bandwidth of the closed-loop system, and ω donates the grid frequency. The inverter currents (i inv_d and i inv_q ) are transformed by the Park transformation to synchronize the proposed inverter with the grid, as follows: where θ grid is the grid phase, and i inv_d and i inv_q are compared with the inverter reference current values (i ref_d and i ref_q ). The errors are used to calculate the reference voltage (v ref_d and v ref_q ) by the proportional-integral (PI) controller. The duty cycle of the proposed inverter can be determined by v ref_d and v ref_q using the inverse Park transformation as follows:

Voltage Compensation Control Scheme
The voltage compensation control scheme is used in the proposed inverter to reduce the voltage fluctuation, as shown in Figure 6b. The output voltage of the proposed inverter (v inv ) is controlled by comparing the inverter reference voltage (v inv_ref ). i ref_q can be determined by a PI controller. After calculating i ref_q , the voltage compensation scheme uses the same control scheme as the proposed grid-connected inverter control scheme for controlling the proposed inverter. Therefore, the inverter can reduce the fluctuation of the grid voltage.

Frequency Compensation Control Scheme
The frequency compensation control scheme is used in the proposed inverter to reduce frequency fluctuation, as shown in Figure 6c. The output frequency of the proposed inverter (f inv ) is controlled by comparing the inverter reference frequency (f inv_ref ). i ref_d can be determined by a PI controller. After calculating i ref_d , the frequency compensation scheme uses the same control scheme as the proposed grid-connected inverter control scheme for controlling the proposed inverter. Therefore, the proposed inverter can reduce the fluctuation of the grid frequency.

Islanding Mode
When an islanding detection condition occurs in the microgrid, the proposed inverter can automatically detect the condition and operate in the islanding mode. The proposed inverter can provide continuous power to local loads under the same frequency and voltage level in the islanding mode. Figure 6d shows the islanding mode control scheme.
Due to islanding from the grid, the grid information, such as phase, frequency, and amplitude, cannot be detected. Thus, ω grid and θ grid are equal to zero, which means the SRF-PLL can be removed. Otherwise, the SOGI-PLL, α-β to d-q transformation, and d-q to α-β transformation use the inverter frequency and phase (ω inv and θ inv = 0). The operation of the islanding mode control scheme is the same as the grid-connected mode.

Setup
The lab-scale testbed for a PV-powered EV charging station was fabricated to verify the superiority and feasibility of the proposed inverter, as shown in Figure 7. Figure 2 shows the connection of all microgrid components. The circuit diagram of the proposed inverter circuit is depicted in Figure 5. The parameters and components of the proposed gridconnected inverter and equipment in the experiments are listed in Table 1. The proposed grid-connected inverter, which determines the appropriate operation mode based on the designed operating strategy, is located between the lab-scale testbed and the grid simulator. A PV simulator (i.e., TerraSAS ETS80) imitates the actual PV array characteristics. A PV array consists of two series-connected PV modules (i.e., NE180TU-21PS6). The output of the PV simulator is connected to a DC/DC converter, which performs MPPT using perturbation and an observation algorithm [36]. The PV simulator can supply power to a battery or the grid simulator through the DC/DC converter. The battery is used to imitate an EV battery, and the bidirectional charger is used to mimic an EV charger. The battery can be charged and discharged through the bidirectional charger. The grid simulator (i.e., CHROMA 61830) is used to imitate the grid, and the AC load (i.e., CHROMA 63803) is used to imitate a local load. The voltage and frequency of the grid simulator can be changed, and the connection can also be disconnected.
inverter can provide continuous power to local loads under the same frequency and volt-age level in the islanding mode. Figure 6d shows the islanding mode control scheme.
Due to islanding from the grid, the grid information, such as phase, frequency, and amplitude, cannot be detected. Thus, ωgrid and θgrid are equal to zero, which means the SRF-PLL can be removed. Otherwise, the SOGI-PLL, α-β to d-q transformation, and d-q to αβ transformation use the inverter frequency and phase (ωinv and θinv=0). The operation of the islanding mode control scheme is the same as the grid-connected mode.

Setup
The lab-scale testbed for a PV-powered EV charging station was fabricated to verify the superiority and feasibility of the proposed inverter, as shown in Figure 7. Figure 2 shows the connection of all microgrid components. The circuit diagram of the proposed inverter circuit is depicted in Figure 5. The parameters and components of the proposed grid-connected inverter and equipment in the experiments are listed in Table 1. The proposed grid-connected inverter, which determines the appropriate operation mode based on the designed operating strategy, is located between the lab-scale testbed and the grid simulator. A PV simulator (i.e., TerraSAS ETS80) imitates the actual PV array characteristics. A PV array consists of two series-connected PV modules (i.e., NE180TU-21PS6). The output of the PV simulator is connected to a DC/DC converter, which performs MPPT using perturbation and an observation algorithm [36]. The PV simulator can supply power to a battery or the grid simulator through the DC/DC converter. The battery is used to imitate an EV battery, and the bidirectional charger is used to mimic an EV charger. The battery can be charged and discharged through the bidirectional charger. The grid simulator (i.e., CHROMA 61830) is used to imitate the grid, and the AC load (i.e., CHROMA 63803) is used to imitate a local load. The voltage and frequency of the grid simulator can be changed, and the connection can also be disconnected.

Results
The operation modes according to the operating strategy of the proposed inverter were verified based on four scenarios: grid normal conditions, grid voltage fluctuations, grid frequency fluctuations, and a blackout. Scenario 1 was used to analyze the operations mode one, mode two, mode three, and mode four under grid normal conditions. Scenarios 2 and 3 were used to analyze the voltage compensation and frequency compensation modes under grid voltage and frequency fluctuations. Scenario 4 was used to analyze the islanding mode under a blackout. Figure 8 shows the waveforms of the PV array output current (I PV ), the battery output current (I bat ), v inv , and i inv in mode one, mode two, mode three, and mode four. In mode one, the inverter supplies power generated from the PV array to the grid and the local load. As shown in Figure 8a, I PV is positive, I bat is zero, and v inv and i inv are in phase, which means that the PV array supplies power to the grid. In mode two, EVs are charged only from the grid. As shown in Figure 8b, I PV is zero, I bat is negative, and v inv and i inv are out of phase, which means that the grid supplies power to the EVs. In mode three, EVs are charged only from the PV array, and the inverter supplies the surplus E PV to the grid. As shown in Figure 8c, I PV is positive, I bat is negative, and v inv and i inv are in phase, which means the PV array supplies power to the EVs and the grid. In mode four, EVs are charged from the PV array and the grid. As shown in Figure 8d, I PV is positive, I bat is negative, and v inv and i inv are out of phase, which means that the PV array and the grid supply power to the EVs. These results prove that the proposed inverter operates in an appropriate mode according to the condition of the EVs and the PV array under grid normal conditions. Figures 9 and 10 show the waveform of v inv and the relationship between the grid fluctuation voltage and the inverter output active power (P inv ) in the voltage compensation mode. The power analyzer measured all the waveforms and data (i.e., WT1806E). As shown in Figure 9a, when the grid voltage increases to 223 V, the proposed inverter operates in the voltage compensation mode and regulates the grid voltage to 220 V in 1.72 s. As shown in Figure 9b, when the grid voltage decreases to 217 V, the proposed inverter also operates in the voltage compensation mode and regulates the grid voltage to 220 V in 2.16 s. These results prove that the proposed inverter can stabilize the grid voltage by reducing the voltage fluctuation using the voltage compensation mode. In addition, Figure 10 shows that the proposed inverter regulates the grid voltage by supplying or absorbing active power to the microgrid by using V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, for the stability of the grid. Figures 11 and 12 show the waveform of f inv and the relationship between the grid fluctuation frequency and the inverter output reactive power in the frequency compensation mode. All the waveforms and data are measured from the power analyzer. As shown in Figure 11a, when the grid frequency increases to 62 Hz, the proposed inverter operates in the frequency compensation mode and regulates the grid frequency to 60 Hz in 3.49 s. As shown in Figure 11b, when the grid frequency decreases to 58 Hz, the proposed inverter also operates in the frequency compensation mode and regulates the grid frequency to 60 Hz in 3.69 s. These results prove that the proposed inverter stabilizes the grid frequency by reducing the frequency fluctuation using the frequency compensation mode. In addition, Figure 12 shows that the proposed inverter regulates the grid frequency by supplying or absorbing reactive power to the microgrid by using a V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, according to the grid stability.  also operates in the voltage compensation mode and regulates the grid voltage to 220V in 2.16s. These results prove that the proposed inverter can stabilize the grid voltage by reducing the voltage fluctuation using the voltage compensation mode. In addition, Figure  10 shows that the proposed inverter regulates the grid voltage by supplying or absorbing active power to the microgrid by using V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, for the stability of the grid.   also operates in the voltage compensation mode and regulates the grid voltage to 220V in 2.16s. These results prove that the proposed inverter can stabilize the grid voltage by reducing the voltage fluctuation using the voltage compensation mode. In addition, Figure  10 shows that the proposed inverter regulates the grid voltage by supplying or absorbing active power to the microgrid by using V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, for the stability of the grid.    Figure 13 shows the waveforms of V inv , I inv , and P inv in the islanding mode. The proposed inverter automatically detects a grid blackout event and operates in the islanding mode when a grid blackout occurs. Moreover, the inverter can provide continuous power to local loads using the PV array and the EV battery. It takes 1.86 s for the inverter to re-energize the local load after the blackout, as shown in Figure 13. This result proves that the proposed inverter can stabilize the microgrid by detecting the grid blackout event and supplying power to the local load using the islanding mode. In addition, this result means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, about the abnormal conditions of the grid.

Scenario 4: Blackout
verter also operates in the frequency compensation mode and regulates the grid frequency to 60 Hz in 3.69 s. These results prove that the proposed inverter stabilizes the grid frequency by reducing the frequency fluctuation using the frequency compensation mode. In addition, Figure 12 shows that the proposed inverter regulates the grid frequency by supplying or absorbing reactive power to the microgrid by using a V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, according to the grid stability.  As shown in Figure 11b, when the grid frequency decreases to 58 Hz, the proposed inverter also operates in the frequency compensation mode and regulates the grid frequency to 60 Hz in 3.69 s. These results prove that the proposed inverter stabilizes the grid frequency by reducing the frequency fluctuation using the frequency compensation mode. In addition, Figure 12 shows that the proposed inverter regulates the grid frequency by supplying or absorbing reactive power to the microgrid by using a V2G and PV generation in a weak grid. This means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, according to the grid stability.   Figure 13 shows the waveforms of Vinv, Iinv, and Pinv in the islanding mode. The proposed inverter automatically detects a grid blackout event and operates in the islanding mode when a grid blackout occurs. Moreover, the inverter can provide continuous power to local loads using the PV array and the EV battery. It takes 1.86 s for the inverter to reenergize the local load after the blackout, as shown in Figure 13. This result proves that the proposed inverter can stabilize the microgrid by detecting the grid blackout event and supplying power to the local load using the islanding mode. In addition, this result means that the proposed inverter can satisfy the requirements of the grid codes, such as IEEE standard 1547-2018, about the abnormal conditions of the grid.

Comparative Study
The functions for enhancing the grid stability of the proposed inverter and a relevant study in [25] are compared in Table 2. The authors in [25] only considered the grid voltage stabilization. They did not consider the stabilization of the grid frequency, detection for

Comparative Study
The functions for enhancing the grid stability of the proposed inverter and a relevant study in [25] are compared in Table 2. The authors in [25] only considered the grid voltage stabilization. They did not consider the stabilization of the grid frequency, detection for the grid abnormal conditions, and operation in an islanding mode. However, the proposed inverter in this study can improve the microgrid stability of the grid voltage and frequency. Moreover, it can detect the grid abnormal conditions and operate in the islanding mode. These functions of the proposed inverter in this study comply with the grid codes, such as IEEE standard 1547-2018.

Conclusions
This paper proposed a grid-connected inverter for PV-powered EV charging stations to enhance microgrid stability. The proposed inverter can operate in the voltage compensation mode and the frequency compensation mode to enhance microgrid stability. If the microgrid voltage and frequency fluctuate, these operation modes can stabilize the microgrid voltage and frequency by supplying or absorbing active or reactive power to or from a microgrid using EVs and PV generation. Moreover, the proposed inverter can automatically detect the abnormal conditions of the microgrid, such as a blackout, and operate in the islanding mode. It is also possible to continuously supply power to local loads using a V2G and PV generation in the islanding mode. In addition, the proposed inverter can not only enhance the stability of the microgrid but also charge EVs in the appropriate mode according to the conditions of the EVs and PV generation.
The lab-scale testbed of the PV-powered EV charging station was built to verify the superiority and feasibility of the proposed inverter. The proposed inverter was verified in the lab-scale testbed with four scenarios, including grid normal conditions, grid voltage fluctuations, grid frequency fluctuations, and a blackout. The experiment results demonstrated that the proposed inverter satisfies the requirements of the grid codes, such as IEEE standard 1547-2018. In addition, it was proved that the proposed inverter can operate in an appropriate mode for charging EVs according to the conditions of the PV array and EVs. Therefore, by applying the proposed inverter to an EV charging station, it will be possible to charge EVs using PV generation and improve the microgrid stability.