Challenge

Modelling a detalied design of an Electric Vehicle in Matlab using Simscape

Creating a Matlab model of an Electric Vehicle using Simscape

In creating a simscape model of an electric car, the Vehicle Body and car tire data must be defined first.

Vehicle Body

This block Represents a two-axle vehicle body in longitudinal motion. The block accounts for body mass, aerodynamic drag, road incline, and also the weight distribution between axles.

Tire model

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

To define the parameters of Vehicle body and Tire model blocks with ease, a matlab script is created.

The script has variables (with parameter names) assigned with specific values. In the Vehicle body and Tire model blocks these variables are given as input values.

Thus by changing the script values, easily vehicle parameters can be changed

%% Vehicle Parameters

rider_mass = 80;     %kg
vehicle_mass = 1000;  %kg
CG_height = 254;     %mm
drag_coeff = 1.2;
front_axle = 1520;   %mm
rear_axle = 1400;    %mm
front_area = 1.33;   %m^2

%% Tire Parameters

tire_b =  10;
tire_c = 1.9;
tire_d = 1;
tire_e = 0.97;
tire_dia = 18;       %in
tire_inertia = 1e-3; %kg*m^2
roll_resist = 0.005;

Vehicle Body block

Tire data block

Connetcing Vehcile body with Tire blocks

The vehicle is designed as a rear-wheel driven one. Hence the motor torque is delivered to the rear axle alone using a connection port

The hub of all the four wheels is connetced to the H (hub) port of the vehicle block.

Similarly the normal force of rear wheels are connected to NR and normal force of front wheels are connected to NF of the Vehcile body block.

The wind velocity and terrain (grade) are given as input ports, whose values will be defined outside the subsystem.

The output port i.e. Vehicle speed of the block is connected to a scope using PS to simulink converter.

Data collection

Ideal force sensors are used in all the four wheels to measure longitudinal tire forces.

Rotational Motion Sensors are used in all the four wheels to measure the wheel speed in rpm

Then the slip values of the tires are given to a Goto block using PS to simulink converter for plotting purposes.

The NR and NF values are also given to GOTO blocks using PS to simulink converter

Data plotting

All the data from the sensors and GOTO tags are appropriately given to Mux block which combines inputs with the same data type and complexity into a vector output.

This vector output is given as input to the scope block for plotting the results.

The entire setup of the vehicle and tire is modelled as given below.

The data from the H port of the vehicle body block is given to a connection port to measure speed.

The entire system is put under a subsystem named vehicle subsystem, which has 3 input ports ans 1 output port.

The data from the H port of the vehicle body block is given to a sensor subsystem as input to measure speed and position of vehicle using Ideal Translational Motion Sensor.

This is put under subsystem vehcile sensor subsystem

These speed and position values are plotted using scope blocks.

Thus the model for vehicle is given below

These two subsystem are put under a single susbsystem named vehicle.

Battery pack

The equivalent circuit of a single cell of the battery pack is modelled using a DC voltage supply along with combination of capacitor and resistors

DC voltage of the cell

Resistor 1 value

Resistor 2 value

Capacitance value

A subsystem named "cell" is created for this equivalent circuit.

An array of these cells are connected in series and parallel connections according to required battery specifications.

All these cells are grouped under subsystem named battery pack subsysem.

Drive cycle

For the drive cycle reference inbuilt drive cycle source block is used

It generates a standard or user-specified longitudinal drive cycle. The block output is the vehicle longitudinal speed. It can import drive cycles from:

- Predefined sources

- Workspace variables, including arrays and time series objects

- mat, xls, xlsx, or txt files

Motor Controller

This model of Electric vehicle uses a DC motor. Hence a dc motor controller such as Class E chopper or H-bridge circuit can be used to generate duty cycle data for the motor based on the given drive cycle data and output vehicle speed.

Alternatively, a simple PID controller can be also used with appropriate gain values to generate the duty cycle

PID controller

The drive cycle speed values and the vehicle speed values are subracted and the output us given to the PID controller.

In this controller only PI is implemented and derivative control part is left.

The compensator formula used is

Proportional gain (P): 0.009

Integral (I): 0.005

In order to reduce the intergral windup, the clampling method which is one of the anti-windup methods for intergal is used

The PI duty cycle output is given to a scope block and PWM average subsystem

PWM Averagae

The duty cycle and the battery connections are given to PWM Averge block

The PWM average block delivers the power to the motor from battery in accordance to the duty cycla value given by the PI controller

Duty cycle ranges from 0-1, thus PS saturation block is used with an upper limit value of 1.

  • Voltage Sensor is used to measure battery pack voltage and this value is multplied with the duty cycle to get the supply voltage for the motor
  • Current Sensor is used to measure the current value given to controllerd current source
  • Controlled voltage source block is used to maintain the specified voltage at its output regardless of the current passing through it.
  • Controlled current scource block is used to maintain the specified current at its output regardless of the voltage passing through it.

DC MOTOR

The Simscpae model of a DC motor is used with below mentioned parameters.

The motor gets supply voltage from battery through the PWM Average block.

The DC motor's electric and mechanical parameters are as defined as below

Transmission

The electrical part of DC motor is connected to a electrical reference and mechanical part is connected to mechanical rotational reference.

In commercial EV's like TESLA cars the transmission ratio is used is around 1:11.

Thus comparing that value single gear system with gear ratio of 1:12 is used in this model.

Transmission inertia is also added in the transmission system using a Transmission interia block.

Motor output is connected to gear system which is then connected to Ideal Torque Sensor.

The output from Ideal Torque Sensor (Input Torque) is given to rear axle of the Vehicle subsystem.

Finally, the entire Simscape model is completed and solver configuration block is added in the model.

In the model since the sensor output is directly connected to an upstream block (sum block), it causes simulink to iteratively solve for value of the signal.

This occurs when all the blocks in the loop have their output depend on the current instance of the input. This is known as Algebric Loop which leads to slow simulation or even converge to incorrect results.

In order to break the algebric loop, a Unit delay block is used in dynamic feedback loop to model the sensor delay and break the dependency on current input and output.

Sample time for the controller is set as 0.05 seconds. Thus for unit delay block also same sample time 0.05 seconds is defined.

Simulating the Electric car model

Case 1: Using a Wide Open Throttle response plot as drive cycle source.

The vehicle is accelerated to 100 km/h at 5 second and maintained at same speed till 70 seconds. After 70 seconds the vehicle speed is set to zero speed.

This simulation runs for 100 seconds.

Simulation results

The yellow line is the reference input speed and pink line is the actual vehicle speed.

It is seen that vehicle requires sometime to accelearate to 100 kmph, whereas the input speed changes from 0 to 100 kmph in no time

Similar delay is seen in deceleration of the vehicle

The small fluctuations in the vehicle speed during acceleration is due to Integral shoot up of the PI controller. Using derivative control might decrease them. Else dc motor controllers like Class E chopper and H-bridge circuit can be used for better accuracy.

Duty cycle plot

In the duty cycle plot, till 5 seconds the value is zero since the vehicle doesnot move.

After 5 seconds the input speed suddenly changes from 0 to 100 kmph, thus to achieve this speed, PI controller gives duty cycle value of 1 to use full rated power of the DC motor

Again the fluctuations in the duty cycle are caused due to the integral shoot up in th PI controller. Once the vehicle reaches 100 kmph, the power required to maintain the speed is reduced and stays contstant till 70 seconds. Hence duty cycle attains a constant vale of around 0.7 and stays the same till 70 seconds.

After 70 seconds the input speed changes from 100 to 0 kmph. So no power is required from the motor. Thus the duty cycle value changes from 1 to 0 after 70 seconds.

Output Vehicle speed and displacement

Longitudinal Tire forces

Normal Tire forces

In the plot it is clearly seen that till 5 second the normal forces on both tires stay same.

Once the vehicle starts to accelerate from 5th second, the weight is transferred to rear wheel, so the normal forces on rear wheel increases and normal forces on front wheel decreases.

Similarly after 70 seconds, during deceleration, the vehicle weight is transferred to front wheel, so front wheel normal forces increases and rear wheel normal forces decreases.

Wheel Speed (rpm)

Wheel Slip

It is clearly seen that in the front wheels the slip is high during acceleration and in rear wheels slip is high during decelaration.

Case 2: FTP75 Drive cycle is used for the simulation. The duration of FTP75 drive cycle is 2474 seconds

Input drive cycle reference speed vs Vehicle Speed

From the Plot, it can be concluded that the motor is able to deliver the require power to the rear axle of the vehicle such that the vehicle can follow the drive cycle without any issues

Output Vehicle speed and displacement

Duty cycle plot

Thus the Electric Vehicle model is modelled in Matlab using simscape and simulation is done.

The results are studied and explained clearly.

The simulink and matlab script files are attached in the project.

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.

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.