Learn how to create a simple closed-loop system to implement a low-pass filter.
- [Instructor] For our last example in Simulink, let's create a really simple lowpass filter. Creating filters is a really common use for Simulink. I'm going to head into my model here, and delete our sine wave, open up our library browser, and let's search for transfer function. There we go. I'm going to click and drag this transfer function block, one over S plus one, into our model. And let's open up our library browser again. And we're going to need a summation block, so I'll search for sum, drag that in.
And lastly, we'll need an input to our system. Let's just grab a step input. That's a pretty typical input used to test a closed-loop system. So grab the step block here, and drag it in. So I'll go ahead and connect up our step function to our summation block, the output of our summer to our transfer function, and the output of the transfer function to the scope. If I go to the center of the line here, hold down control, and drag, I can make another branch that comes off of that line.
I'll connect that into our summation here, and make it look a little bit prettier. There we go. Now if you've done any control systems or filter design before, you'll know we don't want to sum our feedback loop here. We want to subtract it. So if I double-click on our summation block, I can take that second addition sign, and make it a subtraction. There we go. We see now we're subtracting. And if we open up our transfer function block here, we can see that it really is set to be one in the numerator, and two ones in the denominator, so S plus one, which is a very simple lowpass filter.
Often when we're working with systems like this, we want to see the input and compare it to the output. So I'm going to go to my scope here, double-click it, and when my scope pops up, I'm going to click on the gear. And say that we want the number of input ports to be two. Click okay. And now we can see we've got another input on our scope. I'm going to go ahead and delete the wire coming off of our transfer function, hold down control and connect it up to the bottom input of the scope, hold down control again, go to the output from our step function block, and drag that into our scope.
That just keeps the wires looking a little bit cleaner. All right, let's check out our step function block here. And we can see that the step will be initiated at the first step of our simulation. Let's give ourselves a little bit more time to look at it. Let's set that to three. And I'll hit okay. Let's go ahead and run our simulation. Opening up our scope. Super cool, we can see the input here in yellow, and we can see the output of our lowpass filter here in blue.
So this is a very simple example, but this is how you can get started with closed-loop systems in Simulink.
- Creating MATLAB variables
- Working with matrix and scalar operations
- Using if statements and loops
- Creating functions
- Importing data
- Building basic plots and 3D plots
- Working with images
- Creating Simulink models