Challenge

Project-1: Modelling an electric Car with Li-ion battery

AIM:

To build a MATLAB model of an electric car that uses a lithium-ion battery and a suitable motor.

Objective:

Choose suitable blocks from Simscape or Powertrain block set. Implement the vehicle speed control using a PI controller and generate brake and accelerator commands.

Avoid using readymade driver blocks for speed control.

Prepare a report about your model including the following:

Objectives, System level configurations, Model parameters, Results, and Conclusion.

Theory:

Electric Vehicles (EVs) are vehicles that are powered by electrical energy. The main components of an EV are a motor/generator, motor controller, power converters, wheels, and batteries. The electric motor is used to provide the power required for the wheels to move and provide traction. The motor controller and power converters work together to control the amount of power that is delivered to the motor. The batteries store the electrical energy needed to power the motor.

Traditional vehicles use an Internal Combustion (IC) engine which is powered by chemical energy from fossil fuels such as petrol or diesel. Traditional vehicles still represent the majority of all the vehicles being used around the world, however, there are various disadvantages to their use. For instance, the gaseous emissions such as carbon dioxide from those vehicles pose various environmental threats such as air pollution. These threats are said to be related to global warming. In addition, traditional vehicles will only be in demand till the availability of fossil fuels is exhausted. Fossil fuels are an exhaustible fuel source with negative environmental effects in their production as well as their utilization. The biggest advantage of using fossil fuels is their excellent energy density. Fossil fuels are capable of storing enormous amounts of energy per unit weight or unit volume which makes them ideal for efficiency. EVs utilize electrical energy stored in batteries as their power source and to date, even battery technologies are yet to reach the same energy density as fossil fuels were capable of.

What is EV technology?

Let's start by considering the legacy vehicle technology: the internal combustion engine, or ICE. This vehicle is propelled by a combustion engine that can only be fueled by gasoline. The technology is conventional, well-established, and reliable, but it consumes large amounts of gasoline—which can be costly in many ways.

ICE Vehicle model is shown below figure:

Enter the electric vehicle Unlike internal combustion technology—which uses combustion and pressure to propel a vehicle—electric vehicles, or EVs, are propelled by electromagnetism. These vehicles use electricity, typically stored in a battery, to power an electric motor.

The electric vehicle model is shown below figure:

Types of EV:

There are four types of electric vehicles available:

Battery Electric Vehicle (BEV):

Fully powered by electricity. These are more efficient compared to hybrid and plug-in hybrids.

Hybrid Electric Vehicle (HEV):

The vehicle uses both the internal combustion (usually petrol) engine and the battery-powered motor powertrain. The petrol engine is used both to drive and charge when the battery is empty. These vehicles are not as efficient as fully electric or plug-in hybrid vehicles.

Plug-in Hybrid Electric Vehicle (PHEV):

Uses both an internal combustion engine and a battery charged from an external socket (they have a plug). This means the vehicle’s battery can be charged with electricity rather than the engine. PHEVs are more efficient than HEVs but less efficient than BEVs.

Fuel Cell Electric Vehicle (FCEV):

Electric energy is produced from chemical energy. For example, a hydrogen FCEV.

In general, electric vehicles consist of a series of basic components. These include, but are not limited to, the following:

  1. 1. Battery (all-electric auxiliary): In most electric drive vehicles, the auxiliary battery provides electricity for start-up and to power vehicle accessories like the clock. This is not to be confused with the main traction battery pack.
  2. 2. Charge port:The stored energy in a battery cannot last forever and it needs to be recharged from time to time. This is where the charge port comes into play. It allows the EV to be connected to an external power supply.

  1. 3. DC/DC converter:Typically, the traction battery pack will have a higher voltage than many other components in the car. This device converts the higher-voltage DC into lower-voltage DC for safe use.
  2. 4. Electric traction motor: Since the electric vehicle is expected to actually move at some point, a means is needed to convert electricity into rotational force to move the wheels. This is where the traction motor comes in. Some vehicles also have energy regeneration functions at the wheels, too to recoup some of the lost energy.
  3. 5. Onboard charger: As electricity from external sources is typically AC, this device converts it into DC for use in charging the battery. It is also used to monitor battery characteristics such as voltage, current, temperature, and state of charge while charging the pack.
  4. 6. Power electronics controller: This device actively manages the flow of electrical energy delivered to the battery and controls the speed of the electric traction motor (not to mention the torque it generates).
  5. 7. Thermal cooling system: This system maintains the proper operating temperature range of the engine, electric motor, power electronics, and other components.
  6. 8. Traction battery pack:This is the "fuel tank" of the electric vehicle and is the source of all electricity used to run most of the other components in the vehicle.
  7. 9.Electrical transmission: This device transfers mechanical power from the traction motor in order to drive Ev’s wheels.

