Project-1: Modelling an electric Car with Li-ion battery
PROJECT
Create a MATLAB model of electric car which uses lithium ion battery and suitable motor.
Aim) The main aim is Create a MATLAB model of electric car which uses lithium ion battery and suitable motor.
Implement the vehicle speed control using PI controller and generate brake and accelerator commands. Avoid using readymade driver block for speed contro
Contents:-
The Contents of this project are as followes:-
1)What is electrical Car.
2)How An Electric Car works.
3)Types of Electric car
4) Parts of An Electric Car
5)Design Block Digram for Electric car
6)Electric car Simulink model
7)Procedure for model creating with Each block data explanantion.
8)Output Results with plots.
________________________________________________________________
1)What is electrical Car
An electric vehicle(EV) is defined as a vehicle that uses an electric motor or a traction motor for propulsion.
Electric vehicle use electricity for power instead of fossil fuels like conventional vehicles . So, they do not produce any exhaust gases and pollution.
The power needed in the EV come from batteries, generator or any collector system. Batteries fitted in the EV are of high energy densities in order meet the power requirements and range.
The power of a vehicle's electric motor, as in other vehicles, is measured in kilowatts (kW).
Let us take an exapmle an 100 kW electric moter is roughly equal to 134 horsepower, but electric motors can deliver their maximum torque over a wide RPM range. This means that the performance of a vehicle with a 100 kW electric motor exceeds that of a vehicle with a 100 kW Internal Combistion Engine which can only deliver its maximum torque within a limited range of engine speed. Energy is lost during the process of converting the electrical energy to mechanical energy.
Electric Car Image :-
__________________________________________________________________
2)How An Electric Car works:-
All-electric vehicles (EVs) have an electric motor instead of an internal combustion engine. The vehicle uses a large traction battery pack to power the electric motor and must be plugged into a charging station or wall outlet to charge. Because it runs on electricity, the vehicle emits no exhaust from a tailpipe and does not contain the typical liquid fuel components, such as a fuel pump, fuel line, or fuel tank.

Working animation of an electric car
Transmission working of an electric car:-

Transmission working attachment with an electric moter in EV-system
_______________________________________________________________________
3)Types of Electric car
There are a Basically 3 different types of electric vehicle (EV)are avalable .Those are as followes.
1)Plug-in- Elctric-vehicle
2)Plug-in-hybrid-vehicle
3)Hybrid-electric-vehical
1)Plug-in-electric-Vehicle:-
This means the car runs "purely on electricity" and gets all its power when it's plugged in to charge. This type doesn't need petrol or diesel to run so doesn't produce any emissions like traditional cars.
Image--> Pure elctrica car details.
2)Plug-in hybrid-vehicle:-
These cars "Mainly run on electricity but also have a traditional fuel engine so you can use petrol or diesel too if they run out of charge".
When running on fuel, these cars will produce emissions but when they're running on electricity, they won't. Plug-in hybrids can be plugged into an electricity source to recharge their battery.
Image--> Plug-in-Hybrid-car-details
3)Hybrid-electric_vehicle:-
These run "Mainly on fuel like petrol or diesel but also have an electric battery too, which is recharged through regenerative braking".
These let you switch between using your fuel engine and using 'EV' mode at the touch of a button. These cars cannot be plugged into an electricity source and rely on petrol or diesel for energy.
Image -->Hybrid-electric_car details
_______________________________________________________________________
4)Parts of an Electric Car:-
The Pure elctric car contains maily the following parts:-
1)Electric Motor
2)Inverter
3)Drive train
4)Battery system
5)Charging
1)Electric Motor :-
It Provides power to rotate the wheels. It can be DC/AC type, however, AC motors are more common.
2)Inverter:-
Converts the electric current in the form of Direct Current (DC) into Alternating Current (AC)
3)Drivetrain :-
EVs have a single-speed transmission which sends power from the motor to the wheels.
4)Battery system :-
Store the electricity required to run an EV. The higher the kW of the battery, the higher the range.
5)Charging :-
Plug into an outlet or EV charging point to charge your battery.
_____________________________________________________________________________
5)Design Block Digram for Electric car:-
For desigining purpose we have to create the block diagram for clear understanding to,from where we start the design an Electric car.
The block digram is as followes :-

This block diagram will helps us to designing the Elctric vehicle.
1)Drive cycle :-
A driving cycle is a set of values, generally, velocity vs time, which represents how a vehicle travels through a path. In simple words, it would be a velocity vs time graph of a vehicle.
2)Drive Controller:-
It is a device which improves the performance of an electric motor. It is a machine that is used to regulate the torque generated by the motors of electric vehicles. It does so by means of modifying the energy flow from the power sources to the motor.
Motor controllers can include an automatic or manual means for starting or stopping the motor. It can choose forward or reverse rotation, can select and control the speed, can modify or limit the torque of the EV motor.
3)Power Coverter:-
A power converter is an electrical circuit that changes the electric energy from one form into the desired form optimized for the specific load.
A converter may do one or more functions and give an output that differs from the input.
4)Electric Moter:-
Electric motor is the electro-mechanical machine which converts the electrical energy into mechanical energy. In other words, the devices which produce rotational force For moving the vehicle.
5)Vehicle Body:-
Vehicle body could be the main supporting structure or its particular element. Vehicle body is the main supporting structure of a vehicle, to which all other components are attached.
6)Battery:-
A battery is a very important part of an electric car. It’s simply the powerhouse of an electric car. It stores the energy required by motors to spin the wheels. So, a battery is an integral electric car component.
_________________________________________________________________________________
6)Electric Car Simulink model:-
For creating the Simulink model of an electric car we are using the following blocks:-
- Vehicle body
- Tire
- Simple gear
- Dc motor
- H-bridge
- drive cycle
- pid controller
- bus selector
- Controlled PWM voltage
- controlled Voltage Source
- Current sensor
- Battery
- Gain
- saturation
- Electrical reference
- Constant
- inport
- outport
- scope
- Integrator
- Add
- Display
Total Simulink Model :-

7)Procedure for model creating with Each block data explanantion.
Procedure:-
1. System level configurations
This Electrica car model is created with following subsystem blocks:
- Vehicle body subsystem
- Dc-Motor
- Power Coverter unit subsystem
- speed control using PI controller and generate brake and accelerator commands
- Reference Drive Cycle
- Battery and SOC %
- Output results Plots
a)Vehicle body subsystem:-

This Subsystem Contains following Blocks :-
For creating the Vehicle body we ar used the following blocks:-
Vehicle body:-

This block contain 6 ports which can be used to model various aspects of the vehicle body. The ports are mentioned below;
H- port :-
This port stands for "Hub" and is used to connect the hub port of the wheels to the main body of the vehicle.
V-port :-
Physical signal output port which stands for 'velocity' and is used the output the velocity of the vehicle.
W- port :-
Physical signal input port and allows us to model a "wind velocity" that acts aginst the vehicle.
NR-port :-
Physical signal output port to connect to connect the rear wheels(NR-Normal Rare)
NF-port :-
Physical signal output port to connect the front wheels of the vehicle.(NF-Normal Front)
Beta- port :-
Physicall signall input port which allows the vehicle to undergo an inclination of hill climbing force.
Vehicle body parameters block:-
If we click on the vehicle body block, the pop-up window appears with default values. We need to change the values depending on the requirement of the model to achieve accurate results.

The parameters changed As below :-
Mass -900 kg
Frontal Area- 2 m²
Drag coefficient-0.1
Tire Block :-

A -Port :-
It is the mechanical rotational conserving port for the wheel axle.
H-Port :-
It is is the mechanical translational conserving port for the wheel hub through which the thrust developed by the tire is applied to the vehicle.
N-port:-
It is a physical signal input port that applies the normal force acting on the tire. The force is considered positive if it acts downwards.
S-Port :-
It is a physical signal output port that reports the tire slip.
Tire -Block parameters :-
For the tire block, I was use the all default values are considered for this model.

Gear Block :-

