This is a very simple model, but at this stage you're already all set to create your own models, but let's see how to create
Somewhat complex model yeah, so what are you thinking like a like a plant control?
Yeah, a very simple plant control model
That using some of the inbuilt blocks instead of building anything from scratch, so let's see how that can be done
Yeah, it's a pretty common application for simulant yes
So I'll just shift drag this block shift drag meaning
Holding shift and the keyboard button keyboard and then dragging it with my mouse
So that I can add other blocks now if I don't want this block in my simulation
I can simply delete it
but if I am Not sure I can also comment it out so that I can bring it into my
Simulation later if I need it so it's like commenting out lines of code right and in MATLAB
And you can see it's a similar indicator there right percentage sign
so it's as if it's deleted from your model exactly so when I'm running my
Simulations or generating code later on this block will be ignored by Simulink altogether, right?
But it's just there for my convenience if I just want to turn it on
It's just a single click. I can uncomment it from right here. Yeah, it's just the nature of
Building up models everything's not going to be perfect. You're gonna want to try new things right so you know
Oh, let me try something else
But I might want to go back to this so let me drag this off to the side comment it out
And maybe I'll refer back to it later, yeah
So let me bring in some
Additional blocks here, I can bring in a plant model
Which is essentially a transfer function as I search for it? I find it in the continuous library. I click it and
Bring a very basic transfer function for me. It's a first order transfer function with the denominator coefficients just one and one
Just to make it look slightly interesting. Let me change it to something like 1 5 6
That makes this a second order transfer function slightly
Interesting I can simply
Bring it and join it to the scope block if I'm still interested to monitor this signal
Which I which I am and change this to
plant
And you see this line is intersecting with the plant
I just created so I can simply click that signal and autoroute it so that will take care of
Not intersecting with the blocks, okay?
Okay, so now for the plant model. Let's bring a PID controller
And switch for it. It's available with the continuous library spring it in and
Plug it in
Between the source and the plant you can see how the signal connections are pretty straightforward
Simulink is
Smart enough to understand that if it is aligned with the right port you might want a pond connection
And it would just create a connection for you now one thing I would do with that signal that goes from the sine waves to
The scope I would actually drag it below right?
Yeah, you can yeah you you are free to move the signals around
But you can also let Simulink auto routed according to the algorithm for best optimizes
Exactly so
Once we are done with that. This is still an open loop control
You can run the simulation at this point and just see how it looks like
And also the other thing is we are using sine wave and that's probably not there. Yeah. Yeah, same way. It's not a very
It's tough to really track you can say you can say whether you
Probably a step input. Yeah, yeah, so let me delete the sine wave and bring in a step block from sources library, yeah
The default value is 1 so I'll leave the step time as 1 and just join it back to my model
Let's run the simulation now. It's still open loop control
But also not not very good cuz the blue is the reference and then
Yeah that yeah, that's not the best response
Yeah, so okay, so we want to have a closed loop system instead
yeah, so I bring a sun block sorry I
bring a
sun block here
and
With the intention of you're gonna take the error
you're gonna do a difference here, so yeah, I just look at the difference between the input and
So the output and so that the control signal is
Appropriately sent from the controller to the plan, okay, so once I hit that it changed the sign to - yeah
I would like to just
Drag it here, but there are since there are multiple ports
It would just not join it because it doesn't know which port to join it so in this case you actually have to sever this
Yeah in there, but but it's not that difficult. Just added move the blocks out a little bit if you like
And then take the signal back and connect it to the plant okay?
Bring that signal down here as well now this looks. Do you need yeah?
Yeah, and see how the controller behaves now. That's better. Yeah. I still wouldn't say that. That's
Perfect or ideal or right? Yeah, we could do better than that yes. Yes for sure