Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

General Models and

Features of Simulink
By - Hrishikesh Shirsat - 111910136
Switch Blocks
• Switch blocks is a frequently used block
when you want to give conditions to
multiple inputs.
• In this block, three inputs are given.
• The first one is the input which is allowed to
pass when the condition becomes true.
• The second one is the condition which
allows or denies the passing of inputs
according to the particular condition.
• The input to condition is usually a constant
or simulation time
• The third one is the input which is allowed
to pass when the condition is not fulfilled
and then gets blocked.
Combining Different Inputs

• There is often a need to combine various inputs


in control systems.
• For example, in lathe or servomechanism, the
input continuously changes as the shape of the
master profile or object changes.
• There are several ways of combining different
inputs.
• In this presentation, we will see 3 methods of
combining inputs, getting progressively easier.
1st method
• This method is by far the most tedious ones.
• This uses a ramp input which is connected to three user
defined functions. These user defined functions could be
anything provided that there is no discontinuity.
• In our case we have a step, ramp, and sinusoidal inputs
which are given one after the other.
• There are two step inputs given which control the flow of
user defined functions.
• Step 1 is given a start time of 3 sec and Step 2 a start time
of 6 sec. Before the start time they are zero and after that
they are one.
• Till 3 sec, there is only first function(step) given to the
transfer function and the product block gives 0 output.
After that Step 1 is turned on and it multiplies with the
second function(ramp). So these both functions, the unit
and ramp are given to the transfer function.
• After 6 sec, Step 2 is turned on and cancels with Step 1 to
give 0 which is multiplied with the second function(ramp)
to block it. The other path of Step 2 multiplies with third
function(sinusoidal) to allow it to flow.
• The input(blue) and output(yellow) are as shown in the
second image.
2nd method
• This method is easier than the earlier one.
• Here two switch blocks are provided to control
the flow of inputs to the transfer function. The
problem is the same as the previous one.
• Here the bottom switch block allows the unit
function to flow to the transfer function till 3
sec. After 3 sec, the flow is cut off and the
ramp function is allowed to pass through it.
• The overall output of the bottom switch block is
then passed as input to the upper switch block.
• This upper switch block also gets a sinusoidal
function as input. When t<6, the output of first
switch block is allowed to pass through. After 6
sec, the sinusoidal function passes to the
transfer function.
• Hence we get a smooth response as shown in
the second image.
3rd method
• This is by far the easiest method, but is
used only when the block structure
becomes too complicated. The use of it is
not recommended.
• This is the same problem as the previous
one.
• Here instead of creating multiple blocks,
a matlab function is created which
simulates the combined inputs.
• A ramp input is given to the matlab
function block and this is connected to
the scope.
• The output is as shown in the result fig.
Circles
• There are many predefined libraries for standard
inputs like step, ramp, sinusoidal input etc.
• However Circular input is not one of them. This
forces us to make a separate block diagram for
it.
• Normally a block diagram as in first image is
usually drawn.
• There are two sum blocks which take inputs of the
square of the radius and square of (t-c) where t is
the simulation time and c is any constant by
which you want to shift your circle.
• Then a square root operation is performed and
both positive and negative roots are given to the
scope.
• The negative root is formed by taking a gain of
-1.
• So one half of circle is made with positive root
and other half with negative root.
Circles
• The another method to draw a circle is by using
an XY graph.
• In this method, there are 2 product blocks. A
ramp input is given to both sin and cos blocks.
This input acts as theta.
• To one product block, a constant input which is
the radius and sin input is given.
• To the other one, a radius input and cos input is
given. These both product blocks connect to
the XY Graph. When you run and click on the
XY Graph, the output is given as shown in the
second image.
• This method is better and easier than the other
one because there are few block elements
and the inputs given are in terms of sin, cos and
radius which are easier for the user to
understand than the long equation in the last
method.
Differential Equations
• Using Simulink, we can easily solve a set of
ODEs or PDEs.
• Here is an example to demonstrate how
Simulink can be used to solve these
equations.
• In this example, there are two equations with
two variables x and y which we have to find
out as shown in the first image.
• Firstly we rearrange these equations such
that the highest order term is on the left and
all others are on the right as shown in the
second image.
Differential Equations
• After rearranging the equations we draw its block
diagram as shown in the first image.
• We first give a sin input to the add/subtract block.
Then we place an integrator in front of the sum
block which would integrate it once and give you
x. This x is fed back to the add/subtract block.
• We draw another add/subtract block for y. The
first input that we give here is x after passing
through gain block. Then we place two
integrators in front of it in order to integrate it
twice as the order of equation is 2.
• The other input is fed back the value of y’ after
passing through a gain
• The third input of x block is also fed the value of y’
after passing through a gain.
• And finally we attach scope to both the ends of x
and y system.
• The output is as shown in the second image. x is
the yellow sinusoidal and y is the blue one.
Differential Equations

• This was just an example of solving


differential equations with an integrator.
• However any kind of differential equations
like Mass – Damper, Mass-Spring-Damper,
Electrical circuits, hydraulic and pneumatic
systems can be solved using the process
shown in the example although the block
diagrams will be a bit different.
Thank You

You might also like