This block represents fixed-ratio gear.
It has two terminals B and F. B represents base and F represents the Follower of the gear and are mechanical rotational conserving ports.
The F terminal is connected to the rear axle and the B terminal is connected to the DC motor.
Gear block Parameters:-
This torque is provided to the rear axle of the vehicle to increase the propulsion.
Electrical vehicles transmission is much simpler as the motor provides motion from zero speed upwards.
i.e.by just connecting a simple gear Box.

THis Block parameters Gear Ratio is changed to 2 to increase 2 times the torque produced by the motor.
Output shaft Rotation :- In the same direction of input shaft
Vehical body Subsystem Simulink Model :-

Procedure:-
- The above subsystem of vehicle body is created by using the Four tires are connected , In this right two tires are the Rear wheels and the Left two are the Front wheels.
- The right side two tire are interlinked by using the "A(Axle)-Port" with each other.In the same way the left side two tire s also interlinked with each othe by using the "A(Axle)-Port".
- Finally These foure tire are interconnected By usingH-port in each tire with to "vehicle body" block by using the "Hub Port" in vehicle body.
- From the Vehicle body, the both NR and NF are Connected to the "N-Port" Of Rear and Front tires respectively.
- In the Vehicle body reming ports ,wind velocity port and Beeta ports are connected to physical constant blocks which is kept as zero.
- And the "V" port is give the reference feed to the driver Block.
- In this model we are assuming the vehicle is Rear wheel driving ,that way we are Using the gear system or transmission system connection to the Rear wheel of vehicle.
- Here we are used the "A simple gear" For transmission purpose. In this gear "F" ort is connected to the Rear wheel set of axle port(A-port) Of tires.
- From above steps we are created the body of vehicle.
b)Dc-Motor:-

This block represents the electrical and torque characteristics of a DC motor. while using this block we assume that no electromagnetic energy is lost and hence the black emf and torque constants have same numerical values.
Motor parameters can be either be specified directly or derived from no-load speed and torque. when a positive current flows from the electrical + to - port, a positive torque acts from the mechanical C to R ports.
C-port :- Stand for Casing
R-port:- Stands for Rotor
Procedure :-
In this DC-Motor
>> R-port is connected to theBase -Port Og the "Simple gear "Blcok
>> C-port :- It is connected to the Mechanical rotational Reference Block , That means This part is remains Constant part
>> (+) -Port is connected to the (+)- Port of the H-bridge Block.
>> And (-) -Port is connected to the (-)- Port of the H-bridge Block
Dc motor Block parameters:-

For thIs Dc-Motor i was used the following parameters:-
Field Type :- Perminent Magnenet
Model Parameterization:- By rated load and speed.
No-load speed:-5000 RPm
Rated Speed (at rated load) :-4000 RPM
Rated load(mechanical power) :_50KW
The Rated DC supply voltage :-300
Initial Rotor speed :-4000 RPM
C) power Converter Unit subsystem:-

This Subsystem Contains following Blocks :-
For creating the Vehicle body we are used the following blocks:-
H-Bridge:-

This block represents an H-bridge motor drive. The block can be driven by the Controlled PWM Voltage block in PWM or Averaged mode.
In PWM mode, the motor is powered if the PWM port voltage is above the Enable threshold voltage.
In Averaged mode, the PWM port voltage divided by the PWM signal amplitude parameter defines the ratio of the on-time to the PWM period. Using this ratio and assumptions about the load, the block applies an average voltage to the load that achieves the correct average load current.
The Simulation mode parameter value must be the same for the Controlled PWM Voltage and H-Bridge blocks.
If the REV port voltage is greater than the Reverse threshold voltage, then the output voltage polarity is reversed.
If the BRK port voltage is greater than the Braking threshold voltage, then the output terminals are short circuited via one bridge arm in series with the parallel combination of a second bridge arm and a freewheeling diode.
Voltages at ports PWM, REV and BRK - ports are defined relative to the REF port.
Parameters Block :-

The H_Bridge Parameters are changed as followes :-
Power Supplu:- Internal
Simulation mode :- Averaged
Enabled Threshold Voltage :-0.1 V
PWM Signal Amplitude :- 1 V
Reverse Threshold Voltage:-0.1
Braking Threshold Voltage :-0.1 V
Output Voltage Amplitude:-300 V
The remaining values are kept constant.
Controlled PWM Voltage:-
This block creates a Pulse-Width Modulated (PWM) voltage across the PWM and REF ports.
The output voltage is zero when the pulse is low, and is equal to the Output voltage amplitude parameter when high. Duty cycle is set by the input value.
At time zero, the pulse is initialized as high unless the duty cycle is set to zero or the Pulse delay time is greater than zero.
The Simulation mode can be set to PWM or Averaged:-
In PWM mode, the output is a PWM signal.
In Averaged mode, the output is constant with value equal to the averaged PWM signal.
Parameters Block :-

Parameters changed As followes :-
Pwm frequency :-1000 Hz
Simulation mode:- Averaged
Input Voltage for 100% duty cycle:- 1 v
Output voltage amplitude:-300 V
Controlled Voltage Source:-

The block represents an ideal voltage source that is powerful enough to maintain the specified voltage at its output regardless of the current passing through it.
The output voltage is V = Vs, where Vs is the numerical value presented at the physical signal port
Converter Part Subsystem Total Simulink Model :-

Procedure for creating this power converter Block :-
For creating this model the H-bridge is used as Coverter for in both motering and regerative breaking purpose. this bridge acts as motering condition while its Pulses from the Controlles PWM Voltage Source.
And This H-Bridge Acts as (generator )- while breaking Condition and at this time the given battery is charged throug the gates semiconducter switches used in it.
This H-Bridge Converter both Positive and negative poprts are connected to Motor positive and negative terminals respectively.
From the "Controlled PWM Voltage "Source Block H-brige Gets the signals for acceleration .
The reference Of the "Controlled PWM Voltage "Block is conncted to the refernce port of H-Bridge.
ref + And Ref- Ports are connected to the Controlled voltage source block and Electrical reference block respectvely.
brk " port of the H-bridge is connected to the Controlled voltage source block for getting the DEseleration ? Break command from the driver block.
Acceleration and Break command:-
c)speed control using PI controller and generate brake and accelerator commands
Here we are using the a Pi controller For giving the acceleration command ab dbreak command to the Power converter for controlling the vehicle.
For creating this Block we are using the following blocks:-
PID controller:- This block implements continuous- and discrete-time PID control algorithms and includes advanced features such as anti-windup, external reset, and signal tracking.
saturation:-Limit input signal to the upper and lower saturation values.
add :-To wreten the output signal as addition of input signals.
in:-Provide an input port for a subsystem or model.
out1:-Provide an output port for a subsystem or model.
Simulink model :-

Procedure :-
>>For this acceleration and Break commands we are used the the "PI" controller for controlling the vehicle.
PI controller parameters:-

>> For getting the controlled level here we used the saturation block for acceleration and deseleration also
>> THis Block is working on the basis og what we gave the upper and lower limit to the block.
>>Based on the Limit values this saturation blocks will works either acceleration command or deselartion command.
Acceleration saturation block parameters:-
For acceleration command the upper and lower limit is set as followes -
upper limit :-75
Lower Limit:-0

Decelaration saturation block parameters:-
For Deceleration command the upper and lower limit is set as followes -
upper limit :-0
Lower Limit:--75

>>The Pi control gets the two signals for comaring and gave the signal to out put how to move the Vehicle
>> one signal is from the Standard Drive cycle.
>>Second signal is feedback signal from the Vehicle velocity port.
>>and , Finally these all blocks together works as aceleration and break command signals as output for the Power converter.
d)Drive Cycle:-

The range of electric vehicles is the major problem faced by the automobile industry because storing electrical energy efficiently is a very tough task for engineers. This is a critical issue in the design of any electrical vehicle. For that what we can do is test the vehicle by driving in reality or in simulation through a profile of ever-changing speeds. These test drive cycles have been developed to provide a realistic and practical test for the emissions of vehicles.
Now for this model, the FTP75 drive cycle is chosen and with this cycle as input reference, Created simulation model of the Electrtic Car was done.
With this simulation, the distance traveled by the vehicle at the end of this cycle is calculated using MATLAB software And display th evaluse by using The Display block.
In this drive cycle, the condition or the velocity of the propelling vehicle is noted at each second. The important data that needs to maintain as a record is the amount of charge removed from the battery.
The depth of discharge of the battery, and the distance traveled. By taking these velocities as input and is fed to the longitudinal driver block.
It calculates acceleration and thus the tractive effort, and thus the motor power, torque, and speed. Using this data motor efficiency can be found and also the electrical power going into the motor. This calculation is repeated every one second till the end of the cycle.
Parameter Block :-

