Welcome to the World of Modelling and Simulation

What is Modelling?

This blog is all about system dynamics modelling and simulation applied in the engineering field, especially mechanical, electrical, and ...

Modelling and Simulation of an Electric Vehicle in SIMULINK

In this tutorial, I am going to present you a very simple way to design and control your very first electric vehicle in SIMULINK. You need to have MATLAB version 2019/2020 with full features. Most of the features that I will be using are from Simulink and Simscape libraries. Simscape is a very powerful tool that Matlab has integrated lately. This tutorial will be straightforward - showing you the diagrams and explaining afterwards. At first, let's begin with a simple question, how an overall electric vehicle system looks like? Below is the image of the electric vehicle system. 

Complete Simulink-Simscape block diagram of an electric vehicle system












As it appears, this is a Simulink block diagram, which contains many blocks from the library browser. Let's see what are the fundamental components of an electric vehicle system. From the diagram, there are five main blocks:

1. Vehicle Body 
2. DC Motor
3. DC Motor Driver
4. Battery
5. Controller

1. Vehicle Body

In this modelling, we can consider some basic properties of a vehicle. Below, we see the model of the vehicle body, which has four tires, a simple gear, and vehicle property block. When you click on each block, you will find the respective properties that you need to choose or enter independently. Just remember, these blocks represent the governing dynamics that Matlab has already prepared for us in the Simulink blocks. You do not need to spend hours for deriving system equations. Rather, here, we ought to be paying attention while connecting the blocks and providing appropriate parameters.

Representing vehicle body by Simscape blocks
















When you click on the vehicle body block, it will pop-up a new window as below. For this tutorial, I just chose the default parameters, but you can certainly change these for your specific problem.

Simscape vehicle body block parameters
















The following is the tire property block.

Simscape vehicle tire model block


















This is how a simple gear block appears when you double click the block.

Simscape simple gear box model block
















2. DC Motor

The purpose of the DC motor in electric vehicle is to drive the tires/wheels. It should be noted that from the Simscape library, you can choose different types of motors. The one side of the DC motor block is connected to the vehicle body blocks, and the other side is connected to the DC motor driver, which controls and rotates the motor. The following image shows the DC motor block in Simulink.

DC motor block properties


3. DC Motor Driver

To precisely control a DC motor, we are required to design a driver for that. There are numerous ways you may develop the motor controller. I used an H-Bridge block from Simscape library along with the PWM voltage controller block. In the following image, you see that there are some other blocks, such as, current and voltage sensors, electrical reference etc. 

DC motor driver system in Simulink - Simscape















4. Battery

For any electric vehicle, battery is a very important part. Still, in industries, people are struggling to find a better solution for the battery that can run an electric vehicle with more mileage before it drains fully. Here, I have chosen a simple battery model from Simscape library where you can obviously tune the parameters for your design requirement. To implement the battery and connect it to the rest of the system, a controlled current source block is added. As before, we need to have an electrical reference for the current source block, which is depicted in the subsequent figure.

Simscape battery system blocks

5. Controller

In newer versions Matlab with full features, you will find a block named 'Longitudinal Driver' that may act as a controller for the electric vehicle system. Below, we see the block parameters. I am using all the default properties for this block. You can decide the type of the controllers at first, then shift type, units, output gear signal, and so forth. There is a whole lot option to tune this block parameter for your specific goals.

Showing longitudinal driver block properties





















We begin this tutorial with the final version of the Simulink system model of an electric vehicle. There were some blocks that were masked by some images, below you can see the original version of the complete system diagram for your first virtual electric vehicle model. As you can see, in this model, most of the blocks are from the Simscape library, and you cannot connect them directly to any other Simulink blocks. But, with a converter, you can easily make the connections. In Simscape, there are two blocks - PS-Simulink and Simulink-PS converter - which are used to convert physical signals from Simscape block into Simulink compatible signal and vice versa.

Complete Simulink-Simscape block diagram of an electric vehicle system













Some Results

Everything is done. Now, if you would like to see the responses of different parts of the electric vehicle, you can do so. You need to add the oscilloscope blocks from the Simulink library to those parts. 

Here is the source signal that is fed into the system to run the vehicle.

Signal generated from the source
















This is the signal that is an output from the longitudinal driver block.

Signal from the longitudinal driver block






















This oscilloscope shows the current from a current source block.

Shows the current from a current source block.



















That's all. We have designed a virtual model for an electric car. Certainly, this is not a Tesla as the picture of the vehicle body block shows in the first image. Nevertheless, we can at least have a little sense of accomplishment that a simple model may even be designed in our laptops. 



#ElectricVehicle #Simulink #Simscape #Modelling #Simulation #DCmotor #Blog #Blogger

2 comments: