Proportional-integral-derivative (PID) controllers are ubiquitous. Designing and tuning them may appear simple in theory, but it can be difficult and time-consuming in practice. A common method of tuning PID controllers is to manually adjust controller gains while the controller runs the plant. This time-consuming method requires access to the plant hardware and can lead to plant damage if chosen gain values result in unstable plant behavior. In this article we show how a development process can be improved by using Model-Based Design to systematically design, test, and implement PID controllers on programmable logic controllers (PLCs), programmable automation controllers (PACs), and microprocessors.
With Model-Based Design we use a block-diagram environment to create system models of the plant and controller. These models can be simulated, allowing us to quickly iterate and refine controller design before it is implemented and deployed. The need for access to plant hardware is reduced because we can do a lot of testing through simulations instead of involving the plant. Early verification through simulation ensures that the controller performs as expected when deployed to the actual plant.
Model-Based Design of PID controllers involves the following four steps:
Creating the plant model
- Designing the PID controller
- Testing controller in real-time
- Implementing design
Using a digital-motion control system as an example, we describe how to apply Model-Based Design for rapid design and prototyping of a PID controller.
Digital Motion Control System
Figure 1 shows the plant, or the physical system, that we are trying to control.
Figure 1: Picture of the digital motion control system.
That plant consists of a power amplifier driving a DC motor and two rotary optical encoders for measuring the position of the motor shaft and the load. The motor is connected to the load through a small flexible shaft to approximate the compliance found between the actuator and the load in many motion control systems. The control system ensures that the load follows the specified trajectory by measuring the error between the commanded and measured load angle. It then uses a PID controller to calculate and send a voltage request to the motor. Our design is to improve machine performance from the current maximum speed of 150 rad/sec and acceleration of 2000 rad/sec^2 to new speed and acceleration targets of 250 rad/sec and 5000 rad/sec^2, respectively. We want to achieve these performance gains without losing any position accuracy. Specifically, we want the error between commanded and measured load angle to be less than one degree. The existing controller design does not meet the new performance specifications, as shown in Figure 2.
Figure 2: Old controller design with a maximum position error of more than 4 degrees (bottom) when trying to follow reference trajectory (top, red line – commanded load angle; yellow line-measured load angle) corresponding to new speed and acceleration targets. The performance specification is for the error to be less than 1 degree.
Instead of manually tuning PID gains on the actual plant hardware, we can use Model-Based Design to develop, test, and implement the controller.
Creating the Plant Model
There are two primary approaches for creating a plant model: data-driven modeling and first-principles modeling.
With data-driven modeling we create a plant model that fits measured input-output test data. We want to operate the controller during data collection to ensure minimal disruption of plant operation. To collect the input-output data, we add as our input signal a random white noise signal onto the voltage fed to the DC motor. Our output signal is the overall voltage that the controller commands to the DC motor. After we collect this input-output data, we can calculate the frequency response of the closed-loop system. And because we know the exact gains in our current controller design (the one we are trying to improve), we can obtain the frequency response of the plant. Finally, to be able to simulate our controller in the time domain, we use the frequency response of the plant to estimate the plant transfer function using system identification techniques.