ANN Controlled Vehicle to Grid and Grid to Vehicle System Using MATLAB
Product Description
This MATLAB/Simulink model demonstrates a ANN Controlled Vehicle to Grid and Grid to Vehicle System Using MATLAB. The system enables controlled power transfer between an electric-vehicle battery and the utility grid through a grid-connected converter and a bidirectional DC–DC converter.
In V2G mode, the EV battery discharges and supplies power to the grid. In G2V mode, power is drawn from the grid to charge the EV battery. The grid-side converter regulates the DC-link voltage and controls the source current, while the ANN-based battery-side controller determines the converter control output.
The ANN is trained using control outputs generated by a Fuzzy Inference System, allowing the trained network to reproduce the FIS control behaviour with high prediction accuracy. Training, validation, testing, regression, prediction-error and error-histogram results are included to evaluate the ANN controller.
Main Specifications
Simulation platform: MATLAB/Simulink
System type: Single-phase grid-connected V2G–G2V system
Grid voltage: Approximately 230 V RMS
Grid frequency: 50 Hz
Grid-voltage peak: Approximately ±325 V
DC-link voltage reference: 380 V
Battery nominal voltage: Approximately 128 V
Initial battery SOC: Approximately 50%
Battery discharge current: Approximately +10 A
Battery charging current: Approximately −10 A
Simulation duration: 2 seconds
Operating-mode transition: At approximately 1 second
Discrete simulation sample time: 5 × 10⁻⁶ seconds
ANN training epochs: 1000
ANN correlation coefficient: R ≈ 0.99998
Final mean squared error: Approximately 2 × 10⁻⁶
ANN testing error: Predominantly concentrated close to zero
Control methods: PI control, PWM control, FIS reference generation and ANN control
System Configuration
The model consists of:
Single-phase AC grid source
Grid voltage and current measurement blocks
Grid-side bidirectional converter
Grid filter inductor
DC-link capacitor
DC-link voltage measurement
Bidirectional battery DC–DC converter
Converter inductance and DC-side capacitor
Electric-vehicle battery model
Battery voltage, current and SOC monitoring
Grid-side PI control system
Phase-synchronisation and sinusoidal reference generation
Fuzzy Inference System for reference control-data generation
Artificial Neural Network controller
PWM pulse-generation unit
Charging and discharging mode-selection logic
Operating Principle
1. Grid-Side Converter Control
The measured DC-link voltage is compared with the reference value of 380 V. The resulting voltage error is processed by a PI controller to determine the required grid-current amplitude.
A synchronised sinusoidal signal generated from the measured grid voltage is used to form the grid-current reference. The current reference is compared with the measured source current, and the current error is processed by the inner current controller to generate PWM switching pulses.
This control structure maintains the DC-link voltage and supports controlled power exchange with the single-phase grid.
2. Vehicle-to-Grid Mode
During the initial operating interval, the battery current is approximately +10 A. According to the current convention used in the model, positive current represents battery discharge.
The battery SOC gradually decreases from approximately 50%, confirming that energy is transferred from the EV battery toward the DC link and the utility grid. The grid-side converter converts the DC power into AC power and regulates the injected grid current.
3. Grid-to-Vehicle Mode
At approximately 1 second, the operating command changes and the battery current reverses to approximately −10 A. Negative battery current represents charging operation.
Power is then transferred from the single-phase grid through the grid-side converter, DC link and bidirectional DC–DC converter to the EV battery. The battery SOC begins to increase, confirming successful G2V charging operation.
4. DC-Link Response
The DC-link voltage is normally maintained close to its 380 V reference. A temporary voltage reduction occurs near the V2G-to-G2V transition because the direction of battery current and power flow changes.
The controller restores the DC-link voltage to its reference level after the transient. The response demonstrates the ability of the system to maintain DC-bus stability during bidirectional power-flow changes.
5. ANN-Based Converter Control
The Fuzzy Inference System is initially used to generate the desired converter-control output under different input conditions. These input-output samples are used as the ANN training dataset.
After training, the ANN receives the relevant controller inputs and directly predicts the required converter control output. The ANN output is passed through the duty-cycle limiting and PWM-generation stages to operate the bidirectional battery converter.
The FIS-versus-ANN comparison shows that the predicted ANN output closely follows the FIS target throughout the operating range.
ANN Performance
The ANN training results demonstrate highly accurate approximation of the fuzzy controller:
Training correlation: approximately 0.99998
Validation correlation: approximately 0.99998
Testing correlation: approximately 0.99998
Overall correlation: approximately 0.99998
Training, validation and testing errors converge to nearly the same level
Final MSE is approximately in the order of 10⁻⁶
Prediction errors are concentrated around zero
Most testing errors remain within approximately ±0.005
The FIS and ANN outputs almost overlap across the complete output range
The close agreement between training, validation and testing results indicates consistent ANN performance without a significant difference among the datasets.
