Skip to main content
emobility.academy
M.TechCharging & gridAdvanced About 9 weeksMATLAB & Simulink

Vehicle-to-Grid Bidirectional Charger with Grid Support Functions

Model a single-phase bidirectional EV charger with a grid-tied active front end and a dual-active-bridge DC–DC stage, then add grid-support functions: frequency–watt droop, volt–var control and scheduled discharge. The study measures power quality and the battery cost of grid support.

Tools: Simulink · Simscape Electrical

Vehicle-to-Grid Bidirectional Charger with Grid Support Functions: Learners at an EV charging panel trainer in a DIYguru workshop
Representative photo from DIYguru's EV lab, not of this specific project.

The problem

Vehicle-to-grid lets a parked EV export power to support the grid, but it needs a bidirectional power stage, tight current control for power quality and supervisory logic that respects the driver's energy needs. Each grid-support function also adds battery throughput. This project builds the converter, its control and the support functions, and measures both grid benefit and battery cost.

Objectives

  • Model a grid-tied full-bridge active front end with an LCL or L filter and a DC link.
  • Model a dual-active-bridge DC–DC converter with phase-shift power control.
  • Design a grid current controller with PLL synchronisation for both power directions.
  • Implement frequency–watt droop and volt–var functions with a driver SOC reserve.
  • Measure current THD, power factor, response time and added battery throughput.

What you need

Tools and toolboxes

  • Simulink — Control design, PLL, supervisory logic and logging.
  • Simscape Electrical — Full-bridge converters, high-frequency transformer, LCL filter, grid source and battery model; FFT analysis via the powergui tools.
  • Stateflow — Optional: charge, idle, discharge and grid-support mode logic. A MATLAB Function block can do the same on a base licence.
  • Control System Toolbox — Optional: loop design from linearised plant models with Bode and margin analysis.

Software

  • MATLAB R2023b or later
  • Simulink
  • A grid code or interconnection standard of the user's choice for droop and power-quality limits

Extra parts and data

None beyond the software above.

Key concepts

Active front end
A full-bridge converter that can rectify or invert, controlling grid current to be sinusoidal at any chosen power factor. It replaces the diode rectifier of a one-way charger.
Dual active bridge
Two full bridges linked by a high-frequency transformer. Power flows from the leading bridge to the lagging one, and its magnitude is set by the phase shift between them, P = V1·V2·φ·(π−|φ|)/(2π²·f·L·n).
Phase-locked loop
Tracks grid voltage angle and frequency so the current reference can be synchronised. A second-order generalised integrator (SOGI) PLL is common for single-phase systems.
Frequency–watt droop
When grid frequency falls below a dead band, the charger reduces charging or starts exporting in proportion to the deviation, supporting frequency like a small generator.

