Lab 2
Lab 2
Mechatronics LAB 2
Q 1. Modelling a First Order Equation (RC Circuit) The RC Circuit is schematically shown
below.
The differential equation is -
Where (xdot) is the time rate of change of the output voltage, R and C are constants, f(t) is
the forcing function (Input voltage), and x is the output voltage.
Input:
Description:
To plot the f(t) function, we take Ramp block. For R and C we take the constant
blocks and assume the values of each.
We use integrator block to convert the first derivative function to a single linear
function. Then we subtract x from f(t).
We reciprocate the R*C term and multiply it with the expression.
We get the final graph of the function in scope block.
Output:
The graph for the function is displayed above. It starts at 0 and increases in a curve.
The response of this system is governed by the equation of motion which is a second-order
differential equation, and is shown-
Where (xddot) is the acceleration of the mass m, (xdot) is the velocity, x is the displacement,
f(t) is the forcing function (input force), c is the damping coefficient, and k is the spring
constant.
Input:
Description:
We first take a Ramp block as f(t) function.
By using integrators, we convert double derivative to a linear function ‘x’.
We multiply x’ with c and x with k, assuming the values c = 5 and k = 4.
Then we finally obtain the expression using a subtract block.
Finally, we multiply the expression by reciprocal of m, where we assumed the value
of m = 3.
We plot the graph of the final function using a scope block.
Output:
We get a curve with gradually increasing slope until one point and a constant slope after that
point.
Q 3. Solve the first order differential equation (ODE) using Simulink - dx/dt = 2 sin 3t − 4x.
Input:
Description:
We take a sine wave as an input function first, with Amplitude 2 and Frequency 3 and
multiply it with 2.
We use an integrator for getting the value in linear function x. And then we multiply x
by 4.
We subtract the second expression from the first and plot the resultant graph using a
scope block.
Output:
The following graph is obtained for the expression.
Input:
Description:
We take clock as input and as it starts with 0, we add one.
We reciprocate it by using 1/u block and then give it a gain of 2.
We use integrator for integrating the function into linear form and multiply y by the
previous expression.
The graph of the function is displayed in scope block.
Output:
We get the following curve as an output.
Q 5. If you take your hot cup of tea, and let it sit in a cold room, the tea will cool off and
reach room temperature after a period of time. The law of cooling is attributed to Isaac
Newton (1642-1727) who was probably the first to state results on how bodies cool.1 The
main idea is that a body .at temperature T(t) is initially at temperature T(0) = T0. It is placed
in an environment at an ambient temperature of Ta. The goal is to find the temperature at a
later time, T(t).We will assume that the rate of change of the temperature of the body is
proportional to the temperature difference between the body and its surroundings. Thus, we
have-
Input:
Description:
We assume the value of dT/dt = 2 and then convert it into a linear function T by
integrator block.
We subtract a value Ta = 15 by use of constant block and subtract block.
Then we assume a value of the proportionality constant as 1 and plot the graph in the
scope.
Output:
Q 6. A cup of tea at 90oC cools to 85oC in ten minutes. If the room temperature is 22oC,
what is its temperature after 30 minutes? Using the general solution with T0 = 90oC,
Input:
Description:
We take clock and add one to it as input.
We apply a -1 gain to it and then use the eu function for exponentation.
We multiply that function to 68 and add 22 to the final function.
The graph of the function is displayed using slope.
Output:
We get the following graph as output. This graph depicts a negative exponential function.
Input:
Description:
First, we use integrator to convert a function from double derivative to single
derivative.
Then we use another integrator to convert single derivative to a linear function.
The single derivative is applied a gain of 5 and then subtracted from the double
derivative.
Similarly, the linear variable y is applied gain of 6 and subtracted from the double
derivative.
The final function y is taken, and the graph is plotted of the model using the scope
block.
Output:
Input:
Description:
We take a gain value of -1/m where we assume the value of m as 2.
We use 2 integrators to convert it to x.
We use another gain function for the value of k. we assume the value of k as 5.
Output:
We get the following curve similar to a cosine curve with the max and min values as 1 and -1.
Input:
Description:
We use 2 integrators to convert double derivative into linear function.
The double derivative is applied a gain of value m = 0.5, to get the mx’’ term.
The single derivative is applied a gain of b = 2 and then subtracted from the double
derivative term.
Similarly, the linear variable x is applied gain of k = 5 and subtracted from the
double derivative term.
The final function x is taken, and the graph is plotted of the model using the scope
block.
Output:
This is the graph for function mx” + bx’ + kx = 0, where m = 0.5, b = 2 and k = 5.
mL ¨θ = −mg sin θ
Input:
Description:
By the equation mLθ = -mgsinθ, we can simplify it as, θ = -gsinθ/L.
So, we use constant block of value -9.81 to give it value of -g, we assume value of L
= 5.
We use 2 integrators to convert double derivative of theta term to a linear term θ.
We use sin function on the theta and we multiply -g with sinθ, and divide it by L to
get value of θ.
We use scope to plot the graph of the expression.
Output: