When we talk about feedback systems, we can get caught up thinking solely about the relationship between the reference signal and the output. You know, how well is the system going to follow our commands? However, if we want to fully understand how a feedback system behaves, we actually need to look at four different transfer functions. And if our system has a feed-forward path, then this expands to six. Now the goal of this video is to provide a little intuition around why we need to look at more than just a single transfer function to fully capture the properties of the system.
And it's not going to be all mathematics. I'm also going to demonstrate some of these concepts with some hardware at the end. So I hope you stick around for it. I'm Brian and welcome to a MATLAB Tech Talk.
If you want to dive deep into the mathematics of the gang of four and gang of six transfer functions, you should definitely check out the books. and other references by Professor Carl Astrum. I've linked to one particularly good chapter in the description below. But here's a quick overview of what he talks about so that we can set the stage for the rest of this video. Here is a basic block diagram of a feedback loop.
We have the process that we want to control, which we'll define with function p. There's the feedback controller c, and in this case we're going to add a feed forward controller f. Now the output from the controller is the control variable u and it's the mechanism that we have to impact the state of the system. The external input is the reference and the output is y.
When we draw a single input single output block diagram like this it's easy to focus just on this one overall transfer function. The transfer function that goes from the external input r to the output y. And from this, we can determine the stability of the system and how well it tracks the reference, which are both good things.
However, there are two other external inputs that we need to consider. One is the external disturbances that come from the environment and physically impact the state of the system. For example, in a car, the steering wheel, gas, and brake pedals are the controlled inputs that can affect the car's position and velocity.
But external disturbances like potholes and wind gusts can also affect the car's position. can also change it as well. Now the other external input into the system is noise, which is introduced when we measure the system states.
The process has a state x, but in order for us to know that state we have to measure it, and that measurement has error. So the output y is some noisy approximation of the true system state. And it's important to note that a disturbance directly changes the system state.
It's something physical like a force or a torque. But noise isn't that. Noise just changes our understanding of what the system is doing. But through feedback, our controller then uses that noisy estimate to change the control input, which does change the system state.
So in this way, both noise and disturbances have a physical impact on how the system behaves. With this understanding, we can now ask ourselves additional questions like how sensitive is our system to noise? And how sensitive is it to disturbances?
And how sensitive is the system to process variations? That is, the difference between how the process really behaves and how we've modeled it. And answering these questions can be accomplished by looking at the different relationships between each of the external inputs and each of the system signals that we're interested in.
For this feedback loop, we have three external signals. The reference, the disturbance, and... the noise. And there are three internal signals that we typically care about. The state x, the output y, and the controlled variable u.
So we can determine the transfer functions between each of these inputs and each of these outputs to get the following nine relationships. And with these equations, we now have a way to analyze things like the step response or the frequency response to see how You know, for instance, how noise impacts the state of the system, or how disturbances impact the output. All of the design questions we just asked at the beginning are wrapped up in these nine relationships. But if you look closely, you'll notice that there's really only six unique relationships here.
These are the so-called gang of six transfer functions. And if you're working with a pure feedback system, or in other words, we set the feedforward term f to one, or you know just take it away then these six transfer functions condense down to four the so-called gang of four And these have names like the noise sensitivity function, and the disturbance sensitivity function, and the sensitivity function, and the complementary sensitivity function. There's a lot of sensitivities in these names, but the specific names aren't terribly important as long as you understand what each transfer function is telling us. And I think we get that nicely laid out in this long form, which is why I have a slight preference for looking at it this way. rather than trying to remember what the complementary sensitivity function means.
We can just look and see which transfer function represents the relationship between any input and output that we're interested in analyzing. And what's great about this is that it gives us a way to change the feedback loop in particular locations such that we target the design criteria that we're interested in. Do we want to affect how sensitive the system is to disturbances?
Then we need to look at the transfer function p over 1 plus pc. Do we want to affect how the system follows a reference signal? We need to look at PCF over 1 plus PC. Now adjusting the loop by looking at the frequency response and shaping the response to something that is desired is called loop shaping.
Now something to note here is that every single one of these transfer functions have the same denominator, 1 plus PC. This means that system stability can be determined by looking at any one of these. If the system is unstable, then any input-output relationship that you look at is going to also be unstable.
The only thing that's changing is the numerator, which tells us how the specific output responds to a specific input. But as you can see from these functions, when we change one aspect, we're affecting the others as well. For example, changing the controller impacts every single one of these.
And if you change the controller to limit, you know, say the impact of high frequency noise, then you're necessarily impacting the system's ability to follow high frequency reference signals. In this way, it's impossible to build a system that simultaneously has perfect reference tracking, perfect noise rejection, perfect disturbance rejection, and low sensitivity to process variations. It's a situation where we have to rob from one to give to the other.
So there's a balance that has to be struck between these requirements. And these six equations give us a way to analyze and design our system to strike that balance. Okay, so that's the overall mathematical justification for the Gang of Six. But at this point, I want to show you visually how changing different parts of the feedback system impacts the overall behavior. I want to show you that it can be intuitive why changing the feedback controller, you know, versus the feedforward controller, changes how a system responds to disturbances or to the reference.
That way you hopefully won't get too scared off by the transfer functions and realize instead that they are understandable in their physical applications. For these examples I'm using the Kwanzaa Cube Servo 2. Now on top of this box there's this little attachment point that rotates around and it's driven by a motor that we can control. There's also a rotary encoder inside the box that measures the angle of this attachment head. So we can apply a torque to this with the motor. and then measure the angle with the encoder.
And I'm going to attach the pendulum head, which has a rotary arm and a freely rotating pendulum. There's also another rotary encoder built into this, which measures the angle of the pendulum, so we have to plug it in if we want to read this value. Now, one way to operate this is as an inverted pendulum, where we command the motor to rotate the rotary arm in a way that gets the pendulum to stand upright. However, for this, We're going to just stick with a regular pendulum and treat its motion as a disturbance. So I'm going to unplug the pendulum encoder so that the cable doesn't get in the way, and we're not using that value anyway.
Now the idea here is that the pendulum oscillates at nearly a fixed frequency. It's natural frequency. And that oscillation causes a disturbance on the rotary arm itself.
Therefore, if we set up a controller that commands the rotary arm to step back and forth, between two fixed angles, we're going to have to fight against the disturbance caused by the pendulum. So let's do just that. The Cube Servo 2 is connected via USB to my computer, and we're going to interface with it through Simulink.
And on the Simulink side, this is what the model looks like. This block with a picture on it is the connection to the hardware. The input U is the commanded motor voltage which gets sent via USB to the hardware which then reacts to that command and then the rotary arm encoder measures the angle and sends that angle back to the computer. The angle is then compared to the reference signal to generate the error in our system and I set the reference signal to step between minus 45 and plus 45 degrees every 10 seconds and then just do that indefinitely and then the error is fed into the controller which If we open it up, you can see that it's a simple PD controller.
Okay, that's the whole setup. And when we run this test, we'll just look at a scope comparing the reference to the measured angle. And up in the corner, we're also going to look at what the physical hardware is doing.
So, let's start it up. For this first test, I'm just going to run this system as is with no modifications, and we can see how the controller tracks the reference in the presence of the pendulum disturbance. Now, to run this model, I first have to build it for monitoring. Basically allowing the hardware in the loop to interface with Simulink. Then I have to connect to the hardware and finally I can run the test.
And there it goes. We can see that the arm is moving and the pendulum is oscillating and it's, you know, generally doing what we want. But you're gonna notice that sometimes there's no steady state error, but other times there is where the arm doesn't stop right where it's commanded.
This is because the voltage command isn't large enough to overcome the static friction in the system for this amount of error. I could tune the PD controller differently so that we could overcome this friction and have zero steady state error, but I tuned it this way intentionally because I wanted a controller that does a good job of highlighting the effects that the disturbance has on the system so that you can clearly see what's going on. And you can. There are oscillations in the angle of the rotary arm in the response which are caused by the motion of the pendulum.
Now, the reason the pendulum is oscillating is not because of some external force acting on it, but because our controller itself is driving the rotary arm at a frequency that is exciting the pendulum, or adding energy into that mode. And one way we may try to combat this is to add a notch filter in series with the controller. Basically, by doing this, we're not letting the controller change the voltage at the natural frequency of the pendulum.
which in our case is about 9.7 radians per second. So if we don't command the arm at this frequency, then we shouldn't add any energy into the pendulum. Let's check this out.
Again, to run the model I have to build and then connect and then run, but I'm going to just skip past these steps from now on to speed this video up. And check out this response. We've managed to reduce the oscillations of the pendulum with this modified system. The response now has some overshoot, But that's only because we've changed the controller structure, but we didn't retune the gains. And if you recall from the transfer functions, changing the controller C changes the denominator, and therefore the stability of the system.
We could retune this and reduce the overshoot, but that's not what I care about right now. The important thing that I want to point out with where we've placed the notch filter is that we've introduced a new problem by placing it in series with the controller. The controller itself doesn't add energy into the pendulum.
Great. But that also means it can't remove energy. If an external force causes the pendulum to oscillate, our controller won't be able to damp out that motion. And it makes sense if we think about the problem. Let's say an external force causes the pendulum to start oscillating at 9.7 radians per second.
The pendulum then acts on the rotary arm and causes it to oscillate back and forth at the same frequency. This angle is fed back and compared to the reference, which means that the error term has a 9.7 radians per second oscillation component, which is then removed by the notch filter. And so the controller doesn't see it, and it doesn't react. But let's say we do want our control system to be able to respond to disturbances and to reject those disturbances, but we don't want our commands to be the one responsible for causing them. To accomplish this, we can just move the notch filter into the feed forward path.
Here we're removing the troublesome frequency from our step command, but not impacting the feedback system as a whole. And we can mathematically see that this is the case by looking at the transfer functions from earlier. I already mentioned that when we changed the controller we affected all nine of the relationships, since the controller shows up in the denominator in each.
So if we're adjusting the controller to improve reference tracking or noise rejection, we're necessarily affecting everything. But the feedforward path only shows up in the reference transfer functions, which means with feedforward we have the ability to improve reference tracking without impacting the disturbance or noise rejection capabilities. So let's go see this in action. Notice that our step input now does this back and forth dance at the beginning. This is the result of notching the step input.
And we can sort of think of it this way. The reference steps very fast at the beginning to get the arm moving and then swings back to stop the motion of the pendulum and then comes back again to keep the arm moving. So it's this backward motion that is effectively keeping the pendulum from moving while still allowing the arm to step to the commanded angle.
And the pendulum does a better job following this reference. There's not a lot of disturbance oscillations and notice that the overshoot is back to where it was with no notch filter. This is because the feedback portion of this system hasn't been changed.
We're only changing the reference command which doesn't affect the system stability. We can look at the step response of the system without a notch filter and compare it to the system with a notch filter in the feed forward path and we can see how the two differ. And it might be a bit fast to see the difference, but if I slow it down you can clearly see that the notch filter causes the rotary arm to swing back and forth at the beginning, which causes the pendulum to oscillate less and therefore allows the system to settle faster.
So the notch filter helped. But putting it in the feed forward path has a benefit over putting it in the feedback loop like we did before. This system can still respond to and reject external disturbances at this frequency, which is pretty cool.
In fact, let me show you the difference between how well our system is able to reject disturbances between having the notch filter in the feed forward versus feedback loop. The system that is damped out quickly is the one where the notch filter is in the feed forward path. And the other is when it's in the feedback loop, in series with the controller.
And you can clearly see that one has better disturbance rejection than the other. So for this particular case with what we're trying to do, it makes more sense to adjust the feedforward controller rather than any other part of the system. But if we had other goals, we could have tried making a change in the feedback path in an effort to target measurement noise.
Or we could try to adjust the process itself to make it less sensitive to noise and disturbances. And one simple way to affect just the process is to remove the pendulum, for example. That would definitely remove the disturbance. And all of these adjustments can make intuitive sense if you sit down and think about your system. But the nice thing about the Gang of Six transfer functions, and why they're so important to look at, is that they give you a mathematical way to determine how to change your system to target noise or disturbances or whatever.
You can figure out, based on your requirements, how to change the process, or the controller, or the feed-forward path to get the desired results. So again, if you want to learn more, definitely check out the resources that I've linked to in the description. And I think nothing really helps solidify concepts in your mind better than just testing them out yourself.
So if you want to try this out on your own with Simulink and the Kwanzaa Cube Servo 2, I've linked to everything you need to know to get started. And that's where I'm going to leave this video for now. If you don't want to miss any future Tech Talk videos, don't forget to subscribe to this channel.
And if you want to check out my channel, Control System Lectures, I cover more control theory topics there as well. Thanks for watching and I'll see you next time.