Final Project: Design of an Electric Vehicle
Create a MATLAB model of electric car which uses a battery and a DC motor. Choose suitable blocks from Powertrain block set. Prepare a report about your model including following:
Objectives:
1. System level configurations
2. Model parameters
3. Results
4. Conclusion
Solution:
First we shall see the component blocks that are required to builf the complete model in detail and the different configurations within them for choosing the appropriate ones for our system model.
Mechanical Components/Subsystems:
Vehicle Body:
Two-axle vehicle with longitudinal dynamics and motion and adjustable mass, geometry, and drag properties

Fig: Vehicle Body Block
It represents a 2 axle vehicle in longitudinal motion. Can have a same or different number of wheels on each axle. Wheels are assumed to be identical in size. Centre of Gravity can be at or below the plane of travel.
The block accounts for:
- Body mass/payload
- Drag coefficient(aerodynamic drag)
- Road inclination(grade)
- Weight distribution on the 2 axles due to acceleration and grade profile
- Has optional pitch & suspension dynamics.
The vehicle does not move vertically relative to the ground.
The block has an option to include an externally-defined mass and an externally-defined inertia. The mass, inertia, and center of gravity of the vehicle body can vary over the course of simulation in response to system changes.
Model axes:The vehicle axles are parallel and form a plane. The longitudinal, x, direction lies in this plane and perpendicular to the axles. If the vehicle is traveling on an incline slope, β, the normal, z, direction is not parallel to gravity but is always perpendicular to the axle-longitudinal plane.

Fig: vehicle dynamics and model variables

Fig: variables of the Vehicle Body mathematical model
Equations:

Limitations & Assumptions:
- Only models Longitudinal dynamics,, parallel to the ground and oriented along the direction of motion
- assumed to be in pitch and normal equilibrium. The block does not model pitch or vertical movement
- the equations assume that the wheels never lose contact. This constraint can result in negative normal forces.
Ports:
- W(Wind) - for headwind speed
- Beta - road incline angle
- V - output - longitudinal velocity
- NF - front axle normal force. Wheel forces Considered positive if acting downwards
- NR - Rear axle normal force
- H- horizontal motion - Conserving port associated with the horizontal motion of the vehicle body. Connect tire traction motion to this port.
Block parameters: Main

Block parameters: Drag

Block parameters: Pitch


Fig: Pitch parameters if ON then the options under the 2 cases of Suspension model - Linear or Lookup table. Default is OFF
If set to ON- it helps us to Enable Pitch Dynamics Modeling: which needs 3 parameters/dependencies:
- Suspension model(as we see above image for the 2 types- Linear or Lookup table)
- Hard-Stop Model
- Initial Pitch conditions
Last two are also in the same dialog box drop down menu of Pitch :



Fig: Some variables that need to be defined for Pitch Dynamic modelling if enabled ‘Pitch’
Tire(Magic Formula):

Fig: Tire(Simscape > Driveline) block
Description: For Longitudinal behavior guven by Magic Formula Coefficients, which is an empirical equation based on four fitting coefficients. The block can model tire dynamics under constant or variable pavement conditions.The longitudinal direction of the tire is the same as its direction of motion as it rolls on pavement.
To increase the fidelity of the tire model: you can specify properties such as tire compliance, inertia, and rolling resistance.Tradeoff - these properties increase the complexity of the tire model and can slow down simulation. Consider ignoring tire compliance and inertia if simulating the model in real time or if preparing the model for hardware-in-the-loop (HIL) simulation.
Tire Model:
models the tire as a rigid wheel-tire combination in contact with the road and subject to slip. When torque is applied to the wheel axle, the tire pushes on the ground (while subject to contact friction) and transfers the resulting reaction as a force back on the wheel. This action pushes the wheel forward or backward. (If you include the optional tire compliance, the tire also flexibly deforms under load.)

Fig: Forces acting on the Tire (FBD)
Model Variables are as follows:

Tire kinematics and Response:
Roll and Slip:

Slip at Low Speeds:

Defromation:

tire and wheel dynamics:

fig: behavior of the block is same as the behavior of the system above
the tire model is equivalent to the above component diagram , simulates both steady state and transient behavior well and correctly represents the staring and coming to stop. Spring and damper are equivalent to tire stiffness and damping due to deformation in the Tire block - refer to variables in the table `C_(F_x)` and `b_(F_x)`
The Tire-Road Interaction (Magic Formula) block models the longitudinal force `F_x` on the tire as a function of `F_z` and `k′` using the Magic Formula, with `k′`as the independent slip variable.
The Wheel and Axle radius is the wheel radius `r_w`. The Mass value is the effective mass,`I_w/(r_w)^2` The tire characteristic function `f(k′, F_z)` determines the longitudinal force `F_x`. Together with the driveshaft torque applied to the wheel axis, `F_x` determines the wheel angular motion and longitudinal motion.
Assumptions and Limitations:
- The Tire (Magic Formula) block assumes longitudinal motion only and includes no camber, turning, or lateral motion.
- Tire compliance implies a time lag in the tire response to the forces on it. Time lag simulation increases model fidelity but reduces simulation performance
Input ports :
- N - Nomal Force: the normal force acting on the tire. The normal force is positive if it acts downward on the tire, pressing it against the pavement.
- M - Magic formula coefficients(only if parameterize by
Physical signal Magic Formula coefficientsis selected): a four-element vector, specified in the order [B, C, D, E].
Output ports :
- S - Slip - slip between the tyre and the road
Conserving ports :
- A- Axle : Mechanical rotational port associated with the axle that the tire sits on.
- H- Hub: Mechanical translational port associated with the wheel hub that transmits the thrust generated by the tire to the remainder of the vehicle.
Parameters : Main:

Fig: options to parameterize according to which other parametes will be available
for chosing the Magic formula tire-road interaction model.
The Magic Formula is a specific form for the tire characteristic function, characterized by four dimensionless coefficients, B, C, D, and E, or stiffness, shape, peak, and curvature:

The slope of f at 
Magic formula coeffiemts for typical road conditions:

To model under constant pavement condition chose either of:
- Peak longitudinal force and corresponding slip — Parameterize the Magic Formula with physical characteristics of the tire.
- Constant Magic Formula coefficients — Specify the parameters that define the constant B, C, D, and E coefficients as scalars, with these default values.
- Load-dependent Magic Formula coefficients — Specify the parameters that define the load-dependent C, D, E, K, H, and V coefficients as vectors, one for each coefficient, with the default values available in documentation.
To model tire dynamics under variable pavement conditions, select Physical signal Magic Formula coefficients. Selecting this model exposes a physical signal port M. Use the port to input the Magic Formula coefficients as a four-element vector, specified in the order [B, C, D,E].


Fig: Parameters(dependent on the choice of 'parameterize by') defined
Geometry:
- Rolling Radius: unloaded tire-wheel radius
Dynamics:

Fig: As before , for incorporating the deformation parameters, but at cost of increased time for simulation (can see No compliance - written as an option "sutiable for HIL" and real time simulation.)
Rolling Resistance: Default OFF:

Fig: if ON has 2 options - constant coefficients and Pressure and Velocity dependent
Advanced :
Velocity threshold:Wheel hub velocity `V_"th"` below which the slip calculation is modified to avoid singular evolution at zero velocity. Must be positive. Refer to equations above to understand significance.
Simple Gear:
Simple gear of base and follower wheels with adjustable gear ratio, friction losses, and triggered faults.