Step-by-step guide

  1. 1

    Define ratings and requirements

    Use an example: 7.4 kW single-phase, 230 V, 50 Hz grid; 400 V DC link; 350 V nominal battery. Set targets: grid current THD below 5 per cent at rated power, unity power factor by default, power reversal within 100 ms, droop of full power over a 0.5 Hz deviation with a 0.05 Hz dead band, and a driver SOC reserve below which no export is allowed. Choose an interconnection standard to cite for limits.

    Checkpoint: A requirements table with every target and its source.

  2. 2

    Model the active front end

    In Simscape Electrical, build a single-phase full bridge with IGBTs or MOSFETs, an LCL filter sized for the switching frequency (for example 20 kHz), a DC-link capacitor and an AC voltage source with series impedance for the grid. Use a discrete solver with a step of around 1 µs for the switched model, and also build an average model for long runs.

    Checkpoint: With open-loop sinusoidal PWM the bridge produces an AC voltage whose fundamental matches the modulation index times DC voltage.

  3. 3

    Implement the PLL and current loop

    Build a SOGI-based PLL that outputs grid angle and frequency. Generate a current reference as amplitude times sin(θ). Control grid current with a proportional-resonant controller tuned at 50 Hz, adding harmonic resonant terms if THD is high. An outer PI loop on DC-link voltage sets the current amplitude. Test charging and exporting by reversing the power reference. Discretise the controllers at the switching frequency with Tustin and prewarping at 50 Hz for the resonant term. Add a grid-voltage feedforward so the current loop does not have to work against the grid voltage itself.

    Checkpoint: Grid current is sinusoidal and in phase with voltage when charging, in anti-phase when exporting, with THD below 5 per cent at rated power.

  4. 4

    Model the dual active bridge

    Build two full bridges switching at 50–100 kHz with a high-frequency transformer and a series inductor. Drive both bridges at 50 per cent duty and control power with the phase shift between them. Derive the inductance needed for rated power at about 30 degrees phase shift. Use the average model for long tests and the switched model for waveform checks.

    Checkpoint: Measured DAB power against phase shift follows the analytical curve, and power reverses when the phase shift changes sign.

  5. 5

    Close the battery-side loop

    Add a PI controller on battery current that commands the DAB phase shift. The battery current reference comes from the supervisory power reference divided by battery voltage. Model the battery as an equivalent circuit with SOC. Make sure the AFE DC-link loop and the DAB loop do not fight: keep the DC-link loop slower, or feed the DAB power forward to the AFE.

    Checkpoint: A step in power reference from +7 kW (charging) to −7 kW (exporting) completes within 100 ms with the DC link held within ±5 per cent.

  6. 6

    Add grid-support functions

    Implement frequency–watt droop: compute frequency deviation from the PLL, apply the dead band and a gain, and add the result to the scheduled power reference. Implement volt–var: generate a reactive current component proportional to voltage deviation, within the converter's apparent power limit. Enforce the SOC reserve so export stops when SOC reaches the driver's minimum. Rate-limit the droop output so a noisy frequency measurement does not produce rapid power swings. Prioritise active power or reactive power when the apparent power limit is reached, and state which priority you chose.

    Checkpoint: A simulated 0.3 Hz frequency dip produces a proportional change in power after the dead band, and a voltage rise produces absorbing reactive power.

  7. 7

    Supervisory mode logic

    Build a Stateflow chart (or MATLAB Function) with modes Charge, Idle, V2G and GridSupport. Inputs: driver departure time, target SOC, present SOC, grid frequency and an export schedule. Ensure the vehicle reaches the target SOC by departure, overriding export if needed. Test edge cases such as a frequency event while SOC is at the reserve. Log the active mode as an enumerated signal so it can be plotted alongside power and SOC. Write the edge-case tests as scripted runs so they can be repeated after every change to the chart.

    Checkpoint: In every test case the battery reaches its target SOC by departure, and export never drives SOC below the reserve.

  8. 8

    Power-quality tests

    Using the switched model, measure grid current THD with the powergui FFT tool at 25, 50, 75 and 100 per cent power in both directions. Measure power factor and DC-link ripple. Add 3 per cent fifth-harmonic distortion to the grid voltage and check the current controller still meets the THD target. Run each FFT over an integer number of grid cycles after the loops have settled, using at least ten cycles, so leakage does not inflate the harmonic values or hide a genuine problem.

    Checkpoint: A table of THD and power factor at each operating point, all within the requirements, including the distorted-grid case.

  9. 9

    Battery cost of grid support

    Run a 24-hour scenario using the average model, with a recorded or synthetic grid frequency profile. Compute battery energy throughput with and without grid support, and the equivalent full cycles. Use a simple throughput-based ageing estimate to express added wear. Compare the grid service delivered (energy and response) against that added throughput. Keep the departure time and target SOC the same in both cases so the only difference is the grid-support activity. State the ageing estimate as an assumption, not a prediction for a particular cell.

    Checkpoint: A table comparing throughput, equivalent full cycles and grid service for the with and without cases.

  10. 10

    Analyse and report

    Document the converter design, control structure and tuning, the support functions and the test results. Include waveforms of power reversal, droop response and THD spectra. Discuss the trade-off between grid benefit and battery wear and the dependence on driver behaviour. State that this is a simulation study and that real grid connection requires certified hardware and utility approval. Include a requirement-by-requirement table with the measured value next to each target, so an examiner can check every claim against its evidence at a glance.

    Checkpoint: A report with all requirement checks marked pass or fail and the trade-off clearly quantified.

Testing & validation

  • Grid current THD below 5 per cent at all tested power levels in both directions.
  • Power reversal within 100 ms with bounded DC-link deviation.
  • Droop and volt–var responses match their designed characteristics.
  • SOC reserve and departure target respected in all supervisory test cases.

Expected results

A two-stage bidirectional charger model with verified power quality, working frequency–watt and volt–var support and a quantified battery-throughput cost of providing those services.

Research angle for your M.Tech thesis

Research questions: what grid service can a single bidirectional charger provide per unit of added battery wear, and how should the droop gain and SOC reserve be chosen to balance them? Baselines: unidirectional charging and V2G without grid support. Metrics: frequency response delivered, THD and power factor, battery throughput and estimated capacity fade, driver energy shortfall. Use recorded grid frequency data and published cell ageing data to validate the throughput model. A clear benefit-versus-wear trade-off with a justified control parameter choice, compared against a baseline from literature, would make the work suitable for publication.

Take it further

  • Extend to a three-phase active front end for 11 or 22 kW.
  • Add synthetic inertia (rate-of-change-of-frequency response).
  • Coordinate many vehicles at a depot as an aggregated resource.
  • Replace the throughput ageing estimate with an electrochemical ageing model.

Viva and review questions

How does a dual active bridge control the direction of power?

Power flows from the bridge whose square wave leads to the one that lags. Changing the sign of the phase shift reverses the direction without changing the hardware.

Why use a proportional-resonant controller for grid current?

It has very high gain at the grid frequency, so it tracks a sinusoidal reference with near-zero steady-state error, which a PI controller cannot do in the stationary frame.

Why must the DC-link and DAB loops be coordinated?

Both affect the DC link. If they have similar bandwidth they can interact and oscillate, so one is made slower or the DAB power is fed forward to the front end.

What is the cost of grid support to the vehicle owner?

Extra battery throughput adds wear. The study quantifies it so a fair compensation or a limit on participation can be set.

Learn it at DIYguru

These DIYguru courses and programmes teach what this project needs.

Related EV projects

All 100 MATLAB & Simulink EV projects