0% found this document useful (0 votes)
112 views25 pages

Lab 01

The document describes 5 problems solved using Simulink. Each problem involves modeling mathematical or logical operations using Simulink blocks. The problems include arithmetic operations, temperature conversion, differentiation/integration of sine waves, and modeling logical and quadratic equations.

Uploaded by

Mihir Mandhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views25 pages

Lab 01

The document describes 5 problems solved using Simulink. Each problem involves modeling mathematical or logical operations using Simulink blocks. The problems include arithmetic operations, temperature conversion, differentiation/integration of sine waves, and modeling logical and quadratic equations.

Uploaded by

Mihir Mandhare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

1

Bansilal Ramnath Charitable Trust’s


Vishwakarma Institute of Technology

Name: - Mihir Mahendra Mandhare


Roll No.: - 28
PRN No.: - 12111335
Division: - Mech-C
Subject: - Mechatronics Lab
2

Lab 01: Simulink Exercises

1. Problem:
To create a Simulink model which performs simple arithmetic
calculations such as add, subtract, multiply & divide.

a) Input :

b) Description :
1. Constant:
Two Constant blocks are used to provide input values for the
arithmetic operations. For example, set one Constant block to
5 and another Constant block to 3.
2. Add: The Add block is used to perform addition. Connect
the two Constant blocks to the input ports of the Add block.
3. Subtract:
The Subtract block is used to perform subtraction. Connect
the first Constant block to the positive (+) input port and the
3
second Constant block to the negative (-) input port of the
Subtract block.
4. Product:
The Product block is used to perform multiplication. Connect
the two Constant blocks to the input ports of the Product
block.
5. Divide:
The Divide block is used to perform division. Connect the
first Constant block to the numerator input port and the
second Constant block to the denominator input port of the
Divide block.
6. Scope:
The Scope block is used to visualize the output of each
arithmetic operation.

c) Output :
4

d) Conclusion :
In this project, we successfully created a Simulink model to
perform simple arithmetic calculations such as addition,
subtraction, multiplication, and division. By setting the input
constants and using the appropriate arithmetic operator
blocks, we were able to visualise the output using a Scope
block. This exercise helps in understanding the basics of
Simulink and how it can be used for mathematical modelling
and simulations.

2. Problem:
Convert a temperature from Celsius to Fahrenheit using Simulink.
a) Input :

b) Description :
Blocks used ;
1. Constant:
One Constant block is used to input the temperature in
Celsius.

2. Gain:
5
The Gain block multiplies the Celsius temperature by 9/5
(which is 1.8).

3. Sum:
The Sum block adds 32 to the result of the multiplication.

4. Scope:
The Scope block is used to visualize the temperature in
Fahrenheit.

c) Output :

d) Conclusion :
In this project, we successfully created a Simulink model to
convert a temperature from Celsius to Fahrenheit. By using
Constant, Sum, Gain, and Scope blocks, we performed the
necessary calculations and displayed the output in Fahrenheit on
the Scope block. Simulink provides a convenient environment for
mathematical modeling and simulations, and this exercise helps in
understanding the usage of various blocks to implement a simple
temperature conversion formula.

3. Problem: Differentiate/ Integrate Sine wave and display results along


the sine wave.
6

a) Input :

b) Description:
1) Create a new Simulink model by opening Simulink
from the MATLAB Home tab and clicking on "New
Model."
2) Drag and drop the "Sine Wave" block from the
Simulink Library Browser into the model
workspace. Set the parameters of the sine wave,
such as frequency, amplitude, and phase, in the
block's properties.
3) Drag and drop the "Derivative" block from the
Math Operations section of the Simulink Library
Browser into the model workspace. Connect the
output of the Sine Wave block to the input of the
Derivative block.
4) Similarly, drag and drop the "Integral" block from
the Math Operations section and connect the
output of the Sine Wave block to the input of the
Integral block.
5) To display the results along with the sine wave,
add "Scope" blocks from the Sinks section of the
Simulink Library Browser. Connect the outputs of
the Derivative and Integral blocks to separate
Scope blocks.
7
6) Connect the output of the Sine Wave block to a
third Scope block to display the original sine wave.
8
7) Save the Simulink model and run the
simulation by clicking the "Run" button.

c) Output:

d) Conclusion:
In this project, we successfully created a Simulink model
to differentiate and integrate a sine wave signal. By using
the Sine Wave, Derivative, Integral, and Scope blocks, we
performed the differentiation and integration operations
and visualised the results. Simulink's capabilities make it
easy to perform mathematical operations on signals and
visualise their behaviour, making it a valuable tool for
various engineering and scientific applications.
9
4. Problem: Build a Simulink model that implements Logical
operations (AND / OR / XOR / NAND / NOR / NOT).

a) Input :

b) Description :
Blocks used:
1. Constant block :
This block is used to provide constant values (0 or 1)
for the logical inputs.
2. Logical Operator blocks:
There are several Logical Operator blocks available
in Simulink that implement different logical
operations:
● AND block: This block performs the logical AND
operation on its input signals.
10
● OR block: This block performs the logical OR
operation on its input signals.
● XOR block: This block performs the logical XOR
(exclusive OR) operation on its input signals.
● NAND block: This block performs the logical NAND
operation on its input signals.
● NOR block: This block performs the logical NOR
operation on its input signals.
● NOT block: This block performs the logical NOT
operation on its input signal.

3. Scope:
The Scope block is used to visualize the outputs of
the logical operations.
4. Connections:
Connect the Constant blocks to the input ports of the
desired Logical Operator blocks based on the logical
operation you want to perform. Connect the output of
each Logical Operator block to the Scope block for
visualisation.

c) Output :
11

d) Conclusion :
In this project, we successfully created a Simulink model
that implements various logical operations such as AND,
OR, XOR, NAND, NOR, and NOT. By using Constant
and Logical Operator blocks, we performed the desired
logical operations and visualized the outputs using the
Scope block. Simulink provides a flexible and intuitive
environment to design and simulate logic circuits, which
can be beneficial for digital system design and verification.

5. Problem:
Roots of quadratic equation ❑
y=a +2 ab+ √ b
2
12
a) Input :

b) Description :
Blocks used:
1. Constant:
Two Constant blocks are used to input the
values of 'a' and 'b' into the model. Set one
Constant block to 2 for 'a' and another Constant
block to 4 for 'b'.
2. Product:
The Product block is used to compute the
square of 'a' (a^2) by multiplying 'a' with itself.
3. Sum:
13
The Sum block is used to compute the term
'2ab' by adding 'a' and 'b' and then multiplying
the result by 'a'.
4. Square Root:
The Square Root block is used to compute the
square root of 'b'. e. Sum (Second Sum block):
The second Sum block is used to add the
results from the Product block, the first Sum
block, and the Square Root block to get the
final result of the quadratic equation.
5. Scope:
The Scope block is used to visualize the output
of the equation, which represents the roots.

Connections:
● Connect the Constant blocks to the input ports of the
Product, Sum, and Square Root blocks as required by
the quadratic equation.
● Connect the output of the Product block, the first
Sum block, and the Square Root block to the input
ports of the second Sum block.
● Connect the output of the second Sum block to the
input of the Scope block.
c) Output :
14

d) Conclusion :
In this project, we successfully created a Simulink
model to find the roots of the quadratic equation y =
a^2 + 2ab + sqrt(b) when 'a' is 2 and 'b' is 4. By
using Constant, Product, Sum, Square Root, and
Scope blocks, we performed the necessary
calculations and visualized the roots of the quadratic
equation using the Scope block. Simulink provides a
versatile platform for mathematical modeling and
simulations, which can be applied to various
engineering and scientific problems.

6. Problem: Evaluate an expression 2+5e5 in Simulink and


display the result.
a) Input :
15

b) Description:
1. Constant:
This block is used to provide constant values
for the expression. In this case, we need to
input the values 2 and 5e5 (which is equal to
500000).
2. Sum:
The Sum block is used to add the two constant
values together, resulting in the evaluation of the expression.
3. Scope:
The Scope block is used to visualize the output
of the expression.
Connections:
Connect the Constant blocks to the input ports of
the Sum block. Connect the output of the Sum block
to the input of the Scope block.
c) Output:
16

d) Conclusion :
In this project, we successfully created a Simulink
model to evaluate the expression 2 + 5e5. By using
Constant and Sum blocks, we performed the
addition and visualized the result using the Scope
block. Simulink allows us to perform various
mathematical calculations and simulations
efficiently, making it a valuable tool for engineering
and scientific applications.

