File Exchange

## MATLAB and Simulink Racing Lounge: Vehicle Modeling

version 4.0.0.0 (1.48 MB) by MathWorks Student Competitions Team

### MathWorks Student Competitions Team (view profile)

Simulink and Powertrain Blockset models for the Vehicle Modeling series

Updated 20 Jun 2018

This entry contains files accompanying the MATLAB and Simulink Racing Lounge video "Vehicle Modeling, Part 1: Simulink"
The entry also contains the models accompanying the MATLAB and Simulink Racing Lounge video "Vehicle Modeling, Part 2: Powertrain Blockset"
The Simulink models show how to represent vehicle dynamics and specific components using a power loss approach.
* A glider model shows how to model vehicle dynamics to obtain high level information about tractive force requirements for a given weight and drive cycle.
* A battery electric vehicle (BEV) model shows how to use a power loss approach to represent individual components, such as the electric motor.
* A combustion engine vehicle model is also included for additional reference.

The Powertrain Blockset models show how single blocks can represent component operation, e.g: battery, motor, engine, transmission, differential, etc. These models include a glider, a BEV, and a combustion engine vehicle.

### Cite As

MathWorks Student Competitions Team (2020). MATLAB and Simulink Racing Lounge: Vehicle Modeling (https://www.mathworks.com/matlabcentral/fileexchange/63823-matlab-and-simulink-racing-lounge-vehicle-modeling), MATLAB Central File Exchange. Retrieved .

ahmed masry

### ahmed masry (view profile)

DINESH REDDY KOMMIREDDY

### DINESH REDDY KOMMIREDDY (view profile)

Getting an error "Failed to load Driver glider library", Can anyone help me out?

SRIVIJAYAKOLKI P SOME

### SRIVIJAYAKOLKI P SOME (view profile)

I am getting error - "Failed to load Driver glider library", can someone help me with this?

Prateek Gupta

### Prateek Gupta (view profile)

hi christoph. thank you for the model. I would like to know how to edit the parameters like the drive cycles, battery attribute and many more. Look for an early reply

Vineeth A

### Vineeth A (view profile)

I got it sir. I was not in that directory.

Vineeth A

### Vineeth A (view profile)

Hey Christoph sir ,
Should we have to move "driver_glider_library.slx" to somewhere else ?
I am getting error now as "Failed to load Driver glider library"

Zipeng Wang

### Zipeng Wang (view profile)

Hi Christoph, could you please tell me how did you derive the equation of "F_tr = (T_motor-T_loss)*(G/r_w) - F_B " which is used to describe the driveline in this video? where this equation comes from?

Md Shafiqul Islam

Mahmoud Salem

Ang Xian Jia

### Ang Xian Jia (view profile)

Hi Christoph, is it possible to include supercapacitor for your electric vehicle modelling? May you provide any references?

Raj Kumar Muniyandi

### Raj Kumar Muniyandi (view profile)

Hi, Thanks for the video. In the BEV Simulink model. Most of the battery and motor parameters are represented as a structure MDL. Can you tell me how to access them that information or structure?

Christoph Hahn

### Christoph Hahn (view profile)

Hi Dimitrios,
these are the references we used in the project:
[1] Sun, Zongxuan, and Guoming Zhu. Design and control of automotive propulsion systems. Boca Raton, Fla: CRC Press, 2015. Print.
[2] "Dynamometer Drive Schedules.“ EPA. Environmental Protection Agency, 31 Jan. 2017. Web. Apr. 2017.
[3] Zhang, B, and Mi, C. (2011), “Charge-Depleting Control Strategies and Fuel Optimization of Blended-Mode Plug-In Hybrid Electric Vehicles”, IEEE Transactions on Vehicular Technology, Vol. 60, No. 4, May 2011.
Best, Christoph

Dimitrios Vogiatzis

### Dimitrios Vogiatzis (view profile)

Hello Christoph,
It will be very helpful for us to share the sourse of the mathematical equation of the ICE efficiency that is used for the fuel consumption calc in the combustion engine vehicle.
is it possible?

Christoph Hahn

### Christoph Hahn (view profile)

Hi Jeevinthiran, what you did absolutely made sense. I placed a unit delay-block in the feedback loop from driveline subsystem to engine subsystem to avoid an algebraic loop. Additionally, I needed to comment through the radps2rpm-block in the engine subsystem (was using 19b for that). Best, Christoph

Jeevinthiran Karunagaran

### Jeevinthiran Karunagaran (view profile)

Hello Christoph,
I am trying to use the conventional model from the powertrain blockset but when I run the model, I get the ' Input data dependency violation due to action subsystems' . The only way I have managed to solve this is by placing a memory block in between the engine speed output from the driveline to the input in the engine. However, the system runs very slowly. Is there a better way of solving this?

Ang Xian Jia

### Ang Xian Jia (view profile)

Thanks Sir Christoph Han for previous reply. I will slowly learn from the links.
For this model, may I know why there are negative values for motor power output and motor power input? I am trying to calculate efficiency from Sir's model and I'm getting negative efficiency values.

Christoph Hahn

### Christoph Hahn (view profile)

Dear Ang Xian Jia,
yes what you want to do (motor and battery specifications, then output the drive cycle information) is absolutely feasible.
Allow me to refer you to two more resources:
#1 This will help you to model and parametrize batteries, which we didn't cover in detail: https://www.mathworks.com/solutions/power-electronics-control/battery-models.html
#2 Some materials how to output and log drive data from a vehicle / powertrain model: https://www.mathworks.com/videos/student-competition-physical-modeling-training-part-3-introduction-to-vehicle-modeling-107485.html
Hope this helps!
Best, Christoph

Girish babu P

Ang Xian Jia

### Ang Xian Jia (view profile)

Hi Sir Christoph,
Is it possible for us to input the motor and battery specifications, then output the drive cycle information, like speed,distance and range travelled? If yes, may you guide me on how to do it or any reference to refer to? Or is the method to solve the problem is quite same with the model done by you but in a reversing way of model?

Christoph Hahn

### Christoph Hahn (view profile)

Hi Zeeshan,
we are referring to this paper: Zhang, B, and Mi, C. (2011), “Charge-Depleting Control Strategies and Fuel Optimization of Blended-Mode Plug-In Hybrid Electric Vehicles”, IEEE Transactions on Vehicular Technology, Vol. 60, No. 4, May 2011.
Hope this can be of help to you,
Best, Christoph

zeeshan gilani

### zeeshan gilani (view profile)

Hello Christoph,
We are using your model for our 3kw BLDC motor and we would like to calculate the Kc, Kw& Ki constants for our motor model.Can you please tell us how did you derive the equation of Ploss= Kc*Torque^2 + Ki*w + Kw*w^3.
It will be really helpful if you can guide us through the process of deriving those constants and the equation.
Thank you.

Christoph Hahn

### Christoph Hahn (view profile)

Hi Monal,
what model are you referring to?
Please send an email to racinglounge@mathworks.com. We'll be happy to have a look.
Best, Christoph

Monal Gedam

### Monal Gedam (view profile)

Hello, Can anyone tell me what is w_max, and w_ref in the workspace and where it is used. Please help

mudhapaka pushkal

### mudhapaka pushkal (view profile)

Hi Christoph Sir,
I want to model a BEV using induction motor in simulink , could you possibly guide me with the useful resources.

mudhapaka pushkal

Christoph Hahn

### Christoph Hahn (view profile)

Hi Shashank,
Thanks for the notes! I am referring to both of your queries from 14 Aug (#1) and 5 Aug (#2).
#1 I am not entirely sure what exact model you are referring to. Could you please point me to it?
#2 Consider the PID block as 'driver' that tries to stick to the drive cycle. The block will always try to minimize the delta between, e.g. car speed and required speed (from drive cycle). Simulink is coming without units and brake as well as accelerator commands may have values between [0,1].

Hey, in your battery model the open circuit voltage remains constant throughout. Should't that change as a function of state of charge?

Harit Bajaj

### Harit Bajaj (view profile)

Hey Christoph,
Could you possibly guide me to the equations used in the models or the slides that were mentioned in the video

Hello Mr. Chris. I would like to know in what units or nature is the PID output? In the first part of the video, the mph error is somehow processed and PID output a tractive force. I don't understand how that is achieved. Also, secondly can the PID output, which is the accelerator and brake command in the model, be the input to the electric motor? I want to use the drive cycle as a throttle input to my battery/model. Sorry, I'm pretty new to the software.

Christoph Hahn

### Christoph Hahn (view profile)

Hi Kevin, I just downloaded the models and ran 'Driver_Glider.slx' exemplarily without any issue. Make sure your current folder in MATLAB is the one with the model. Hope this helps. Best, Christoph

Kevin Fernandes

### Kevin Fernandes (view profile)

Hi Christoph sir

I've downloaded the models but when I open them, the Canvas interface shows me the next error:
"Failed to load library 'Driver_Glider_Library' referenced by 'BEV/Driver "

how can I solve this problem?

Thankk you

Christoph Hahn

### Christoph Hahn (view profile)

Hi William,
hereby I am linking a T-dependent battery model: https://www.mathworks.com/help/physmod/sps/examples/lithium-ion-temperature-dependent-battery-model.html.
Hope that is relevant to you.
Cheers

Christoph Hahn

### Christoph Hahn (view profile)

HI Parth,
changing the drive cycle is straightforward. Just replace the drive-cycle that comes with the model. (It is stored in the model workspace: https://www.mathworks.com/help/simulink/ug/change-model-workspace-data.html) and replace it with something custom.
Cheers

William McCullough

### William McCullough (view profile)

How would it be possible to make the battery temperature dependent? Such that the battery SOC is affected at different temperatures?

Parth Patel

### Parth Patel (view profile)

How can one change the drive cycle? for Example NEDC ,WTP

Christoph Hahn

### Christoph Hahn (view profile)

Dear Saksham, Thanks for your great feedback! You may of course cite this as internet resource.

Saksham Consul

### Saksham Consul (view profile)

Thank you for such a versatile model. I would like to cite this, can you please guide as to how I should go about doing it?

Thank you.

Veer Alakshendra

### Veer Alakshendra (view profile)

Hi Dinesh,

To answer your second question, it would be better if you could share the email with us on racinglounge@mathworks.com.

Thanks,
Veer

Veer Alakshendra

### Veer Alakshendra (view profile)

Hi Dinesh,

The values are stored in the Simulink model workspace.
You may access it through Simulink toolbar -> View -> Model Explorer.

In case you are still unable to find the data, drop an email to racinglounge@mathworks.com. We will send you the screen shots via email.

Thanks,
Veer

Dinesh tej

### Dinesh tej (view profile)

Hii Christoph sir
I am not getting, should I add BEV model to that Existing 3D Animation or the Power train blocks which are available in the file exchange?

Dinesh tej

### Dinesh tej (view profile)

Hii Christoph sir
Can you Please tell me what is the Specifications of Battery, motor specifications and type of motor used here ?

Christoph Hahn

### Christoph Hahn (view profile)

Hi Deepa,

That inclination angle is used by the GradeForce[N] block, which calculates a force based on massVeh*gravity*sin(inclinationAngle). By default, the sin function in MATLAB takes angles as radians. To operate in degrees, then use massVeh*gravity*sin(deg2rad(inclinationAngle))
The negative speed value means reverse motion. This would happen if resistive forces (like grade) act on the vehicle before the tractive force can dominate the vehicle motion.

Hope this helps,
Best, Christoph

Christoph Hahn

### Christoph Hahn (view profile)

Hi Dinesh Tej,

the model you are referring to is a simplified one. It takes into account the powertrain and the longitudinal dynamics. So e.g. lateral dynamics are entirely missing. It wouldn’t be very helpful to display this in 3D animation.

What you may want to do is the following.
1. Check out the Vehicle Dynamics Blockset including its examples. E.g. run this command >> vdynblksSceneCameraRayStart in the MATLAB Command Window. Thereby you get the 3D animation running.
2. Add the vehicle model features from this FileExchange submission to the model created in #1.

Hope this helps to get started.
Best, Christoph

Dinesh tej

### Dinesh tej (view profile)

Santhosh Kumar S MTech

DEEPA ANAND

DEEPA ANAND

### DEEPA ANAND (view profile)

Hi Christoph sir,
the inclination angle given is zero degrees in the modelling, when we change the angle to say 20 degrees the output velocity is getting started from -2.3 mph while the input is unchanged, can you please briefly describe what does that negative values interpret in the real time?

MathWorks Student Competitions Team

### MathWorks Student Competitions Team (view profile)

Hi Deepa, you may certainly give it an initial try using PID Tuner (https://www.mathworks.com/discovery/pid-tuning.html). With respect to the vehicle model, the PID block is actually a (very simplified) representation of the vehicle. So you would want to tune it to mimick you actual vehicle. Same holds true for the driver. Via the PID block you can tune it to be more aggressive or relaxed. Best, Christoph

DEEPA ANAND

### DEEPA ANAND (view profile)

thank you Christoph sir.
And Can you please tell me how the PID constants are selected particularly for both driver glider(P-7500, I-1, D-0) and BEV system(P-250, I-1, D-0).

MathWorks Student Competitions Team

### MathWorks Student Competitions Team (view profile)

Hi Deepa, these are motor loss constants: k_c [s / kg m^2], ki [J], k_w [kg m^2]. In general, you could say that: P_loss = P_in - P_out. P_loss in our example is a function of p_in and is approximated by a quadratic equation with these constants: P_loss = C_0 + C_1 * P_in + C_2 * P_in^2. If you have test data about losses, I suggest you do your own regression / curve fitting to get the constants. If you don't have test data, you could start with an ideal (lossless) motor and estimate the impact of the error. Best, Christoph

DEEPA ANAND

### DEEPA ANAND (view profile)

Sir how to choose the constants like Kc, Ki, Kw etc. ?

MathWorks Student Competitions Team

### MathWorks Student Competitions Team (view profile)

Hi Yujie, I guess you are referring to the models of the physical modeling tutorial that we are mentioning in the video. Find them here: https://www.mathworks.com/videos/series/student-competition-physical-modeling-training-107490.html. Hope this is what you are looking for. Best, Christoph

Yujie Hu

### Yujie Hu (view profile)

battery, motor, engine... models cannot be found in the zip file. Could you add them in? Thank you very much!

Xiaoyu Huang

Christoph Hahn

### Christoph Hahn (view profile)

Hi Deepa Anand,
the drive cycle is stored in the Simulink model workspace.
You may access it through Simulink toolbar -> View -> Model Explorer.
Best, Christoph

DEEPA ANAND

### DEEPA ANAND (view profile)

how I can access the drive cycle stored parameters?

lovedeep dhilon

### lovedeep dhilon (view profile)

Trung Quang Nguyen

### Trung Quang Nguyen (view profile)

Yassine ofqir-hamma morroco

### Yassine ofqir-hamma morroco (view profile)

MathWorks Student Competitions Team

### MathWorks Student Competitions Team (view profile)

Hi Josh,
good point! The data is accessible through the Simulink model workspace. See here a reference: https://www.mathworks.com/help/simulink/ug/using-model-workspaces.html.
Hope that helps.
Best, Christoph

Josh Fleming

### Josh Fleming (view profile)

Hello, I'm confused how I can access the drive cycle and other similarly stored parameters. For instance, the Constant block contains DrCycles.US06. How do I access and view the data stored in US06? Normally I would look in the Matlab workspace but I don't see it.

OmarAlfarouq Alfazazi

### OmarAlfarouq Alfazazi (view profile)

salutations, je veux exploiter le modèle de véhicule électrique à batterie (BEV), mais je n'ai pas compris comment ils ont modelisé chaque bloc. est ce qu'il ya un ecrit explicatif de ce modele? merci.
cordialement.

PRINCE ALEXIS

### PRINCE ALEXIS (view profile)

i dont have matlab 2018 latest version. I am using Matlab 2017 b Can you please export this to my version?

Samarth Shah

Amr ESMAEIL

### Amr ESMAEIL (view profile)

Thanks for sharing such nice model.
One minor note on engine rotational speed calculation in the conventional model (version 3.0):
inside the driveline subsystem, it is calculating omega by dividing Velocity [mph] by wheel radius [m], the velocity shall be converted from mph to mps before division.

Veer Alakshendra

### Veer Alakshendra (view profile)

I would also encourage you to upgrade to the latest release.

Carlos Carmona

### Carlos Carmona (view profile)

I downloaded the models but when I open them, the Canvas interface shows me the next error:
"Failed to load library 'Driver_Glider_Library' "
Can anyone help ?
Thanks

Vasudevan Nambeesan

### Vasudevan Nambeesan (view profile)

Hi, is it possible to release the files in an earlier version of MATLAB? Maybe r2015a? Thanks!

ARJUNBARATH G

### ARJUNBARATH G (view profile)

Christian Mansell

mahmoud nasser

### mahmoud nasser (view profile)

how can i run this models with matlab 2016 a version ? it gives me an error because this models were created with different version.

Veer Alakshendra

Shehara Perera

### Shehara Perera (view profile)

when I run simulation I get errors
Warning: Could not evaluate MaskDisplay commands of block 'PTB_BatteryElectricVehicle/Battery/Datasheet Battery':
Undefined function 'autoicon' for input arguments of type 'char'.

can anyone help??
Thanks

gökalp ayaz

ARJUNBARATH G

### ARJUNBARATH G (view profile)

 15 May 2018 4.0.0.0 Update model to R2018 and fixed minor bugs. 25 Jan 2018 3.0.0.0 Updated models to R2017b and fixed minor bugs. 6 Sep 2017 2.0.0.0 Added vehicle models that use Powertrain Blockset. Updated description.
##### MATLAB Release Compatibility
Created with R2018a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux