Modelling of EV using MATLAB and Simulink
AIM: To create a basic Electric Vehicle model using MATLAB/Simulink
OBJECTIVES:
1. Explain System-level configurations.
2. Explain each model parameters & blocks.
3. Comment on results.
4. Conclusion.
EXPLANATION:
Electric vehicles have low running costs as they have fewer moving parts for maintenance and are also very environmentally friendly as they use little or no fossil fuels (petrol or diesel). While some EVs used lead-acid or nickel-metal hydride batteries, the standard for modern battery electric vehicles is now considered to be lithium-ion batteries a s they have greater longevity and are excellent at retaining energy, with a self-discharge rate of just 5% per month. Despite this improved efficiency, there are still challenges with these batteries as they can experience thermal runaway, which has, for example, caused fires or explosions in the Tesla Model S, although efforts have been made to improve the safety of these batteries.
What are the inner parts of an EV?
EVs have 90% fewer moving parts than an ICE (Internal Combustion Engine) car. Here's a breakdown of the parts that keep an EV moving:
- Electric Engine/Motor - Provides power to rotate the wheels. It can be DC/AC type, however, AC motors are more common.
- Inverter - Converts the electric current in the form of Direct Current (DC) into Alternating Current (AC)
- Drivetrain - EVs have a single-speed transmission that sends power from the motor to the wheels.
- Batteries - Store the electricity required to run an EV. The higher the kW of the battery, the higher the range.
- Charging - Plug into an outlet or EV charging point to charge your battery.
Working principle of EV:
When the pedal of the car is pressed, then:
- The controller takes and regulates electrical energy from batteries and inverters
- With the controller set, the inverter then sends a certain amount of electrical energy to the motor (according to the depth of pressure on the pedal)
- An electric motor converts electrical energy into mechanical energy (rotation)
- Rotation of the motor rotor rotates the transmission so the wheels turn and then the car moves.

Basic block model of an EV:

fig. Electric Vehicle architecture
The block diagram above describes the basics architecture of an Electric Vehicle.
Drive cycle: This is the input given to the vehicle. There are different types of drive cycle based on the application we choose. In this vehicle is simulated for acceleration & deceleration for a particular type with the varying speed range.
Driver controller: To drive the drive cycle as per the given condition, a driver controller is present to run the vehicle taking the input and feedback from to move from one place to another.
Power Converter: They are used to process and control the flow of electrical energy by supplying required voltages and current in a form that is optimally suited for the user loads.
Battery: This the powerhouse which supplies the energy required to drive the vehicle.
Motor: It is the rotating device which converts the electrical energy in the form of current and voltage into the mechanical energy at the vehicle through a transmission system.
Vehicle body: This is where the output is achieved via the motor power is transferred to the wheel considering the different forces and resistance and compare with the input drive cycle.
Powertrain Blocksets:
They provide fully assembled reference application models of automotive powertrains, including gasoline, diesel, hybrid, and electric systems. It includes a component library for simulating engine subsystems, transmission assemblies, traction motors, battery packs, and controller models. Also, they provide a standard model architecture that can be reused throughout the development process. It can use it for design tradeoff analysis and component sizing, control parameter optimization, and hardware-in-the-loop testing. And it can customize models by parameterizing components in a reference application with customizing data or by replacing a subsystem with the self-created model.
Simulink Model:

DETAILED MODEL STUDY: Configuration & Parameters
1) VEHICLE BLOCK:
Vehicle Block consists of Body of vehicle, Tires and Transmission System. Vehicle block is shown below:
a) Vehicle Body:

- represents a two-axle vehicle body in motion.
- accounts for body mass, aerodynamic drag, grade,externally-defined mass and center of gravity of the vehicle body.
Input Ports:
- W - Wind Velocity in m/s
- beta - Grade angle in radians
Output Ports:
- V - Velocity in m/s
- NR - Normal force on Rear Axle (N)
- NF - Normal Force on Front Axle (N)
Vehicle Body Parameters:

