# Understanding Control Systems, Part 4: Simulating Disturbance Rejection in Simulink

From the series: Understanding Control Systems

Hello! in this video, I’m going to simulate a car maintaining a certain speed. Ok, not like that. I’m going to use Simulink, which is a block diagram environment that lets us model our physical system visually, and then simulate it.

Here, you see a screenshot taken from the previous video where we used the car example. We want to control the speed of our car, keeping it steady at 20 m/s. First, I want to look at the open-loop system response. I’ll start with simulating this part which consists of the actuator and the plant. In order to model a system in Simulink, you use blocks from Simulink Library Browser. There are different add-ons. Here, I’m going to use a custom library that I’ve previously created and imported to this library browser. In my custom library, I have preconfigured blocks. If you want to look at what’s inside these subsystems, this demo model is available online. Download it by clicking the link below this video.

Using blocks from this library, I create the open-loop system. I’ll start with an input of pi/18 radians. This corresponds to 10⁰. To see how my speed changes when I press down the gas pedal by 10⁰, I’ll hit the play button and simulate this system. Here is my input of 10⁰ or pi/18 radians. And the speed converges to, if I zoom in here, approximately 6.6 m/s, but my goal was to get to 20 m/s, which means I need to press down further on the gas pedal. For an input of 10⁰, I get 6.6 m/s. I know that this is a linear system; therefore, to get to three times the current speed of 6.6 m/s, I need to triple the input. I increase the angle from 10⁰ to 30⁰ or pi/6 in radians and re-simulate my model. This is my input of 30⁰. As expected, my speed converges to the desired speed. Now I have tuned this open-loop system to make the car go 20 m/s, which is what we wanted.

Until now, I’ve been assuming that the car is driving on a flat road. But what if the car climbs a hill? Will it still be able to maintain the correct speed? To answer this question, I will simulate the car going uphill. When climbing the hill, there’s an additional disturbance force acting on the car. To address that, I’ll add this disturbance to my model. I’ve preconfigured this disturbance block such that the disturbance acts at 200 seconds. So, to see the effect of the disturbance in mu simulation I’m extending simulation time to 400 seconds. If I simulate my system now, I see that my speed drops significantly while going uphill. This means the open-loop system fails if there’s a disturbance acting on the system.

Are you with me so far? Don’t go anywhere yet because we came to the most exciting part where we’re going to close the loop and then the magic will happen. The simulation showed that open-loop fails in the presence of unpredicted disturbances.

However, we’re all set, because we already know from the previous videos that the solution to this problem is to use feedback control. So, that’s what I’m going to do next. I’ll close the loop using the pre-configured blocks from my custom library and simulate the closed-loop system. Noise enters the system through measurement. For realistic simulation results, I make sure to add noise to my model. I set the desired output to 20 m/s as this is the speed that we want to maintain. Once the feedback control system is ready, I hit the play button to simulate it. As opposed to open-loop control, we see that feedback control compensates for the disturbance. To gain insight into how it deals with the disturbance, let’s take a look at the error and the pedal position signals. The reason that open-loop control can’t compensate for the disturbance is that it only provides a static input to the actuator. But in the presence of a disturbance, like if we’re going uphill, we need to press down further on the gas pedal. This means we need to change the input to the actuator dynamically instead of keeping it constant. And this is exactly what feedback control does. The controller sees that the error is growing when there’s disturbance. And it increases the signal to the actuator, which in turn increases the engine force and the speed of the car. And in this way, the error is pulled back to zero.

I hope you learned little more about how you can simulate a control system in Simulink. In the next video, using Simulink we’ll simulate robustness to system variations.

#### Product Focus

Recorded: 29 Nov 2016

#### Related Products

Control System Toolbox