This Drive cycle source having a number of pre defined drive cycle.
We can cselect the required drive cycle from scroll down the arroe button.
This model i have used the -FTP75 Drive cycle source.
f)Battery and SOC %
For this model i was used the following Battery model as Lithium Ion battery

Using this battery block, the state of charge (SOC) , current across the battery can also be calculated. these valus are plotted by using the Scope Block.
Parameter Block (Lithium Ion Battery):-

For this model i was used following parameters :-
>>Nominal Voltage :-300v
>>Rated capacity:-80 Ah
>>initial state of charge:-100 %
>>Battery Responce Time=20sec
Bus selector :-
This block accepts a bus as input which can be created from a Bus Creator, Bus Selector or a block that defines its output using a bus object. The left listbox shows the elements in the input bus. Use the Select button to select the output elements. The right listbox shows the selections. Use the Up, Down, or Remove button to reorder the selections. Check 'Output as virtual bus' to output a single bus.
Bus selector parameter Block:-
>>This Bus selector is used for knowing the Battery Current ,Volatage and estimate the % of SOC.
>>This battery % soc is for knowing the chargeble percentage of capacity of battery.
Distance measuring Block :-
Distnace can be obtained by integarion of Velocity of vehicle ,And this can be implemented in simulink by using folloeing subsystem.

>> This Implemenatation of Speed model by using the converting the velocty(Speed) Kmph is integrated by using intergrator block and devide by 3600 sec (for converting to Hrs) using the devide blcok and fimallly the output of this sysytem given to the display blcok for knowing the Distance(KM) travlled by the vehicle.
Other Block details :-
Electrical Reference :-

Electrical reference port. A model must contain at least one electrical reference port (electrical ground).
It is needed to discharge the excess charges flowing through the devices. so all the negative terminals of the devices are connected to the ground.
PS Terminator:-

Use this block to terminate physical signal outputs. Unconnected physical signal output ports do not generate warnings.
PS Constant: :-

This block represents a constant and is taken from the simscape library.
The Constant parameter accepts both positive and negative values. The block output is a physical signal port.
Scope :-

This block is used for getting the Output signal values in graphical represenatation.
Mechanical rotational Reference Block :-

This block represents a mechanical rotational reference point, that is, a frame or a ground. Use it to connect mechanical rotational ports that are rigidly affixed to the frame (ground).
Controlled Current Source :-

Converts the Simulink input signal into an equivalent current source. The generated current is driven by the input signal of the block.
Current Sensor :-

The block represents an ideal current sensor, that is, a device that converts current measured in any electrical branch into a physical signal proportional to the current.
Connections + and - are conserving electrical ports through which the sensor is inserted into the circuit.
Connection I is a physical signal output port that outputs current value.
Solver Configaration :-

This block is used to Defines solver settings to use for simulation.
Powergui:-

This block is used to Set simulation type, simulation parameters, and preferences.
Modeling Parameters List :-
I was created this electric Model by using the follwing assumption parameters.
Design parameters Excel-sheet Link :- Li-Ion battery Model_parameters.xlsx

Output Results Scope :-
This Results of explained With 3 cases having Different values of "PI "Controller Gains.
Praportional Gain :-1
Integartional gain :- 1

Results Scope:-

>> from the Graph
yellow color plot is Vehicle Velocity and Blue color Plot is Reference Drive cycle velocity
>> Fromm The above grapg We can see that the with Low "PI" controller gain values we gat the Output accurecy is very low.
>>Because with Low Values we can gets high peak velocity within the fraction of seconds.
>>From this Graph we can Conclude That the " Vehicle controlling was achived upto 68 % with Low PI controllers.
Battery Bank Scope :-

