Model Predictive Control in LabVIEW
Model Predictive Control in LabVIEW
Model Predictive Control in LabVIEW
Faculty of Technology, Postboks 203, Kjlnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Preface
Model Predictive Control, or MPC, is an advanced method of process control that has been in use in the process industries such as chemical plants and oil refineries since the 1980s. Model predictive controllers rely on dynamic models of the process, most often linear empirical models obtained by system identification. Model predictive control (MPC) refers to a class of computer control algorithms that utilize an explicit process model to predict the future response of a plant. At each control interval an MPC algorithm attempts to optimize future plant behavior by computing a sequence of future manipulated variable adjustments. The rst input in the optimal sequence is then sent into the plant, and the entire calculation is repeated at subsequent control intervals. Originally developed to meet the specialized control needs of power plants and petroleum reneries, MPC technology can now be found in a wide variety of application areas including chemicals, food processing, automotive, and aerospace applications.
Programming tools like, e.g., MATLAB (Model Predictive Control Toolbox) and LabVIEW (Control Design and Simulation Module) has MPC functionality. DeltaV, which is a DCS (Distributed Control System) system has MPC functionality (DeltaV Predict/ DeltaV Predict Pro). These are just a few examples, but mentioned here because these tools and systems are availble at TUC.
In this Tutorial we will use the Predictive Control functionality which is part of the LabVIEW Control Design and Simulation Module. The scope with this Tutorial is not to go in depth of the theory behind MPC, but to use and give an overview of the MPC implementation in LabVIEW.
Table of Contents
Preface...................................................................................................................................................... i Table of Contents .....................................................................................................................................ii 1 Introduction to Model Predictive Control ...................................................................................... 3 1.1 1.2 1.3 1.4 1.5 1.6 2 3 Introduction ............................................................................................................................. 3 Prediction and Control Horizons ............................................................................................. 4 Model ...................................................................................................................................... 5 Cost Function ........................................................................................................................... 6 Constraints .............................................................................................................................. 7 MPC vs. Traditional Control (PID) ............................................................................................ 8
LabVIEW Control and Simulation Module .................................................................................... 10 MPC in LabVIEW ........................................................................................................................... 12 3.1 3.2 3.3 Example 1: Simple 1. order Model ........................................................................................ 12 Example 2: Model with Time Delay ....................................................................................... 15 Example: Multiple Inputs ...................................................................................................... 18
ii
Model Predictive Control (MPC) is a control strategy which is a special case of the optimal control theory developed in the 1960 and lather. MPC consists of an optimization problem at each time instants, k.
The main point of this optimization problem is to compute a new control input vector, , to be feed to the system, and at the same time take process constraints into consideration (e.g., constraints on process variables). An MPC algorithm consists of: A Cost function Constraints A Model of the process
Control horizon ( ) The number of samples within the prediction horizon where the MPC controller can affect the control action. Note!
For time the MPC controller predicts the plant output for time that the control action does not change after the control horizon ends.
The rst input in the optimal sequence is then sent into the plant, and the entire calculation is repeated at subsequent control intervals. For each iteration the prediction horizon is moving forward in time and the MPC controller again predicts the plant output.
Prediction horizon: A short prediction horizon reduces the length of time during which the MPC controller predicts the plant outputs. When the prediction horizon is short the MPC controller works more like a traditional feedback controller. A long prediction horizon increases the predictive ability of the MPC controller, but the performance poorer due to extra calculations. Control horizon: A short control horizon means more carefully changes in the control action. A long control horizon means more aggressive changes in the control action.
1.3 Model
The main drawback with MPC is that a model for the process, i.e., a model which describes the input to output behavior of the process, is needed. Mechanistic models derived from conservation laws can be used. Usually, however in practice simply data-driven linear models are used. In MPC it is assumed that the model is a discrete state-space model of the form:
( Where: Prediction horizon Setpoint Predicted process output Predicted change in control value, Output error weight matrix Control weight matrix
This works for MIMO systems (Multiple Input and Multiple Outputs) so we are dealing with vectors and matrices. For a scalar system we have: ( )
By solving this we get the future optimal control. Solving is quite complex and will not be part of this tutorial, but in the figure below we see
1.5 Constraints
All physical systems have constraints. We have physical constraints like actuator limits, etc. and we have safety constraints like temperature and pressure limits. Finally we have performance constraints like overshoot, etc. In MPC you normally define these constraints: Constraints in the outputs:
Note! The MPC controller takes all these constraints into consideration when calculating the future controls.
No knowledge about constraints Setpoint far from constraints Not optimal process operation SISO systems A mathematical model is not needed
Constraints included in the design Setpoint can be closer to constraints Improved process operation MIMO systems A mathematical model is needed
The models used in MPC are generally intended to represent the behavior of complex dynamical systems. The additional complexity of the MPC control algorithm is not generally needed to provide adequate control of simple systems, which are often controlled well by PID controllers. Common dynamic characteristics that are difficult for PID controllers include large time delays and high-order dynamics. Another advantage of MPC is that cross coupling in multiple input and multiple output (MIMO) systems are taken into consideration in an optimal way. MPC is a simple method for controlling MIMO systems.
10
11
You use the CD Create MPC Controller VI to create an MPC controller. This VI bases the MPC controller on a state-space model of the plant that you provide. The CD Implement MPC Controller is used to calculate the control values for each sampling time and is normally implemented in a loop, e.g., a While Loop.
3 MPC in LabVIEW
In this chapter we will use the Vis in the Predictive Control palette in in some example.
Results:
12
13
MPC in LabVIEW
Setpoint Profile:
14
MPC in LabVIEW
Block Diagram:
We can divide the solution into 2 different parts: Initialization the MPC Controller: This is something we do only once when we start the program. We use the CD Create MPC Controller.vi.
15
MPC in LabVIEW
Run the Controller: This operation is performed each sample, and this is normally executed inside a loop, e.g. a While Loop. We use the CD Implement MPC Controller.vi.
[End of Example]
16 We set , and
MPC in LabVIEW
The MPC algorithm requires that the model is a linear state-space model, but the time delay causes problems. A solution could be to transform the differential equation we have to a transfer function. Then we can use built-in functions in LabVIEW to convert it to a linear state-space model. We use Laplace on the differential equation above: ( ) ( ) ( )
Note! We use the following Laplace transformation: ( ) ( ) This gives: ( ) Next: ( )( Next: ( ) ( ) Finally: ( ) With values ( , , ): ( ) LabVIEW application: We can use the CD Construct Special TF Model.vi in order to create the transfer function. Then we use miscellaneous function in order to end up with a discrete state-space model that handles the time delay (additional states are added). ( ) ( ) ( ) ( ) ) ( ) ( ) ( ) ( ( ) )
17
MPC in LabVIEW
Where
Rest of the code is similar to previous example, except that we have been using a state machine in order to implement the code. Below we see the front panel:
18 [End of Example]
MPC in LabVIEW
We define the setpoint profile the system should follow in advance (the future setpoint is known) and see how the MPC controller works in order to follow the setpoint.
We see that the controller starts to react before the reference actually changes, which is a typically feature for the MPC controller.
19
MPC in LabVIEW
Here we see the main difference between a MPC controller and a more traditional PID controller. Another main difference between MPC and PID is that MPC can handle MIMO (Multiple Inputs, Multiple Outputs) systems, while PID is used for SISO systems (Single Input, Single Output). Block Diagram: Below we see the block diagram for the program:
We can divide the solution into 2 different parts: Initialization the MPC Controller: This is something we do only once when we start the program. We use the CD Create MPC Controller.vi.
20
MPC in LabVIEW
Run the Controller: This operation is performed each sample, and this is normally executed inside a loop, e.g. a While Loop. We use the CD Implement MPC Controller.vi.
[End of Example]
Telemark University College Faculty of Technology Kjlnes Ring 56 N-3914 Porsgrunn, Norway www.hit.no
Hans-Petter Halvorsen, M.Sc. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics
Phone: +47 3557 5158 E-mail: [email protected] Blog: http://home.hit.no/~hansha/ Room: B-237a