Main Content

Switch Controller Online and Offline with Bumpless Transfer

这个例子展示了如何获得无扰转移when switching a model predictive controller from manual to automatic operation or vice versa.

在制造过程的启动过程中,在切换到自动控制之前,操作员经常手动调整关键执行器,直到工厂接近所需的操作点。如果未正确完成,转移会导致颠簸;也就是说,大型执行器运动可能是不安全或不希望的。

在此示例中,您模拟了一个simulink®模型,该模型包含单输入金宝app单输出LTI工厂和MPC控制器块。

这model predictive controller monitors all known plant signals, even when it is not in control of the actuators. This continuous monitoring improves the quality of its state estimates and allows a bumpless transfer to automatic operation.

In particular, since the last used value of the control signal is a part of the internal controller state, you must use MPC blockext.mv输入信号以保持内部MPC状态最新,当操作员(或其他控制器)控制工厂时。

定义植物模型

定义线性开环动态植物模型。

num = [1 1]; den = [1 3 2 0.5]; sys = tf(num,den);

该工厂是稳定的单输入单输出系统,如其步骤响应中所见。

step(sys)

Design MPC Controller

创建一个MPC控制器,指定:

  • Plant model

  • Sample time (0.5time units).

  • 预测范围15steps.

  • Control horizon2steps.

mpcobj = mpc(sys,0.5,15,2);
-->The "Weights.ManipulatedVariables" property is empty. Assuming default 0.00000. -->The "Weights.ManipulatedVariablesRate" property is empty. Assuming default 0.10000. -->The "Weights.OutputVariables" property is empty. Assuming default 1.00000.

在操纵变量上定义约束。

mpcobj.mv = struct(',,,,-1,'最大限度',,,,1);

Specify the output tuning weight.

mpcobj.weights.output = 0.01;

Open and Configure Simulink Model

Open the Simulink model.

mdl ='mpc_bumpless'; open_system(mdl)

In this model, the MPC Controller block is already configured for bumpless transfer using the following controller parameter settings.

  • 外部操纵变量parameter in the MPC Controller block is selected. This parameter adds theext.mv在块上进行机构,从而允许块监视外部控制信号。

  • Use external signal to enable or disable optimizationparameter in the MPC Controller block is selected. This parameter adds aswitchinport to switch off the controller optimization calculations when they are not needed.

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

stateObj = mpcstate(mpc1);stateObj.plant = x0;

在哪里X0is a vector of the initial plant states. Then, set theInitial Controller Stateparameter of the MPC Controller block tostatebj

To simulate switching between manual and automatic operation, the Switching Signal 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.

在这两种情况下,实际的工厂输入都会回馈控制器ext.mvinport, 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.

该模型还显示了优化开关选项。当系统切换到手动操作时,非零信号进入switch控制器的尺寸。这个非零标记l turns off the optimization calculations of the controller, which reduces computational effort.

在Simulink中模拟控制器金宝app

Simulate closed-loop control of the linear plant model in Simulink.

SIM(MDL)% open the scope blocks windowsopen_system([mdl'/yplots'])open_system([MDL'/MVplots'])
-->Converting the "Model.Plant" property to state-space. -->Converting model to discrete time. -->Assuming output disturbance added to measured output channel #1 is integrated white noise. -->The "Model.Noise" property is empty. Assuming white noise on each measured output.

在前90个时间单元中,开关信号为0,使系统以自动模式运行。在此期间,控制器将受控工厂从其初始值0驱动到所需的参考值-0.5。

控制器状态估计器的初始条件为零,为默认情况,当此模拟开始时,这是合适的。因此,启动时没有颠簸。通常,当系统以手动模式启动时,最好让它运行足够长的时间,以便控制器可以在切换到自动模式之前收敛到准确的状态估计。

在时间90时,开关信号更改为1。此更改将系统切换为手动操作,并将操作员命令发送到工厂。同时,输入控制器的开关的非零信号关闭了优化计算。

在关闭优化时,MPC控制器内置估计器继续使用工厂输出测量,以及操纵变量的最后值(那是ext.mvsignal), to estimate the plant state. The MPC Controller block also passesext.mvto the controller output port.

Once in manual mode, the Operator Commands block sets 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.

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.

Turn Off Manipulated Variable Feedback

To examine the controller behavior without manipulated variable feedback, modify the model as follows:

  • Delete the signals entering theext.mvand switch企业of the MPC Controller block.

  • Delete the Unit Delay block and the signal line entering its inport.

  • For the MPC Controller block, clear the外部操纵变量andUse external signal to enable or disable optimization参数。

要编程执行这些步骤,请使用以下命令。

delete_line(mdl,'Switch/1',,,,“单位延迟/1”);delete_line(mdl,“单位延迟/1”,,,,'MPC控制器/3');delete_block([MDL'/单位延迟']); delete_line(mdl,'Switching Signal/1',,,,'MPC控制器/4');set_param([MDL'/MPC Controller'],'mv_inport',,,,'off');set_param([MDL'/MPC Controller'],'switch_inport',,,,'off');

Adjust the limits of the response plots, and simulate the model.

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)

这behavior of the system is identical to the original case for the first 90 time units.

当系统在时间90时切换到手动模式时,植物行为与以前相同。但是,控制器继续计算将植物保持在设定点所需的控制输入。因此,如控制器输出范围所示,操纵变量不断增加并最终饱和。此外,由于控制器假设其输出将进入工厂,因此其状态估计变得不准确。因此,当系统在时间180时切换回自动模式时,植物内部的执行器运动中有一个大颠簸,如植物输出范围所示。

By using the controllerext.mv输入信号以保持内部MPC状态在不在工厂上运行时更新内部的MPC状态,您可以使从手动到自动操作的平稳传输,从而消除不需要的执行器移动。

bdclose(mdl)

也可以看看