Matlab Project - Quarter Vehicle: Name: Sebastian Preil Student ID: 1256334 Winter Semester 2015/16
Matlab Project - Quarter Vehicle: Name: Sebastian Preil Student ID: 1256334 Winter Semester 2015/16
Figure 1: Quarter-Vehicle
Table of Contents
1 Introduction ................................................................................................................................3
2 Mathematic Model .....................................................................................................................3
2.1 Equation of Motion .............................................................................................................3
3 Programming ..............................................................................................................................5
3.1 Program the simulation model – Qauarter_Vehicle.m .........................................................5
3.2 Creating the User-Interface with Matlab GUIDE ...................................................................7
3.3 Combination of the basic simulation model and the user-interface.................................... 18
3.4 Test of the finished Quarter-Vehicle simulation program ................................................... 26
4 Different Weight-Analysis.......................................................................................................... 28
5 Conclusion ................................................................................................................................ 29
Table of Figures
Figure 1: Quarter-Vehicle ....................................................................................................................1
Figure 2: Quarter-Vehicle / 3-Mass-System .........................................................................................3
Figure 3: First-Plot in the basic program ..............................................................................................7
Figure 4: Opening the "GUIDE" for creating the User-Interface ...........................................................7
Figure: 5: Blank GUI (Default) User-Interface Page ..............................................................................8
Figure 6: User-Interface with Graphic-Module and Static/Edit-Text-Modules ......................................8
Figure 7: Edit "Static-Text-Field"..........................................................................................................9
Figure 8: Edit "Edit-Text-Field" ............................................................................................................9
Figure 9: Edit "Axes" - Graphic-Module ............................................................................................. 10
Figure 10: Finished User-Interface..................................................................................................... 10
Figure 11: Edit "Push-Button" ........................................................................................................... 11
Figure 12: Finished User-Interface Callback ....................................................................................... 11
Figure 13: Test of the finished Quarter-Vehicle simulation program .................................................. 26
Figure 14: Finished Quarter-Vehicle simulation program ................................................................... 27
Figure 15: Light-Weight-Vehicle ........................................................................................................ 28
Figure 16: Normal-Weight-Vehicle .................................................................................................... 28
Figure 17: Heavy-Weight-Vehicle ...................................................................................................... 28
2
Matlab Project – Quarter-Vehicle
Sebastian Preil
1 Introduction
For my task to create a Matlab-Program I was looking for a project which is used in the reality and
refers to my major study – Automotive Engineering with preference to the matlab programming.
According to that I decided to write a program with a user interface for analysing a quarter-vehicle,
also known as a three-mass-system. The quarter-vehicle I programmed includes the street with an
edge with the height h, one wheel which contains one mass m1 and one spring stiffness c1, the
undercarriage (auto body, motor, …) with the functions of one mass m2, one spring stiffness c2 and
also one dumper constant k2. At last the program involves the seat of a car with one person on it
which also serves as one mass m3, one spring stiffness c3 and one dumper constant k3. The dumper
constant of the wheels can be neglected as far as the vibration damper of the undercarriage is
working correctly.
The focus of this analysation was to illustrate the answers of the system according to the liftings of
wheel, undercarriage and drivers-seat after driving over a kerb.
2 Mathematic Model
̈ + ∗( ̇ − ̇ )+ ∗( − )=0
̈ + ∗( ̇ − ̇ )− ∗( − )+ ∗( ̇ − ̇ )+ ∗( − )=0
̈ + ∗( ̇ − ̇ )− ∗( − )+ ∗ = ∗ℎ
3
Matlab Project – Quarter-Vehicle
Sebastian Preil
System Matrix:
0 1 0 0 0 0
⎡ ( + ) ⎤
⎢− − 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 1 0 0 ⎥
=⎢ ( + ) ( + ) ⎥
⎢ − − ⎥
⎢ ⎥
⎢ 0 0 0 0 0 1 ⎥
⎢ 0 0 − − ⎥
⎣ ⎦
Steering Matrix:
0
⎡ ⎤
⎢ ⎥
⎢ ⎥
=⎢ 0 ⎥
⎢ 0 ⎥
⎢ 0 ⎥
⎣ 0 ⎦
Observation Matrix:
= [1 0 0 0 0 0]
= [0]
+
ℎ =
2∗
=
2∗
=
2∗
4
Matlab Project – Quarter-Vehicle
Sebastian Preil
3 Programming
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Name: Sebastian Preil %
% Student-ID: 1256334 %
% Date: November 2015 %
% %
% Matlab-Project: %
% Quarter-Vehicle %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
% System Parameter
% System Matrix
A = [ 0 1 0 0 0 0 ;
-(c2+c1)/m1 -k2/m1 c2/m1 k2/m1 0 0 ;
0 0 0 1 0 0 ;
c2/m2 k2/m2 -(c3+c2)/m2 -(k3+k2)/m2 c3/m2 k3/m2 ;
0 0 0 0 0 1 ;
0 0 c3/m3 k3/m3 -c3/m3 -k3/m3];
5
Matlab Project – Quarter-Vehicle
Sebastian Preil
% Steering Matrix
B = [0 c1/m1 0 0 0 0]';
% Observation Matrix
C = [1 0 0 0 0 0];
D = [0];
% Simulation Period
t = 0:0.001:tend;
fWheel = sqrt((c1+c2)/m1)/(2*pi)
fCarriage = sqrt(c2/m2)/(2*pi)
fDriver = sqrt(c3/m3)/(2*pi)
% Street
% Calculation
6
Matlab Project – Quarter-Vehicle
Sebastian Preil
For this first program I declared the system parameters to fixed values. I did this for an easy control
check if the programming is correct and works properly. After I have finished writing this program I
pushed the “Run-Button” to see if everything is working well.
7
Matlab Project – Quarter-Vehicle
Sebastian Preil
After I generated the blank GUIDE-Page, I established one area “axes1” whereas the graphs will be
illustrated in for the simulation program. Also I created 10 “Static-Text” and 10 “Edit-Text” fields. Into
the static-text fields I wrote the variable names and they will stay fixed the whole time, whereas the
edit-text fields will be clear in the finished program and there the user can type in the values of the
variables.
8
Matlab Project – Quarter-Vehicle
Sebastian Preil
9
Matlab Project – Quarter-Vehicle
Sebastian Preil
In the next step I moved the static- and the edit-text fields and created another graphic-module to
insert “Figure 2: Quarter-Vehicle / 3-Mass-System” (page 3) which shall be shown all the time. The
set up for “axes2” is similar to that what you can see in Figure 9: Edit "Axes" - Graphic-Module.
Furthermore I built up a push-button and called it “RUN”, which starts calculating the simulation
after the user has typed in all variable values and will show the graphic solution of the system.
10
Matlab Project – Quarter-Vehicle
Sebastian Preil
The user-interface in the Matlab-GUIDE is finished now. I clicked onto the “RUN-Button” and did the
“Callback” for generating a new M-File with all the functions of that interface and called it
“Quarter_Vehicle_User.m”.
11
Matlab Project – Quarter-Vehicle
Sebastian Preil
Quarter_Vehicle_User.m
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
12
Matlab Project – Quarter-Vehicle
Sebastian Preil
% --- Outputs from this function are returned to the command line.
function varargout = Quarter_Vehicle_User_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
13
Matlab Project – Quarter-Vehicle
Sebastian Preil
14
Matlab Project – Quarter-Vehicle
Sebastian Preil
15
Matlab Project – Quarter-Vehicle
Sebastian Preil
16
Matlab Project – Quarter-Vehicle
Sebastian Preil
17
Matlab Project – Quarter-Vehicle
Sebastian Preil
In the following pages there is the combination of both programs shown. The different program-lines
of the user-interface M-File are marked as:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Name: Sebastian Preil %
% Student-ID: 1256334 %
% Date: November 2015 %
% %
% Matlab-Project: %
% Quarter-Vehicle %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
Matlab Project – Quarter-Vehicle
Sebastian Preil
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = Quarter_Vehicle_User_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
19
Matlab Project – Quarter-Vehicle
Sebastian Preil
20
Matlab Project – Quarter-Vehicle
Sebastian Preil
21
Matlab Project – Quarter-Vehicle
Sebastian Preil
22
Matlab Project – Quarter-Vehicle
Sebastian Preil
23
Matlab Project – Quarter-Vehicle
Sebastian Preil
% System Parameter
% System Matrix
A = [ 0 1 0 0 0 0 ;
-(c2+c1)/m1 -k2/m1 c2/m1 k2/m1 0 0 ;
0 0 0 1 0 0 ;
c2/m2 k2/m2 -(c3+c2)/m2 -(k3+k2)/m2 c3/m2 k3/m2 ;
0 0 0 0 0 1 ;
0 0 c3/m3 k3/m3 -c3/m3 -k3/m3];
% Steering Matrix
B = [0 c1/m1 0 0 0 0]';
% Observation Matrix
D = [0];
% Simulation Period
t = 0:0.001:tend;
24
Matlab Project – Quarter-Vehicle
Sebastian Preil
fWheel = sqrt((c1+c2)/m1)/(2*pi)
fCarriage = sqrt(c2/m2)/(2*pi)
fDriver = sqrt(c3/m3)/(2*pi)
% Street
% Calculation
25
Matlab Project – Quarter-Vehicle
Sebastian Preil
Secondly there was a small mistake about the y-axle in the graph on the left, because you cannot see
the labelling. So I changed the graphic design of “axes1” in the GUIDE-Model
“Quarter_Vehicle_User.fig” and compiled the user-interface and the program was changed
automatically. In Figure 14 there is everything correct now.
26
Matlab Project – Quarter-Vehicle
Sebastian Preil
27
Matlab Project – Quarter-Vehicle
Sebastian Preil
4 Different Weight-Analysis
Figure 15: Light-Weight-Vehicle
28
Matlab Project – Quarter-Vehicle
Sebastian Preil
In the Figures 15 to 17 above there I used the same spring-stiffness- and dumper-constant-settings; I
only diversified the weights m1, m2 and m3 to see the influences related to the liftings of each part
of the quarter-vehicle-system. As you can see, the heavier the masses the larger is the amount of the
amplitudes and the oscillating time of a heavy car is also longer than of a light-weight vehicle.
5 Conclusion
With this project I have learned a lot about Matlab, Matlab-GUI and its programming. Also I have
established Matlab is a very useful and powerful tool for analysing simulation models. Additionally I
enlarged my matrixes knowledge and learned how to work and program in a structural way.
After the program was finally written, I could “play” with the physical variables and the program
generated an easily interpreted graphic image of the consequences on the movements in the
quarter-vehicle-system.
29