Block Diagram of Electric car:

The block diagram shows the arrangement of the components of the electric vehicle.

The Drive cycle has used the input of the driver controller. The driver controller controls the Acceleration and Braking of the power converter. The power converter H- Bridge is having a regenerative braking system. The DC motor is driven by the H-Bridge power converter. DC motor is connected to the vehicle body block. This block consists of vehicle transmission components like gear, wheels, and vehicle body. Finally, the battery is connected to the power converter block. This block consists of battery parameters charge, discharge, and SOC. The driver controller block has velocity feedback from the vehicle body to control the power converter. The motor block has the DC Motor and mechanical connection blocks.

The simulation model diagram is shown below:

System level configurations:

This Electric car model is created with the following subsystem blocks:

  • Transmission
  • Motor and controller
  • Longitudinal driver
  • Drive Cycle
  • Battery and SOC %
  • Results

Drive Cycle:

The Drive Cycle Source block generates a standard or user-specified longitudinal drive cycle. The block output is the specified vehicle longitudinal speed, which you can use to:

Predict the engine torque and fuel consumption that a vehicle requires to achieve desired speed and acceleration for a given gear shift reference. Produce realistic velocity and shift references for closed-loop acceleration and braking commands for vehicle control and plant models. Study, tune, and optimize vehicle control, system performance, and system robustness over multiple drive cycles.

Drive cycles from predefined sources. By default, the block includes the FTP–75 drive cycle. To install additional drive cycles from a support package, see Install Drive Cycle Data. The support package has driven cycles that include the gear shift schedules, for example, JC08 and CUEDC.

Workspace variables that define your own drive cycles.

. mat, .xls, .xlsx, or .txt files.

Longitudinal Driver:

speed control using PI controller and generate brake and accelerator commands:

In this model, we are using PI controller block to give the acceleration and deceleration commands to the power converter for controlling the vehicle.

The below figure shows the longitudinal driver subsystem building with Simulink primitive blocks.

This subsystem contains the PI block, Sum, Saturation, Inport, and outports.

This subsystem has two input ports ref_velocity and velocity. For the ref_velocity port, a drive cycle source is given as input and for the velocity port, a feedback signal is taken from the Transmission subsystem/vehicle body.

Ref_velocity signal is given to a sum block positive port and velocity is given to a sum block negative port. The output of the sum block is given to a PID controller block.

The PID block properties are shown below:

Then the PID block output signal is given to two saturation blocks named Acceleration and Deceleration.

Acceleration Block properties:

Deceleration Block properties:

The acceleration block output signal is given to the motor controller subsystem and the deceleration signal is also given the same.

Motor and Controller Subsystem:

In this subsystem, we are building the controller and motor with Simulink blocks.

This motor controller subsystem consists of a DC motor, H-Bridge, controlled PWM voltage, controlled voltage source, current sensor, electrical reference, PS-Simulink converter, and mechanical reference blocks.

The above figure shows the motor control subsystem.

Controlled Voltage Source:

The Controlled Voltage Source block represents an ideal voltage source that is powerful enough to maintain the specified voltage at its output regardless of the current flowing through the source. The output voltage is V = Vs, where Vs is the numerical value presented at the physical signal port.

In this subsystem, we are using two controlled voltage source blocks. The first controlled voltage block positive terminal is connected to the controlled PWM voltage block positive terminal. The negative terminal is connected to PWM blocks negative reference input terminal and then the reference terminal is connected to the driver blocks acceleration terminal.

The second controlled voltage source block positive terminal is connected to the H-Bridge BRK terminal, the negative terminal is connected to the common and electrical reference block and then the reference terminal is connected to the breaking command terminal of the longitudinal driver block.

Controlled PWM Voltage:

The Controlled PWM Voltage block represents a pulse-width modulated (PWM) voltage source. You can model electrical or physical signal input ports by setting the Modeling option parameter to either the block calculates the duty cycle based on the reference voltage across its ref+ and ref- ports. This option is the default. PS input Specify the duty cycle value directly by using an input physical signal port.

The controlled PWM Voltage positive reference port is connected to the positive terminal of the controlled voltage source, negative reference port is connected to the common ground terminal. The PWM port is connected to the H-Bridge PWM port, and then the REF port is connected to the common ground terminal. The Controlled PWM voltage block parameters are: PWM frequency is 50 Hz and simulation mode is Averaged. Input scaling parameters are the Input voltage for 0% duty cycle is zero volts and then the Input voltage for 100% duty cycle is 1v. The output voltage amplitude is 5V.