> From the graph we can observed that the
Top Plot :-(SOC %)
>> This can observed that from the graph after travelling the 4.949 Km vehicle the battery can 95.5 % used the vehicle running upto 2437 sec.
>>Between due to regenerative breakings battery gets charged also.

Middle plot (Current ):-
>> From the we can observe that the Vehicel draws tho peak current at 178.3sec
>>Maximum current gets at almost 2002.364sec
>> Draws minimum current nearly 2437 sec

Bottom graph :-(Voltage )
>>From the we can observe that the Vehicel draws tho peak Voltage gets at 127 sec
>> Draws minimum current nearly 2437 sec.
>> peak to peak voltage :-85.57 V

Distance Graph :-

>> From the above graph we can observed that the vehicle with contains Praportional Gain :-1 and Integartional gain :- 1 gains values then the vehicle was travelled the distance as 4.949 km.
Praportional Gain :-10
Integartional gain :- 1

Velocity Results Scope:-

>> from the Graph
yellow color plot is Vehicle Velocity and Blue color Plot is Reference Drive cycle velocity
>> Fromm The above grapg We can see that the withincreasing the Praportionla gain values we gat the Output accurecy is Increased compared with the above values.
>>From this Graph we can Conclude That the " Vehicle controlling was achived upto 80 % with Low PI controllers.
Battery Scope :-

> From the graph we can observed that the
Top Plot :-(SOC %)
>> This can observed that from the graph after travelling the 4.949 Km vehicle the battery can 95.6 % used the vehicle running upto 2454 sec.
>>Between due to regenerative breakings battery gets charged also.

Middle plot (Current ):-
>> From the we can observe that the Vehicel draws tho peak current at 163 sec
>>Maximum current gets at almost 2422 sec
>> Draws minimum current nearly 2354 sec

Bottom graph :-(Voltage )
>>From the we can observe that the Vehicel draws tho peak Voltage gets at 127 sec
>> Draws minimum current nearly 2424 sec.
>> peak to peak voltage ;-60.91 V

Distance Graph :-

>> From the above graph we can observed that the vehicle with contains Praportional Gain :-10 and Integartional gain :- 1 gains values then the vehicle was travelled the distance as 4.948 km.
Praportional Gain :-30
Integartional gain :- 15

Results Scope for Velocity:-

>> from the Graph
yellow color plot is Vehicle Velocity and Blue color Plot is Reference Drive cycle velocity
>> Fromm The above grapg We can see that the withincreasing the Both Praportionla and Integral gain values we gat the Output accurecy is Increased compared with the above values. almosth the vehicle velocity and drive cycle velocity is matchd .
>>but some littele difference when gets deseleration time this can be observed in the graph.
>>From this Graph we can Conclude That the " Vehicle controlling was achived upto 85% -90 % % with Low PI controllers.
FOr Battery Parameters Scope:-

> From the graph we can observed that the
Top Plot :-(SOC %)
>> This can observed that from the graph after travelling the 4.948 Km vehicle the battery can 95.6 % used the vehicle running upto 2251 sec.
>>Between due to regenerative breakings battery gets charged also.

Middle plot (Current ):-
>> From the we can observe that the Vehicel draws tho peak current at 170 sec
>>Maximum current gets at almost 2000 sec
>> Draws minimum current nearly 2278 sec

Bottom graph :-(Voltage )
>>From the we can observe that the Vehicel draws tho peak Voltage gets at 127 sec
>> Draws minimum current nearly 2431 sec.
>> peak to peak voltage ;-84.73V

Distance Graph :-

>> From the above graph we can observed that the vehicle with contains Praportional Gain :-30 and Integartional gain :- 15 gains values then the vehicle was travelled the distance as 4.948 km.
PI controller Observations table:-

Final Conclusion :-
The Li-Ion Battery Model Elctric car is designed With using the "Pi" Controller with following Observations.
We can conclude that with the increase the PI controller Gain values we can get the Output is accuracy but difference twith the Peak and GAin values.
These values are can understand the by using the above PI controller Gain Variation Table.
-------------------------------------------------------------------------------------------------------------------------------------------- (The End)