MBSD_Lab 2
MBSD_Lab 2
2023/24
Purposes
Implement the “one pedal controller” as a Simulink model.
To implement the system, follow the description already provided in the Laboratory 1
document considering also eventual assumptions already stated in this latter document.
The safety mechanisms are not required in this laboratory.
The longitudinal physical model and the test stimuli generators shall demonstrate the
effectiveness of the implemented controller with respect to the expected functionalities.
Consider the plant model description as an example of the comments to be inserted in the
Controller Software Unit description report.
The deliverable, composed of the 3 Simulink models and a PDF file obtained by filling the
following pages of this document (please delete this first page), has to be provided as a .ZIP
file up to May 24th at 23:59 through “Consegna Elaborati” of the Portale della Didattica. It
shall also contain a brief report explaining the design of the controller, using the following
template. It is sufficient that only one of the group members uploads it.
Model-Based Software Design, A.Y. 2023/24
Laboratory 2 Report
Considering that the torque is equally split between the two wheels (valid only on straight
tracks)
T ( t ) −2 ⋅F s ( t ) ⋅ r=2 I ⋅ ω̇ ( t ) ( 2 )
{
2⋅ F s ( t ) ⋅r =F x ( t )
v ( t )=2 π ⋅r ⋅ ω ( t )
and considering the moment of inertia of the wheels I =0 , we can define the following
T (t )
equation, given that T ( t )=2 ⋅ F s ( t ) ⋅r F s ( t )= .
2 ⋅r
The drag force that limits the maximum speed of the vehicle is equal to:
2
F d ( v ( t ) )=X air ⋅ ( v ( t ) ) + X tyres ⋅ v ( t ) ( 3 )
where:
1
X air = ⋅ S ⋅ c x ⋅ ρ ( 4 )
2
and, as usually modeled:
X air ⋅50
X tyres ❑ → X tyres = ( 5)
Xtyres ( 50
km
h ) (
= X air 50
km
h ) 3.6
By substituting the (2) equation in (1), and by integrating both sides, we obtain:
t t
1 1
v ( t )= ∫ F x ( t ) − F d ( v ( t )) dt = ∫ 2 ⋅ F s ( t ) − F d ( v ( t ) ) dt=¿
m 0 m 0
t
1 T (t)
∫ − Fd ( v ( t ) ) dt ( 6 )
m 0 r
Remember that the integrator block of Simulink requires an initial condition corresponding
to the vehicle's longitudinal speed at the beginning of the simulation, v ( 0 ). A possible
configuration of the integration block is shown in Figure 2.
During the model development, put all the needed gain to obtain as an output of the
physical model a speed expressed in km/h.
To simulate the slope θ of the terrain, it is possible to add the gravity force F g ( θ ) as follows:
t
1 T (t)
v ( t )= ∫
2
− X air ⋅ ( v ( t ) ) − X tyres ⋅∨ v ( t ) ∨⋅ dt+m ⋅ g⋅ sin ( θ ) ( 8 )
m 0 r
With g=9.81 the gravity acceleration on Earth.
Reasonable values for an electric compact car can be:
m=1600 kg
r =0.3 m
The torque T (at the wheel) can vary in the range [ −60 ; 960 ] Nm
S=3.5 m2
c x =0.3
Figure 1 Graph showing drag forces of tires (in orange) and air (in blue) at various speeds. It is possible to observe that, as
imposed in equation (5), X tyre =X air at 50 km/h. Below this speed, the tire drag is dominant, after that, the air drag is
T
dominant. Moreover, it is possible to see the top speed of the car (around 230 km/h) when F x = = X + X air , with
r tyre
F x =3200 N .
With those values, the top speed on level ground reachable by the car is about 230 km/h,
where the drag forces equal the traction force (3200 N).
Considering the reverse direction, the maximum speed reachable with a limitation of -60
Nm is about 45 km/h.
Figure 2 Settings window for the Integrator block of Simulink
Use these values (with a certain tolerance, for example, 10 %) to saturate the integrator
block.
To make the model more realistic, it is possible to compute the torque request at the
engine/motor. A typical ratio value for transmission of an electric car with a single gear can
be around i t =12.
All the initialization parameters of the model are automatically loaded model by a callback
of the function init_fn as shown in Figure 3.
Draw the Finite State Machine (FSM) representing the controller logic
Comment on the design choices of the FSM, which are not trivial to be understood just by
analyzing the controller logic.
When moving the Park state, the transmission locks and the wheels cannot move.
While in the neutral state, the car is in an intermediate state between reverse and drive. In
this state, pressing of the Throttle pedal does not produce any torque demand from the
controller.
In the reverse state the pressure of the pedal produces a negative torque demand that will
2
Input, Output, Local, Global, Volatile
go to move the car with negative speed.
In the drive state the pedal pressure is translated into a positive torque demand that will
induce positive speed.
In the brake state, a pedal pressure of more than one-third of its travel produces behavior
comparable to the behavior of the drive state; whereas if less than one-third of the pedal is
pressed, the engine brake comes into action, which will cause the car to brake.
To move between states certain conditions must be met and these conditions are shown in
the above graph
Comment with plots of the results obtained from the test cases (it is suggested to use the
Data Inspector)
The graph doincide with the expected results. The speed trend appears to increase, almost,
linearly until it reaches 85.4 and then stabilizes for about 10 seconds. The stabilizing
coincides with the reduction in pedal pressure.
After the 30 seconds the speed begins to decrease, almost, linearly after the throttle pedal is
completely released. when pressed again the speed stops decreasing and then resumes
when the pedal is released. Once the speed is reset it remains so until the reverse gear is
engaged and the throttle pedal is depressed. At that time the vehicle begins to move with
negative velocity.