7. Problem:
Generate a Sine wave. Pass the signal with a constant
gain of 5. Apply a saturation of ±3 and show the display
before and after saturation.
a) Input :
17

b) Description:
1. Sine Wave:
The Sine Wave block generates a sinusoidal
waveform with specified frequency, amplitude,
and phase.
2. Gain:
The Gain block is used to multiply the input
signal (Sine wave) by a constant value of 5.
3. Saturation:
The Saturation block is used to limit the signal
amplitude between ±3.
4. Scope:
Two Scope blocks are used to visualize the
original signal and the signal after saturation.
18
c) Output :

Before saturation After saturation

d) Conclusion :
In this project, we successfully created a Simulink
model to generate a Sine wave, pass it through a
constant gain of 5, and apply saturation of ±3. By
using the Sine Wave, Gain, Saturation, and Scope
blocks, we performed the desired operations and
visualized the waveforms before and after saturation
using the Scope blocks. Simulink provides a
powerful platform for signal processing and
analysis, and this exercise demonstrates how to
manipulate signals using various blocks in the
Simulink environment.

8. Problem:
To create a Simulink model which performs
multiplication of 2x2 Matrix.
19
a) Input :

b) Description :
1. Constant:
Four Constant blocks are used to input the elements
of the two 2x2 matrices. Each block will represent
one element of each matrix.
2. Product:
The Product block is used to perform the matrix
multiplication.
3. Display:
The display block is used to visualize the output of
the matrix multiplication.
Connections:
1. Connect the Constant blocks to the appropriate input
ports of the Product block, representing the elements
of the two 2x2 matrices. The Constant blocks'
arrangement will depend on the order of the elements
in the matrices for multiplication.
2. Connect the output of the Product block to the input
of the Scope block.
20
c) Output :

d) Conclusion :
In this project, we successfully created a Simulink model
to perform multiplication of a 2x2 matrix. By using
Constant and Product blocks, we input the elements of the
matrices and perform the matrix multiplication. The Scope
block visualizes the result of the matrix multiplication.
Simulink provides a convenient environment for matrix
operations and simulations, which can be applied to
various engineering and mathematical applications.

9. Problem:
Plot the function y(x) = (x-1) * (x-3)^2 * (x-9)^2 using
basic Simulink blocks.
a) Input :
21

b) Description:
1. Square block :
The "Square" block in Simulink is a simple
mathematical block that squares its input value.
It performs the operation y = x^2, where 'x' is
the input and 'y' is the squared output.
2. Constant:
Three Constant blocks are used to set the
values for the constants (1, 3, and 9) in the
function.

3. Sum:
The Sum block is used to perform the
subtraction operation 'x - constant' for each
constant value.
4. Product:
22
The Product block is used to multiply the
results of the subtractions together,
representing the function y(x).
5. Scope:
The Scope block is used to visualize the plot of
the function y(x).
c) Output:

d) Conclusion :
In this project, we successfully created a Simulink model
to plot the function y(x) = (x-1) * (x-3)^2 * (x-9)^2. By
using basic Simulink blocks such as Ramp, Constant, Sum,
Product, and Scope, we generated the function and
visualized the plot using the Scope block. Simulink
provides a flexible and powerful environment for
mathematical modeling and simulations, which can be
applied to various engineering and scientific problems.
23

10. Problem:
Simulate the flight of a cannon ball after it has been shot out of a
cannon.

consider only the vertical motion of the cannon ball under the
influence of gravity. What happens when you drop a cannon
ball? This can be described by the equation below.

a) Input :
24

b) Description :
1. Derivative (Derivative Gain):
The Derivative block is used to calculate the
time derivative of the vertical position 'y',
representing the velocity 'dy/dt'.

2. Integrator:
The Integrator block integrates the velocity
'dy/dt' to calculate the vertical position 'y'.
3. Constant:
The Constant block is used to set the value of
acceleration due to gravity 'g' (typically 9.81
m/s^2)

c) Output :
25

d) Conclusion:
In this project, we successfully created a Simulink model
to simulate the vertical motion of a cannonball under the
influence of gravity. By using the Derivative, Integrator,
Constant, and Sum blocks, we numerically solved the
equation of motion and visualized the vertical position 'y'
of the cannonball over time using the Scope block.
Simulink provides a versatile platform for modeling and
simulating various physical systems, and this exercise
demonstrates its capability in simulating simple physics
problems like the vertical motion of a cannonball.

You might also like