What Are LTIs? Linearizing Systems Made Easy with MATLAB and Simulink
Linear time-invariant systems (LTIs) are exactly what you would think they are: systems that are linear and time-invariant. Linear time-invariant systems are some of the easier systems to model because the inputs and outputs have a linear relationship that doesn’t vary based on the input that is given. However, very few systems are naturally linear and time-invariant; with MATLAB® and Simulink®, you can create linear representations of your system to aid in control design.
Published: 30 Aug 2023
Control systems, they're all around us. They underpin everything from energy processing at wind farms to airplane autopilots to managing the temperature in your refrigerator. Each of these systems require controllers to help them behave and respond to their environment. The popular way to design these controllers is with linear time-invariant representations of these systems.
What are LTI systems? Linear time-invariant systems are systems that are linear and time invariant. Thanks for watching. For more information-- I'm kidding. But actually, it is exactly what it says on the tin.
For a system to be linear, the inputs and outputs have to have a linear relationship as opposed to a nonlinear relationship like exponential or logistic or random. For a system to be time invariant, the outputs have to not vary based on the time the input is provided. For example, an input at 9:00 PM has the same output as the same input at 9:00 AM.
If that doesn't quite make sense, I like to think of an LTI system like the plunger on a magical pinball machine. This magical contraption isn't rigged and can't be broken. When you pull and release the plunger to launch the pinball, you extend and release the spring attached with perfect accuracy.
This means the amount of extension, i.e. how hard the plunger is pulled, has a directly proportional relationship with the amount of force on the pinball. It's linear because how hard you pull the plunger is how fast the ball moves. The system is time invariant because it doesn't matter if you launch the pinball first thing in the morning or last thing at night. The machine is going to behave the same way every time.
But obviously, this is a pinball machine that couldn't exist in reality. If someone pulls too hard on the plunger, the spring will break. Worse yet, there's a range of force that doesn't break the spring but just deforms it, changing the relationship between how hard the plunger is pulled and the force on the pinball. While the relationship is linear within the elastic limit of the spring, the relationship between how hard the plunger is pulled and the force on the pinball isn't actually linear.
However, we can model the spring of a regular pinball machine as an LTI as long as we model it within the elastic limit of the spring. We can make sure our spring with said elastic limit can handle the range of human strength and hope our pinball machine doesn't get too popular amongst silverback gorillas.
Why design controllers with LTI systems? Well, to quote Brian Douglas quoting Richard Feynman, "Linear systems are important because we can solve them." This isn't to say that we can't use nonlinear systems for control design. It's just that linear systems are significantly easier to model and work with. We can get to a linear or linear time-invariant representation of a nonlinear system by using transfer functions.
Transfer functions are derived using differential equations and the Laplace transform. If you're anything like me, the phrase differential equation sets off your fight-or-flight response. Learning diff EQ was hard enough the first time around. And I'm not doing it again. Fortunately, with MATLAB and Simulink, you don't have to derive the transfer functions yourself. The computer does it for you. Let's take a look at using Simulink in a real-world example.
In this example, we have a water tank. And we want to maintain a particular water level in the tank. Essentially, our system is made up of a water tank and two valves, one that lets water in and one that lets water out, and a sensor inside that tells us our current water level.
Here's what the overall model looks like in Simulink. If we double click the water tank, we can see the system equations for the tank. The input to the system is the voltage to the valves, which determines by how much the valve should be opened or closed. And the output is the measured height.
If we go back to the top-level model, we can see that the water height is fed back into the system. So we can compare it to our desired water height. Based on that difference, we feed the value into the controller to generate a particular voltage for our valves in the water tank system.
Now, this is a simple nonlinear system. You can see here that there's a square root in the system of the tank. Having a linear model of this system makes it easier to tune a controller, such as a PI controller. The first step to linearize this system is to specify linear analysis points, in our case, with the input of the voltage and the output of height.
We left click the signal here, and set analysis points, and then go to the app section of the tool strip, and select the model linearizer. As one might suspect, this app helps us get linear representations of our nonlinear systems to aid in control design.
In the model linearizer, we need to select the operating points. In this case, we're OK with linearizing the system with the initial water level of the tank. And so we select the model initial conditions from the dropdown.
When we linearize the system at this operating point, we get the linear representation as a state-space model. However, we can convert this state-space model into a transfer function by exporting it into MATLAB and using the ss2tf function.
With the transfer function, we can create a new model where the water tank system is represented with an LTI. We place an LTI block in our model and call the LTI model from our MATLAB workspace. After the system has been replaced, we can bring over components from the previous model and tune our controllers.
Now we have a linear representation of our model that we can use to do control design and analysis in MATLAB and Simulink. But you don't even need to go to that much trouble to tune a PID controller. The PID tuner app does the linearization and tuning for you automatically. But now that we've seen the workflow in a simple system, let's take a look at the same process in a more complex system.
In an engine control system, the goal is to maintain a particular number of engine revolutions per minute in relation to how hard the driver is pushing down on the pedal. As one can imagine, an engine control system has significantly more going on than just a tank with two valves. Let's take a look at the system in Simulink.
Our input is the throttle angle. And our output is the engine speed. We have four separate systems, throttle and manifold, induction to power stroke delay, combustion, drag torque, and vehicle dynamics. We're trying to design a controller that gives the desired engine speed for a particular throttle input. To achieve this aim, we need to design a PI controller for this complex nonlinear system.
However, unlike, say, water valves, the system dynamics of our system varies at different engine speeds. Tuning a single PI controller would not provide a good controller performance across the operating range of the engine. So we need a gain-scheduled PI controller that can adapt the gains depending on the engine speed.
In order to do that, we need to generate LTI representations at different operating points of the engine and use it to tune PI controllers. Let's take a look at how to do just that.
The premise is the same. We put the linearization points at the inputs and outputs of the model. Before we can run the model linearizer, we need to select an operating point. In this case, we choose the operating point of six seconds. Six seconds is when the engine is in a steady state.
Now that we have the operating point and linearization points, we can run the model linearizer. But a model for just six seconds isn't enough. We need a linear representation at two throttle inputs, maybe one at 8 degrees and one at 20 degrees. At 8 degrees, the engine settles at 6 seconds and at 20 at 14 seconds.
We are going to shift the operating points to 6 and 14 seconds. We get two models by running the linearizer. And we can use the models between these points to get a linear representation of the system.
But this is all well and good if you happen to have a Simulink model of your system. What if you don't have time to construct a model or bought an engine from a manufacturer and don't have knowledge of the inner workings of the engine's system?
We can put some gas in the engine, fire it up, press the throttle, and record the engine speed at different throttle positions, giving us a set of inputs and outputs to work with. Once we've imported the data into MATLAB, we can do system identification to fit transfer functions to the data.
We can let the PID tuner automatically fit a transfer function, or we can do it ourselves graphically. When we run the PID tuner, we can fit the model by sight. Just click the curve, and bring it to the response data.
So that's the bird's eye view of LTIs. Obviously, as is the case of anything modeling related, things can go horribly wrong. When troubleshooting your system, I encourage you to check out the documentation on LTIs in Simulink and the documentation on the demos we did.
For more information about controls design, please check out our series on understanding control systems and our series on control systems in practice. If you enjoyed this video, please click that Like button, and subscribe to the MATLAB channel for more videos like this. Thanks for watching, and happy Simulinking.