H-Bridge:

The H-Bridge block represents an H-bridge motor driver. The block has the following two Simulation mode options:

PWM — The H-Bridge block output is a controlled voltage that depends on the input signal at the PWM port. If the input signal has a value greater than the Enable threshold voltage parameter value, the H-Bridge block output is on and has a value equal to the value of the Output voltage amplitude parameter. If it has a value less than the Enable threshold voltage parameter value, the block maintains the load circuit using one of the following three Freewheeling mode options:

    • Via one semiconductor switch and one freewheeling diode
    • Via two freewheeling diodes
    • Via two semiconductor switches and one freewheeling diode

The first and third options are sometimes referred to as synchronous operations.

The signal at the REV port determines the polarity of the output. If the value of the signal at the REV port is less than the value of the Reverse threshold voltage parameter, the output has positive polarity; otherwise, it has negative polarity.

Averaged — This mode has two Load current characteristics options:

    • Smoothed
    • Unsmoothed or discontinuous

The Smoothed option assumes that the current is practically continuous due to load inductance. In this case, the H-Bridge block output is:

Vo.VPWM/APWM − IOUTRON

where:

    • VO is the value of the Output voltage amplitude parameter.
    • VPWM is the value of the voltage at the PWM port.
    • APWM is the value of the PWM signal amplitude parameter.
    • IOUT is the value of the output current.
    • RON is the Bridge on the resistance parameter.

The current will be smooth if the PWM frequency is large enough. Synchronous operation where freewheeling is via a bridge arm back to the supply also helps smooth the current. For cases where the current is not smooth, or possibly discontinuous (that is, it goes to zero between PWM cycles), use the Unsmoothed or discontinuous option. For this option, you must also provide values for the Total load series resistance, Total load series inductance, and PWM frequency. During simulation, the block uses these values to calculate a more accurate value for H-bridge output voltage that achieves the same average current as would be present if simulated in PWM mode.

Set the Simulation mode parameter to Averaged to speed up simulations when driving the H-Bridge block with a Controlled PWM Voltage block. You must also set the Simulation mode parameter of the Controlled PWM Voltage block to Averaged mode. This applies the average of the demanded PWM voltage to the motor. The accuracy of the Averaged mode simulation results relies on the validity of your assumption about the load current. If you specify that the current is Unsmoothed or discontinuous, then the accuracy also depends on the values you provide for load resistance and inductance being representative. This mode also makes some simplifying assumptions about the underlying equations for the case when the current is discontinuous. For typical motor and bridge parameters, accuracy should be within a few percent. To verify Averaged mode accuracy, run the simulation using the PWM mode and compare the results to those obtained from using the Averaged mode.

Braking mode is invoked when the voltage presented at the BRK port is larger than the Braking threshold voltage. Regardless of whether in PWM or Averaged mode, when in braking mode the H-bridge is modeled by a series combination of two resistances R1 and R2 where:

  • R1 is the resistance of a single bridge arm, that is, half the value of the Total bridge on the resistance parameter.
  • R2 is the resistance of a single bridge arm in parallel with a diode resistance, that is, R1 · Rd / (R1 + Rd), where Rd is the diode resistance.

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 port that outputs the current value.

The current sensor’s positive input terminal is connected to the H-Bridge Positive terminal and the negative terminal of the current sensor is connected to the DC motor positive terminal. The reference port is connected to the controlled current source common terminal, and for analyzing the current parameters a scope is connected to the current sensor common terminal with a ps-Simulink converter block. This block converts the physical signal into a Simulink signal.

PS-Simulink Converter:

The PS-Simulink Converter block converts a physical signal into a Simulink® output signal. Use this block to connect outputs of a Simscape™ physical network to Simulink scopes or other Simulink blocks.

DC MOTOR:

This block represents the electrical and torque characteristics of a DC motor.

The block assumes that no electromagnetic energy is lost, and hence the back-emf and torque constants have the same numerical value when in SI units. Motor parameters can either be specified directly or derived from the no-load speed and stall torque. If no information is available on armature inductance, this parameter can be set to some small non-zero value.

When a positive current flows from the electrical + to - ports, a positive torque acts from the mechanical C to R ports. Motor torque direction can be changed by altering the sign of the back-emf or torque constants.

Mechanical Rotational Reference:

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).

Voltage Sensor:

The Voltage Sensor block represents an ideal voltage sensor, that is, a device that converts voltage measured between two points of an electrical circuit into a physical signal proportional to the voltage.

