Exercises MBD 02062024
Exercises MBD 02062024
Inhalt
Exercise 1 ............................................................................................................................................................. 2
Exercise 2 ............................................................................................................................................................. 5
Exercise 3 ........................................................................................................................................................... 14
Examination 13.07.2023 (Summer term 2023) ................................................................................................. 21
Examination 14.07.2022 (Summer term 2022) ................................................................................................. 26
Examination 10.02.2022 (Winter term 2021).................................................................................................... 31
Examination 14.07.2021 (Summer term 2021) ................................................................................................. 37
Examination 14.09.2020 (Summer term 2020) ................................................................................................. 42
Examination 27.01.2020 (Winter term 2019).................................................................................................... 46
Examination 25.07.2019 (Summer term 2019) ................................................................................................. 52
Examination 05.02.2019 (Winter term 2018).................................................................................................... 59
Seite 1
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Exercise 1
1.1 Build the submodel for the Heater. The Heater is a subsystem that has a constant air
flow rate, “M_dot”. The heater can be turned on or off by an additional input signal.
When the heater is on, it blows hot air at temperature T_Heater at a constant flow
rate of M_dot into the house. The heat flow into the room is expressed by the follow-
ing equation:
∗ ∗
heat losses to the environment. Heat losses and the temperature time derivative are
expressed by the following equation:
1
" #
! ∗
with ! mass of air inside the house.
equivalent thermal resistance of the house.
Use the following values for the constants above: ! 1778.4 kg;
4.27 * 10-7 K*h/J; T_inIC = 20 °C as initial value for the house temperature.
Seite 3
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
2.2 Add a second scope to view the accumulated cost for heating the house. Change the
Setpoint to 18°C and compare the accumulated cost. How big is the financial effect
of heating with 3°C lower temperature per day? Why is the room temperature some-
times out of the specified range around the setpoint (+/- 1°C)?
Seite 4
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Exercise 2
The following exercise consists of parts originally used as examination tasks in winter term
2017/18 and summer term 2018.
Seite 5
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
)* !
)* + ,) - . * ! * /01 $ 2
) 5678
* ! 3 4 (in [;])
9678 /:
* ! * ! 3 273 ;
Take into account, that above equations calculate the boiler temperature as an absolute
temperature in [K], while all other temperatures (pump, pipes, radiators, …) in the model
are in [°@]!
Test your library subsystem with a test
model Test_Boiler.slx, which
should look similar to the model to the
right. The Pulse Generator should be
configured to generate a pulse with an
amplitude of 15 kW every 10 minutes,
which lasts for 5 minutes (50 %). Provide constants set to
0H
40 °@ for the backflow temperature and a value of 2 for the
amount of water flowing back into the boiler. The result
should be similar to the adjoining picture.
Seite 6
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The model for the pump can be derived from the following equa-
tions:
∗P
,) J ∗ K ∗ L; K MN ∗ O ; J
N
∗ Q;
L ∗ MN ∗ O ∗ X
W
,)
Seite 7
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Draw the Simulink library subsystem for the pipe. Use only basic Simulink blocks like
gain, constant, integrator, sum, … The water flow ,) through the pipe is not influenced.
Test your library subsystem with a suitable test model Test_Pipe.slx.
)Y !
) Z+1 $
)[ 1 $
) !+H
) Z+1 $ \ ,) - Z+1 $
)[ 1 $ \ ,) - [ 1 $
) !+H C KY ! Y ! Y
) ] ^7 6
Y ! 3 4 (in [;])
] ^ /:
Y ! Y ! 3 273 ;
[ 1 $ \ Y ! _ 1 \ Z+1 $
Seite 8
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The Burner can be switched on with the Signal t* ! from the subsystem “Room_Thermo-
stat”. It delivers a “1” to switch the burner on, a “0” to switch it off. Additionally, the burner
must be switched on, if the boiler temperature * ! is below 50 °@. The burner must be
switched off, if the temperature gets higher than 60 °@ (Hysteresis).
model Test_Burner.slx.
Seite 9
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
)Y ) !+H
)u ) !+H
)- ) -!+ $
Y 3 v
w! Y 3
)Y
xw! yY wZY
Y Y 3 273 ;
)[ ) -!+ $ _ )- _[
Seite 10
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Use only basic Simulink blocks like gain, constant, integrator, sum, … The initial tempera-
ture of the room should be set to t_init_room = 293 ;.
In the above room model, two additional subsystems must be built. The heat flow through
windows can be modelled by the following equation (the heat capacity is neglected):
Seite 11
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Next, the subsystem for the heat flow through the wall must be modelled. This subsystem
can be described by a simplified model, where the wall consists of layers of different materi-
als (plaster, bricks, isolation, …). Here, we assume a wall consisting of only two layers:
With: ): Heat flow from room to the outside [I];
Y : Temperature in room [°@];
[ : Temperature at the outside [°C];
7
The thermal resistance ‰! is defined as ‰! Š7 w]66‹
.
Seite 12
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
You may configure the Pulse Generator to create a pulse of 2000 I with a period of 250 (
and a pulse width of 10 %.
Task 11: Build and simulate the complete thermal model of the house
Now you created all library subsystems for the complete house model. Build the model and
name it House_Heat_simulation.slx. Use the screenshot from page 1 of this exercise
as a template.
Seite 13
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Exercise 3
Two different fluids are mixed together in a chemical reactor. This mixture must be heated
to a dedicated temperature. Mixing is done by an electric motor M. The following picture de-
scribes the technical setup:
• If during the heating phase the pressure sensor S5 reports an overpressure situa-
tion, the pressure relieve valve Q4 must be opened until the overpressure is gone.
• After heating is done, the mixer runs for another 10 s. Afterwards valve Q3 must be
openend.
• If the reactor is empty again (S1), valve Q3 is closed again.
• By pressing a Reset button, the control unit can be resetted to the initial state.
Tasks:
1. Develop a control algorithm for this process by using a state chart.
2. Draw a Simulink model with all input and output signals needed for the chemical re-
actor process and implement your state chart from task 1. (Just use constant blocks
to stimulate the input signals.)
3. Simulate your model.
Seite 15
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The complete process is controlled with air pipes installed at the bottom of the aeration ba-
sin. The air in the air pipes is driven by compressor units and valves. The following drawing
shows this part of the wastewater treatment plant:
Process:
(Source: Wikipedia)
All variables in the above table have only binary values (“0”/”1”)!
In the above table, all available input and output signals are listed, which are necessary for
the implementation of a sequential process control. This control should realize two different
operation modes, depending on the operation mode switch OM.
In operation mode 1 only one of the three air pipes is active at the same time. The pro-
gram begins with ventilation of air pipe 1 with opening valve V1. After 5 minutes of ventila-
tion, valve V1 is closed and air pipe 2 is activated by opening valve V2. Again, after 5
Seite 16
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
minutes V2 is closed and V3 is opened in order to activate air pipe 3. 5 minutes later, V3 is
closed and the process is repeated, beginning with pipe 1.
In operation mode 2 one or two air pipes are ventilated at the same time. The program be-
gins the ventilation with air pipe 1. 3 minutes later, air pipe 2 is ventilated additionally. After
2 additional minutes, air pipe 1 is deactivated. 1 minute later, air pipe 3 is activated. 2
minutes later, air pipe 2 is deactivated. 1 minute later, air pipe 1 is activated and 2 minutes
later air pipe 3 is deactivated and the process repeats.
The process begins with activation of the start switch Start. In operation mode 1 only com-
pressor unit 1 must be activated. In operation mode 2 both compressor units must run.
1. Draw the output signals V1 to V3 for operation mode 1 into the following diagrams
(time axis is in minutes):
Seite 17
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
2. Draw the output signals V1 to V3 for operation mode 2 into the following diagrams
(time axis is in minutes):
4. Draw a state chart needed to implement the control algorithm for the aeration basin
described above. Use absolute time temporal logic where necessary.
Seite 18
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
This picture shows only one half of the traffic lights. The second half for the opposing traffic
or the pedestrians from the other side of the road are controlled identically.
This Table lists the available input and output signals for the control algorithm. A pedestrian
can request green light with switch S1. After that, the sequence for the traffic lights begins,
as it is described in Task 1.
If the Day/Night sensor detects darkness, then the traffic lights are switched into night
mode, 2 minutes after the last active sequence. In night mode the yellow light blinks every
1.5 second (0.75 second on, 0.75 second off).
1. Complete the following diagram. The drawing needn´t be true to scale. The se-
quence, which should be implemented, consists of the following steps:
2. Draw a (top level) Simulink model with a Stateflow chart and all necessary input
and output signals.
3. Draw a state chart needed to implement the control algorithm for the traffic light
control described above. Use absolute time temporal logic where necessary.
4. Expand your state chart from task 3 by adding states and transitions for the night
operation.
Seite 20
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Supporting Wheel
Seite 21
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.2 If the robot should drive straight forward, Q must be set to 0. This would lead in the 6P
calculation of radius r in Eq. 5 to a division by zero. Copy your model kinematics.slx to
a new model kinematics2.slx. Then add in the Backward_kinematics subsystem the
following distinction of cases:
1.3 Next, we want to use the kinematic model to calculate position and orientation of the 8P
robot in a global (x,y) coordinate system:
The following differential equation describes
the orientation ” of the robot:
”) Q (Eq. 6)
The x- and y-position can be calculated from
the following equations:
•) J cos ” (Eq. 7)
™) J sin ” (Eq. 8)
init_theta = 5
init_x = 2
init_y = 2
1.4 Change the solver settings to “Fixed-step” solver “ode4” with a step size of 0.1 s and 4 P
a stop time of 6 s. Run the simulation and open the xy Graph.
What geometric figure does the robot drive in the xy-plane? (Be careful and look at the
axis scaling!)
Figure = _______________________________________________________
(x,y)(t = 6 s) = __________________________________________________
(You can read out the values if you enable the “Data Cursors”.)
1.5 Next, we use our simulation models for simulation of following a straight path with a 10 P
simple control loop. Open the prepared Simulink model path_control.slx:
Copy the complete model from the file sim_trajectory.slx (without the setpoint con-
stants) into the model path_control.slx. Copy the subsystem “Backward_kinematics”
from model kinematics2.slx into model path_control.slx and connect its outputs v_l
and v_r to the inputs of subsystem Forward_kinematics. The inputs of subsystem
Backward_kinematic must be calculated from the setpoints and actual values in the
following way:
J •) V !+ (Eq. 9)
Q ;V .™ V !+ ™2 _ ;V_ ‰ ” V !+ ” (Eq. 10)
Define ;V 1 and ;V_ ‰ 1.5 as workspace variables in the file “constant.m”
from task 1.1. Furthermore, the initial values for the integrators for ”, •, ™ must be
set to different values compared to task 1.3. Define workspace variables start_orien-
tation = 0, start_x = 0 and start_y = 1 in “constant.m” and use them in the integrators
instead of the “init_...” values from task 1.3. Run the simulation. Take a screenshot
and save it in the Matlab working directory.
Seite 23
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Implement in subsystem “path_finder” a Stateflow chart and define all necessary in-
puts and outputs with appropriate data type. Connect inputs and outputs of the chart
to the inports and outports of the subsystem.
2.2 Draw a state chart needed to implement the path finding algorithm. The robot will 13 P
make one forward step or one turning action in each simulation step, based on the
sensor information from the previous step.
If there is a wall on the right side (sens_right == true), then step forward. If there is a
wall on the right side and a wall in front, then turn left. If there is no wall forward and
no wall left and no wall right, then turn right. If signal dest == true, then the robot has
reached its destination. Then all outputs must be set to false.
In all steps, only one output signal may be set to true. All others must be set to false.
The robot cannot move forward and turn in the same step.
(Hints: You can solve this problem with a state chart consisting of only 4 states! For
debugging your algorithm, it may be helpful to single step through the simulation and
look at the animated map at the same
time. If you just run the simulation, you
will only see the end result.) In the end,
it should look like this:
The light gray points show the path the
robot has driven.
Seite 25
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The following equation represents the “usual“ PID control law in the continuous time
domain (input e(s) system deviation, output u(s) control signal) with constant parame-
ters P, I and D:
…
šUZ› ( ‚ _ œ _ •( with the Laplace operator (. (Eq. 1.1)
Open the prepared Simulink model pid_control1.slx and implement above equa-
tion for šUZ› ( in the subsystem “PID Controller” by using only basic blocks (Gain,
Integrator, Derivative, Sum). Do not use a transfer function or the built-in PID block
from the Simulink blocksets.Use Variables “P”, “I” and “D” instead of numerical values.
1.2 Set the values for “P” to 2.0, “I” to 1.0 and “D” to 0.3. Use the InitFcn callback func- 3P
tion to initialize the values. Run the simulation! What value can you readout for y(t) at
time t = 2 s?
y ( 2 s ) = ________________________________________
1.3 Equation Eq. 1.1 from task 1.1 uses constant gains for the P, I and D factors. This is 6P
sufficient, if you want to control a system only near to an operating point. If you want to
use a controller in a bigger range around an operating point, it is better to use a set of
P, I and D factors. One possibility to implement this is by using lookup tables, where
the input depends on the system deviation or some other signal.
Copy the model pid_control1.slx from task 1.1 to a new Simulink model
pid_control2.slx. Next, change the implementation of the PID controller from task 1.1
to a new implementation, where the P and I factors are given by two 1-D lookup tables
dependent on the system deviation e(s). This means that you should implement the
following formula:
Seite 26
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
…
šUZ›N ( žŸ U n ( _ žŸ Z .n ( 2 _ •( (Eq. 1.2)
Answer:
1.5 Copy the model pid_control2.slx from task 1.3 to a new Simulink model 3P
pid_control3.slx.
The output of the PID controller (control signal u(s)) is limited to a lower and an upper
value because of technical restraints. Add a saturation block, representing these re-
straints, to the Simulink model. Set the upper limit of the saturation to 8.0, the lower
limit to 0.0. What value shows the output signal y(t) of the controlled system after 30 s.
y( 30 s ) = ______________________________________
1.6 With the added saturation block, the PID controller encounters a new problem. If the 2P
value of the control signal is too low because of the saturation, the setpoint may not be
reached in steady state. This means that the deviation signal e(s) will not become “0”
Seite 27
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
in steady state situations. Therefore, the integral part of the controller will compute
higher and higher values. This effect is called the “windup” effect.
Add a Scope to measure the integral part of the controller. How big is the value of the
integrator output at time t = 10 s?
Value = _________________________________________
1.7 A possible anti-windup procedure is the calculation of a new signal consisting of the 4P
difference between saturated and non-saturated output of the controller multiplied by a
gain factor. This signal must be added to the input of the integrator in the PID control-
ler (internal feedback).
Add this anti-windup procedure to your Simulink model. Set the gain factor to 50.
Seite 28
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
All Variables in the above table have only boolean values (true/false)! Exception: AW is a
numerical value.
A stop actor Y2 stops the next empty can at the filling position, if the conveyor belt is run-
ning. Sensor B1 signals, that an empty can is at the filling position. Next the conveyor belt
must stop and the filling with cream begins.
Filling is done by activating the filling mechanism Y1 for a fixed period of time (10 s). After
that, the conveyor belt starts again (M1) and the stopper Y2 is deactivated for 1 s, so that
the filled can is transported out of the filling machine. At the same time the next empty can
is fed into the filling machine from the right side and the next filling can take place.
The filling system can be turned off by switching it off with the start switch S0. Additionally,
it must also be switched off, if the storage tank is empty (S1). In both cases, the filling of the
can currently filled must be finished and this can must be transported out of the filling ma-
chine.
Every filled can must be counted. The control algorithm must provide an additional output
AW with the number of filled cans. This number is visualized on an external numerical dis-
play. An input key Reset is used to reset the counter value to zero. A reset can only be
done, if the filling machine is not running.
Seite 29
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
3.1 Complete the following drawing with the input and output signals according to the pre- 6 P
vious description. It must show at least one complete filling cycle. Add vertical dashed
lines to mark the possible states.
3.2 Open the prepared Simulink model filling.slx. It looks like this: 9P
Add a Stateflow chart in subsystem “Filling Control” and define all necessary input and
output signals with correct data type.
3.3 Draw a state chart needed to implement the control algorithm for the filling system 15 P
described above.
Seite 30
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
+•
Symbol Einheit Bedeutung
‰ ‰ °C Temperature inside the hall
‰
+• °C Temperature of the environment
‰ W Heat flow from the heater
W Heat loss through walls and windows
Because of the big dimensions of the hall, the effects of heating on the hall temperature can
be described by the following simplified equations:
‰ +• / ‰ (Equ. 1)
)‰ ‰ – / ! ∗ ! (Equ. 2)
‰ 4 )‰ (Equ. 3)
The following table describes the mathematical symbols and values of necessary con-
stants:
Variable or constant Matlab/Simulink Symbol Value Unit
Thermal resistance of walls and windows R_therm ‰ 6.27 ∗ 10’¢ ;/I
Mass of air inside hall M_air ! 3.6 ∗ 10 • CD
Specific heat capacity of air c_air ! 1.005 ∗ 10• ~/ CD;
Temperature of environment (constant) T_env +• 15 ℃
Initial temperature in hall T_hall_0 ‰ ¤ 25 ℃
Maximum heat flow into hall Q_heat_max ‰ ¥ 50 ¦§
1.3 Open the provided template script “constant.m” in Matlab. It includes all variables 3P/
from the above table. Create a new Simulink model with the name “sim_temp.slx”.
Add a PreLoadFunction Callback (Property Inspector or context menu model proper-
ties) and use it to run constant.m. Save the model and close it. Clean the Matlab work-
space. Open it again and verify, that all constants from the script are defined as work-
space variables within Matlab. Use these workspace variables in the following
subtasks in all Simulink blocks instead of using numbers.
1.4 Next, integrate a Pulse generator, which simulates the heat flow ‰ . Configure the 6 P /
Pulse generator, so that the output has an amplitude of ‰ ¥ . This amplitude
Seite 31
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
shouldn´t be output continuously. Instead, the output should be set to this value for 15
s for each 60 s. In the rest of this period, the output is 0 kW. Furthermore, the heating
should begin after an initial delay of 30 minutes. Please see the following drawing
(not drawn to scale):
Note: The simulation time is considered to be in s.
Add a Scope to your model, set the simulation stop time to an appropriate value, so
that you can verify the correct settings of your pulse generator. Make a screenshot of
your scope window with the built in snipping tool and save this screenshot in your
working directory under the file-name screen.png.
1.5 Include all necessary blocks from the appropriate Simulink blocksets to build a simu- 7 P /
lation model for equations 1 to 3 above. Don´t forget to set the initial temperature of
the hall. Comment your model by writing at least the names of the outputs of the
equations 1 to 3 to the corresponding signals in the model. Connect the output signal
(temperature ‰ ) to a Scope block to visualize the temperature.
1.6 Configure the simulation, so that it uses the fixed-step solver ode2 (Heun). Set the 2P/
stop time to 5 hours and the step size to 1 s. Start the simulation. What temperature
is reached after 5 hours (mean value, estimated from the scope window).
1.7 This open loop feed forward control is not very comfortable. Let us try to improve it by 8P/
adding a simple discrete controller to our model implemented with Stateflow. The con-
trol-law can be described by the following textual description:
Let us assume, that we define a temperature setpoint of 23 °C. The heater must be
turned on, if the actual temperature ‰ drops more than 1 °C below this setpoint.
Turning on the heater means that it will produce a constant heat flow of 30 kW. If the
actual temperature ‰ gets higher than setpoint + 1 °C, then the heater must be
turned off. Turning off means producing a heat flow of 0 W.
Save your Simulink model sim_temp.slx under the new name control_temp.slx. Then
replace the Pulse generator by a state chart needed to implement the control algo-
rithm. The output of the chart is ‰ . If you run the simulation, what is the new
mean value of the temperature after 5 simulated hours?
Seite 32
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
West
East Elevation
Azimuth angle angle
In this examination, you tested your tracking algorithm against a simulation model, which
provided signals for the solar sensor and simulated the two electrical motors for azimuth
and elevation angles.
This time, you should design the simulation model for the signals AZS, ELS, AZP and ELP.
Table of input and output signals:
Inputs / Outputs Var. Meaning
O: Solar sensor azimuth angle AZS Analog value, -90° … +90°, east-west-position of sun
O: Solar sensor elevation angle ELS Analog value, 0° … +90°
O: Azimuth angle of PV AZP Analog value, -90° … +90°, east-west-position of PV
O: Elevation angle of PV ELP Analog value, 0° … +90°
I: Azimuth motor pos. direction AZM+ AZM+ = true, motor is turning PV system in positive
azimuth direction
I: Azimuth motor neg. direction AZM- AZM- = true, motor is turning PV system in negative
azimuth direction
I: Elevation motor positive direc- ELM+ ELM+ = true, motor is turning PV system in positive
tion elevation direction
I: Elevation motor negative di- ELM- ELM- = true, motor is turning PV system in negative
rection elevation direction
Seite 33
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The left subsystem called “Control” contains the tracking algorithm from last examination
which is used to generate the signals AZP+, AZP-, ELM+ and ELM-. The left subsystem
“Simulation” is empty and should be filled by you. Please, keep in mind, that the simulation
time is scaled in hours with a timestep in minutes. The simulation runs for one complete
day (24 hours).
The outputs of the simulation subsystem can be described by the following formulas:
1. The earth rotates 360° around the sun in 24 hours, which defines the simulation of
the azimuth angle: K¨t 4 360•24 . (Initial value of integrator: -180°) If we as-
sume a place near Greenwich (Longitude 0°, Latitude around 50° North), we can see
the sun probably at azimuth angles between -70° up +70°. You can model this by
adding a saturation block with appropriate limits.
2. The measured elevation ELS can be calculated from the azimuth angle with the help
of this formula: ©žt 90° sin 90° _ K¨t 40°. The value of ELS should also be lim-
ited to positive values with a saturation block. Please, remember that in Matlab and
Simulink the argument of the sin-function is given in radians!
3. The azimuth motor of the PV system can move the PV system at a speed of +/- 100
degrees per hour. Therefore, we can use an integrator to model the azimuth angle
with this mathematical formula: K¨‚ 4 100K¨ ˆ 100K¨ ’ with an initial
value of -70°. This is the angle where we expect to see the sun first in the morning.
4. The elevation can be calculated from the same formula but with different input sig-
nals: ©ž‚ 4 120©ž ˆ 120©ž ’ . The initial value is 0°, meaning the PV sys-
tem points to the horizon. The elevation motor is a little bit faster with 120 °/hour.
2.1 First, add the part of the model necessary for simulating the values of the solar sen- 10 P /
sors AZS and ELS.
2.2 Next, add the part of the model necessary for simulating the values of the angles of 10 P /
azimuth and elevation motor AZP and ELP. Attention: The inputs AZM+, AZM-,
ELM+ and ELM- are boolean values, which you cannot use directly in calculations.
If your solution is correct, you will get a scope view similar to the following picture:
Seite 34
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Gas streams through two magnetic valves into a nozzle, where it is mixed with air. After ig-
nition, it burns and produces continuously heat. With two control flaps the gas and air flow
is regulated. A fan blows air into the nozzle. There are several sensors for gas pressure
(PSL, PSH), air pressure difference (PD) and a flame detector (RSL). The burner is started
with a start switch and turned off with a stop switch.
Seite 35
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
3.1 There is a Simulink model burner.slx prepared for this task. Open it! Inside the model, 14 P /
you find a Stateflow chart. Use this chart to implement the complete startup procedure
described above.
Seite 36
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
+•
Symbol Einheit Bedeutung
‰ ‰ °C Temperature inside the hall
‰
+• °C Temperature of the environment
‰ W Heat flow from the heater
W Heat loss through walls and windows
Because of the big dimensions of the hall, the effects of heating on the hall temperature can
be described by the following simplified equations:
‰ +• / ‰ (Equ. 1)
)‰ ‰ – / ! ∗ ! (Equ. 2)
‰ 4 )‰ (Equ. 3)
The following table describes the mathematical symbols and values of necessary con-
stants:
Variable or constant Matlab/Simulink Symbol Value Unit
Thermal resistance of walls and windows R_therm ‰ 4.27 ∗ 10 ’¢ ;/I
Mass of air inside hall M_air ! 3.6 ∗ 10• CD
Specific heat capacity of air c_air ! 1.005 ∗ 10 • ~/ CD;
Temperature of environment (constant) T_env +• 10 ℃
Initial temperature in hall T_hall_0 ‰ ¤ 20 ℃
Maximum heat flow into hall Q_heater_max ‰ ¥ 50 ¦§
1.8 Open the provided template script “constant.m” in Matlab. Add variables for all 6P/
needed constants from the above table to this script, using the variable names in the
column “Matlab/Simulink” and values from the table. Don´t forget to add a short com-
ment for each constant, describing the unit and the meaning of the constant. Save
and run this script and verify, that all constants from your script are defined as work-
space variables within Matlab. Use these workspace variables in the following
subtasks in all Simulink blocks instead of using numbers.
Seite 37
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.9 Create a new Simulink model with the name “sim_temp.slx”. First integrate a Pulse 6P/
generator, which simulates the heat flow ‰ . Configure the Pulse generator, so
that the output has an amplitude of ‰ ¥ . This amplitude shouldn´t be output con-
tinuously. Instead the output should be set to this value for 120 s for each 600 s. In
the rest of this period, the output is 0 kW. Furthermore, the heating should begin with
a delay of 1 hour. Please see the following drawing (not drawn to scale):
1.10 Include all necessary blocks from the appropriate Simulink blocksets to build a simu- 7 P /
lation model for equations 1 to 3 above. Don´t forget to set the initial temperature of
the hall. Comment your model by writing at least the names of the outputs of the
equations 1 to 3 to the corresponding signals in the model. Connect the output signal
(temperature ‰ ) to a Scope block to visualize the temperature.
1.11 Configure the simulation, so that it uses the fixed-step solver ode2 (Heun). Set the 2P/
stop time to 5 hours and the step size to 1 s. Start the simulation. What temperature
is reached after 5 hours (mean value, estimated from the scope window).
1.12 Include the call of constant.m into the PreLoadFunction Callback. Close the model, 2P/
clear the Workspace and open the model again to make sure, that the Callback mech-
anism works.
1.13 This open loop feed forward control is not very comfortable. Let us try to improve it by 6P/
adding a simple closed loop proportional controller to our model. The control-law can
be described by the following formula:
-
‰ 5000 3 ∗ 25 ℃ ‰ (Equ. 4)
Seite 38
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
This means that we assume a setpoint of 25 °C and a proportional gain of 5000 W/K.
Furthermore, we must limit the value of ‰ to values between 0 and 50 kW (by us-
ing a Saturation block in Simulink).
Save your Simulink model sim_temp.slx under the new name control_temp.slx. Then
replace the Pulse generator by Simulink blocks needed to implement the control law
in Equ. 4 together with a saturation block to limit its output. If you run the simulation,
what is the new mean value of the temperature after 5 simulated hours?
West
East Elevation
Azimuth angle angle
The solar sensor delivers azimuth and elevation angles of the sun. The azimuth for this
sensor is defined as 0°, if the sun is exactly in the south direction. The value is -90°, if the
sun is in the east and +90°, if the sun stands in the west. The elevation is defined as the an-
gle between horizon and sun. It is a positive value, 0° means that the sun is just hitting the
horizon, 90° means that the sun is directly on top of the PV system (which is not possible in
our country).
The PV system is mounted on a pole and can be moved in azimuth and elevation direction
by two electrical motors. Both angles are measured with special angle sensors, which pro-
vide azimuth and elevation angle of the PV system to the control algorithm. Both values are
already transformed into the coordinate system of the solar sensor.
In order to save energy, the PV system should not be moved continuously towards the
sun. Instead, it should only move, if the angles of the current orientation differs too much
from the detected position of the sun. If the difference in azimuth direction is more than +/-
5°, then the azimuth motor is switched on. The allowed difference in elevation direction is
+/- 3°. Therefore, we get a discrete control algorithm, which we can implement with State-
flow.
Seite 39
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
In addition, there is a manual mode for maintenance work, which disables the automatic
control and moves the PV system to an elevation angle of 90°. The azimuth angle stays at
the current angle until the automatic mode is switched on again. The manual mode can be
activated at any time.
Table of input and output signals:
Inputs / Outputs Var. Meaning
I: Manual mode switch S1 S1 = true, manual mode is activated
I: Solar sensor azimuth angle AZS Analog value, -90° … +90°, east-west-position of sun
I: Solar sensor elevation angle ELS Analog value, 0° … +90°
I: Azimuth sensor PV orientation AZP Analog value, -90° … +90°, east-west-position of PV
I: Elevation sensor PV orient. ELP Analog value, 0° … +90°
O: Azimuth motor pos. direction AZM+ AZM+ = true, motor is turning PV system in positive
azimuth direction
O: Azimuth motor neg. direction AZM- AZM- = true, motor is turning PV system in negative
azimuth direction
O: Elevation motor positive di- ELM+ ELM+ = true, motor is turning PV system in positive
rection elevation direction
O: Elevation motor negative di- ELM- ELM- = true, motor is turning PV system in negative
rection elevation direction
The right subsystem called “Simulation” contains a simple simulation of the movement of
the sun which is used to generate the signals AZS and ELS of the solar sensor. The angle
sensors AZP and ELP are also simulated, dependent on the motor control signals. The left
subsystem “Control” is empty and should be filled by you:
2.1 First, add an empty state chart for the control system inside the subsystem “Control”. 9 P /
Define all necessary input and output signals with the appropriate datatype ac-
Seite 40
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
cording to the above table. (Use the datatype “double” for analog values.) Connect in-
puts and outputs of the chart to the already prepared inports and outports of the Sim-
ulink Subsystem Control.
2.2 Next, design the state chart for the control 14 P /
algorithm described above. Do only imple-
ment the part of the chart needed for the
automatic mode! This means, you do not
need input signal S1. If you get a warning
message regarding signal S1, you can ignore
it.
If your solution is correct, you will get a scope
view similar to the picture to the right.
2.3 In the last step, you should add the manual mode. Before you start adding the neces- 8 P /
sary parts, please use the “Save As” function from Simulink to save your model under
the new name pv_control2.slx. After that you can add the states and transitions
needed for the manual mode. Hint: The easiest way to do this is by using super-
states.
Seite 41
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
A cable connects the irrigation car with the mass mC with a counter balance weight m
through a pulley. The inclination of the ramp is given with angle α. Initial position x0 and ini-
tial velocity v0 of the car on the ramp should be assumed to be 0. The mass mC(t) is not
constant but changes in a linear way with time. It can be described by:
,ª 4
‹¬ -
Δ, (Equ. 1)
®¯
with an initial mass mC0 and an final mass mempty (tank of car empty). The loss of mass per
second is given by Δ,.
The weight FM is given by š° , ∗ D (Equ. 2), where g is the gravitational acceleration.
The grade resistance FCR of the car can be described by:
šªY ,ª ∗ D ∗ sin ± (Equ. 3).
The acceleration a(t) of both masses can be calculated by:
² ³ ²®] ’ ²´
ƒ ˆ
(Gl. 4).
³ ®
Seite 42
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The following table describes the mathematical symbols and values of necessary con-
stants:
Variable or constant Matlab/Simulink Symbol Value Unit
Initial mass of irrigation car m_c0 ,ª¤ 1000 CD
Mass of empty irrigation car m_empty , V µ 400 CD
Mass loss per second delta_m Δ, 50 CD/(
Mass of counter balance weight m , 600 CD
Angle of ramp alpha ± 60 °
Initial velocity v_0 J¤ 0 ,/(
Initial position x_0 •¤ 0 ,
Gravitational acceleration g D 9.81 ,/( N
1.14 Open the provided template script “constant.m” in Matlab. Add variables for all 4P/
needed constants from the above table to this script, using the variable names in
the column “Matlab/Simulink” and values from the table. Don´t forget to add a
short comment for each constant, describing the unit and the meaning of the
constant. Save and run this script and verify, that all constants from your script
are defined as workspace variables within Matlab.
1.15 Create a new Simulink model with the name “carsim.slx”. Include all necessary 14 P /
blocks from the appropriate Simulink blocksets to build a simulation model for
equations 1 to 6. Do not use numeric values in your model, use the workspace
variables defined in task 1.1 instead. Comment your model by writing the
names of the outputs of the equations 1 to 6 to the corresponding signals in the
model. Connect the output signal (position x(t)) to a Scope block to visualize the
position of the car.
1.16 Configure the simulation, so that it uses the fixed-step solver ode1 (Euler). Set 2P/
the stop time to 20 s and the step size to 0.01 s.
1.17 Run the simulation with the settings from task 1.3. What is the end position of the 2P/
car after 20 s of simulation?
1.18 Of course, a negative end position is not correct! Change your model, so that the 2P/
position x(t) is limited to positive values.
Seite 43
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
All inputs (except S2) and outputs are boolean signals (true / false) and must be imple-
mented with this datatype in the state chart.
The process for the control system of the coffee maker can be described by the following
steps:
In the idle state the machine is active and waits for user input. The user can request
a cup of coffee (Button S3) or tea (S4) or start the cleaning process (S5).
Each of the above sub-processes can only be started, if there is enough water in the
tank.
If the user starts the coffee program, then the control system first activates the cof-
fee bean mill for 1 second.
Next pump and heater are directly activated.
0.1 s later, which are needed to provide pressure to the system, valve Q3 is opened
and the brewing unit is activated with the correct signal for coffee.
Brewing of coffee is finished, when sensor S2 measures at least a flow of 0.15 dm3.
After that, heater and brewing unit are turned off and valve Q4 is opened.
For another 1.5 s cold water is pumped through pipes and brewing unit in order
clean it for the next user request.
The tea program is a little bit easier: When the user request it, then pump and
heater are directly activated.
After 0.1 s valve Q3 is opened and the brewing unit is activated with the correct sig-
nal for tea.
The process ends, when sensor S2 measures at least a flow of 0.15 dm3.
In the cleaning program, cold water is pumped through pipes and brewing unit, until
sensor S2 measures at least a flow of 0.3 dm3. The cleaning program also must acti-
vate the correct signal in the brewing unit and open valve Q4.
The Simulink model coffee_maker.slx is already prepared as a template. The prepared
blocks (constants and Pulse generators) can be used as input for your Stateflow chart. The
integrated Scope block should be connected to the outputs of your chart. The chosen pa-
rameters on the input side blocks will trigger a test run of the coffee program.
2.1 First, add an empty state chart for the control system described in above step-by- 8P/
step-description. Define all necessary input and output signals with the appropriate
data type. Connect inputs and outputs to the already prepared blocks of the Simulink
model.
2.2 Next, design the state chart for the control system, according to the above descrip- 16 P /
tion. Note: Sensor signal S2 is automatically reset, when a new user request is re-
ceived. It is not necessary to integrate this reset procedure into your chart!
Seite 45
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
The pump supplies a flow with pressure x… to the system. There is a control valve 1,
which is needed to provide a constant pressure xN to the cylinder. This valve is controlled
by variable K, which is the orifice area of the valve. It divides the flow into a turbulent flow
¶…N and a laminar flow ¶ 0 back into the fluid reservoir. The flow ¶…N leads to the interme-
diate pressure xN , which undergoes a subsequent pressure drop in the line connecting it to
the control valve 2 and to the actuator cylinder. It can be assumed, that control valve 2 has
no influence on the dynamics of the hydraulic system. The cylinder pressure x• moves the
piston against a spring load, resulting in a position •.
The next table describes the mathematical symbols and values of necessary constants:
Variable or constant Matlab/Simulink Symbol Value Unit
@… 2 ∗ 10’· , •
•
sec ‚ƒ
Laminar flow coefficient C1
@N 3 ∗ 10’¹ ,••
sec ‚ƒ
Flow coefficient C2
Orifice discharge coefficient Cd @ 0.61
¶ 0.0015 ,••
Reflow from cylinder q_rf 1 (n
L 800 CD•
,•
Fluid density rho
Fluid bulk modulus beta º 7 ∗ 10· ‚ƒ
Cylinder cross-sectional area Ac K/ 1 ∗ 10’• ,N
; 5 ∗ 10¢ »•
Spring constant K ,
Fluid volume in the piston for x=0 V30 y•¤ 2.5 ∗ 10’¼ ,•
Initial value for x… p10 x…¤ 3.33 ∗ 10½ ‚ƒ
Seite 46
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.19 Open in Matlab the provided template script “constant.m”. Add variables for all 5P/
needed constants from the above table to this script, using the variable names and
values from the table. Don´t forget to add a short comment for each constant, de-
scribing the unit and the meaning of the constant. Save and run this script and ver-
ify, that all constants from your script are defined as workspace variables within
Matlab. (There are other constants already defined in this script, which are needed for
the Simulink template below.)
In this template the structure of the model needed for the simulation of the hydraulic system
is already given. In the following tasks, you should build the models into the empty subsys-
tems. Note: Each task can be solved independently!
1.20 Configure the simulation, so that it uses the fixed-step solver ode4 (Runge-Kutta). 2P/
Set the stop time to 0.1 s and the step size to 0.0001 s.
1.21 First, start with the pump model. It can be described by the following formulas: 3P/
¬¾‹¬ ’ ‡h
x… ªh
(Eq. 1) and ¶ 0 V V ¶…N (Eq. 2).
Build the simulation model for the equations Eq. 1 and Eq. 2 within the subsystem
“Pump”. Use the variables defined in constant.m in your model. Use only basic blocks,
like constant, gain, sum, …
1.22 Next, build the model for control valve 1 and 2. Valve 1 can be described by the fol- 8P/
lowing equation:
N
¶…N @ ∗ K ∗ (Dq x… xN ∗ ¿À ∗ |x… xN | (Eq. 3).
Above equation Eq. 3 is only valid, if the signal t of Valve 2 is true ( 1). If t is false
( 0), then the value of ¶…N 0.
Seite 47
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Build the simulation model for the equation Eq. 3 within the subsystem “Con-
trol_Valves”. Use the variables defined in constant.m in your model. Use only basic
blocks, like constant, gain, sum, sign, abs, sqrt, …
1.5 Next part is the cylinder model. The dynamic behaviour of the cylinder can be de- 12 P /
scribed by the following equations:
 w®
x•) ∗ ¶…N Kª •) (Eq. 4) with •) x•) (Eq. 5)
ÃS 3
w®
y• y•¤ _ Kª • (Eq. 6) with • 3
x• (Eq. 7)
xN x• _ ‡h
(Eq. 8).
ª‡
As long as Ä is true, you can use ÅÆŽ calculated from Eq. 3 in task 1.4. If Ä is
false, then the you should use ÅÇÈ in Eq. 4. In order to avoid negative values for •,
you should limit the lower limit of the integrator for x• to 0.
Hint: You should first use equations Eq. 4 and Eq. 5 to calculate a differential equa-
tion for x•) .
Room for calculations:
Build the simulation model for the equations Eq. 4 up to Eq. 8 within the subsystem
“Cylinder”. Use the variables defined in constant.m in your model. Use only basic
blocks, like constant, gain, sum, integrator, …
If you now start the simulation and everything is correct, the result for the cylinder position x
should look similar to the following picture (ignore warnings about algebraic loops):
Seite 48
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Seite 49
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Seite 50
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
2.4 Draw a state chart needed to implement the control algorithm for the synchronization 10 P /
mechanism as described above. Wherever you may need a time in your transitions,
use 1 second.
Seite 51
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.23 Open Matlab and generate a new script “constant.m”. Add variables for all needed 4P/
constants from the above table to this script, using the variable names and values
from the table. Don´t forget to add a short comment for each constant, describing the
meaning of the constant. Run this script and verify, that all constants from your script
are defined as workspace variables within Matlab.
1.24 Open SIMULINK and generate a new model “Lorenz.slx”. Configure the simulation 2P/
so that it uses the fixed-step solver ode4 (Runge-Kutta). Set the stop time to 100 s
and the step size to 0.005 s.
Seite 52
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.25 Build the simulation model for the equations Eq. 1, Eq. 2 and Eq 3. Use the varia- 12 P /
bles defined in constant.m in your model. Don´t forget to set the correct initial values
for the integrators!
1.26 Next, add three “To Workspace” blocks to your model. Name them “x”, “y” and “z” 3P/
and connect them to the integrators for x, y and z. Change the “Save format” setting of
each “To workspace” block to “Array”. Start the simulation. Now you should have
three additional variables x, y and z in your Workspace.
1.5 As the last step, generate an new Matlab script “visualization.m”. As the plotting ca- 3P/
pabilities of Simulink don´t allow to generate 3D-plots, you should implement this with
the help of the “plot3”-command in a Matlab script by using the generated workspace
variables from task 1.4.
The result, when you run the script, should be similar to the following picture:
In order to get a higher precision, the environmental temperature must also be taken into
account. In the datasheet of the photoresistor we can find the following diagram, which
shows us a correction factor dependent on temperature.
Seite 53
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
2.2 Use the data import tool in Matlab to import the look-up-table data from the Excel file 3 P /
“resistor.xlsx”. Transfer the data needed for the look-up-table into two Matlab
workspace variables “factor” and “temperature”. Save this two variables with the
“save”-command to a mat-file “resistor.mat”.
Seite 54
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
2.3 Use the “Initfcn” callback function (File -> Model Properties) to load the mat-file “re- 3 P /
sistor.mat” every time, the simulation is started. Save your model and clear the work-
space. If you start your simulation now, your variables should be loaded again from
the mat-file.
2.4 Next, use the workspace variables from task 2.2 as breakpoint and table data for the 4 P /
look-up-table in your model and run the simulation. Look at the Scope window,
make a screenshot of it and save it under the filename “lookup.jpg” in jpg-format.
You can use the Windows Snipping tool for that task.
Seite 55
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
This state chart needs the following input and output signals:
Table of input and output signals:
Inputs / Outputs Variable Meaning
I: Start position of cyl. S1 S1 = true, pneumatic cylinder is in start position
I: End position of cyl. S2 S2 = true, pneumatic cylinder is in end position
I: Bottle fill sensor S3 S3 = true, bottle is full
I: Bottle position sensor S4 S4 = true, bottle is in filling position
I: Liquor storage sensor S5 S5 = true, enough liquor for filling a bottle is in storage
I: On/Off switch S6 S6 = true, filling station is on
O: Vacuum pump Q1 Q1 = true, pump is on, producing vacuum
O: Pneumatic cylinder Q2 Q2 = true, cylinder moves downwards
O: Vacuum valve V1 V1 = true, filler head and bottle get evacuated
O: Liquor fill valve V2 V2 = true, liquor is filled in bottle
O: Conveyor motor M1 M1 = true, conveyor belt moves
All inputs and outputs are boolean signals (true / false).
3.1 Complete the diagram on the next page. It is not necessary for the drawing to be true
to scale. It must include at least one filling process, which can be described by the
following statements:
The filling station is started by pressing the On/Off-switch S6. It is only possible
to start the process, if the liquor storage sensor S5 shows, that there is enough
liquor in the storage.
After that, the vacuum pump Q1 is activated. Vacuum valve V1 is closed. The
pump stays activated, as long as the On/Off-switch S6 is in the “On” state.
It takes 2 s to generate the vacuum.
Afterwards the conveyor belt begins to move by activating motor M1. The belt
moves as long as is needed to detect a bottle at the filling position by sensor
S4.
Next, the filler head is moved downwards onto the bottle. This is done with the
help of a pneumatic cylinder by applying pressure to it with a control valve (not
included in drawing), which is actuated by signal Q2.
Sensors S1 and S2 show the starting and end position of the cylinder.
When the filler head is on top of the bottle (S2 is activated), the vacuum valve
V1 gets opened for 1 s and then closed again. Now, bottle and filler head are
evacuated.
After that, the filling valve V2 gets opened. Liquor is filled into the bottle be-
cause of the vacuum. When the bottle is full, sensor S3 gets activated.
Then V2 is closed again. The filler head is moved upwards by the pneumatic
cylinder. As the reverse movement of the cylinder is driven by a built-in spring,
this movement is activated by deactivating signal Q2.
When the cylinder is back in its start position (S1), the conveyor belt starts to
move again and transports the next empty bottle to the filling position.
Seite 56
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
This process is repeated, as long as the switch S6 is on and enough liquor is in the liquor
storage, shown by S5.
9P/
Seite 57
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
3.2 For this task, a Simulink model named „filling.slx“ is prepared. It includes a very basic 6 P /
process model in the subsystem “Process_Simulation”. In the empty subsystem “Con-
trol” you should implement a state chart, representing the control algorithm described
by the task description and analyzed in Task 3.1. First, add a Stateflow chart and de-
fine all necessary input and output signals with the appropriate data type according
to the above table. Connect inputs and outputs of the chart to the corresponding in-
ports and outports of the subsystem.
3.3 Draw a state chart needed to implement the control algorithm as described above. 9P/
Use absolute time temporal logic where necessary. If your model is correct, you will
get an output in the prepared scope similar to the diagram in task 3.1
Seite 58
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
In this examination, you should design a simulation model for a two stage bal-
listic rocket. The following tasks guide you through the complete model build-
ing in a step-by-step process. This process is supported by some already pre-
pared files, placed in the directory created automatically at the login.
This differential equation is based on the conservation of momentum and describes the ac-
celeration of a rocket starting in vertical direction with disregard of the aerodynamic re-
sistance. Velocity and actual mass of the rocket can be calculated with the following integral
equations:
J 4 J) ; ,Y 4 ,) ;
(A rocket burns its fuel continuously and therefore loses continuously mass, ,) is negative!)
The next table describes the mathematical symbols and values of necessary constants:
Variable or constant Matlab Symbol Value Unit
Height above ground h ℎ ,
Velocity v J , ⁄(
Gravitational acceleration a_grav ƒH • , ⁄( N
Velocity of exhaust gas from rocket nozzle v_Gas JÌ 4500 ,⁄(
Actual mass of rocket m_R ,Y CD
Mass of rocket at start time of stage 1 M_Start1 e … 123000 CD
Mass of rocket at end of combustion of stage 1 M_End1 Í+ … 35500 CD
Fuel rate combusted per second for stage 1 dM1 ,) … -2000 CD⁄(
Mass of rocket at start time of stage 2 M_Start2 e N 23000 CD
Mass of rocket at end of combustion of stage 2 M_End2 Í+ N 5500 CD
Fuel rate combusted per second for stage 2 dM2 ,) N -1000 CD⁄(
Acceleration of gravity at ground level g D -9.81 ,⁄( N
Gravitational constant G Î 6.674e-11 ,• ⁄CD( N
Mass of Earth m_E ,Í 5.972e24 CD
Radius of Earth r_E MÍ 6.371e6 ,
Seite 59
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
(The above table also includes constants, which you need for later tasks.)
1.27 Open the prepared MATLAB script “constant_declaration.m”. Add variables for all 7P/
needed constants from the above table to this script, using the variable names and
values from the table. Don´t forget to add a short comment for each constant, de-
scribing the meaning and the unit of the constant.
1.29 The subsystem “Rocket_Stage1” from task 1.2 is empty. Inside this subsystem, you 7P/
should now implement the rocket equation. The best way to do this, is to start with the
calculation of the rocket mass ,Y . You will need an integrator block from the Sim-
ulink library. Drag this block into your subsystem and activate the “Limit output” Op-
tion in the Block Parameters dialog. Now you can also set the upper and lower satura-
tion limit (Mass of rocket stage 1 at start time and at end of combustion). Don´t forget
to set the correct initial value!
The calculation of the rocket mass is given by the following equations:
°ÏÐ^‡
,Y… 4°Ñ ,)… if signal (“ignition” is true) AND ,Y… Ò Í+ … ;
‡
°ÏÐ^‡
,Y… 4°Ñ ‡ 0 otherwise.
You will need a switch block at the input of the integrator to implement this decision.
Use the constants defined in “constant_declaration.m” inside of constant blocks in
your model.
1.30 Next, add the calculation of the acceleration J) (output 1 of the subsystem) of the 7P/
rocket. It can be calculated from the following equation:
JÌ
J) Ó ∗ ,)… Ô _ ƒH •
,Y…
Seite 60
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
1.5 As the last step, add the signal for the second output of the subsystem (burnout). 2P/
This boolean signal gives a “true” value, if the actual mass of the rocket is less than or
equal to the mass at the end of combustion: opMqsp ,Y… “ Í+ … .
Now you can simulate your single-stage rocket. The result of the simulation in the pro-
vided scope should look similar to the following picture:
Seite 61
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
Next, replace the subsystem “Rocket_Stage1” in this model with the subsystem
“Rocket_Stage1” from your previous model “Sim_Rocket_v1.slx” of task 1.
2.3 Because of the height above ground level this rocket can reach, it is not appropriate to 5 P /
use a constant value for the gravitational acceleration. Instead, we can calculate the
acceleration from Newton´s law of universal gravitation:
,Í
ƒH • Î∗
MÍ _ ℎ N
Implement this equation in the empty subsystem “Gravitation”. The output “gravity” of
this subsystem is ƒH • .
Seite 62
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
3.1 In subsystem “Control” of model “Sim_Rocket_v2.slx”, add a Stateflow chart and de- 7P/
fine all necessary input and output signals with the appropriate data type according
to the above table. Connect inputs and outputs of the chart to the corresponding in-
ports and outports of the subsystem.
3.2 Draw a state chart needed to implement the control algorithm for the rocket launch as 12 P /
described above. Use absolute time temporal logic where necessary. (Hint: You can
implement the Countdown with the help of a local variable, which is decremented
every second within one state.)
Seite 63
Fakultät für Ingenieurwissenschaften
Prof. Dr.-Ing. Franz Perschl
If your model is correct, you will get an output in the prepared scope similar to this picture:
Seite 64