G2V and V2G Operation in Single Phase Grid in MATLAB
G2V and V2G Operation in Single Phase Grid in MATLAB
𝐈𝐧𝐭𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧
𝐆𝐫𝐢𝐝-𝐭𝐨-𝐕𝐞𝐡𝐢𝐜𝐥𝐞 (G2V) and 𝐕𝐞𝐡𝐢𝐜𝐥𝐞-𝐭𝐨-𝐆𝐫𝐢𝐝 (V2G) are important operating concepts in modern electric vehicle charging systems.

In this MATLAB/Simulink model:
𝐆2𝐕 mode allows the electrical grid to charge the EV battery.
𝐕2𝐆 mode allows the EV battery to send stored energy back to the grid.
A 𝐛𝐢𝐝𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐃𝐂-𝐃𝐂 𝐜𝐨𝐧𝐯𝐞𝐫𝐭𝐞𝐫 controls the battery charging and discharging current.
A 𝐬𝐢𝐧𝐠𝐥𝐞-𝐩𝐡𝐚𝐬𝐞 𝐢𝐧𝐯𝐞𝐫𝐭𝐞𝐫 provides controlled power transfer between the DC link and the AC grid.
The DC-link voltage is regulated at approximately 𝐜𝐨𝐧𝐬𝐭𝐚𝐧𝐭 𝐯𝐨𝐥𝐭𝐚𝐠𝐞.
Grid synchronization is achieved using a 𝐏𝐋𝐋.
This model is useful for understanding bidirectional EV charging, grid interaction, converter control, and current direction management in MATLAB/Simulink.
𝐒𝐲𝐬𝐭𝐞𝐦 𝐎𝐯𝐞𝐫𝐯𝐢𝐞𝐰
The complete system consists of the following major sections:
Single-phase utility grid
LCL filter
Single-phase full-bridge inverter
DC-link capacitor
Bidirectional DC-DC converter
EV battery
Battery current controller
DC-link voltage controller
Grid synchronization using PLL
Reference current generation
Proportional Resonant current controller
PWM pulse generation
Main System Parameters
Parameter | Value / Description |
Grid type | Single-phase AC grid |
EV battery nominal voltage | 160 V |
EV battery rated capacity | 120 Ah |
Initial battery SOC | 50% |
DC-link reference voltage | 400 V |
Converter type | Bidirectional DC-DC converter |
Grid converter | Single-phase inverter |
Grid-side filter | LCL filter |
Battery current controller | PI controller |
Inverter current controller | PR controller |
Grid synchronization | PLL |
Operating modes | G2V and V2G |
𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐏𝐫𝐨𝐜𝐞𝐬𝐬
The model supports power transfer in both directions.
𝐆𝐫𝐢𝐝-𝐭𝐨-𝐕𝐞𝐡𝐢𝐜𝐥𝐞 𝐌𝐨𝐝𝐞
In G2V operation:
Power is taken from the single-phase grid.
The inverter transfers power to the DC link.
The bidirectional DC-DC converter regulates the battery charging current.
The EV battery receives energy and operates in charging mode.
Grid voltage and grid current remain approximately in phase.
Therefore, the grid acts as the power source and the battery acts as the load.
𝐕𝐞𝐡𝐢𝐜𝐥𝐞-𝐭𝐨-𝐆𝐫𝐢𝐝 𝐌𝐨𝐝𝐞
In V2G operation:
Power is taken from the EV battery.
The bidirectional converter transfers battery energy to the DC link.
The inverter converts the DC-link power into AC power.
Power is delivered back to the utility grid.
The grid current direction reverses.
Grid voltage and current exhibit approximately 180° phase difference.
Therefore, the EV battery operates as a distributed energy source.
𝐆2𝐕 𝐚𝐧𝐝 𝐕2𝐆 𝐌𝐨𝐝𝐞 𝐂𝐨𝐦𝐩𝐚𝐫𝐢𝐬𝐨𝐧
Operating Condition | G2V | V2G |
Power flow | Grid → EV battery | EV battery → Grid |
Battery condition | Charging | Discharging |
Battery current sign used in model | Negative | Positive |
Grid current relation | Approximately in phase with voltage | Approximately 180° shifted |
Main purpose | Charge EV battery | Supply stored EV energy to grid |
𝐂𝐨𝐧𝐭𝐫𝐨𝐥 𝐒𝐭𝐫𝐚𝐭𝐞𝐠𝐲
1. 𝐁𝐚𝐭𝐭𝐞𝐫𝐲 𝐂𝐮𝐫𝐫𝐞𝐧𝐭 𝐂𝐨𝐧𝐭𝐫𝐨𝐥
The bidirectional DC-DC converter controls the direction and magnitude of battery current.
The control process is:
Measure actual battery current.
Compare it with the reference battery current.
Process the current error using a 𝐏𝐈 𝐜𝐨𝐧𝐭𝐫𝐨𝐥𝐥𝐞𝐫.
Generate the required duty cycle.
Send the duty cycle to the PWM generator.
Generate switching pulses for the upper and lower IGBTs.
Use complementary switching for proper bidirectional converter operation.
The sign of the current reference decides the operating mode.
Current Reference Examples
Battery Current Reference | Operating Mode | Battery Condition |
-2 A | G2V | Charging |
-12 A | G2V | Charging |
+12 A | V2G | Discharging |
2. 𝐃𝐂-𝐋𝐢𝐧𝐤 𝐕𝐨𝐥𝐭𝐚𝐠𝐞 𝐂𝐨𝐧𝐭𝐫𝐨𝐥
The inverter controller regulates the DC-link voltage.
The model maintains the DC-link voltage close to:
400 V
Control steps:
Measure DC-link voltage.
Compare it with the 400 V reference.
Process the voltage error using a PI controller.
Generate the reference current magnitude.
Use this value for grid current reference generation.
Maintaining a stable DC link is important because the inverter and bidirectional converter are both connected through the same DC bus.
3. 𝐏𝐋𝐋-𝐁𝐚𝐬𝐞𝐝 𝐆𝐫𝐢𝐝 𝐒𝐲𝐧𝐜𝐡𝐫𝐨𝐧𝐢𝐳𝐚𝐭𝐢𝐨𝐧
The measured grid voltage is supplied to the Phase Locked Loop.
The PLL provides the grid phase-angle information required for synchronization.
This signal is used to generate a sinusoidal reference waveform synchronized with the grid voltage.
The synchronized waveform is then combined with the current-reference magnitude to obtain the final instantaneous current reference.
4. 𝐏𝐑 𝐂𝐮𝐫𝐫𝐞𝐧𝐭 𝐂𝐨𝐧𝐭𝐫𝐨𝐥
The generated sinusoidal reference current is compared with the measured inverter current.
The resulting current error is processed using a 𝐏𝐫𝐨𝐩𝐨𝐫𝐭𝐢𝐨𝐧𝐚𝐥 𝐑𝐞𝐬𝐨𝐧𝐚𝐧𝐭 (PR) controller.
The PR controller is suitable for single-phase AC current regulation because it helps the inverter current accurately follow a sinusoidal reference.
Its output is combined with the grid-voltage-related control signal and supplied to the PWM stage.
5. 𝐈𝐧𝐯𝐞𝐫𝐭𝐞𝐫 𝐏𝐖𝐌 𝐂𝐨𝐧𝐭𝐫𝐨𝐥
The single-phase inverter uses four IGBT switches.
The PWM section generates four switching pulses to:
Control inverter output current.
Maintain DC-link voltage.
Synchronize inverter current with the grid.
Reverse power-flow direction between G2V and V2G modes.
𝐎𝐩𝐞𝐫𝐚𝐭𝐢𝐧𝐠 𝐒𝐞𝐪𝐮𝐞𝐧𝐜𝐞
A simple step input can be used to demonstrate automatic transition between the two operating modes.
Simulation Time | Battery Current Reference | Mode |
Before 0.5 s | -12 A | G2V |
At and after 0.5 s | +12 A | V2G |
This creates a clear change in battery current direction and grid power-flow direction during the simulation.
𝐒𝐢𝐦𝐮𝐥𝐚𝐭𝐢𝐨𝐧 𝐑𝐞𝐬𝐮𝐥𝐭𝐬
𝐆2𝐕 𝐑𝐞𝐬𝐮𝐥𝐭
During G2V operation:
Battery current becomes negative according to the selected sign convention.
The EV battery enters charging mode.
Battery voltage is approximately around 170 V in the demonstrated operating condition.
Grid voltage and current are approximately in phase.
Active power flows from the grid toward the EV battery.
Example observed condition:
Quantity | Approximate Value / Behaviour |
Battery current | -12 A during demonstrated charging case |
Battery voltage | Around 170 V |
Grid voltage/current phase relation | Approximately 0° |
Power direction | Grid → Battery |
𝐕2𝐆 𝐑𝐞𝐬𝐮𝐥𝐭
When the reference current is changed to a positive value:
Battery current becomes positive.
Battery starts supplying energy.
Current direction reverses.
Grid current changes its phase relationship with grid voltage.
Approximately 180° phase difference can be observed.
Power therefore flows from the EV battery toward the grid.
Quantity | Approximate Value / Behaviour |
Battery current | +12 A |
Battery condition | Discharging |
Grid voltage/current phase relation | Approximately 180° |
Power direction | Battery → Grid |
𝐌𝐨𝐝𝐞 𝐓𝐫𝐚𝐧𝐬𝐢𝐭𝐢𝐨𝐧 𝐑𝐞𝐬𝐮𝐥𝐭
When the step reference changes at 0.5 s:
Battery current changes from approximately -12 A to +12 A.
The charging operation changes into discharging operation.
Grid current phase changes accordingly.
The inverter automatically adjusts its current direction.
The system successfully changes from G2V to V2G operation.
This demonstrates the main advantage of bidirectional EV charging: the same converter system can both absorb and inject electrical power.
𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬
𝐁𝐢𝐝𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐩𝐨𝐰𝐞𝐫 𝐟𝐥𝐨𝐰 between grid and EV battery.
Single-phase grid-connected operation.
LCL filter for grid interfacing.
Bidirectional DC-DC converter for battery current regulation.
PI-based battery current controller.
PI-based DC-link voltage regulation.
PLL-based grid synchronization.
PR controller for sinusoidal grid-current tracking.
Four-pulse inverter PWM control.
Adjustable G2V and V2G battery-current reference.
Automatic mode transition using step input.
Battery charging and discharging waveforms can be observed directly.
Grid voltage-current phase relationship clearly indicates power-flow direction.
MATLAB/Simulink implementation suitable for control-system study and analysis.
𝐀𝐩𝐩𝐥𝐢𝐜𝐚𝐭𝐢𝐨𝐧𝐬
This G2V and V2G MATLAB model can be useful in:
Smart EV charging systems
Bidirectional EV chargers
Smart grid studies
Vehicle-to-grid energy management
Grid-support applications
Distributed energy-resource analysis
EV battery charging research
Power-electronics converter control
Grid-connected inverter studies
Demand-side energy management
Renewable-energy-supported EV charging
Microgrid and EV integration studies
𝐖𝐡𝐲 𝐆2𝐕 𝐚𝐧𝐝 𝐕2𝐆 𝐀𝐫𝐞 𝐈𝐦𝐩𝐨𝐫𝐭𝐚𝐧𝐭
Conventional EV charging normally allows energy to flow only from the grid to the vehicle.
A bidirectional charging system adds the ability to return energy to the grid.
This can help researchers study:
Controlled EV charging
Battery energy utilization
Grid power support
Bidirectional converter design
Current-direction control
DC-link regulation
Grid synchronization
Power-flow reversal
Charging and discharging characteristics
𝐖𝐡𝐚𝐭 𝐂𝐚𝐧 𝐁𝐞 𝐋𝐞𝐚𝐫𝐧𝐞𝐝 𝐅𝐫𝐨𝐦 𝐓𝐡𝐢𝐬 𝐌𝐨𝐝𝐞𝐥?
Students, researchers, and engineers can use this model to understand:
How a single-phase inverter interacts with the utility grid.
How an EV battery can charge and discharge through the same converter.
How battery-current direction controls G2V and V2G operation.
How DC-link voltage is maintained at a fixed reference.
How a PLL synchronizes the converter with the grid.
How a PR controller tracks sinusoidal current.
How phase relationship indicates the direction of active-power transfer.
How a step reference can automatically change the operating mode.
𝐂𝐨𝐧𝐜𝐥𝐮𝐬𝐢𝐨𝐧
The G2V and V2G Operation in Single Phase Grid in MATLAB model demonstrates a complete bidirectional EV charging system using a single-phase grid, inverter, DC link, bidirectional DC-DC converter, and EV battery.
The important operating behaviour can be summarized as:
𝐆2𝐕: Grid supplies power and the EV battery charges.
𝐕2𝐆: EV battery supplies power back to the grid.
Negative battery-current reference represents charging in this model.
Positive battery-current reference represents discharging.
The DC-link voltage is controlled around 400 V.
PLL synchronization and PR current control provide controlled grid interaction.
A step change from -12 A to +12 A demonstrates smooth transition from G2V to V2G mode.
Overall, this MATLAB/Simulink implementation provides a clear and practical platform for studying bidirectional EV charging, single-phase grid integration, power-flow control, battery current regulation, and V2G technology.



Comments