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 the Powertrain block set.
An Electric car is modelled in simulink using powertrain blocks, DC motor and battery.
The blocks used in this model,
- Drive cycle source
- Longitudinal Driver
- Controlled PWM voltage
- H-bridge
- Controlled voltage source
- Controlled current source
- DC motor
- Battery
- Tire (Magic formula)
- Vehicle body
- Simple gear
- Current sensor
- Gain and Rate conversion
Blocks and configurations:
Drive cycle source
A driving cycle is a series of data points representing the speed of a vehicle versus time.The Drive Cycle Source block generates a standard or user-specified longitudinal drive cycle. In this Model we use default drive cycle source FTP-75 for 2474 seconds. Other drive cycle sources can be installed or excel file can be loaded as drive cycle.

Longitudinal Driver
The Longitudinal Driver block implements a longitudinal speed-tracking controller. Based on reference and feedback velocities, the block generates normalized acceleration and braking commands that can vary from 0 through 1. You can use the block to model the dynamic response of a driver or to generate the commands necessary to track a longitudinal drive cycle.
A parametric longitudinal speed tracking controller for generating normalized acceleration and braking commands based on reference and feedback velocities.
Use the external actions to input signals that can disable, hold, or override the closed-loop commands determined by the block. The block uses this priority for the input commands: disable, hold, override.

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.Switch between electrical +ref/-ref ports and PS input u to specify 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.

In this model this block is configured,
Frequency ⇒ 1000 Hz
Simulation mode ⇒ averaged
Output voltage amplitude ⇒ 330 V
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 are defined relative to the REF port.
If exposing the power supply connections, the block only supports PWM mode.

In this model this block is configured,
Power supply ⇒ Internal
Simulation mode ⇒ Averaged
Regenerative braking ⇒ Always Enabled (suitable for linearization)
Enable threshold voltage ⇒ 0.5 V
PWM threshold voltage ⇒ 5 V
Reverse threshold voltage ⇒ 0.5 V
Braking threshold voltage ⇒ 0.5 V
Output voltage amplitude ⇒ 330 V
Total bridge on resistance ⇒ 0.1 ohm
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.

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

In this model this block is configured,
Field type ⇒ Permanent magnet
Model parameterization ⇒ By rated load and speed
No load speed ⇒ 10000 RPM
Rated speed ⇒ 9000 RPM
Rated load (mechanical power) ⇒ 70 KW
Rated DC supply voltage ⇒ 330 V
Controlled current source
The block represents an ideal current source that is powerful enough to maintain the specified current through it regardless of the voltage across it. The output current is I = Is, where Is is the numerical value presented at the physical signal port.

Battery
This block models a battery. If you select Infinite for the Battery charge capacity parameter, the block models the battery as a series internal resistance and a constant voltage source. If you select Finite for the Battery charge capacity parameter, the block models the battery as a series internal resistance plus a charge-dependent voltage
In this model this block is configured,
Nominal voltage ⇒ 400 V
Internal resistance ⇒ 0.2 ohm
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.

In this model this block is configured,
Parameterize by ⇒ Load dependent magic formula coefficient
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 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.

In this model this block is configured,
Mass ⇒ 1200 kg
Number of wheels per axle ⇒ 2
Simple Gear
Represents a fixed-ratio gear or gear box. 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 Friction model to a temperature-dependent setting.

Teeth ratio ⇒ 2
Output shaft rotates ⇒ In same direction as input shaft
Sensor, Gain and rate conversion blocks are used where it is required.
By using the above blocks in simulink. A model of Electric car is created.

Motor and Controller subsystem:

Vehicle Body subsystem:

Battery subsystem

Working:
The above blocks are connected as shown. The drive cycle source is provided to longitudinal driver. That provides the acceleration and braking command to the controlled voltage source. PWM is generated from Controlled PWM voltage and fed to H-bridge which control the DC motor based on the command from the longitudinal driver. The velocity feedback is provided to longitudinal driver from the vehicle body. Based on the velocity feedback the controller will adjust the performance of vehicel. The regeneration while braking is also obtained here.
Conclusion:
The drive cycle source is tried to match with vehicle velocity. The total distance for the drive cycle is also calculated. The SOC of the battery is also plotted.

_______________________________________________________________________________________
https://drive.google.com/file/d/10ynfjXQ6iNgZs9cM4SjUAWJK-KhXTG38/view?usp=sharing