Simulation is a powerful tool for engineers when they try to understand
some dynamic systems they usually model the systems and then they simulate it a
system is any set of connected objects which you want to study so it could be a
few electrical components it could be a mix of electrical and mechanical
components the simulation is a controllable experiment which we
performed on the model of the system so this is how usually the simulations is
defined just briefly what is the model so more than when we say model so model
is an approximation of the system because most of the real life systems
are so complex so what we do we model the system with approximate mathematical
models and then we simulate it but it doesn't mean that you need a lot of
mathematical knowledge in scilab we have a powerful simulator just like Samuel
Inc in MATLAB we have X caused in scilab it's a visual tool so the modeling has
been done inside the tools so you don't have to have the mathematical knowledge
of how to model a system you can straightaway
use the blocks so there are blocks for every component for example blocks for
displaying that data blocks for reading writing the data so all these blocks
they are called palettes they are available in X cause you can use those
blocks in order to start X course you write a command X cause on the command
prompt and enter and it will open these windows for you so you better just
adjust these windows first so they don't overlap each other otherwise where you
go in one window the other will be gone these are the pellets these are the
blocks which are available in X caused which we can use for modeling so there
are huge number of blocks available as you can see on the left this is the list
of the palettes available and in this first lesson we will use only two or
three types of elements and there will be two sources which we will be using
and what are sources sources are from where we activate the blocks for example
clocks clocks usually activate the scopes or the displays where we see the
output of a system simulation and similarly the files from where we read
the data so similarly the input ports so all these type of things are in sources
so in syncs you have displaced and you can write data here you can write data
to or you can say the output ports are also available they are also in syncs so
output ports for writing data so these type of things are available in these
pellets so explaining all this will take a lot of time but there are little
differences for example let's say that this is a single display scope this is a
multiple display scope this is a floating-point scope so these are little
differences in all these but we will be only using this single scope single
display scope from this sink section and from the sources section we will use
this clock so currently we are not reading data from any files we are not
using any input ports from here we only use this clock from here and then we use
from sinks we use this display scope single display scope and one more thing
we will be using from source is this step input like most of other courses we
will also start our first example from a step input to a first-order control
system so for that we will use this step and this clock and this from sync we use
display and then from the continuous time system we will use this transfer
function block so these four things we will use in this first lesson and we
will only build a model of these and in the next lesson we will make the
simulation because in simulation I have to explain certain other things
otherwise this video will be too long so first of all let's start from the
transfer function block so this is a transfer function block so click on this
and then you can drag it here in the working window so just release the mouse
button and it will be placed here now we go to sinks and in sinks we need this
single display scope and we drag it and we put it in front of here
don't worry about the alignment we can align it very easily later on then from
the sources we have to put two things for this simulation step input to the
system and I will explain you a little bit what is this step input and what is
the first order system because if you don't know anything about this then it's
harder to explain this simulation so there Phil I will take a few minutes to
explain this first order system after I put all these blocks here and then we
will simulate in our next lesson so now the last thing left is the claw so we
just put a clock here and now we have to link all these components so let me
explain that this red type of connections they are activation
connections it means that some something is being activated from the other block
so this in this case this block is activating our display and these are the
input-output connections so this is input connection to this transfer
function block and this is output connection to this transfer function
block similarly it's a single input display so in order to connect for
example let's start from the left side when you hover your mouse over this it
will become green then you press the left mouse button and drag to the next
connection and when it becomes green you release the button and it will be
connected now you can click outside and it will be connected and similarly you
over over this then click the button drag to the next connection when it
becomes green release the button similarly do it here and now these are
all are connected now we want to align these blocks so the best way instead of
you just try to align these as you can see there is hard to align because even
if I try aligning it will be very hard for me to you can do it like this but
the best way to will I just select all these blocks and while keeping your
mouse on any of these dots right click and then in to form it there is aligned
blocks and in a line blocks these are different alignments available so as you
can see that we want this type of alignment the
alignment so that all blocks are horizontally in the middle they are
aligned so you just click on this and the blocks will be aligned then you
click somewhere else and it will you are ready to simulate now you can start the
simulation here or you can change or you can set the parameters of these
components so the parameters of these components can be set by going into
first click on the block you want to set and in the simulation go to setup in
setup when you go here now you can set these parameters here so for example
final integration time means how long you want the simulation to run 10 second
30 second or 30 second so you don't need to set any of these but there are option
available for example these are the solvers these are the numerical methods
which the software will use to solve this block so there are different values
available you can try different and if you want to go back to default you can
press the default for example you go here you use the renji Kuta method and
then you come here then you want the default one we just click default and it
will be selected similarly if you click on clock go to simulation and setup then
you can set the parameters of this clock in this way you can set the parameters
so for example here instead of this one and one if you want to put some variable
for example instead of one you want to put K in the numerator and some time in
the denominator first you put this by editing these blocks you put here in the
numerator you put K for example and in the denominator you can put instead of
one you can put T and then after this you can just go here and by clicking on
this go here set core text and then you can assign the values to those those K
and T or whatever variables you are taking you can assign values here so in
this way you can do some parameter setting and some value assignment two
variables in this working window before we start a simulation let me explain to
you a little bit about what is this transfer function
what should be the response when we connect these three scopes what should
we expect where should we what are we looking for here so that I will explain
now so this is the transfer function of the system transfer function is the
output of the system divided by the input of the system in s domain so s is
a complex number and we cannot explain everything here but let's say that this
is the transfer function of your control system so you have a numerator and you
have a constant term so this numerator you can say it's a K its general form in
the general form it's a K at the gain of the system and this constant term you
can say it's a a so when we say step input it means we commanded the system
to go to the value equals to 1 it's a unit step so one so system should follow
our command and system should start from 0 and it should reach the value of 1
because the system has some dynamics so it cannot go straight away to 1 like
jump from 0 to 1 so system will follow a certain path and it will reach the
position 1 so it will follow a curve so if you draw a tangent at the point 0 of
this curve you will get the value of a it is the reciprocal of the time
constant or it is also the initial slope of this curve so this is the first order
systems first order system will go like this the second arrow system will not go
like this and when we say the first order system and second order system it
means power of the S if the maximum power of s is 1 it is a first order
system and what is the time constant the time constant is the time in which the
system reaches 63 percent of its final value so the final value is 1 so the 63
percent that one is 0.63 and if you drop it like here you will see that this is
0.5 0.5 means 1 divided by 2 this is 2 so it means 1 divided by a so that is
the constant the time constant of the system is the time in which the system
reaches 63 percent of its final value and this parameter is very
important because if you know the transfer function of any system you can
apply control theory and then you can say a lot about those system your
understanding of that system becomes almost complete if you know the transfer
function of the system but the problem is finding a transfer function is not
always easy because this transfer function comes from differential
equations and those differential equations are hard to make so therefore
there is another technique that is called system identification and in
system identification we we analyze the system using this curve if the system is
following the curve which looks like a first order system then we see okay this
is the curve and how can I get the value where the system is reaching 63% of the
final value so this is the time constant of the system then we get the a then we
see the ratio of this K to a which is the final value the final value is 1
which is the ratio of this numerator to the constant term K divided by is 1 so
then we can actually identify the system we can identify means that we can get
the transfer function of the system just by giving it a step input and looking at
the response of the system we can find the value of a and we can find the value
of K and we can make this equation we can make the transfer function equation
and this is very important and this technique is called system
identification I am NOT going into detail of system identification but I am
just telling you that why this curve is so important so now let's take another
example where K is different than a in this example the transfer function is 6
to 80 by s plus 2 so no K is changed K is 6 but a still to know the system's
value the final value which is K divided by s 6 divided by 2 is 3 now the final
value of the system is 3 and the time constant is still the same this is the
step response of this transfer function I plotted it for a very long time as you
can see 400 seconds but then I zoomed it and I just cropped the image and I
cropped for only initial part of the image so that I can clearly show you
otherwise the curve will not be very prominent so
oh no let's say that we don't know anything we don't know anything about
this system we only have this curve so from this curve we can find K and we can
find a by looking at the 63% of the final value and the final value itself
we can find K and a and and week hence we can find this equation which is the
transfer function of the system and now in simulation what we will do we will
take any transfer function we will apply a step input and we will get this
response this is what we will be doing in our simulation in the next video