Professional Documents
Culture Documents
FACULTY OF ENGINEERING
MECHATRONICS ENGINEERING DEPARTMENT
Credit Hours Programs
Contents*
Description: Hydraulic circuits are an important component of many mechatronic systems. A basic
hydraulic system usually includes:
The following figure shows a basic hydraulic circuit to control the extension and retraction of a hydraulic
cylinder:
Piston Mechanical
System
Hydraulic
Cylinder
Valve
Spool
Tank
Pump
By controlling the position of the spool, we could force the hydraulic fluid to move the piston of the
hydraulic cylinder forward and backward.
Hydraulic schematics are usually used to represent hydraulic circuits, the shown hydraulic cylinder is
represented by the following diagram:
*
Parts of this lab sheet are based on the Simscape documentation, provided by Mathworks
The hydraulics section in the foundation library is used to model basic hydraulic elements and many
hydraulic components could be modelled using them. Implementing the hydraulic components like valves
and pumps using the basic hydraulic elements is usually difficult and time consuming.
We will use Simscape Fluids to model the hydraulic circuit shown above.
Build Model
1. At the MATLAB® command prompt, enter ssc_new to create a new Simscape file.
2. Add the following blocks to the diagram:
Page 2 of 27
The PS Constant block is used to directly provide a constant physical signal. We will use it to specify the
angular velocity of the source.
The rotational mechanical reference will be connected to the C port.
5. The hydraulic cylinder is a translational mechanical actuator that is operated using a hydraulic circuits. We
will now place a mechanical system for the cylinder to act against.
Note that the cylinder block itself has no mass or inertia specified and thus using it without connecting it
to a load will cause the simulation to fail.
Add the following elements to the diagram:
7. Note that we left the physical properties of all the added components to their default values.
8. We now need a signal to drive the spool of the directional control valve. Add a Sine block and use the S
PS block to provide this signal. Make sure to change the units of the S PS block to mm as the motion of
the spool is usually very limited.
9. Run the simulation and try to fix any errors that might appear.
10. Notice that we haven’t added any sensors or scopes yet. When using Simscape, we could monitor the
status of all physical elements using the Simscape Results Explorer. In Simulation>Model Configuration
Parameters>Simscape (See Figure 1 in page 5) change the “Log simulation data” combo box to “All”.
After running the simulation again, right click on any physical element>Simscape>View Simulation
Data>simlog to view its parameters.
Note: The Simscape Results Explorer is not available before R2014b, for those who have older versions,
you will still need to add a sensor and scope for any variable you wish to plot.
Page 3 of 27
Note that in the figure above we are monitoring the parameters of the translational spring and its
displacement (x) is the same as that of the cylinder.
11. Note that the displacement of the spring does not go below 0. This is because, by default, the hydraulic
cylinder is in full retracted position. To adjust this double click on the hydraulic cylinder and in the “Initial
conditions” tab. Set “Piston initial distance from cap A” to 0.05m which is half the total stroke of the
cylinder.
12. Note that the cylinder doesn’t reach its full stroke (0.05m). Could you modify the system to increase the
velocity of the piston?
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
13. Note that we didn’t specify the properties of the fluid. In order to do that add the following block to the
system and connect it to the hydraulic reference.
What happens to the velocity of the piston when you increase the amount of trapped air in the fluid to 0.5?
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
Use Simscape Foundation Library to model and simulate the following system. Assume any needed parameters for
the modelling
a. The Figure below shows a double-acting piston and cylinder. The device moves the load mass m in
response to the pressure sources p1 and p2. Assume the fluid is incompressible, the resistances
are linear, and the piston mass is included in m.
Derive the equation of motion for m.
Construct a Simscape model.
Plot the results of x
Page 4 of 27
Use these values to simulate the model:
m = 1kg (Mass of load), A = 5×10-04 m2 (Piston area), ρ= 850 kg/m3 (Density of hydraulic fluid), p1 =
2×105 Pa (Source pressure), p2 = p1 (Source pressure), R1 = 1010 Pa/(m^3/s) (Linear flow resistance),
R2 = R1.
Description: This exercise shows the usage of thermal blocks for developing a model of a long iron rod that is
heated with a heat source through face A. Face B and the outer cylindrical surface are open to atmosphere and
subjected to forced heat convection. The rod is made of iron, is 20 cm in length and 2.25 cm in diameter. The
rod is treated as a single thermal mass. There is one convective heat transfer element for the single cylindrical
surface and two equally divided conductive heat transfer elements for the two halves of the rod.
Build Model
Simulink>Sinks Scope 1
Page 5 of 27
3. Assign 120 for Constant1 which represents the source signal for the ideal heat flow source block; and 300
for Constant2
4. Specify the following parameters for both of Conductive Heat Transfer and Conductive Heat
Transfer1 Blocks
5. For Convective Heat Transfer and Convective Heat Transfer1 Blocks, Specify the following parameters
6. Increase the simulation time to 10000 seconds and then run the simulation. The simulation results are
shown in the following illustration.
Page 6 of 27
7. Change Constant1 value which represents the source signal for the ideal heat flow source block to be
Zero, Run the simulation, and comment.
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
a. Hardness and other properties of metal can be improved by the rapid cooling that occurs during quenching, a
process in which a heated object is placed into a liquid bath (see the Figure below).
Consider a lead cube with a side length of d = 20 mm. The cube is immersed in an oil bath for which h = 200
W/(m2 · ◦C). The oil temperature is Tb. Thermal conductivity varies as function of temperature, but for lead the
variation is relatively small (k for lead varies from 35.5 W/m· ◦C at 0◦C to 31.2 W/m·◦C at 327◦C). The density
of lead is 1.134 × 104 kg/m3. Take the specific heat of lead to be 129 J/kg·◦C.
Develop a simulation model to predict the temperature T as a function of time, for a given constant bath
temperature 𝑻𝒃 . Consider Tb = 50
Solution guide:
You will need the following elements in order to build a Simscape model for this thermal system:
1. a model of the thermal mass,
2. a model of the convective resistance,
3. a reference temperature,
4. a source temperature to specify 𝑇𝑏 , and
5. a way to measure the cube temperature T.
b. Using simscape to mode the system in the figure below if you consider the quenching process treated in the
previous example. If the thermal capacitance of the liquid bath is not large, the heat energy transferred from the
cube will change the bath temperature, and we will need a model to describe its dynamics. Consider the
representation shown in the Figure below. The temperature outside the bath is To, which is assumed to be known.
The convective resistance between the cube and the bath is R1, and the combined convective/conductive
resistance of the container wall and the liquid surface is R2. The capacitances of the cube and the liquid bath are
C and Cb, respectively
Page 7 of 27
Figure: Quenching with a variable bath temperature.
This Exercise shows a solenoid with a spring return. The solenoid is modelled as an inductance whose value L depends
on the plunger position x. The back emf for a time-varying inductance is given by:
In the model, equation 2 is rearranged to solve for i, and then implemented using Physical Signal blocks. A controlled
current source then constrains the current to equate to i.
Steps:
A- Solenoid subsystem
Page 8 of 27
a) Voltage Current Interface subsystem
i- Controlled Current Source : The Controlled Current Source block represents an ideal current
source that is powerful enough to maintain the specified current through it regardless of the
voltage across the source. The output current is I = Is, where Is is the numerical value presented
at the physical signal port. The positive direction of the current flow is indicated by the arrow.
ii- Voltage Sensor: The Voltage Sensor block represents an ideal voltage sensor, that is, a device
that converts voltage measured between two points of an electrical circuit into a physical signal
proportional to the voltage. Connections + and – are electrical conserving ports through which
the sensor is connected to the circuit. Connection V is a physical signal port that outputs the
measurement result. The block has the following ports: + Electrical conserving port associated
with the sensor positive terminal. - Electrical conserving port associated with the sensor negative
terminal. V Physical signal output port for voltage.
iii- Connection Ports: Two of which (1 & 2) need location to be Left and the other Two (3&4)
needs it to be Right.
Page 9 of 27
b) Calculate Force and Current subsystem
iii- Connection Ports: 1&2&3 locations on parent subsystems are Right and 4&5 locations are Left
Page 10 of 27
- LUT PtoL
Page 11 of 27
d- Other Blocks
D- Energise subsystem
Page 12 of 27
Set step time to 0.1 , Initial value =0, final value = 1.
E- DC Voltage Source
Set Constant voltage to 50 V.
Hint: You can find it at Simscape/Foundation Library/Electrical/Electrical Sources
F- Switch
Set Closed resistance R_closed: to 0.01 Ohm.
One Last Step is to log and show the model variables: From Model Configuration Parameters:
Page 13 of 27
Exercise 4: Modelling of Linear Electric Actuator with worm gear and screw.
Description: This example shows a detailed implementation model of a controlled linear actuator. The actuator consists
of a DC motor driving a worm gear which in turn drives a lead screw to produce linear motion. The model includes
quantization effects of the Hall-effect sensor and the implementation of the control. There are multiple variant subsystems
in this model that have models at varying levels of fidelity.
The speed control and current control models are implemented using pure Simulink blocks. This permits us to easily
specify the control algorithm and identify the requirements for an analog circuit implementation, which is shown in
another variant
The motor drive circuit model is implemented in an abstract circuit which can simulate in two different simulation modes.
In average mode, the voltage applied to the motor varies continuously between the maximum and minimum values
depending upon the voltages at its input pins. In PWM mode, a PWM voltage is applied to the motor and its duty cycle
depends on the voltage applied at its input pins.
Page 14 of 27
2- Examine the speed controller subsystem and identify the function of each block.
3- Examine the current controller subsystem and identify the function of each block.
4- Examine the PWM and H-bridge subsystem and identify the function of each block.
Page 15 of 27
5- Open the motor current scope and comment on the result.
6- Change the simulation mode to PWM in both the Controlled PWM and H-Bridge blocks.
Page 16 of 27
Reference:
https://www.mathworks.com/examples/simelectronics/mw/elec_product-elec_motor_linact_control-linear-electric-
actuator-with-control
1. Create a model of Loudspeaker shown in Figure 2. Consider coil resistance (R)=6Ω, inductance
(L)=0.2mH, speed proportional constant of electromechanical converter= 3 V/(m/s), voice coil and
diaphragm mass=50 gm, stiffness (k)= 500 kN/m, damping coefficient (B)= 6×10 -3N/(m/s). Measure
the steady state electric power consumed by the speaker and the time it takes for the diaphragm
oscillation (x) to settle (reach steady state) if the input electrical signal was sinusoidal with frequency
500 Hz and amplitude 12V.
Page 17 of 27
Figure 2
2. Figure 3 shows a schematic diagram of a microphone which is used as a transducer to convert
acoustic waves into electric signal. It consists of a diaphragm attached to a circular coil of wire that
moves back and forth through a magnetic field when sound waves hit the diaphragm. The magnetic
field is supplied by a cylindrical permanent magnet having concentric north and south poles. Create a
model for a microphone using Simscape given that: The resistance connected to the microphone is 50
Ohm, Microphone Diameter is 12.7 mm, its thickness is 0.1mm and it is made from Aluminum
(density 2700 kg/m3), Equivalent damping is 2 N/(m/s), electromechanical speed constant is and K m
= 10 V/(m/s). The inductance of the microphone coil is 0.5 mH. The equivalent stiffness is 10 N/mm.
Figure 3
3. Use Simscape Foundation library and Driveline to solve this problem
The specifications of a machine that utilizes a lead screw mechanism are:
Power screw: Diameter: 14 mm, length: 500 mm, pitch: 0.5 rev/mm, efficiency: 45%, material: steel (steel
density=7800kg/m3)
Mechanical data: Friction coefficient (μ): 0.1, load: 6 kg.
A geared DC motor was used to drive Taking into consideration that the motor parameters are:
Ra = armature winding resistance = 0.2 Ω
Measure the motor current (A), motor torque (Nm), motor speed (rpm), load speed (m/s), and load
displacement (mm) if the motor is continuous running.
Page 18 of 27
4. Consider a machine with a rotary motion axis driven by an electric geared servo motor; as shown in
the figure below. The machine is connected to the geared motor shaft through timing belt. The
following specifications summarize the system: The motor gear box reduction: 10:1, the timing belt
reduction ratio: 2:1, the rotary load is a solid cylindrical shape made of steel material, d= 100 mm, l=
60mm, ρ= 7800 kg/m3, the equivalent viscous damping coefficient of the bearings on machine shaft is
1.5N.m.s/rad. A friction load is applied to the load (μ= 0.2)
The geared DC motor was used to drive the load through the belt. Taking into consideration that the motor
parameters are:
Measure the motor current (A), motor torque (Nm), motor speed (rpm), load speed (rpm), and load torque
(Nm) if the motor is continuous running.
Note: You may need to consider the pretension in the belt to prevent pulleys slip, by setting a high priority deformation
in the spring (belt stiffness) e.g. you can use 0.01m.
7. Extra Exercises:
Steps:
a- From File:
make input file “motor_losses.mat” (Find it attached)
Page 20 of 27
b- Goto:
Set each Goto tag to one of the above variable names and make the Tag visibility global as follows.
c- Thermal Masses:
Page 21 of 27
e- Convective Heat Parameters :
B- Subsystems
a- Q_Rotor:
i- Find Ideal Heat Flow Source at Foundation Library/Thermal/Thermal Sources
ii- From: Find it at Simulink/Signal Routing, Set Goto tag to Q_Rotor.
iii- Input signal unit is W.
b- Q_Wind:
i- Find Ideal Heat Flow Source at Foundation Library/Thermal/Thermal Sources
ii- From: Find it at Simulink/Signal Routing, Set Goto tag to Q_Wind.
iii- Input signal unit is W.
c- Q_Stator:
i- Find Ideal Temperature sensor at Foundation Library/Thermal/Thermal Sensors.
ii- Input signal unit is W, Output signal unit is 1.
d- Atmosphere Temperature:
i- Input signal unit is 1.
Page 22 of 27
Then finalize connections as follows:
One Last Step is to log and show the model variables: From Model Configuration Parameters, as in
last step in Solenoid Exercise.
This exercise shows how to model a simple house heating system. The model contains a heater, thermostat, and a house
structure with four parts: inside air, house walls, windows, and roof.
The house exchanges heat with the environment through its walls, windows, and roof. Each path is simulated as a
combination of a thermal convection, thermal conduction, and the thermal mass. The heater starts pumping hot air if
room temperature falls below 18 degrees C and is turned off if the temperature exceeds 23 degrees C. The simulation
calculates the heating cost and indoor temperatures.
The manual switch allows you to investigate system behaviour with the heating system turned off.
Steps:
Page 23 of 27
A- Building Blocks(Other than subsystems)
a- Daily Temp Variation : Sine Wave
B- Building Blocks(subsystems)
a- Heater Switch
b- Thermostat:
It’s a MATLAB Function at Library path (Simulink/User Defined Functions).
Make an m-file with the following code, and name it Thermostat.m and add it to your model directory and
set the MATLAB Function block to Thermostat.
%#codegen
persistent HEAT
if isempty(HEAT)
HEAT = false;
end
HEAT = false;
heat = HEAT;
end
Page 24 of 27
Block Library Path Quantity
Page 25 of 27
iv- Conductive Heat parameters:
One Last Step is to log and show the model variables: From Model Configuration Parameters, as in last step in
Solenoid Exercise.
This file contains a model of a backhoe arm built using Simscape. The hydraulic actuation system, including pump,
valves, and hydraulic cylinders, actuates the arm and bucket. The three-dimensional mechanical system is modeled,
including the arm joints and bucket linkage. Examples in this submission show how to model custom hydraulic valves,
tune controller and physical system parameters, and generate C code from the entire model.
Please read the README.txt file to get started.
See an overview of this model in this video (5 min):
https://www.mathworks.com/videos/applications-and-tasks-in-simhydraulics-74107.html
Page 26 of 27
Here are some key points about this demonstration model:
1. You must run "startup_Backhoe.m" to set the path and load key values.
2. Double click on the grey block labelled "Script" to open an HTML page within MATLAB that will guide
you through the different examples included in this submission.
1- Explore Different subsystems in the Backhoe Arm using multibody blocks second generation.
Comment :
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
………………………………………………………………………………………………
Comment :
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………
Comment :
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
…………………………………………………………………………………………………
Comment :
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………
……………………
Page 27 of 27