Accelerating the pace of engineering and science

# Documentation

## Design Controller for Plant with Delays

This example shows how to design an MPC controller for a plant with delays.

The Model Predictive Control Toolbox™ can handle models that include delays. A typical example is the distillation column model, which includes a delay in each input/output channel. The presence of delays influences controller performance, and your controller specifications should account for them.

Create the distillation column plant model.

```g11 = tf( 12.8, [16.7 1], 'IOdelay', 1.0,'TimeUnit','minutes');
g12 = tf(-18.9, [21.0 1], 'IOdelay', 3.0,'TimeUnit','minutes');
g13 = tf(  3.8, [14.9 1], 'IOdelay', 8.1,'TimeUnit','minutes');
g21 = tf(  6.6, [10.9 1], 'IOdelay', 7.0,'TimeUnit','minutes');
g22 = tf(-19.4, [14.4 1], 'IOdelay', 3.0,'TimeUnit','minutes');
g23 = tf(  4.9, [13.2 1], 'IOdelay', 3.4,'TimeUnit','minutes');
DC = [g11 g12 g13
g21 g22 g23];
DC.InputName = {'Reflux Rate', 'Steam Rate', 'Feed Rate'};
DC.OutputName = {'Distillate Purity', 'Bottoms Purity'};
DC = setmpcsignals(DC, 'MD', 3);```

The largest ioDelay of the DC model delay is 8.1 minutes.

Open the Model Predictive Control Toolbox design tool.

`mpctool`

Click Import Plant and import the DC model into the tool.

In the tree, select MPC Design Task > Controllers > MPC1.

It is good practice to specify the prediction and control horizons such that

$P-M\gg {t}_{d}/\Delta t$

Here, P is the prediction horizon, M is the control horizon, td,max is the maximum delay, and Δt is the control interval. In the Control interval (time units) box, which specifies Δt, enter 1. Then, because the maximum ioDelay for the DC model is 8.1 minutes, td,maxt is 8.1. You can satisfy the inequality by setting P = 30 and M = 5. In the Prediction horizon (intervals) box, enter 30, and in the Control horizon (intervals) box, enter 5.

Now that you have specified the controller horizons, simulate the model to test the controller performance. In the tree, select Scenarios > Scenario1.

Specify the simulation settings as follows:

• In the Duration box, enter 50.

• In the Setpoints table, for the Distillate Purity setpoint, enter 1 in the Initial Value box.

• In the Setpoints table, for the Bottoms Purity setpoint, from the Type list, select Step. In the Time box, enter 25.

Click Simulate.

The plant outputs plot shows that the first output does not respond for the first minute, which corresponds to the delay from the first input. The first output reaches the setpoint in two minutes and settles quickly. Similarly, the second output does respond for three minutes, which corresponds to the delay from the second input, and settles rapidly afterwards. Changing the setpoint for the Bottoms Purity output disturbs the Distillate Purity output, but the magnitude of this interaction is less than 10%.

The plant inputs plot shows that the initial input moves are more than five times the final change. Also, there are periodic pulses in the control action as the controller attempts to counteract the delayed effects of each input on the two outputs.

You can moderate these effects by tuning the controller weights or by specifying a custom blocking strategy. For this example, use the latter approach. In the tree, select MPC Design Task > Controllers > MPC1. Select the Blocking check box.

In the Blocking section:

• From the Blocking allocation within prediction horizon list, select Custom

• In the Custom move allocation vector, enter [5 5 5 5 10]

In the tree, select Scenarios > Scenario1.

Click Simulate.

The initial input moves are much smaller and the moves are less oscillatory. The trade-off is a slower output response, with about 20% interaction between the outputs.