top of page

MATLAB Simulation of Fuzzy Logic Control of V2G and G2V in Single Phase Grid

1 day ago
7 min read

MATLAB Simulation of Fuzzy Logic Control of V2G and G2V in Single Phase Grid


𝐈𝐧𝐭𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧

The MATLAB Simulation of Fuzzy Logic Control of V2G and G2V in Single Phase Grid demonstrates bidirectional energy transfer between an electric vehicle battery and a single-phase utility grid.


Fuzzy Logic Control of V2G and G2V in Single Phase Grid

Fuzzy Logic control of V2G and G2V in Single Phase Grid in MATLAB
₹10,000.00₹5,000.00
Buy Now

The Simulink model supports two operating modes:

  • Vehicle-to-Grid (V2G): Battery delivers power to the grid.

  • Grid-to-Vehicle (G2V): Grid supplies power to charge the battery.

A fuzzy logic controller regulates the battery current, while the grid-side converter control maintains the DC-link voltage and controls the grid current.

This model is useful for understanding:

  • Bidirectional EV charging

  • V2G and G2V operation

  • Fuzzy logic current control

  • DC-link voltage regulation

  • Single-phase grid synchronization

  • Unity power factor operation

  • Battery charging and discharging behavior

𝐒𝐲𝐬𝐭𝐞𝐦 𝐎𝐯𝐞𝐫𝐯𝐢𝐞𝐰

The overall system consists of a single-phase grid, grid-side converter, DC link, bidirectional DC-DC converter, LC filter, lithium-ion battery, fuzzy logic controller, and converter control system.

Main System Components

Component

Description

Single-Phase Grid

Supplies or receives electrical power

Source Inductor

Limits and smooths grid current

Grid-Side Converter

Provides AC-DC and DC-AC bidirectional conversion

DC-Link Capacitor

Maintains the intermediate DC voltage

Bidirectional DC-DC Converter

Controls battery charging and discharging

LC Filter

Reduces current and voltage ripple

Lithium-Ion Battery

Energy storage source for V2G/G2V operation

Fuzzy Logic Controller

Controls battery current

PI Controllers

Regulate DC-link voltage and grid current

PLL

Extracts grid phase information

PWM Generator

Generates switching pulses

𝐒𝐲𝐬𝐭𝐞𝐦 𝐏𝐚𝐫𝐚𝐦𝐞𝐭𝐞𝐫𝐬

The important numerical values used in the model are summarized below.

Parameter

Value

Grid Peak Voltage

325 V

Grid Frequency

50 Hz

Source Inductance

2.3 mH

DC-Link Reference Voltage

380 V

Battery Nominal Voltage

220 V

Battery Capacity

48 Ah

Initial Battery SOC

50%

Battery Type

Lithium-Ion

V2G Current Reference

+10 A

G2V Current Reference

-10 A

Fuzzy Error Membership Functions

5

Fuzzy Change-of-Error Membership Functions

5

Fuzzy Output Membership Functions

5

Total Fuzzy Rules

25

Operating Change Time

1 s

𝐕𝟐𝐆 𝐚𝐧𝐝 𝐆𝟐𝐕 𝐎𝐩𝐞𝐫𝐚𝐭𝐢𝐧𝐠 𝐌𝐨𝐝𝐞𝐬

The operating mode is selected by changing the battery current reference.

Current Reference

Battery Condition

Power Direction

Operating Mode

Positive

Discharging

Battery → Grid

V2G

Negative

Charging

Grid → Battery

G2V

Vehicle-to-Grid Mode

When the reference battery current is set to +10 A:

  • Battery operates in discharge mode.

  • Battery current follows approximately +10 A.

  • Battery SOC gradually decreases.

  • Power flows from the EV battery toward the grid.

  • Grid current direction changes according to exported power.

  • DC-link voltage is maintained near its reference value.

Grid-to-Vehicle Mode

When the current reference is changed to -10 A:

  • Battery operates in charging mode.

  • Battery current changes toward -10 A.

  • Battery SOC begins increasing.

  • Grid supplies power to the EV battery.

  • Grid voltage and current operate with the required phase relationship.

  • DC-link voltage returns to its reference after the transient.

𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐏𝐫𝐨𝐜𝐞𝐬𝐬

The complete power conversion path can be understood as:

Single-Phase Grid → Bidirectional Grid Converter → DC Link → Bidirectional DC-DC Converter → Battery

Power can also flow in the reverse direction:

Battery → Bidirectional DC-DC Converter → DC Link → Grid Converter → Single-Phase Grid

The direction of power flow depends mainly on the selected battery current reference.

Basic Operating Sequence

  1. The single-phase grid is connected to the grid-side converter.

  2. The converter establishes the controlled DC-link voltage.

  3. The battery is connected through the bidirectional DC-DC converter.

  4. The desired battery current reference is selected.

  5. Actual battery current is measured.

  6. Reference and measured currents are compared.

  7. Current error is calculated.

  8. Change in current error is determined.

  9. Both signals are supplied to the fuzzy controller.

  10. Fuzzy logic generates the required duty-cycle command.

  11. PWM pulses operate the bidirectional converter.

  12. Battery charging or discharging takes place according to the reference.