Fig: Simple Gear (Simscape> Driveline)
Description: The Simple Gear block represents a gearbox that constrains the connected driveline axes of the base gear, B, and the follower gear, F, to corotate with a fixed ratio that you specify. You choose whether the follower axis rotates in the same or opposite direction as the base axis.
The kinematic constraint that the Simple Gear block imposes on the two connected axes is:
`=>r_f omega_f = r_bomega_b`
The follower-base gear ratio is
`=>g_"FB" = r_f/r_b = N_F/N_B`
where :
`N_F` = is the number of teeth in the follower gear.
`N_B` = is the number of teeth in the base gear.
Example- Say gear ration between follower and base is 2:1, then it means that The follower shaft torque is twice the base shaft torque and the angular velocity of the follower is half the angular velocity of the base
Reducing the two degrees of freedom to one independent degree of freedom yields the torque transfer equation:
`=>g_"FB"tau_B + tau_F - tau_"loss" = 0`
where:
`tau_B` = is the Input torque
`tau_F` = is the Output torque
`tau_"loss"` = is due to friction and in ideal case is 0
Nonideal constraints and losses:
In a nonideal gear pair (B,F), the angular velocity, gear radii, and gear teeth constraints are unchanged. But the transferred torque and power are reduced by:
- Coulomb friction between teeth surfaces on gears B and F, characterized by efficiency, η
- Viscous coupling of driveshafts with bearings, parametrized by viscous friction coefficients, μ
Efficiency cases: are two and can be seen in the image below-

Fig: 2 efficiency cases and no efficiency case
Thermal Model:
You can model the effects of heat flow and temperature change by selecting a thermal block variant. Selecting a thermal variant:
- Exposes port H, a conserving port in the thermal domain.
- Enables the Thermal mass parameter, which allows you to specify the ability of the component to resist changes in temperature.
- Enables the Initial Temperature parameter, which allows you to set the initial temperature.
To select a thermal variant, right-click the block in your model and, from the context menu, select Simscape > Block choices


Fig: With thermal port enabled to model thermal effects
Assumptions:
- Gear inertia is assumed negligible.
- Gears are treated as rigid components.
- Coulomb friction slows down simulation. So keep this tradeoff in mind for model fidelity vs runtime
Ports:
- B - Rotational mechanical conserving port associated with the base, or input, shaft.
- F - Rotational mechanical conserving port associated with the follower, or output, shaft.
Parameters:
- Gear ratio - Fixed ratio `g_"FB"` of the follower axis to the base axis. The gear ratio must be strictly positive.
- Motion direction -direction of motion of the follower (output) driveshaft relative to the motion of the base (input) driveshaft.. either in samr or opposite
Friction Models:
Friction models at various precision levels for estimating power losses due to meshing.
- No meshing losses - Suitable for HIL simulation — Neglect friction between gear cogs. Meshing is ideal.
- Constant efficiency — Reduce torque transfer by a constant efficiency factor. This factor falls in the range 0 < η ≤ 1 and is independent from load.
- Load-dependent efficiency — Reduce torque transfer by a variable efficiency factor. This factor falls in the range 0 < η < 1 and varies with the torque load.
Electrical Components/Subsystems:
DC Motor:

Fig: Simscape Block for Brushless DC motor
Description:The DC Motor block represents the electrical and torque characteristics of a DC motor using the following equivalent circuit model:

Options for Model parameterization:
- equivalent circuit parameters - which we see above R & L
- rated load and torque
- stall torque and no-load speed

Model paramertixation options
in the other cases the block will convert the given parameters into equivalent circuit parameters and proceed internally.
The DC Motor block assumes that there are no electromagnetic losses. This means that mechanical power is equal to the electrical power dissipated by the back emf in the armature. Equating these two terms gives:

Magnetic field genration:
either permanent magnet or field winding. In case of PM 
and in case of field winding 
The torque-speed characteristic: for the DC Motor block is related to the parameters in the preceding figure. When you set the Model parameterization parameter to By stall torque & no-load speed or By rated power, rated speed & no-load speed, the block solves for the equivalent circuit parameters as follows:

When you set the Model parameterization parameter to By rated power, rated speed & no-load speed, the block uses the rated speed and power to calculate the rated torque. The block uses the rated torque and no-load speed values in the preceding equation to determine values for `R` and `k_t`.
After incorporating interia `J` and damping `lambda` the torque eqaution becomes:

Usually we extimate the rotor damping using the following logic:For no-load, the electrically-generated mechanical torque must equal the rotor damping torque.
`=k_ti_"noload" = lambda omega_"noload"`

