主要内容

在线切换控制器,并通过浮力转移离线

This example shows how to obtain bumpless transfer when switching a model predictive controller from manual to automatic operation or vice versa.

During startup of a manufacturing process, before switching to automatic control, operators adjust key actuators manually until the plant is near the desired operating point. If not done correctly, the transfer can cause a bump; that is, a 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.

In particular, it shows how theEXT.MVinput signal to the MPC block can be used to keep the internal MPC state up to date when the operator or another controller is in control.

Define Plant Model

Define linear open-loop dynamic 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.

步骤(系统)

设计MPC控制器

Create an MPC controller, specifying the:

  • 植物模型

  • Sample timeTs

  • Prediction horizonp

  • 控制视野m

TS = 0.5;p = 15;M = 2;mpcobj = mpc(sys,ts,p,m);
- >“ MPC”对象的“权重”属性是空的。假设默认为0.00000。- >“ weights.manipulationVariablesrate”属性“ MPC”对象是空的。假设默认为0.10000。- >“ MPC”对象的“ weight.outputvariables”属性为空。假设默认为1.00000。

Define constraints on the manipulated variable.

mpcobj.MV=struct('Min',-1,'Max',1);

指定输出调整重量。

mpcobj.Weights.Output=0.01;

打开并配置simulink模型金宝app

打开Simulin金宝appk模型。

mdl ='mpc_bumpless';Open_System(MDL)

在此模型中,已经使用以下控制器参数设置配置了MPC控制器块,以供频繁传输。

  • TheExternal manipulated variable选择参数。该参数通过添加来实现外部操纵变量的使用EXT.MVinport to the block.

  • The使用外部信号启用或禁用优化is selected. This parameter adds a转变inport for switching off the controller optimization calculations.

为了实现廉价转移,植物和控制器的初始状态必须相同,在本示例中,工厂和控制器就是这种情况。但是,如果系统的初始条件不匹配,则可以将控制器的初始状态设置为植物初始状态。为此,提取mpcstateobject from your controller and set the initial state of the plant.

stateobj = mpcstate(MPC1); stateobj.Plant = x0;

wherex0是初始植物状态的媒介。然后,设置初始控制器状态MPC控制器块的参数stateobj.

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 controllerEXT.MV在机构中,除非工厂输入在-1或1处饱和。控制器不断监视工厂的产量,并在手动操作中更新其对植物状态的估计。

This model also shows the optimization switching option. When the system switches to manual operation, a nonzero signal enters the转变控制器块的机构。信号关闭控制器的优化计算,从而减少了计算工作。

Simulate Controller in Simulink

模拟Simulink中线性植物模型的闭环控制。金宝app

sim(mdl)
- >将“ MPC”对象的“ model.plant”属性转换为状态空间。- >将模型转换为离散时间。- >假设添加到测量的输出通道#1中的输出干扰是集成的白噪声。- >“ MPC”对象的“ model.noise”属性为空。假设每个测得的输出通道上都有白噪声。

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.

在时间90时,开关信号更改为1。此更改将系统切换为手动操作,并将操作员命令发送到工厂。同时,输入控制器的开关的非零信号关闭了优化计算。关闭优化时,MPC控制器块通过电流传递EXT.MVsignal to the Controller Output.

Once in manual mode, the operator commands set the manipulated variable to -0.5 for 10 time units, and then to 0. The Plant Output plot shows the open-loop response between times 90 and 180 when the controller is deactivated.

在时间180时,系统切换回自动模式。结果,工厂的输出顺利返回参考值,并且在控制器输出中发生了类似的平滑调整。

关闭操纵可变反馈

要检查没有操纵可变反馈的控制器行为,请按以下方式修改模型:

  • 删除输入的信号EXT.MV和切换inportsMPC控制器块。

  • 删除单位延迟块和信号线进入其INPORT。

  • For the MPC Controller block, clear theExternal manipulated variable使用外部信号启用或禁用优化parameters.

To perform these steps programmatically, use the following commands.

delete_line(MDL,'开关/1','Unit Delay/1');delete_line(MDL,'Unit Delay/1','MPC Controller/3');delete_block([mdl'/Unit Delay');delete_line(MDL,'Switching/1',“MPC控制器/ 4”);set_param([MDL'/MPC控制器'],,'mv_inport','离开');set_param([MDL'/MPC控制器'],,'switch_inport','离开');

调整响应图的极限,并模拟模型。

set_param([MDL'/Yplots'],,'ymin','-1.1〜 -0.1')set_param([MDL'/Yplots'],,'ymax','2〜1.1')set_param([MDL'/mvplots'],,'ymin','-0.6〜 -0.5')set_param([MDL'/mvplots'],,'ymax','1.1〜1.1')SIM(MDL)

The behavior of the system 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 Plant Output.

这样的凹凸在植物内部创造了大型的致动力运动。通过平稳地从手动转移到自动操作,模型预测控制器消除了这种不必要的运动。

BDCLOSE(MDL)

See Also