- Vehicle body mass, Centre of gravity distance values and aerodynamic drag variables are modified.
- Pitch dynamics are kept ON with other variable values as default values.
b) Tires

- used to model a tire with longitudinal behavior given by equation based on four fitting coefficients.
- The block can model tire dynamics under constant or variable contact surface conditions.
Input Port:
- N - Normal force acting on tire, positive when force is acting downwards/towards the contact surface,
Output Port:
- S - Slip value relative to tire and surface of contact.
Conserving Ports:
- H - represents wheel hub which transmits thrust generated by the wheel to the body of the vehicle.
- A - represents axle on which the tires are mounted.
Tire Parameters:

- Nominal load and radius of tires are modified.
- Rolling resistance is kept at default values and dynamics depends on default damping and stiffness values of the tire.
c) Gear

- A simple gear block is used to connect the motor to the rear axle of the vehicle.
- It represents the gearbox which connects the input shaft to the base gear and ouput from the foller gear.
Conserving Ports:
- B - port associated with input shaft (motor shaft)
- F - port associated with ouput shaft (axle / differential)
Simple Gear Parameters:

- Gear ratio and output direction is modified.
- Meshing loss is kept constant and gear is having a constant efficiency throughout the simulation.
- Viscous losses and faluts are kept at default conditions.
2) MOTOR & POWER CONVERTER:
The motor & its control block is as shown below:

The components and parameters of the motor and power control block is as follows:
a) DC Motor:

Ports:
- + - Ports receiving electrical signal associated with Motor positive terminal
- - - Port receiving electrical signal associated with Motor Negative terminal.
- C - Mechamical conserving port associated with casing of the motor and is connected to a mechanical rotational reference block
- R - Mechanical conserving port associated with Rotor shaft of the motor which produces required input to the transmission system.
Motor Parameters:

- Model parameterization is set to Rated load and speed condition.
- Rated voltage, speed and load values alongwith No-load speed is modified.
- Mechanical variables are kept as default vlaues only.
b) H-Bridge:

- H-Bridge block is used to represent H-bridge motor driver which controls the power innput to the motor accoeding to the load requirements.
- Output provided by the block is controlled voltage depending on the control signal
Ports:
- + - Conserving port associated with positive load connection usually connected to positive port of the motor.
- - - Conserving port associated with negative load connection usually connected to the negative terminal of the motor.
- PWM - Conserving port associated with PWM control signal (voltage pulses)
- REF - Conserving port associated with a ZERO voltage reference.
- REV - Conserving port associated with voltage controlling polarity change of Bridge outut signal.
- BRK - Conserving port associated with voltage when brakes are applied, thereby aiding the process of regenerative braking.
H-Bridge Parameters:

- H-Bridge is selected to have its own power source as internal.
- Averaged simulation is selected for faster simulation and Regenerative braking is enabled.
- Output voltage amplitude is set as equal to rated voltage of the motor. Rest values are left as default values only.
The acceleration(PWM) and deceleration(BRK) command signal from the driver is controlled by a Controlled Voltage Source before it is fed to the H-Bridge. Default parameters are maintained for the Controlled Voltage Source.
c) Controlled PWM voltage

- produces Pulse-Width modulated signals to control voltage fed to H-Bridge as per requirements.
Conserving Ports:
- ref+ - positive reference voltage signal port
- ref- - negative reference voltage signal port
- PWM - Pulse-Width mmodulated electrical signal
- REF - Port associated with ZERO voltage reference
Controlled PWM voltage Source Parameters:
- The simulation mode is set to PWM and output voltage amplitude is set similar to the input signal amplitude of the H-Bridge
d) Solver COnfiguration

- A solver configuration block specifies solver parameters necessary for simulation and is connected to the physical network of motor controller.
3) BATTERY
Components of battery block is depicted below:

- represents the powerhouse of the model which supplies the power required by the motor as controlled by the controllers.
- SoC calculation of battery is done to trace the battery reliability and range of the vehicle model. Soc is calculated by reducing the usage from the nominal SoC value on a timely basis.
Battery Parameters:

- Nominal voltage, Ampere-hour rating values are modified keeping dynamics OFF and other variables as default values.
- Rate transition and time integration is used inorder to calculate real-time SoC values.
4) LONGITUDINAL DRIVER

- Represents a longitudinal speed controller which produces acceleration and deceleration commads based on input and feedback speed variables provided using a Proportional integral (PI) control.
Input Ports:
- VelRef - input port associated with input reference velocity of the vehicle (m/s)
- VelFdbk - input port associated with velocity feedback from the vehicle which helps in smooth control of the system.
- Grade - input port associated with inclination of surface in degrees.
Ouput Ports.
- Info - ouput port associated with a bus signal for acceleartion, deceleration, error in velocity etc
- AccelCmd - Output port associated with acceleration commands with reference to input signal.
- DecelCmd - Output port associated with deceleration commads with reference to the input drive signal.
Driver Parameters:

- Proportional-Integral Control Type is selected and the other control variables are kept as default values.
5) DRIVE CYCLE SOURCE

- Represents block which generates a drive cycle for a particular time. It is basically time vs speed data which resembles similar to that of a real-time driving conditions with acceleration and deceleration in an irregular patern.
- By default, FTP75 drive cycle is selected. Wide-Open-Throttle condition can also be selected. Drive cycle data can also be taken from spreadsheet data or through a glider block or a signal bulider block.
- Simulation default time for FTP75 is 2474 seconds.

- Wide open throttle Condition is also Simulated with following parameters.

(2) Driver Controller:
The input from the drive cycle is attached to VelRef port, the feedback is gained from the vehicle body which acts as feedback signal is connected to VelFdbk. The AccelCmd & DecelCmd are the output signal given for accelerating and braking to the vehicle. A terminator block is connected to Info port as we are not using any bus signals for this model. A constant block is attached to the Grade port as road grade angle is 0 in our case, i.e the vehicle is running at a straight road.

fig. Longitudinal driver system block
Longitudinal driver block: It is a parametric longitudinal speed tracking controller for generating normalized acceleration and braking commands based on reference and feedback velocities. They use the external actions to input signals that can disable, hold, or override the closed-loop commands determined by the block.

Port:
| Port Name | Description |
| VelRef | Input port for the reference velocity signal |
| VelFdbk | Input port for the feedback velocity signal |
| Grade | Input port for the gradability to the vehicle (road grade angle) |
| AccelCmd | Output port for the acceleration signal command |
| DecelCmd | Output port for the deceleration or braking signal command |
| Info | Bus signal for Gear, clutch, acceleration, etc. |
(3) Power Converter:
This is the main circuit where the input signals are processed and are sent at the output. The electrical power from the battery source is converted into the mechanical output of the DC motor. This block is divided into 3 stages.

fig. Power converter system blocks
Stage 1: PWM controlled voltage
Stage 2: H-birdge motor drive
Stage 3: Simple DC motor
At stage 1, there are two controlled voltage sources used, one takes the input signals for acceleration from the longitudinal driver's output signal and another is used for deceleration or braking.
At stage 2, the circuit consists of a controller and an H-Bridge. The controlled PWM voltage block receives the input signal from the Acceleration's Controlled voltages source and generated modulated width pulses output for the H-Bridge and which is connected to the positive terminal of the block. The PWM signals are received by the H-Bridge connected to the PWM port of it. The other controlled voltage source is connected to the braking port of an H-Bridge. The reverse port is connected to the ground along with the Reference port. Here we have used selected as Average as the simulation mode to reduce the time for the overall operation.
At stage 3, a DC motor receives the input signal from the H-Bridge and in between them is the current sensor. The rotational motion signal is sent as an output to the motor shaft. A mechanical rotation reference is connected at the constant port.
A battery is attached separately, which is not directly connected to the DC motor but is used for visualization of the SOC of the battery. The signal from the current sensor goes into the controlled current source block. Thus, generating current whenever the vehicle goes into regenerative mode. A subsystem is attached to display the SOC of the battery which is in series with the output signal of the current sensor.
(4) Vehicle body
This subsystem represents the 4 wheeler vehicle body with the transmission.