Fig: rotor damping parameterization option
If you select By no-load current for the Rotor damping parameterization parameter, then this equation is used in addition to the torque-speed equation to determine values for λ and the other equation coefficients.
Importance of damping valueThe value for rotor damping, whether specified directly or in terms of no-load current, is taken into account when determining equivalent circuit parameters for Model parameterization options By stall torque and no-load speed and By rated power, rated speed and no-load speed.
When a positive current flows from the electrical + to - ports, a positive torque acts from the mechanical C to R ports.
Ports:
- Positive terminal
- Negative terminal
- C- Motor Case :Mechanical rotational conserving port associated with the DC motor case.
- R- Motor Rotor: Mechanical rotational conserving port associated with the DC motor rotor
- H- thermal port: when thermal model enabled
in case of model parameterization by Rated Load and Speed:
- armature inductance:Inductance of the conducting portion of the motor. If you do not have information about this inductance, set the value of this parameter to a small, nonzero number.
- no load speed:Speed of the motor when not driving a load.
- rated speed: Motor speed at the rated mechanical power level.
- rated load: The mechanical power the motor is designed to deliver at the rated speed.
- DC supply volatge: The voltage at which the motor is rated to operate.
Controlled PWM Voltage:


Fig: controlled PWM voltage dialog box
the output is a PWM voltage across the PWM and REF v and will vary between 0 and Output volatge set(i set 5V) for low and high pulse respectively.
the duty cycle will be decided by the value of the input voltages that are to be given as voltage corresponding to 0% duty cycle and 100% duty cycle respectively.
there are 2 Simulation modes:
- PWM mode - the output will be a PWM signal
- Averaged mode - the output is constant with the value equal to the average of the PWM signal
The block has two modeling variants, accessible by right-clicking the block in your block diagram and then selecting the appropriate option from the context menu, under Simscape > Block choices:
- Electrical input ports — The block calculates the duty cycle based on the reference voltage across its ref+ and ref- ports. This modeling variant is the default. where the demanded duty cycle is calculated as

- PS input — Specify the duty cycle value directly by using an input physical signal port.
we have used the electrical input ports where the ref will vary from 0 to 1 that actually comes from the
the value of the output voltage amplitude determines the vlaue of the output voltage.
if we want to use it to drive a motor: given in Documentation
"Do not use the Controlled PWM block to drive a motor block directly. A PWM motor driver goes open circuit in between pulses. Use the H-Bridge block to drive a motor block." as given in the documentation.
and
"When driving a motor via the H-Bridge block, set the Simulation mode parameter to Averaged to speed up simulations. You must also set the Simulation mode parameter of the H-Bridge block to Averaged mode. This applies the average of the demanded PWM voltage to the motor. The Averaged mode assumes that the impedance of the motor inductive term is small at the PWM frequency. To verify this assumption, run the simulation using the PWM mode and compare the results to those obtained from using the Averaged mode."
Conserving ports:

Input Scaling


H-Bridge:


Fig: H-Bridge Dialog Box
The H-Bridge block represents an H-bridge motor driver. The block has the following two Simulation mode options:PWM & Averaged
- 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 three Freewheeling mode options
- Averaged - This mode has two Load current characteristics options:
- Smoothed
- Unsmoothed or discontinuous
- The
Smoothedoption assumes that the current is practically continuous due to load inductance. In this case, the H-Bridge block output is:
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
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 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.
Conserving ports:

Parameters:


Input thresholds:

Bridge Parameters:

Control Component:
Longitudinal Driver:
longitudinal Driver:
desciption:longitudinal speed tracking controller based on reference and feedback velocities
output: generates nomrmalized braking and acceleration commands which will have a value between 0 an 1. This means that the PWM generator input should be between 0 & 1 for 0% and 100% PWM Signal. It generates the command necessary to track a longitudinal drive cycle
configurations:
i) External actions:

Fig: external actions available
selecting the options will create corresponding input ports for signals that can disable, hold, or override the closed-loop acceleration or deceleration commands. The block uses this priority order for the input commands: disable (highest), hold, override.

