Project-1: Modelling an electric Car with Li-ion battery
Project : Modelling an Electric Car with Li-ion Battery -
Q : Create a MATLAB Model of Electric car which uses lithium ion battery and suitable blocks from SImscape or Powertrain block set. Implement the vehicle speed control using PI controller and generate brake and accelerator commands. Avoid using readymade driver block for speed control.
Prepare a report about your model including the following.
Objectives, System level configurations, Model Parameters, Results, Conclusion.
(Note : The Simulink model file should be compulsorily attached).
A). AIM : Create a Simulink model of an Electric Car that uses a Lithium-ion battery and a DC Motor.
OBJECTIVES : To create a Simulink model of an Electric car with the neccesory components like Lithium battery, DC Motor, Vehicle Body and connections and visualize the discharge characterstics of the battery and to create a control of Vehicle speed using PI controller and generate brake and accelerator commands with avoid using readymade driver block for speed control.
EV model System level configurations :

Electric Vehicle : Plug-in electric vehicles (also known as electric cars or EVs) are connected, fun, and practical. They can reduce emissions and even save you money.
Fueling with electricity offers some advantages not available in conventional internal combustion engine vehicles. Because electric motors react quickly, EVs are very responsive and have very good torque. EVs are often more digitaly connected than conventional vehicles, with many EV charging stations providing the option to control charging from a smartphone app.
Just like a smartphone, you can plug in your EV when you get home and have it ready for you to use the next morning, Since the electric grid is available almost anywhere, there are a variety of options for charging: at home, at work or on the road. By charging often, you may never need to go to a gas station again!
But EVs provide more than just individual benefits. EVs can help the United States have a greater diversity of fuel choices available for transportation. The U.S. used nearly nine billion barrels of petroleum last year, two-thirds of which went towards transportation. Our reliance on petroleum makes us vulnerable to price spikes and supply disruptions. EVs help reduce this threat because almost all' U.S. electricity is produced from domestic sources, including coal, nuclear, natural gas, and renewable sources.
EVs can also reduce the emissions that contribute to climate change and smog,improving public health and reducing ecological damage Charging your EV on renewable energy such as solar or wind minimizes these emissions even more. See the difference in emissions between a coventional vehicle and an EV using the calculator on the right. Learn more about how EVs reduce pollution and their lfecycle emissions.
The main components of an Electric vehicle are :
- Battery (auxiliary) : The auxiliary battery of the electric vehicle provides electricity to power the accesories of the vehicle.
- Electric traction motor : Power is taken from the traction battery pack and with the motor drives the wheels of the vehicle. Some vehicles use motors which serve as drive as well as regeneration.
- Onboard charger : AC electricity supplied via the charge port is converted to DC power for charging the traction battery. It also communicates with the charging equipment and monitors battery characteristics such as voltage, current,temparature and state of charge while charging the pack.
- Thermal system (cooling) : The thermal system for cooling makes sure that proper operating temparature range of the engine, power electronics, electric motor and other components are maintained.
- Power electronics controller : The flow of electricity which is delivered by the traction battery to the electric motor is controlled and required speed and torque is produced.
- DC/DC converter : The high voltage of the traction battery is stepped down to a low voltage DC power to run the vehicle accesories and recharge the auxiliary battery.
- Charge port : The charge port is an external power supply from which the traction battery in the electric vehicle is charged.
- Transmission (electric) : The transmission converts electric power to mechanical power in order to drive the wheels of the vehicle.
- Traction battery pack : The traction battery pack stores electricity for use by the electric tranction motor.
Block Diagram :

Model Parameters :
Vehicle Body Subsystem :

The following blocks that were used for the creation of this model :
- Vehicle Body
- Tire (magic formula)
- Simple gear
- Inertia
- PS constant
Vehcile Body :

This vehicle body block is a representation of a two--axle vehicle body in longitudinal motion. The vehicle can have the same or different number of wheels on each axle. The vehicle can have a centre of gravity that is at or below the plane of travel This block accounts for body mass, aerodynamic drag, road incline and weight distribution between axles due to acceleration and road profile which optionally includes pitch and suspension dynamics. The vehicle does not move vertically relative to the ground.
Connection H is the mechanical translational çonserving port which is associated with the horizontal motion of the vehicle body. The traction motion developed by the tires should be connected to this port
Connections V, NF and NR are physical signal output ports that represents vehicle velocity and front and rear normal wheel forces. These wheel forces are considered positive if acting downward. Connections W and beta are physical signal ports that signify headwind speed and road inclination angle respectively.


