Tuning a PID Controller When a Plant Model Is Not Available
By Arkadiy Turevskiy, MathWorks
As control engineers know, having an accurate plant model is critical for designing a controller with high performance and robustness. If a plant model is already available (in the form of a transfer function, state-space representation, or Simulink® block diagram), then tuning PID controller gains is straightforward. But what if no plant model is available and you cannot easily create one from first principles? Maybe the system you have to control is too complex to model, or you do not have enough insight into the physics of the system. Is your only option, then, to tweak the gains on the actual hardware, hoping you do not damage it in the process?
Luckily, the answer is no. In situations like that, you can use system identification. With system identification you create a mathematical model describing a physical system from measured input-output test data. Practicing controls engineers are sometimes intimidated by system identification because it is typically taught only in graduate-level controls classes, and some engineers believe they need a Ph.D. in controls to use system identification techniques.
This article describes a workflow for creating a plant transfer function from input-output test data and using this transfer function to automatically tune PID controller gains. The entire workflow is completed using the PID Tuner app in Control System Toolbox™.
Plant Modeling and Control Design Challenge
Let’s suppose that we cannot create a plant model using first principles because we do not have an understanding of the physics of the system, but we do have access to the actual hardware. This means that we can run excitation signals through the system and record the input-output data. We will use this measured input-output data to create a plant model, and then use this model to tune PID controller gains so that the PID controller provides a fast and stable response.
Workflow for System Identification and Control Design
The workflow consists of three main steps:
- Import the input-output test data.
- Identify plant model from the data.
- Use the identified plant model to tune PID controller gains.
Importing Input-Output Test Data
Input-output test data is shown in Figure 1. To excite the system dynamics, we inject a step change into the system at 5 seconds and record the output (available as a variable
output in MATLAB workspace). Visual analysis of the output data shows that it seems to capture changes in system dynamics. Step input is a common way to excite system dynamics, but other excitation signals can be used instead.
We begin by importing the measured input-output data into the PID Tuner. To do that, we launch PID Tuner app, either by typing
pidTuner at the MATLAB command line or by selecting the PID Tuner app in the MATLAB apps gallery. When the PID Tuner opens up, we select the option to identify a new plant from input-output data, and we specify the output and input signals (Figure 2). Because our input to the system is a step signal, we specify characteristics of the step signal that we injected into the system and the data where the measured output signal is stored. The tool also supports import of arbitrary input-output data.
Identifying a Plant Model
Once we have imported the data, we are ready to use System Identification Toolbox™ to create a plant model. System identification involves choosing a plant model structure and parameter values for that structure that will make the simulated model output match the measured output data. PID Tuner provides the capabilities for preprocessing the measured data, selecting a model structure, and adjusting model parameters until the simulated model output matches the test data.
We will not discuss data preprocessing in detail here, but will just mention that we removed the offset from the measured output data (Figure 3). The green line in Figure 3 shows the measured system output. Note that this line starts at 0, while the measured output data in Figure 1 starts at around -2. This is because we preprocessed the measured output data by removing an offset, a common technique in system identification. PID Tuner includes other data preprocessing capabilities, such as filtering and resampling.
We now need to select the model structure and adjust the model parameters until we have a good fit between the measured system output and the response of the identified plant model. The blue line in Figure 3 shows the initial response of the identified plant model (with default model structure and default model parameter values). We need to adjust the model to improve the fit between the blue and green lines. We can quickly try different model structures by selecting from a drop-down list in the PID Tuner. The choices include one pole, a pair of real poles, a pair of underdamped poles, and a state-space model of a chosen order. We can also specify whether the model should include time delay, zero, and an integrator.
Once we have selected the model structure we can adjust parameters interactively or let the PID Tuner automatically compute parameter values for a given model structure. For the measured output data in our example we obtained a good fit by using a first-order model with time delay (Figure 4). If we did not get a good fit with this low-order transfer function, we could easily try fitting a higher-order model to the data. We would simply select a higher-order model from the dropdown list. PID Tuner would automatically estimate the parameter values.
Tuning the Controller
Now that we have identified a plant model, we can use it to tune the PID controller gains. The PID Tuner automatically computes controller gains to provide a fast and stable response. We can use interactive sliders to adjust closed-loop performance. In our example, in addition to designing a fast and stable controller, we need to make sure that the controller output sent to the actuator does not exceed the maximum value that the actuator can provide. This is why we added a controller effort plot to the closed-loop step response and used the sliders to achieve the desired performance—fast and stable response that does not place unrealistic demands on the actuator (Figure 5).
We can now export the tuned PID controller to the MATLAB workspace for further analysis and design.
Published 2014 - 92234v00