fig: list of ports and their functionality
ii)Contorller:

Fig: controller options available
these are the type of control options available for the controller.


Fig: associated controller options will appear under the control option. Ex: PI control options
iii)Shift type:
this is to specify the shift options:
the options with the functionality they implement are:
⦁ None:No transmission. Block outputs a constant gear of 1.Use this setting to minimize the number of parameters you need to generate acceleration and braking commands to track forward vehicle motion. This setting does not allow reverse vehicle motion.
⦁ Reverse, Neutral, Drive: Block uses a Stateflow® chart to model reverse, neutral, and drive gear shift scheduling.Use this setting to generate acceleration and braking commands to track forward and reverse vehicle motion using simple reverse, neutral, and drive gear shift scheduling. Depending on the vehicle state and vehicle velocity feedback, the block uses the initial gear and time required to shift to shift the vehicle up into drive or down into reverse or neutral.For neutral gears, the block uses braking commands to control the vehicle speed. For reverse gears, the block uses an acceleration command to generate torque and a brake command to reduce vehicle speed.
⦁ Scheduled:Block uses a Stateflow chart to model reverse, neutral, park, and N-speed gear shift scheduling. Use this setting to generate acceleration and braking commands to track forward and reverse vehicle motion using reverse, neutral, park, and N-speed gear shift scheduling. Depending on the vehicle state and vehicle velocity feedback, the block uses these parameters to determine the:
⦁ Initial gear
⦁ Upshift and downshift accelerator pedal positions.
⦁ Upshift and downshift velocity.
⦁ Timing for shifting and engaging forward and reverse from neutral.
⦁ For neutral gears, the block uses braking commands to control the vehicle speed. For reverse gears, the block uses an acceleration command to generate torque and a brake command to reduce vehicle speed.
⦁ External:Block uses the input gear, vehicle state, and velocity feedback to generate acceleration and braking commands to track forward and reverse vehicle motion.For neutral gears, the block uses braking commands to control the vehicle speed. For reverse gears, the block uses an acceleration command to generate torque and a brake command to reduce vehicle speed.
iv)Gear Signal:Use the Output gear signal parameter to create the GearCmd output port. The GearCmd signal contains the integer value of the commanded vehicle gear.

Fig: value of output corresponding to particular gear
Controller : PI Speed Tracking:
the cases of controller to be PI or Sheduced PI will implement a PI controller with tracking windup and feedforward gains for the PI .For schecules PI the gains will depend on the vehicle velocity and therfore a fcuntion of that
equations corresponding to both cases are:
where,


Input Ports:

Output Port:

info: contains a bus signal with the follwoing information:

depends of course on the block parameters chosen.
for the PI controller gain:

the block uses the nominal speed specified to normalize the controller gains. in case of PI ans Schecduled PI
---------------------------------------------------------------------------------------------------------------------
The System Model

Fig: Complete Model for the System

Fig: Inside the Vehicle Subsystem Driven by the Motor Mechanical Output
the System Blocks:
- Some reference to track - Speed VS time - A drive cycle
- Conveter to convert Linear Parameters to Electrical parameters - Longitudinal driver and controlled voltage source. to create the relevant Acceleration and Decelleration commands
- Controlled electrical signals - created by the Controlled PWM Voltage
- Motor Driver - H-bridge motor drive that will use the electrical signals corresponding to acceleration and deceleration into appropriate voltage for the motor to be driven in terms of magnitude and polarity
- Motor - the motor used to convert the elctrical signals/energy into mechanical output required to obtain the desired speed vs time performance
- Mechanical gear - to couple/link the motor shaft with the vehicle transmission
- Wheels - to apply the angular motion that it receives from the gear to the wheels and get the correspoding response from the vehicle body and driving condtions
- vehicle body - to model the vehicle parameters as well as the road conditions and get the velocity output that will be compared with the desired output to assess the performance of the model
- current measurement and integration - to get the total amount of discharge done in order to determine the state of charge using the coulomb counting method