Use the + and - ports to connect the sensor in parallel with the block (or several blocks) where you want to measure the voltage. Port V outputs the measurement result as a physical signal. Use a PS-Simulink Converter block to connect this port to Simulink® blocks, such as Scope or Display.

This voltage sensor block positive terminal is connected to the DC motor positive terminal, the negative terminal of the voltage sensor is connected to DC motor negative terminal, and then the common port is connected to the scope through PS- Simulink converter block. This block converts the physical signal to the Simulink signal. Voltage sensor block properties are shown below.

Solver Configuration:

Each physical network represented by a connected Simscape™ block diagram requires solver settings information for simulation. The Solver Configuration block specifies the solver parameters that your model needs before you can begin the simulation.

Each topologically distinct Simscape block diagram requires exactly one Solver Configuration block to be connected to it.

Electrical Reference:

The Electrical Reference block 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. A model with electrical elements must contain at least one Electrical Reference block.

Connection Port:

The Connection Port block transfers a physical connection or signal across subsystem boundaries. Physical connections include Simscape™ conserving and physical signal connections, Simscape Multibody connections, and Vehicle Dynamics Block set two-way connection ports, among others. This block is similar in function to the Inport and Outport blocks in the Simulink® library.

A subsystem needs a Connection Port block for each physical connection line that crosses its boundary. You can manually place a Connection Port block inside a subsystem, or Simulink can automatically insert a Connection Port block when you create a subsystem within an existing network.

Transmission:

The transmission system contains vehicle wheels, gears, and vehicle body blocks. These are mechanical components that connected each other and drive the vehicle smoothly. This transmission subsystem is shown below.

Blocks used in the transmission subsystem:

Vehicle Body

Tire (Magic Formula)

Simple Gear

PS to Simulink Converter

PS constant

Scope

Connecting port

Vehicle Body:

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.

Connection H is the mechanical translational conserving port associated with the horizontal motion of the vehicle body. The resulting traction motion developed by tires should be connected to this port. Connections V, NF, and NR are physical signal output ports for vehicle velocity and front and rear normal wheel forces, respectively. Wheel forces are considered positive if acting downwards. Connections W and beta are physical signal input ports corresponding to headwind speed and road inclination angle, respectively. If the variable mass is modeled, the physical signal input ports CG and M are exposed. CG accepts a two-element vector representing the x and y distance offsets from vehicle CG to additional load mass CG. M represents the additional mass. If both variable mass and pitch dynamics are included, the physical signal port J accepts the inertia of the additional mass about its own CG.

The vehicle body is having the following ports:

NR- It is a rear axle force port.

NF- It is a front axle force port.

Beta – This is a road incline angle port.

H – This port is connected to the horizontal motion of the vehicle’s body.

V – it is a vehicle longitudinal velocity port.

W – is the Headwind speed port.

The vehicle body is a physical block, and the output signals are physical signals. The NR port is connected to the Rear wheels (left side) and the NF port is connected to the Front wheels (Right side). V port is connected to connecting port Velocity. Beta and W ports are connected to the PS Constant block.

Tire (Magic Formula):

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.

Connection A is the mechanical rotational conserving port for the wheel axle. Connection H is the mechanical translational conserving port for the wheel hub through which the thrust developed by the tire is applied to the vehicle. Connection N is a physical signal input port that applies the normal force acting on the tire. The force is considered positive if it acts downwards. Connection S is a physical signal output port that reports the tire slip. Optionally expose physical signal port M by setting Parameterize by to Physical signal Magic Formula coefficients. Physical signal port M accepts a four-element vector corresponding to the B, C, D, and E Magic Formula coefficients.

The tire block has the following ports:

N- This is a normal force connecting the port to the vehicle body.

A – This is the axle signal connecting the port.

S – this is a slip signal connecting the port.

H – this is a mechanical translational port. This wheel hub transmits the thrust generated by the tire.

The left side tire’s (Rear Axle) N port is connected to the NR port of the vehicle body. The right side tire’s front wheels’ N port is connected to the NF terminal. H terminals are connected to the vehicle body H port. The S port is open, we are not taking any slip for the wheels.

PS Constant:

This block generates the physical signal of a constant value. The Constant parameter accepts both positive and negative values. The block output is a physical signal port.

Simple Gear:

Represents a fixed-ratio gear or gearbox. No inertia or compliance is modeled in this block. You can optionally include gear meshing and viscous bearing losses.