fig. Vehicle body system sub-block
A set of four tire block are used - two for the front axle and two for the rear axle and the required connections are made with the vehicle body block. The normal force signal from the vehicle body block is sent to the normal force input ports of the tires.
The A ports of the tire are the mechanical rotational conserving port and receive mechanical rotational input from the gearbox which receives its input from the DC motor.
The H port of the tire is the mechanical translational conserving port for the wheel hub and is connected to the H port of the vehicle body through which the trust developed by the tire is applied to the vehicle.
Here we are not considering any slip, so an terminator block is connected to all the slip port of each tire. Also, grade angle and wind velocity are not considered.
The input is received from the DC motor to the simple gear block which is then transmitted to the wheel considering the inertia couple at the output shaft.
(i) Vehicle body:
The block represents a two-axle vehicle body in longitudinal motion. The block accounts for body mass, aerodynamic drag, road incline, and weight distribution between axles due to acceleration and road profile. The vehicle can have the same or a different number of wheels on each axle. Optionally include pitch and suspension dynamics or additional variable mass and inertia. The vehicle does not move vertically relative to the ground.

Parameters:
The weight of the vehicle is considered as 800 kg and rest of the parameters are same as default ones.

Ports:
| Port Name | Description |
| H | It is the mechanical translation converting port associated with the horizontal motion of the vehicle body |
| NR | Signal output port for rear normal wheel forces |
| NF | Signal output port for front normal wheel forces |
| V | Signal output port for vehicle velocity |
| Beta | Signal output port for road inclination angle |
| W | Signal output port for headwind speed |
(ii) Tire (Magic formula):
The block represents the longitudinal behavior of a highway tire characterized by the tire Magic Formula. The block is built from Tire-Road Interaction (Magic Formula) and Simscape Foundation Library Wheel and Axle blocks. Optionally, the effects of tire inertia, stiffness, and damping can be included.

Parameters:
The tire is parameterized by peak longitudinal force and corresponding slip and rest of the parameters are keep as same as default.

Ports:
| Port Name | Description |
| N | Signal input port that applies the normal force acting on the tire |
| A | It is the mechanical rotational conserving port for the wheel axle |
| S | Signal output port that reports the tire slip |
| H | It is the mechanical translational conserving port for the wheel hub |
(iii) Simple gear:

Parameter:
In the we have kept gear ratio as 7. The more the gear ratio the better the speed with more traction power. As torque is directly is directly proportional to the speed. The gear ratio is high at the start of the vehicle as it requires more torque and as the speed increases, torques redues and so as the gear ratio. For our application, the range of gear ratio is from 5-10.

Ports:
| Port Name | Description |
| B | Input signal for mechanical rotational conserving port from DC motor |
| F | Output signal for mechanical rotational conversing port after gear reduction |
(iv) Shaft inertia:
The block represents an ideal mechanical rotational inertia. The block positive direction is from its port to the reference point. This means that the inertia torque is positive if the inertia is accelerated in the positive direction.

Parameters:
All the parameters are kept as default.

(5) SOC (Stage of Charge):
This will determine the voltage level in the battery at each point of simulation. The output from the current block is received at the input signal of the block and display the characteristic of the battery voltage consumed for the particular drive cycle.