Tire (Magic formula) :
The magic tire block models a tire with longitudinal behaviour which is given by a magic formula an empirical equation based on four fitting coefficients. Under constant or variable pavement conditions this block can model tire dynamics. The longitudinal direction of the tire is same as the direction of motion as it rolls on the pavement.
Connection A is referred to the mechanical rotational conserving port for the wheel axle. Connection His the mechanical translational conseving port for the whel hub through which the thnust is developed by the tire which is applied to the wheel. Connection N is a physical Sgnal input por that applies the normal force acting on the tire. f it is acting downwards the force is considered positive. Connection S is a physical signal output port reveals the tire slip.

Simple Gear :

The simple gear box represents the gearbox that constrains the connected driveline axes of the base gear B and the follower gear F to corotate with a fixed ratio that is specified. Connections B which is the base and F the follower are mechanical rotational conserving portts.

Inertia :

This block represents a mechanical rotational inertia and is given by the following equation:
T = jdw/dt
where,
T = inertia torque
J = inertia
w = angular velocity
t = time

- Tansnisslen is an important aspect of the vehicle which is used to supply the propulsion power from the motor and then the wheels.
- For the creation of the above subsystem the following blocks that were used were Tire (Magic formula) block, simple gear block, vehicle body, inertia block, PS Simulink converter, PS constant and PS terminator so as to create the base for the model.
- Firstly the wheels of the vehicte are modelled by using the Tire block, Four tire blocks are created for the vehicle and named them as front and rear wheels.
- For the tire block there are various parameters which can be edited according to the requirement. During the simulation default Parametersef the tiie block were used.
- Then all the ports of each tire block are connected with each other. Port A represents axle so the rear wheels A ports are connected with each other whiech signifies that they are on the same axle, Similarly, the front wheels are also connected to the same axle.
- Then the tHport represents the hub and all the H ports are connected to each other.
- The Nand S port represents the normal force and slip of the tire respectively. So, the nornmal force on the rear wheels is the same, so the N port of both rear wheels is connected with each other and similarly for the front wheels normal force. The port S represents the stip ecruming in the wheel. The port can be connected or can be ignored. In the above model it is connected to a PS Terminator block which teminates the physical signal outputs.
- Then a vehicle body diagram is used which represents the vehicle dynamics where there are various parameters which can be changed according to the requirement.
- The NR and NF port in the vehicle body represents the normal force on rear and front tires respectively. So, the N port of the front and rear ties are connected with NR and NF ports accordingly.
- The H pot n the vehicle body is associated with the horizontal motion of the body and is connected to the H port of all the tires.
- The W and BETA port represents the wind speed and roadl inclination angle which can be entered as an input. In the above model the W and the BETA port ae connected to a PS constant block since we have assumed both to be zero.
- The port V in the vehicle bodly represents the velocity output from the vehicle., So, this is connected to the output port. Since the powe from the motor has to be transmited to the wheels a transmission block is used which is a SlIMPLE GEAR BLOCK. This block is connected to the rear wheel axle since the model is considered as &rear wheel drive and to this inertia block is added.
- Finally the subsystem is modelled where the input of the system is the power given to the simple gear box and output is the velocity of the vehicle.
Motor Contoller :

The following blocks that were used for the creation of the model are:
- Controlled voltage source
- Controlled PWM voltage
- H-Bridge
- Current sensor
- Solver configuration
- DC Motor
- Mechanical rotational sensor
- Electrical reference
- Scope
Controlled Voltage Source :

The controlled voltage source depicts an ideal voltage source which is powerful enough to maintain the specified voltage at its output irrespective of the current flowing through the source.
The output voltage V = Vs where Vs is the numerical value presented at the physical signal port.
Controlled PWM voltage :

The Controlled PWM voltage block represents a pulse width modulated (PWM) voltage source.This blocck has two modelling variants by right clicking on the block and then selecting simscape and then block choices which are electrical input ports and PS input.
- Electrical input ports : This block calculates the duty cycle which is based on the reference voltage across ref+ and ref- ports. This modelling variant is default.
- PS input : Specifies the duty cycle value directly by using an input signal port. For electrical input ports variant of the block, the duty cycle calculated is:
100*Vref - Vmin/Vmax - Vmin%
Where,
Vref is the reference voltage across ref+ and ref- ports
Vmin is the minimum reference voltage
Vmax is the maximum reference voltage


H - Bridge :