System level configuration & model Parameters:
the vehicle body chosen is as follows:
- Mass: `1200kg`
- Wheels per axle: 2 . That is , it is a 4-wheeler
- Frontal area : `3m^2`
- wheel radius: `0.3m`
external conditions chosen :
- Air density: `1.18 (kg)/m^3`
- Drag coefficient : 0.4
motor:
- no load speed: 8000 rpm
- rated speed: 5000 rpm
- rated load: 150kW
- rated DC Supply:300V
H-Bridge:
- Output voltage aplitude:300V
- enable threshold voltage: 0.1V
- PWM signal amplitude: 5V
Controlled PWM Voltage:
- Output voltage: 5V
- Input scaling: 0 to 1
- frequency: 1000Hz
Drive cycle used: FTP75
so for the rating of the motor the power needed is to be calculated:
as we know that forces acting on the vehicle are:
`=>F = ma + mgsintheta + 1/2 rho AC_d v^2 + mu_rmgcostheta`
using the drive cycle FTP75 we will calculate the instantaneous power required by calculating the power as:
`"Power" = "Force"xx "velocity"`
from the FTP75 speed vs time data and the vehicle and driving condition parameters we can see the total power required at any instant. From this we can conclude that the Motor which gives an approximate 150kW would be appropriate to meet the vehcile drive requirement
therefore the DC Motor parameters can be set as:


since the DC Supply Voltage is 300V then the Motor Driver H-Bridge should also have Output voltage as 300V


and power supply is kept internal as in case of external we have only the PWM Simulation mode avaialable and that would take the simulation to run in a lot of time.
regenerative braking is always enabled as that is how actually our controller operates to ensure regenerative braking. and Load characterstics are Smoothed as it is assumed continuous due to practical load inductance.
controlled PWM voltage should give us the same voltage that is in the input threshold of the Hbridge in the PWM signal parameters

which is 5 V here so for the Controlled PWM voltage the output should also be 5V as w can see

now for running the PWM controlled voltage we need to understand the range of the signal for scaling the 0% to 100% PWM signal. Since the input signal is coming from the longitudinal driver which gives us the Acceleration and Decceleration commands which are actually normalised signals and hence are going to be in the range 0 to 1. Therfrore the input signal range for 0% to 100% PWM is ) 0 to 1.

for the Gear ratio an appropriate ratio of 5 is chosen taking into consideration the wheel radius an the Motor RPM

for estimation of charge we have chosen to assume a battery pack made of Cells with Nominal Voltage 3.7V and Nominal Capacity 3.5Ah
from the simualtion we will see the current drawn from the motor reaches upto 300A

assuming the battery to be able to sustain 1.25C discharge rate easily we can say that the capacity of the battery will be 300/1.25 = 240Ah which means 240/3.5=68.57 = 69 cells in parallel
and for the no of cells in series we know the motor voltage rating is 300V = 300/3.7 = 81.08 = 82 cells in series . So the pack will be 82S69P
this will be implemented as the battery with the above conguration and nominal ratings as:

Fig: 3.7V and 3.6Ah in 82S69P configuration
so after running the simulation we will see the depletion in the soc after 1000s running on the FTP75 drive cycle.
Running the Simulation: Results
Simulation time: 1000s
after running the simulation for 1000s we will observe the results

total distance travelled by the vehicle in 1000s of FTP75 Drive cycle

Distance VS time

Fig: FTP75 input Drive cycle (majenta) and actual response of the vehicle(red)
Observation: we see that the response of the vehicle matches the required response closely but not completely accurately but htis is with the acceptable limits of persormance as the major curves and changes are captured in a timely manner.

Fig: State of charge. Depletion of charge from 100% to 97.85% . Total Deplection go 2.15% in 1000s
Conclusion:
we see that the model behaves very closely to the expected perfomance even though no changes are made in the default Kp and Ki values of the Longitudinal Driver block ( Ki=1 and Kp=15).
but in conclusion the configuration and sizing of the components is correctly done as can be seen from the perfomance of the model and the drive cycle is tracked well to get the desired behavior.