The sub-block of the SOC contains the Rate transition block, gain block and the discrete time ingegrator. The decrease & increase of the battery voltage is have multiple data point which is handle by the rate transistor. Then this converts these data points and calculate the SOC at each point of the drive cycle. The gain block will calculate the values and display on the scope.
The gain is given by
K=1V_rated⋅Time">K=1V_rated⋅TimeK=1V_rated⋅Time
where, time is in secs, i.e. 3600 and the multiplication is element-wise.

fig. SOC Sub-block system
(i) Rate Transistion:
It handles data transfer between different rates and tasks.

Parameters:

(ii) Gain:

(iii) Discrete-time Integrator:
It is the accumulation of the input signals.

Parameters:

(5) Output circuit:
The output of the vehicle body is Velocity which is sent as feedback to the longitudinal driver block and is separately used to calculate the distance travelled by the vehicle through another subsystem - distance calculator.
The velocity signal is first integrated to calculate the distance and then divide by 3600 to convert the distance into km.

fig. Output system display block
COMPLETE MODEL OF AN EV:

fig. Simulink model of an EV
RESULTS:
The simulations are run for various drive cycles and the results are in the following table.
Simulation Time - It is the time for which the simulation is run. Each drive cycle has its own time duration which needs to be updated in simulation time, each time the drive cycle is changed.
Speed Trace - It is a plot of the reference speed from the drive cycle and the feedback speed from the vehicle body.
SOC (%) - It is the state of charge of the battery which decreases when the vehicle accelerated and slightly increases when the vehicle decelerates.
Distance Travelled - It is the total distance travelled by the vehicle following a particular drive cycle and its duration.
| Case 1 | Case 2 | Case 3 | Case 4 | |
| Drive Cycle, Simulation Time (sec) | FTP75, 2474 | US06,600 | Artemis Motorway 150kmph, 1068 | World Harmonized Vehicle Cycle (WHVC),900 |
| Vehicle body weight (kg), Frontal area (m2), Drag co-efficient, Rolling resistance | 800,3, 0.4, 0.015 | 800,3, 0.4, 0.015 | 800,3, 0.4, 0.015 | 800,3, 0.4, 0.015 |
| Battery Nominal Voltage (V) | 300 | 300 | 400 | 200 |
| DC Motor Rated load (kW), Rated DC supply voltage (V) | 60, 300 | 75, 200 | 85, 350 | 60, 150 |
| H-Brigde Output voltage amplitude | 300 | 200 | 350 | 150 |
| Distance (km), Top speed (kmph) | 4.97, 25.2 | 3.54,30.8 | 7.77, 32.6 | 1.52,18.2 |
| SOC at end of drive cycle (Initial SOC 100%) | 96 | 94 | 93 | 97 |
| Top speed reached? kWh per km | Yes | No | No | Yes |
Output graphs:
(I) Case 1
(i) Speed Charateristics:

(ii) SOC (%):

(II) Case 2
(i) Speed Charateristics:

(ii) SOC (%):

(III) Case 3
(i) Speed Charateristics:

(ii) SOC (%):

(IV) Case 4
(i) Speed Charateristics:

(ii) SOC (%):

CONCLUSION:
- In the speed trace plots for all the drive cycles which are observed in this study, the feedback speed plot and the reference speed plot overlap each other almost completely but there are regions where both the speeds are different. It is when the vehicle is decelerating.
The reference speed plot falls sharply but the feedback speed does not. This is due to the inertia of the vehicle body. As the inertia of the vehicle body is higher, it takes a longer duration for it to decelerate. That is why the overlapping is not 100%. - The battery's state of charge for each drive cycle can be visualized from the SOC plot. As long as the vehicle is accelerating the SOC is decreasing but as soon as the deceleration starts, the SOC plot goes slightly up. This is because the battery is being charged, due to regenerative braking during deceleration.
FUTURE SCOPE:
- Detailed Parameterisation of Block variables of the model to reduce the variation between reference speed signal and ouput speed signal.
- Optimisation of battery pack for increased mileage and peak performance.
- Detailed simulation rather than performing averaged mode simulation.