The Quanser Coupled Tanks, shown below, is a reconfigurable nonlinear process control experiment. The pump drives the water from the bottom basin up to the top outflow orifices and into tank 1 and/or tank 2. The water level of the tanks is measured using pressure sensors. Traditionally, PID-based algorithms are used to control the level of water in the tank. While this can be effective and perform well, using PID control is a model-based design approach. If the model does not accurately represent the system, then the controller may not perform adequately or as expected. For more information about the control challenges and design using PID, please see this previous blog post. Given the nonlinear dynamics, uncertainties, and actuator limits of the system, Model Predictive Control (MPC) is worth exploring and is often used in process control applications. Here we show how to use the MathWorks® Model Predictive Control Toolbox™ to design an MPC to perform tracking control of the water level in tank 1.
Before You Run this Example
The Coupled Tanks model predictive control can be simulated in MATLAB and Simulink using a nonlinear model of the system. If you have the Quanser Coupled Tankshardware, or its virtual twin, then you can run the controller on that system as well. The following toolboxes and additional software are required depending on what you want to do:
- MathWorks Control System Toolbox to define transfer functions in MATLAB and so on.
- MathWorks Model Predictive Control Toolbox. Required to define uncertain parameters that are used when performing the robust control tuning.
- [optional] Quanser QLabs Virtual Coupled Tanks experiment. Only needed to run the controller on the Coupled Tanks Virtual Twin. If you don't have QLabs, you can sign up for a free trial here.
- [optional] Quanser QUARC Real-Time Control Software is required to run the controllers on the actual Coupled Tanks hardware. If you don’t have the QUARC software, you can sign up for free trial here.
How Does it Work?
The model predictive control is designed using the Model Predictive Control Toolbox™ and the design process is detailed in this Quanser blog. For this experiment, the MPC is designed for the top tank, i.e., tank 1, system. This is a single input single output (SISO) system. The input is the pump outflow, and the output is the water level of tank 1. The Coupled Tanks can be configured as a cascade system (e.g., control tank 2 via tank 1), or a shared input system as well.
The MPC designed is implemented using the MPC Controller block from the Model Predictive Control Toolbox™, as shown below in the s_tanks_1_mpc.slx Simulink model. This model simulates the MPC control using a nonlinear model of the Quanser Coupled Tanks system.
Here is a sample response.
As shown in the Tank 1 Level scope, the tracking response improves as the simulation is running, i.e., the steady-state error decreases after each cycle.
How to Run the Example
Go through each section of the Coupled_Tanks_MPC.mlxLive Script. The script designs the model predictive control (MPC) and shows how to run the MPC (1) in the simulation, (2) on the QLabs Virtual Coupled Tanks, and (3) on the Coupled Tanks hardware.