This example shows how to bumplessly transfer between manual and automatic operations of a plant.
During startup of a manufacturing process, operators adjust key actuators manually until the plant is near the desired operating point before switching to automatic control. If not done correctly, the transfer can cause a bump, that is, large actuator movement.
In this example, you simulate a Simulink® model that contains a single-input single-output LTI plant and an MPC Controller block.
A model predictive controller monitors all known plant signals, even when it is not in control of the actuators. This monitoring improves its state estimates and allows a bumpless transfer to automatic operation.
Open the Simulink model.
To simulate switching between manual and automatic operation, the Switching block sends either 1 or 0 to control a switch. When it sends 0, the system is in automatic mode, and the output from the MPC Controller block goes to the plant. Otherwise, the system is in manual mode, and the signal from the Operator Commands block goes to the plant.
In both cases, the actual plant input feeds back to the controller
unless the plant input saturates at –1 or 1. The controller
constantly monitors the plant output and updates its estimate of the
plant state, even when in manual operation.
This model also shows the optimization switching option. When
the system switches to manual operation, a nonzero signal enters the
of the controller block. The signal turns off the optimization calculations,
which reduces computational effort.
Create the plant model.
num = [1 1]; den = [1 3 2 0.5]; sys = tf(num,den);
The plant is a stable single-input single-output system as seen in its step response.
Create an MPC controller.
Ts = 0.5; % sampling time (seconds) p = 15; % prediction horizon m = 2; % control horizon MPC1 = mpc(sys,Ts,p,m); MPC1.Weights.Output = 0.01; MPC1.MV = struct('Min',-1,'Max',1); Tstop = 250;
To achieve bumpless transfer, the initial states of your plant and controller must be the same, which is the case for the plant and controller in this example.
Open the Block Parameters dialog box for the MPC Controller block.
In the MPC Controller box, specify
(optional) In the Initial Controller State box,
specify the initial conditions for the controller. This step is not
necessary if the controller and plant already have the same initial
state, as is the case for this example. To specify initial conditions,
first extract the
mpcstate object from your controller
and set the initial state of the plant.
stateobj = mpcstate(MPC1); stateobj.Plant = x0;
x0 is a vector of the initial plant
states. Then, specify
stateobj in the Initial
Controller State box.
Verify that the External Manipulated Variable
(ext.mv) option in the General tab
is selected. This option adds the
to the block to enable the use of external manipulated variables.
Verify that the Use external signal to enable
or disable optimization (switch) option in the Others tab
is selected. This option adds the
to the controller block to enable switching off the optimization calculations.
Click Run in the Simulink model window to simulate the model.
For the first 90 time units, the
Switching Signal is
0, which makes the system operate in automatic mode. During this time,
the controller smoothly drives the controlled plant output from its
initial value, 0, to the desired reference value, –0.5.
The controller state estimator has zero initial conditions as a default, which is appropriate when this simulation begins. Thus, there is no bump at startup. In general, start the system running in manual mode long enough for the controller to acquire an accurate state estimate before switching to automatic mode.
At time 90, the
Switching Signal changes
to 1. This change switches the system to manual operation and sends
the operator commands to the plant. Simultaneously, the nonzero signal
switch inport of the controller turns
off the optimization calculations. While the optimization is turned
off, the MPC Controller block passes the current
Once in manual mode, the operator commands set the manipulated
variable to –0.5 for 10 time units, and then to 0. The
Output plot shows the open-loop response between times 90
and 180 when the controller is deactivated.
At time 180, the system switches back to automatic mode. As a result, the plant output returns to the reference value smoothly, and a similar smooth adjustment occurs in the controller output.
Delete the signals entering the
of the controller block.
Delete the Unit Delay block and the signal line entering its inport.
Open the Function Block Parameters: MPC Controller dialog box.
Deselect the External Manipulated Variable (ext.mv) option
in the General tab to remove the
from the controller block.
Deselect the Use external signal to enable or disable
optimization (switch) option in the Others tab
to remove the
switch inport from the controller
Click OK. The Simulink model now resembles the following figure.
Click Run to simulate the model.
The behavior is identical to the original case for the first 90 time units.
When the system switches to manual mode at time 90, the plant
behavior is the same as before. However, the controller tries to hold
the plant at the setpoint. So, its output increases and eventually
saturates, as seen in
Controller Output. Since
the controller assumes that this output is going to the plant, its
state estimates become inaccurate. Therefore, when the system switches
back to automatic mode at time 180, there is a large bump in the
Such a bump creates large actuator movements within the plant. By smoothly transferring from manual to automatic operation, a model predictive controller eliminates such undesired movements.