Connections B (base) and F (follower) are mechanical rotational conserving ports. Specify the relation between base and follower rotation directions with the Output shaft rotates parameter. Optionally include thermal effects and expose thermal conserving port H by setting the Friction model to a temperature-dependent setting.

The simple gear block has one input port and one output port. The input port is connected to the motor controller gear output terminal. And the F port is connected to the real wheels Axle terminal.

Here we are taking the integrator block at the velocity feedback port. When the velocity is integrated with respect to the time, the total distance is covered from the initial position to the final position of the vehicle. The integrated output of distance is multiplied and divided by the constant value 1000 to get the distance in Kilometres. The total distance in kilometers is visible in the display block.

Model explanation:

When the simulation is started the Drive Cycle Source is giving the reference speed as an input to the Longitudinal driver block and this block. PI controller is used in the longitudinal driver block this was generating normalized acceleration and braking commands based on the reference and feedback velocities. The acceleration and deceleration commands are given to the motor controller block.

In the Motor Controller block, two controlled voltage source blocks are taken for acceleration and deceleration ports. When the Acceleration command is generated from the longitudinal driver block it is given to the controller voltage source common terminal. 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 output voltage is zero when the pulse is low and is equal to the Output voltage amplitude parameter when high. The duty cycle is set by the input value. 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. The PWM block positive output port is connected to the current sensor Positive input port. This current sensor converts the current measured in any electrical branch into a physical signal proportional to the current. Connection I is a physical signal port that outputs the current value. This output is given to the battery subsystems controlled current source common terminal. The motor positive terminal is connected to the current sensor-negative terminal. The motor mechanical R port is connected to the simple gear. A voltage sensor is placed in parallel with DC Motor to measure the voltage. A solver is placed at common ground. In the transmission subsystem Gear is the input signal and the vehicle body is connected to the tires.

The vehicle body has the inclination angle and wind force ports these are connected to PS constant blocks. This vehicle body has an H port this port is connected to the wheel hub port of all four wheels. Tires force N port is connected to NR and NF these are rear force and font force. V port is the velocity of the vehicle body output for the longitudinal driver block which is feedback.

In the battery subsystem, we are calculating the battery SOC. For this subsystem, the current is the input, and the output is connected to the scope to view the battery SOC. The battery is connected to the controlled current source common port is connected to the motor controller current sensor output port. A bus selector is connected to a battery measurement port and the bus selector has one input and three outputs (SOC, Voltage, and Current).

To calculate the total distance covered by the vehicle, I am taking the velocity from the transmission block and integrating the velocity then dividing by 1000. The output of the divider block is given to a display block and scope block.

Results:

This model is simulated for 2474 seconds with three different PI controller gain values.

Test-1: Proportional gain =1 and Integral gain = 1.

velocity:

from the above plot, we can observe the vehicle velocity in blue color and ref_velocity from the drive cycle source block in yellow color. vehicle velocity is tracking the ref_ velocity.

Battery_ SOC_VOLTAGE_CURRENT:

from the above plot, the SOC is reduced from 100% to 98%. and during the discharge, some time period of time battery soc is increasing and decreasing. when the battery is charged in regenerative braking and in the motoring mode battery is discharged. the current at the start is 0 and t reaches 282 amps. the voltage of the battery is at start is 350 volts and it reaches peak around 380 volts.

motor voltage and current:

from the above plot, we can observe the motor voltage and current response. motor peak voltage is 282 volts and the peak current is 284A.

Distance:

from the above plot, we can observe the vehicle traveled distance is 4.9km.

Test-2: Proportional gain: 10 integral gain: 5

Velocity:

in the above plot, the actuval velocity is tracking efficiently the ref_velocity as compare to to test-1.

battery SOC VOLTAGE AND CURRENT:

from the above plot the soc decreased from 100% to 98.7%

peak current is 292A

peak voltage is 324v

Motor voltage and current:

Distance:

vehicle traveled distance is 4.93km

Test-3: Proportional gain: 30 Integral gain: 10

Velocity:

when the PI values are changed the velocity is tracked more accurately and the both waves are lie on same. but at the peak ranges the wave is controlled.

Distance:

in the above graph vehicle distance is observed. vehicle distance is 4.93km

Motor voltage and current:

the motor peak voltage is 243V

motor peak current is 293A

battery soc voltage and current:

the battery SOX fall from 100% to 98.7%

peak voltage is 373volts.

peak current is 293A.

Conclusion:

a MATLAB model of electric car which uses lithium ion battery and suitable motor is designed in simulation and by using the simulink primitive block longitudinal driver block is created to generate the acceleration and braking commands. model is runnig successfully and results observed with different PI values for 3 test cases.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.