Project-1: Modelling an electric Car with Li-ion battery
Aim:
Create a MATLAB model of electric car which uses lithium ion battery and suitable motor. Choose suitable blocks from Simscape or Powertrain block set. Implement the vehicle speed control using PI controller and generate brake and accelerator commands. Avoid using readymade driver block for speed control.
Objectives:
Design the Vehicle speed control using the PI controller and generate Brake and acceleration commands.
Run the model with theDrive cycle and observe the Distance travelled, Soc and velocity of the vechicle.
SIMULINK MODEL:

TRANSMISSION SUBSYSTEM :
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.

Tire:
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 Friction model to Physical signal friction coefficients. Physical signal port M accepts a two element vector corresponding to the static and kinetic friction coefficients.
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, backlash, 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.
MOTOR SUBSYSTEM :

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.
H-BRIDGE CONVERTER :

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


The Battery block implements a generic dynamic model that represents most popular types of rechargeable batteries.
Energy calculation is done by the formula P⋅t1000">P⋅t1000P⋅t10001s+1 KWh
Power (P) = Voltage * Current
integrating it gives the Energy consmption in Watts and dividing it with 3600 gives Watt-Hour.
Controlled Current Source:
The Controlled Current Source block converts the Simulink® input signal into an equivalent current source. The generated current is driven by the input signal of the block. The positive current direction is as shown by the arrow in the block icon.
You can initialize the Controlled Current Source block with a specific AC or DC current. If you want to start the simulation in steady state, the block input must be connected to a signal starting as a sinusoidal or DC waveform corresponding to the initial values.
It gets the control single from the H-Bridge current measurnment block.
BUS SELECTOR:

CONTROLLER:

PID:

PID:
The Discrete PID Controller block implements a PID controller (PID, PI, PD, P only, or I only). The block is identical to the PID Controller block with the Time domain parameter set to Discrete-time.
The block output is a weighted sum of the input signal, the integral of the input signal, and the derivative of the input signal. The weights are the proportional, integral, and derivative gain parameters. A first-order pole filters the derivative action.
The block supports several controller types and structures. Configurable options in the block include:
-
Controller type (PID, PI, PD, P only, or I only) — See the Controller parameter.
-
Controller form (Parallel or Ideal) — See the Form parameter.
-
Time domain (continuous or discrete) — See the Time domain parameter.
-
Initial conditions and reset trigger — See the Source and External reset parameters.
-
Output saturation limits and built-in anti-windup mechanism — See the Limit output parameter.
-
Signal tracking for bumpless control transfer and multiloop control — See the Enable tracking mode parameter.
As you change these options, the internal structure of the block changes by activating different variant subsystems. (For more information, see Variant Subsystem). To examine the internal structure of the block and its variant subsystems, right-click the block and select Mask > Look Under Mask.
SATURATION BLOCK :
user acceleration and deacceleration


The Saturation block produces an output signal that is the value of the input signal bounded to the upper and lower saturation values. The upper and lower limits are specified by the parameters Upper limit and Lower limit.
Here we used the 2 saturaion blockes one for Acceleration and other for Braking as shown above. This will sparate the Acceleration signal and deceleration signal and give it to the Transfer function.
Result :