𝐂𝐨𝐧𝐭𝐫𝐨𝐥 𝐒𝐭𝐫𝐚𝐭𝐞𝐠𝐲

The system uses two major control sections:

  • Fuzzy Logic Battery Current Control

  • Grid-Side Converter Control

𝐅𝐮𝐳𝐳𝐲 𝐋𝐨𝐠𝐢𝐜 𝐂𝐨𝐧𝐭𝐫𝐨𝐥

The fuzzy logic controller is responsible for controlling the battery current.

Fuzzy Controller Inputs

Two input variables are used:

  • Current Error

  • Rate of Change of Current Error

The actual battery current is continuously compared with the selected current reference.

Fuzzy Controller Output

The fuzzy controller generates:

  • Duty Cycle

The generated duty cycle is sent to the PWM generator, which produces gate pulses for the bidirectional DC-DC converter.

Fuzzy Logic Configuration

Fuzzy Variable

Number of Membership Functions

Current Error

5

Change of Error

5

Duty Cycle Output

5

Total Rule Base

25 Rules

The 25-rule fuzzy rule base determines the appropriate duty-cycle correction depending on battery current error conditions.

𝐁𝐢𝐝𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧𝐚𝐥 𝐃𝐂-𝐃𝐂 𝐂𝐨𝐧𝐯𝐞𝐫𝐭𝐞𝐫 𝐂𝐨𝐧𝐭𝐫𝐨𝐥

The battery-side converter contains two IGBT switches and operates bidirectionally.

Its main functions are:

  • Controlling battery charging current

  • Controlling battery discharging current

  • Enabling V2G operation

  • Enabling G2V operation

  • Maintaining accurate battery current tracking

  • Providing controlled power exchange with the DC link

The switching action changes automatically according to the fuzzy controller output.

𝐆𝐫𝐢𝐝-𝐒𝐢𝐝𝐞 𝐂𝐨𝐧𝐯𝐞𝐫𝐭𝐞𝐫 𝐂𝐨𝐧𝐭𝐫𝐨𝐥

The grid-side converter performs both rectifier and inverter operation.

It is designed to:

  • Maintain the DC-link voltage

  • Generate sinusoidal grid current

  • Synchronize grid current with grid voltage

  • Support bidirectional power transfer

  • Maintain good power factor

DC-Link Voltage Control

The DC-link voltage is measured and compared with the 380 V reference.

The resulting error is processed by a PI controller.

The controller produces the required grid current magnitude reference.

𝐏𝐋𝐋 𝐚𝐧𝐝 𝐒𝐲𝐧𝐜𝐡𝐫𝐨𝐧𝐢𝐳𝐚𝐭𝐢𝐨𝐧

Grid voltage is measured and supplied to the Phase-Locked Loop (PLL).

The PLL provides the grid phase angle.

This phase information is used to generate a sinusoidal reference waveform synchronized with the grid.

The resulting reference is combined with the grid current magnitude command to obtain the instantaneous source current reference.

𝐂𝐮𝐫𝐫𝐞𝐧𝐭 𝐂𝐨𝐧𝐭𝐫𝐨𝐥 𝐋𝐨𝐨𝐩

The desired source current is compared with the measured source current.

The current error is processed through another PI controller.

The controller produces the modulation signal required by the PWM generator.

The PWM generator then controls the switches of the single-phase grid converter.

This control helps obtain:

  • Sinusoidal grid current

  • Controlled current magnitude

  • Required current phase

  • Stable DC-link voltage

  • Bidirectional power transfer

𝐒𝐢𝐦𝐮𝐥𝐚𝐭𝐢𝐨𝐧 𝐓𝐞𝐬𝐭 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧

The model is tested using two current-reference levels.

Simulation Interval

Battery Current Reference

Operating Mode

Initial Period

+10 A

V2G

After 1 Second

-10 A

G2V

The model can also be tested in the reverse sequence:

Initial Condition

Second Condition

-10 A → G2V

+10 A → V2G

This allows the user to study dynamic transition between both power-flow modes.

𝐒𝐢𝐦𝐮𝐥𝐚𝐭𝐢𝐨𝐧 𝐑𝐞𝐬𝐮𝐥𝐭𝐬

Several important signals are observed during simulation.

1. Source Voltage

  • Maintains the required sinusoidal waveform.

  • Operates at 50 Hz.

  • Used as the synchronization reference for converter control.

2. Source Current

The source current changes according to power-flow direction.

During V2G

  • Battery delivers energy to the grid.

  • Current direction corresponds to power export.

  • Grid voltage and current show the required phase relationship for reverse power flow.

During G2V

  • Grid supplies energy to the battery.

  • Current follows the charging power requirement.

  • Grid voltage and current operate approximately in phase for grid-to-battery energy transfer.

𝐁𝐚𝐭𝐭𝐞𝐫𝐲 𝐂𝐮𝐫𝐫𝐞𝐧𝐭 𝐑𝐞𝐬𝐩𝐨𝐧𝐬𝐞

The fuzzy controller tracks the selected reference current.