H-Bridge block output is a controlled voltage that depends on the input signal at the PWM port. The H-Bridge is connected to Pulse Width Modulation for controlling of the voltage signals and the output of the H-bridge is connectedd to the terminals to provide the controlled voltage to the DC Motor.
The ports in H-Bridge are:
- PWM - this stand for pulse width modulation which provides the voltage pulses to H-bridge either in PWM or average mode.
- REF - is the floating zero volt reference.
- REV - voltage that controls when to reverse the polarity of the H-bridge block output.


Current Sensor :
The current sensor block represents an ideal current sensor it is a device that converts current measured in any electrical branch into physical signal proportional to the current. The connection + and - in the block are electrical conserving ports through which the sensor is inserted in the circuit.
Solver Configuration :

The solver configuration block requires solver settings information for simulation. The block specifies the solver parameters that the model requires before running the simulation.
DC Motor :

There are 2 sides to the block as seen above the mechanical side and electrical side. The mechanical side has 2 ports, C and R. The C refers to casing and R for the rotation of the rotor. The electrical side has a positive and negative terminal for the voltage to be applied. The C port of the mechanical side needs to be connected to a mechanical rotational reference because it will be stationary. The R port will be connected to the simple gear of the vehicle body block.
DC motor block represents the torque and electrical characterstics of DC motor using the equivalent circuit model.

The resistor R refers to the resistance which is specified in the armature resistance parameter. The inductor corresponds to the inductance which is specified in the armature inductance parameter.


Mechanical Rotational Reference :
The mechanical rotational reference block represents a reference point or frame for all mechanical ports.
Electrical Reference :

The electrical reference ground represents an electrical ground. Electrical conserving ports of all the blocks that are directly connected to the ground must be connected to an electrical reference block.
Scope :

Scope is used for viewing the graph of the signals after the simulation is run.
Explanation of the Motor Controller:
- The motor controller subsystem contains mainly of H- bridge and a controlled PWM voltage block, D.C motor, current sensor and controlled voltage source.
- A controller is needed to control the motor according to the needs which is why a controller block is used which is the H-bridge.
- H-bridge is used to supply power from the battery to the D.C motor. H- bridges has four switches that give the controlled D.C voltage supply to the D.C motor that can control the supply of voltage.
- In H-bridge block parameters there are two options for simulation mode to chooses from either averaged or PWM but averaged mode is chosen since the simulation time is in mins or hours and it is faster as compared to PWM mode.
- In the H-BRIDGE BLOCK there is a PWM signal input port, where PWM input can be given to this port. The REF and REV ports are grounded using electrical reference block. This is done to prevent reverse operation of the motor. BRK port is connected to a controlled voltage source which helps in carrying out regenerative braking.
- PWM signals is given to the H- BRIDGE BLOCK by using CONTROLLED VOLTAGE BLOCK. This block helps in creating PWM signals which are generated according to the variable voltage.
- The PWM and REF port of the controlled PWM voltage is connected to PWM and REF port of the H-BRIDGE. The ref- port is grounded since we don't need negative voltage and is connected to the REF and REV port of the H-BRIDGE. The ref+ port is connected to CONTROLLED VOLTAGE BLOCK so that the input voltage is the same always.
- Controlled PWM voltage block is connected to the input PWM port in the H- bridge block.
- This block will apply pulses and based on these pulses from the fixed battery voltage variable output voltage will be available to the motor and the motor torque and motor speed are changed.
- Now an appropriate motor is selected for the electric vehicle so a C motor block is used to represent the DC motor. In the D.C motor block the parameters were changed like the rated DC voltage of the motor, rated load. no load speed, rated speed according to the vehicle needs.
- The motor block has 4 ports -,+, Cand R where -and+ ports are the motor terminals where the power supply is connected and the positive torque is from port C to R, and port Cis considered as fixed end of motor so it is connected to the mechanical rotational reference block to which a solver configuration block is added. The + port of the DC motor is connected to the H-BRIDGE through current sensor and the negative port of the DC motor is connected to negative of the H-BRIDGE as well as the REF port of the H-BRIDGE. The port R is connected to vehicle dynamics input which is the simple gear box.
- Finally, the subsystem is created with the following blocks and the subsystem will control the power supply to the D.C motor.
Distance Calculation :

In the above model for distance calculation the input is taken from the velocity feedback and it is integrated using the integrator block and divided by 3600.
Energy Consumption & SOC% :
State of charge is defined as the measurement of available charge in the battery. When the battery is fully charged, it is considered to have 100% and when it is 0% it is said to be discharged. After the simulation is run, we get an estimate of the current and SOC of the battery with respect to time.

