Main Content

设计MPC控制器金宝app

此示例显示了如何在Simulink中为连续搅拌坦克反应器(CSTR)设计模型预测控制器金宝app®你singMPC设计师

此示例需要金宝appSimulink控制设计™software to define the MPC structure by linearizing a nonlinear Simulink model.

如果你没有金宝appSimulink控制设计软件,您必须首先创建一个mpcobject in the MATLAB®工作区。有关更多信息,请参阅设计Controller Using MPC Designerand在命令行中设计MPC控制器

CSTR Model

连续搅拌罐反应器(CSTR)的非线性模型在CSTR Model。在the model, the inputs are arranged in the vector((t)and are as follows.

  • 1-CAF,以kmol/m测量的入口饲料流中的试剂A的浓度3

  • 2-tF,,,,the temperature of the inlet feed stream, measured in K

  • 3-tC,在K中测量的夹克冷却液温度

while the state variables are arranged in the vectorX((t)。

  • X1-C一个,以kmol/m测量的反应器中的试剂A的浓度3

  • X2-t,,,,the temperature in the reactor, measured in K

控制目标是保持残余浓度,C一个,,,,at its nominal setpoint by adjusting the coolant temperature,tC。Changes in the feed concentration,CAF,,,,and feed temperature,tF,引起CSTR反应的干扰。

反应堆温度,t,,,,is usually measured. However, for this example, ignore the reactor temperature, and assume that the residual concentration is measured directly.

Open the Simulink model.

open_system('cstr_closedloop'

Simulink model showing the closed loop system between the CSTR reactor and the MPC controller.

连接测量的干扰信号

在the Simulink model window, double-click theMPC控制器堵塞。

在the Block Parameters dialog box, on theGeneral选项卡,选择Measured disturbance (md)Check box.

MPC控制器的“块参数”对话框的部分,突出显示了测量的干扰复选框。

点击申请添加mdinput port to the controller block.

在the Simulink model window, connect the进料温度block output to themd输入端口。

Simulink model of the closed loop showing the measured disturbance signal entering both the plant and the MPC controller blocks.

线性化模型金宝app

在此示例中,您可以从内部线性化simulink模型金宝appMPC设计师,,,,which requires金宝appSimulink控制设计软件。有关更多信息,请参阅使用MPC设计器线性金宝app化模型

如果你没有金宝appSimulink控制设计软件,您必须首先创建一个mpcMATLAB工作区中的对象,并在该控制器中指定该控制器对象MPC控制器堵塞。

to openMPC设计师, 打开MPC控制器block and click设计

MPC设计师,,,,on theMPC设计师选项卡,结构section, clickMPC Structure

在the Define MPC Structure By Linearization dialog box, in theController Sample Time部分,指定样本时间0。1

在theMPC Structuresection, clickChange I/O Sizes添加你nmeasured disturbance and measured disturbance signal dimensions.

在the MPC Block Signal Sizes dialog box, specify the number of input/output channels of each type.

MPC Block Signal Sizes dialog box.

点击OK

在the Define MPC Structure By Linearization dialog box, in theSimulink Signals for Plant Inputssection, the app adds a row for无法衡量的干扰((UD)

MPC Block Signal Sizes dialog box.

操纵变量,测量的干扰和测量的输出已经分配给其各自的Simulink信号线,这些信号线连接到该信号线金宝appMPC控制器堵塞。

在theSimulink Signals for Plant Inputs部分,选择无法衡量的干扰((UD)row, and clickSelect Signals

在the Simulink model window, click the output signal from theFeed Concentration堵塞。

这signal is highlighted and its block path is added to the Select Signal for MPC Input Channels dialog box.

Select Signal for MPC Input Channels dialog box.

在the Select Signals for MPC Input Channels dialog box, clickOK

在the Define MPC Structure By Linearization dialog box, in theSimulink Signals for Plant Inputs表,Block PathFor the unmeasured disturbance signal is updated.

在this example, you linearize the Simulink model at a steady-state equilibrium operating point where the residual concentration is 2 kmol/m3。to compute such an operating point, add theCA信号作为装饰输出约束,并指定其目标约束值。

在the Simulink model window, select the signal line connected toCAoutput port of theCSTR堵塞。

Simulink model of the closed loop showing the CA output signal highlighted.

On the一个pps选项卡,单击线性化管理器。这n, on theLinearization选项卡,插入分析点gallery, under the修剪section, select修剪Output Constraint

CAsignal can now be used to define output specifications for calculating a model steady-state operating point.

在the Define MPC Structure By Linearization dialog box, in theSimulink Operating Point部分,在Create下拉列表,选择修剪Model

在装饰中,模型对话框在Outputstab, check the box in theKnownColumn forChannel - 1并指定Valueof2

修剪the model dialog box.

此设置将操作点搜索过程中输出信号的值限制为已知值。

点击Start Trimming

这修剪progress viewer window opens up showing the optimization progress towards finding a point in the state-input space of the model with the characteristics specified in the状态s,,,,输入,,,,andOutputstabs. After the optimization process terminates, close the trim progress window as well as the Trim the model dialog box.

在the Define MPC Structure By Linearization dialog box, in theSimulink Operating Point部分,计算的操作点,op_trim1 (MPC_OP_Workspace),,,,is added to the drop-down list and selected.

在theSimulink Operating Pointsection, clickEdit

Edit dialog box.

在“编辑对话框”中状态选项卡,一个Ct你al dxColumn, the near-zero derivative values indicate that the computed operating point is at steady-state.

to set the initial states of the Simulink model to the operating point values in the一个Ct你al Values列,单击在itialize model。这样做使您稍后可以在计算的操作点上模拟Simulink模型,而不是在默认模型初始条件下金宝app模拟模型。

在初始化模型对话框中,单击OK

When setting the model initial conditions,MPC设计师exports the operating point to the MATLAB workspace. Also, in the Simulink Configuration Parameters dialog box, in theData Import/Exportsection, it selects the在putand在itial stateparameters and configures them to use the states and inputs in the exported operating point.

to reset the model initial conditions, for example if you delete the exported operating point, clear the在putand在itial state参数。

Close the Edit dialog box.

在the Define MPC Structure By Linearization dialog box, linearize the Simulink model and import the linearized model inMPC设计师by clicking进口

在左侧的数据浏览器部分中,该应用添加了以下项目。

  • 线性化和离散的植物模型植物

  • Default MPC controllerMPC1使用线性化植物作为内部预测模型创建

  • Default simulation scenario方案1

MPC设计器窗口,显示闭环步骤响应。植物的输入位于左侧,植物输出在右侧。

Define Input/Output Channel Attributes

On theMPC设计师选项卡,结构section, clicki/o属性

在the Input and Output Channel Specifications dialog box, in theName列,为每个输入和输出通道指定有意义的名称。

在the单元Column, specify appropriate units for each signal.

输入和OutputChannel Specifications dialog box.

Nominal ValueFor each signal is the corresponding steady-state value at the computed operating point.

点击OK

Define Disturbance Rejection Simulation Scenarios

这primary objective of the controller is to hold the residual concentrationC一个at the nominal value of2kmol/m3。为此,控制器必须拒绝测量和无法测量的干扰。

On theMPC设计师选项卡,Scenariosection, selectEdit Scenario>方案1

在the Simulation Scenario dialog box, in theReference Signals (setpoints for all outputs)桌子,在信号下拉列表选择Constantto hold the output setpoint at its nominal value.

在the测量的干扰桌子,在信号下拉列表,选择Step

Specify a step尺寸of10和一步timeof0

Simulation Scenario dialog box.

点击OK

在theData Browser, 在下面方案,,,,Click方案1。点击方案1第二次重命名md_reject

在theScenariosection, click情节场景>新场景

在the Simulation Scenario dialog box, in the无法衡量的干扰桌子,在信号下拉列表,选择Step

Specify a step尺寸of1和一步timeof0

Section of the Simulation Scenario dialog box showing the unmeasured Disturbances table.

点击OK

在theData Browser, 在下面方案,,,,renamenewscenariotoUD_reject

一个rrange Output Response Plots

to make viewing the tuning results easier, arrange the plot area to display the Output Response plots for both scenarios at the same time.

Right click on the input plots tab bar and selectClose Input Plots

MPC设计器窗口的部分,突出显示“输入图”选项卡栏中的“关闭输入图”选项。

这plot display area changes to display only the output plots.

Right click on the output plots tab bar and selecttile All>top/Bottom

Section of the MPC Designer window, highlighting the Tile All option in the plots tab bar.

这plot display area changes to displayMD_REXEXT:输出tab is in the upper plot area and theUD_reject: Outputplot is in the lower plot area.

MPC设计器窗口的部分,仅显示输出图。

调音控制器性能

On thet你ning选项卡,Horizon节中,指定一个预测范围of20and a控制视野of5

输出响应plots update based on the new horizon values.

Use the default controller constraint and weight configurations.

在the性能调整section, drag theClosed-Loop Performanceslider to the right, which leads to tighter control of outputs and more aggressive control moves. Drag the slider until theMD_REXEXT:输出响应在不到3秒内达到稳态。

MPC设计师窗口,突出显示了向右拖动的闭环性能滑块。

Drag the国家估计slider to the right, which leads to more aggressive unmeasured disturbance rejection. Drag the slider until theUD_reject: Output响应在不到3秒内达到稳态。

MPC设计师window, highlighting the State Estimation slider being dragged to the right.

Update金宝appModel with Tuned Controller

在the分析section, selectExport Controller>仅更新块。这app exports tuned controllerMPC1to the MATLAB workspace. In the Simulink model, theMPC控制器block is updated to use the exported controller.

模拟未测量的干扰拒绝

在the Simulink model window, on theSimulationtab, change停止时间to5seconds.

这model initial conditions are set to the nominal operating point used for linearization.

to simulate a unit step in the feed concentration at time zero, open theFeed Concentrationblock and increase itsConstant valueparameter from10to11

在Simuli金宝appnk模型窗口中,打开Concentration范围并运行模拟。要缩放绘图垂直轴,请单击范围图工具栏中的垂直缩放按钮。

金宝appSimulink范围窗口显示了浓度信号及其参考如何随时间发展。

这output response is similar to theUD_rejectresponse, however the settling time is around 1 second longer. The different result is due to the mismatch between the linear plant used in theMPC设计师simulation and the nonlinear plant in the Simulink model.

模拟测得的干扰拒绝

to simulate the measured disturbance rejection, first return theFeed Concentrationblock to its nominal value of10

to simulate a step change in the feed temperature at time zero, open the进料温度block and increase itsConstant valueparameter from300to310

Run the simulation, and then scale the plot vertical axis.

Simulink scope window showing how the concentration signal and its reference evolve over time in the new scenario.

这output response is similar to themd_reject来自MPC设计师simulation.

也可以看看

一个pps

Blocks

Related Topics