Operating Mode

Reference

Battery Current Response

V2G

+10 A

Approximately +10 A

G2V

-10 A

Approximately -10 A

When the current reference changes, the controller automatically changes the converter operating condition.

𝐁𝐚𝐭𝐭𝐞𝐫𝐲 𝐒𝐎𝐂 𝐁𝐞𝐡𝐚𝐯𝐢𝐨𝐫

Battery SOC provides a clear indication of power-flow direction.

During V2G

  • Battery discharges.

  • SOC gradually decreases.

During G2V

  • Battery charges.

  • SOC gradually increases.

This behavior confirms correct bidirectional operation.

𝐃𝐂-𝐋𝐢𝐧𝐤 𝐕𝐨𝐥𝐭𝐚𝐠𝐞 𝐑𝐞𝐬𝐩𝐨𝐧𝐬𝐞

The DC-link voltage reference is fixed at 380 V.

During normal operation:

  • DC-link voltage remains close to 380 V.

  • A temporary transient appears when the operating mode changes.

  • The voltage subsequently settles back near the reference.

According to the demonstrated response, the settling occurs approximately 0.2 seconds after the operating-mode transition.

Condition

DC-Link Response

Steady-State V2G

Maintained near 380 V

V2G → G2V Transition

Temporary undershoot

After Transition

Returns near 380 V

Approximate Settling Time

0.2 s

𝐏𝐨𝐰𝐞𝐫 𝐅𝐚𝐜𝐭𝐨𝐫 𝐎𝐩𝐞𝐫𝐚𝐭𝐢𝐨𝐧

The converter control system is designed to maintain proper grid-current synchronization.

During both operating modes, the control maintains a high-quality sinusoidal current waveform while changing the direction of active power.

This demonstrates effective grid-side control during:

  • EV battery charging

  • EV battery discharging

  • Power-flow reversal

  • Dynamic mode transition

𝐊𝐞𝐲 𝐅𝐞𝐚𝐭𝐮𝐫𝐞𝐬

  • Single-phase V2G and G2V simulation

  • Fuzzy logic-based battery current control

  • 25-rule fuzzy inference system

  • Bidirectional power flow

  • Lithium-ion battery modeling

  • Bidirectional DC-DC converter

  • Bidirectional AC-DC converter

  • 380 V DC-link regulation

  • PLL-based grid synchronization

  • PI-based voltage and current control

  • Sinusoidal PWM control

  • V2G-to-G2V dynamic transition

  • Battery SOC monitoring

  • Battery current reference tracking

  • Grid voltage and current analysis

𝐀𝐩𝐩𝐥𝐢𝐜𝐚𝐭𝐢𝐨𝐧𝐬

This MATLAB/Simulink model can support learning and research in:

  • Electric vehicle charging systems

  • Smart grid integration

  • Vehicle-to-grid technology

  • Grid-to-vehicle charging

  • Bidirectional EV chargers

  • Fuzzy logic control

  • Battery energy management

  • Smart charging systems

  • Renewable energy integrated EV charging

  • Distributed energy systems

  • Grid support using EV batteries

  • Power electronic converter control

𝐖𝐡𝐲 𝐔𝐬𝐞 𝐅𝐮𝐳𝐳𝐲 𝐋𝐨𝐠𝐢𝐜 𝐂𝐨𝐧𝐭𝐫𝐨𝐥?

Fuzzy logic is useful for this type of system because it provides flexible nonlinear control without requiring a highly complicated mathematical model.

In this simulation, fuzzy logic helps:

  • Track the desired battery current

  • Control charging and discharging

  • Respond to reference-current changes

  • Generate suitable converter duty cycles

  • Handle bidirectional operating conditions

  • Improve the understanding of intelligent EV converter control

𝐖𝐡𝐨 𝐂𝐚𝐧 𝐔𝐬𝐞 𝐓𝐡𝐢𝐬 𝐌𝐨𝐝𝐞𝐥?

This simulation is suitable for:

  • Electrical engineering students

  • Power electronics learners

  • MATLAB/Simulink users

  • EV charging researchers

  • Smart grid researchers

  • Control engineering students

  • Power system engineers

  • Researchers working on V2G and G2V technologies

𝐂𝐨𝐧𝐜𝐥𝐮𝐬𝐢𝐨𝐧

The MATLAB Simulation of Fuzzy Logic Control of V2G and G2V in Single Phase Grid demonstrates effective bidirectional energy transfer between an electric vehicle battery and the utility grid.

The fuzzy logic controller regulates battery current, while the grid-side converter control maintains the 380 V DC link, produces controlled sinusoidal grid current, and manages power-flow reversal.

With a 220 V, 48 Ah lithium-ion battery, a 50 Hz single-phase grid, and selectable +10 A / -10 A battery-current references, the model clearly demonstrates charging, discharging, SOC variation, DC-link transient response, and V2G/G2V mode transition.

It provides a clear MATLAB/Simulink platform for studying fuzzy logic control, bidirectional EV charging, grid-connected power converters, and intelligent energy exchange between electric vehicles and the electrical grid.

Comments


bottom of page