The following blocks that were used for the creation of the subsystem:
- Controlled current source
- Battery
- Bus Selector
- Power gui
- Product
- Integrator
- Constant
- Divide
- Scope
Controlled Current Source :

The controlled current source block converts the simulink input signal into equivalent current source. The positive current direction is as shown by the arrow in the block icon.

Batttery :
This block creates a generic dynamic model parameterized to represent most popular types of rechargeble batteries.
Lithium-ion battries require fewer maintenance and operational costs are less. The average life of a lithium-ion battery is 8 years. The lithium-ion battery has significant environmental benefits over fossil fuels. With increase in electric vehicle we have seen an immediate impact on the reduction of carbon emission.


Bus Selector :
The output of the block specifies subset od elements of bus at its input. The block can output the specified elements as seperate signals.

POWERGUI :

The power gui block chooses the following methods to solve the circuit:
- Continuous, which uses a variable step solver from Simulink.
- Discretization of the electrical system for a solution at fixed time steps.
- Phasor solution
This block is used for steady state and simulation results analysis and also for advanced parameter design. This block is required to simulate Simulink model that contain simscape electrical specialized power system blocks.
EXPLANATION OF ENERGY CONSUMPTION &SOC% :
- This subsystem consists of lithium -ion battery block, a controlled current source, bus selector and power gui block.
- The current sensor is connected to the controlled current source through a PS Simulink converter where the+ connection of the controlled source is connected to the negative port of the battery and the- connection is connected to the positive port of the battery.
- From the Mport of the battery block we obtain the S.OC, ampere and voltage values. These values are extracted using bus selector when it is connected to the m port.
- The ampere and the voltage output is connected to a product block and multiplied so as to get the energy consumption in watts.
- This output is then connected to an integrator block which will add those watts over the simulation time and gives the value in watt second.
- This watt second value is then converted to watt hour by dividing by 3600 to obtain the energy consumed by the electric rickshaw during the course of the simulation.
Driver Input :

The following blocks that were used for the creation of the model:
- Drive cycle source (wide open throttle)
- Sum block
- PID controller
- Saturation block
Drive cyccle source (Wide open throttle) :

This is the wide-open throttle drive cycle in which the vehicle runs at a constant speed of 30km/h for a distance of 16.84 km. the simulation run for the drive cycle is 2100 seconds.


Sum Block :

This block performs addition or subtraction on its inputs.

PID Controller :

The input of the PID Controller block is actually an error signal which is the difference between the reference signal and the system output. The output of the PID controller are proportional, integral and derivative gain parameters. The coefficients of the PID controller are tuned either manually or automatically.
The PID tuner was tuned as shown below:

Saturation Block :

The saturation block produces an output signal that is the value of the input signal bounded to the upper and lower saturation values. The upper and lower limits are specified by parameters.

Explanation of Model :
- in order to measure the speed of the electric vehicle model, scope block is used where 2 input ports are made. One port takes the output velocity signal from the Vehicle Body subsystem block and another port takes the output signal from the Drive cycle.
- The drive cycle used is wide open throttle which is connected to a sum block and instead of a LONGITUDNAL DRIVER BLOCKa PID CONTROLLER where two saturation blocks are connected where the upper and lower limits are given for acceleration as 1 and O and for deceleration O and -1. The saturation blocks for acceleration and deceleration are connected to separate controlled voltage source through Simulink -ps converter.
- The area under the velocity time graph depicts the distance travelled by the vehicle. This means that integration is done with respect to time which gives the distance travelled. Integrator block is used to integrate the velocity signal that is the output from the subsystem. After the integrator block, divide block is used along with constant block with the value of 3600 in order to convert the integrated speed signal which is in kilometres per hour by 3600 which gives the distance travelled in kilometres.
- Finally, the electric rickshaw model is completed and once the simulation is run, we get the following results.
Results :
For Velocity :
The scope below gives the input and output velocity graph, one is the drive cycle and other is the velocity feedback.

SOC (State Of Charge) :
Graph as shown below for wide open throttle which is run for 2100 secs.

Distance Travelled :
By running the elctric vehicle with wide open throttle for 2100 seconds the distance is 16.84 km.

Drive Cycle SOC% Distance travelled (km)
Wide open throttle (2100 secs) 67 16.84 km
Conclusion :
A MATLAB model of EV can be created using lithum-ion battery with a suitable motor, using suitable blocks from simscape or power train block sets. We can implement the vehicle speed control using PI controller, generative brake and accelerator commands. The PID gains can be designed based on system parameters and estimated precisly.