Main Content

pidtune

线性植物模型的PID调整算法

句法

C= pidtune(sys,,,,type)
c = pidtune(sys,c0)
C= pidtune(sys,,,,type,wc)
c = pidtune(sys,c0,wc)
c = pidtune(sys,...,opts)
[[C,,,,信息] = pidtune(...)

Description

C= pidtune(sys,,,,type设计类型的PID控制器type对于植物sys。如果typespecifies a one-degree-of-freedom (1-DOF) PID controller, then the controller is designed for the unit feedback loop as illustrated:

如果type指定一个两度自由(2-DOF)PID控制器,然后pidtune在此图的反馈回路中设计一个二元控制器:

pidtunetunes the parameters of the PID controllerCto balance performance (response time) and robustness (stability margins).

C= pidtune(sys,,,,C0designs a controller of the same type and form as the controllerC0。如果sysandC0are discrete-time models,C具有与C0

C= pidtune(sys,,,,type,,,,wcandC= pidtune(sys,,,,C0,,,,wc指定目标值wcfor the first 0 dB gain crossover frequency of the open-loop response.

C= pidtune(sys,,,,。。。,,,,选择uses additional tuning options, such as the target phase margin. Usepidtuneoptionsto specify the option set选择

[[C,,,,信息] = pidtune(...)returns the data structure信息,其中包含有关闭环稳定性,所选开环增益跨界频率和实际相距的信息。

输入参数

sys

Single-input, single-outputdynamic system modelof the plant for controller design.sys可:

  • 任何类型的SISO动态系统模型,包括数字LTI模型和已识别模型。如果sys是a tunable or uncertain model,pidtune设计一个控制器的当前或名义值的控制器sys

  • 连续或离散的时间模型。

  • Stable, unstable, or integrating. A plant with unstable poles, however, might not be stabilizable under PID control.

  • 一个模型,其中包括任何类型的时间延迟。一个plant with long time delays, however, might not achieve adequate performance under PID control.

  • 一个n array of plant models. Ifsys是an array,pidtune为阵列中的每个工厂设计一个单独的控制器。

如果植物有不稳定的杆子,并且sys是one of the following:

  • 一个FRD模型

  • 一个ss具有内部时间延迟的模型,无法转换为I/O延迟

you must usepidtuneoptionsto specify the number of unstable poles in the plant, if any.

type

Controller type of the controller to design, specified as a character vector. The termController typerefers to which terms are present in the controller action. For example, a PI controller has only a proportional and an integral term, while a PIDF controller contains proportional, integrator, and filtered derivative terms.typeCan take the values summarized below. For more detailed information about these controller types, see调音的PID控制器类型

1-DOF Controllers

  • 'P'— Proportional only

  • 'I'— Integral only

  • 'pi'— Proportional and integral

  • 'PD'— Proportional and derivative

  • 'PDF'— Proportional and derivative with first-order filter on derivative term

  • 'PID'— Proportional, integral, and derivative

  • 'pidf'— Proportional, integral, and derivative with first-order filter on derivative term

2-DOF Controllers

  • 'pi2'- 二二元成比例和积分

  • 'PD2'— 2-DOF proportional and derivative

  • 'PDF2'— 2-DOF proportional and derivative with first-order filter on derivative term

  • 'PID2'— 2-DOF proportional, integral, and derivative

  • 'pidf2'— 2-DOF proportional, integral, and derivative with first-order filter on derivative term

For more information about 2-DOF PID controllers generally, seeTwo-Degree-of-Freedom PID Controllers

2-DOF Controllers with Fixed Setpoint Weights

  • 'i-pd'— 2-DOF PID withb= 0,C= 0

  • 'I-PDF'— 2-DOF PIDF withb= 0,C= 0

  • 'ID-P'— 2-DOF PID withb= 0,C= 1

  • 'idf-p'— 2-DOF PIDF withb= 0,C= 1

  • 'pi-d'— 2-DOF PID withb= 1,C= 0

  • 'PI-DF'— 2-DOF PIDF withb= 1,C= 0

有关固定 - 定量重量2-DOF PID控制器的更多详细信息,请参见调音的PID控制器类型

控制器表格

当您使用type输入,pidtune并行设计一个控制器(pidorPID2) 形式。使用输入C0代替typeif you want to design a controller in standard (pidstdorPIDSTD2) 形式。

如果sys是带有样品时间的离散时间模型Ts,,,,pidtune设计一个离散的时间控制器Ts。The controller has the向前的人积分和衍生作用的离散集成器公式。使用输入C0代替typeif you want to design a controller having a different discrete integrator formula.

有关PID控制器表格和公式的更多信息,请参见:

C0

PID controller setting properties of the designed controller, specified as apid,,,,pidstd,,,,PID2,,,,orPIDSTD2目的。如果您提供C0,,,,pidtune

  • Designs a controller of the type represented byC0

  • 返回apidController, ifC0是apidController.

  • 返回apidstdController, ifC0是apidstdController.

  • 返回二元PID2Controller, ifC0是aPID2Controller.

  • 返回二元PIDSTD2Controller, ifC0是aPIDSTD2Controller.

  • 返回aController with the same如果ormulaandDformulavalues asC0,,,,ifsys是a discrete-time system. See thepid,,,,PID2,,,,pidstd,,,,andPIDSTD2reference pages for more information about如果ormulaandDformula

wc

Target value for the 0 dB gain crossover frequency of the tuned open-loop response. Specifywc在弧度的单位/TimeUnit,,,,whereTimeUnit是the time unit ofsys。交叉频率wc大致设置控制带宽。闭环响应时间大约1/wc

增加wc加快响应速度。减少wcto improve stability. When you omitwc,,,,pidtuneautomatically chooses a value, based on the plant dynamics, that achieves a balance between response and stability.

选择

Option set specifying additional tuning options for thepidtune设计算法,例如目标相位边距或设计焦点。利用pidtuneoptionsto create选择

Output Arguments

C

为了设计控制器sys。如果sys是an array of linear models,pidtunedesigns a controller for each linear model and returns an array of PID controllers.

控制器表格:

  • 如果the second argument topidtunetype,,,,C是apidorPID2Controller.

  • 如果the second argument topidtuneC0

    • C是apidController, ifC0是apid目的。

    • C是apidstdController, ifC0是apidstd目的。

    • C是aPID2Controller, ifC0是aPID2目的。

    • C是aPIDSTD2Controller, ifC0是aPIDSTD2目的。

Controller type:

  • 如果the second argument topidtunetype,,,,C通常具有指定类型。

  • 如果the second argument topidtuneC0,,,,Cgenerally has the same type asC0

In either case, however, where the algorithm can achieve adequate performance and robustness using a lower-order controller than specified withtypeorC0,,,,pidtune返回aChaving fewer actions than specified. For example,CCan be a PI controller even thoughtype'pidf'

Time domain:

  • C具有与sys

  • 如果sys是a discrete-time model,Chas the same sample time assys

  • 如果you specifyC0,,,,Chas the same如果ormulaandDformula作为C0。如果不C0指定,两者都如果ormulaandDformulaare前锋欧拉。看到pid,,,,PID2,,,,pidstd,,,,andPIDSTD2reference pages for more information about如果ormulaandDformula

如果you specifyC0,,,,Calso obtains model properties such as输入名andOutputNamefromC0。For more information about model properties, see the reference pages for each type of dynamic system model.

信息

Data structure containing information about performance and robustness of the tuned PID loop. The fields of信息是:

  • Stable— Boolean value indicating closed-loop stability.Stable是1if the closed loop is stable, and 0 otherwise.

  • 交叉频率- 开环系统的第一个0 dB交叉频率C*sys,,,,inrad/TimeUnit,,,,whereTimeUnit是the time units specified in theTimeUnit财产的sys

  • PhaseMargin- 调谐的PID环的相位边缘为程度。

如果sys是an array of plant models,信息是an array of data structures containing information about each tuned PID loop.

Examples

全部收缩

This example shows how to design a PID controller for the plant given by:

s y s = 1 (( s + 1 3

一个sa first pass, create a model of the plant and design a simple PI controller for it.

sys = zpk([],[ -  1 -1 -1],1);[[C_pi,info] = pidtune(sys,'pi'
C_pi = 1 Kp + Ki * --- s with Kp = 1.14, Ki = 0.454 Continuous-time PI controller in parallel form.
信息=带有字段的结构:Stable: 1 CrossoverFrequency: 0.5205 PhaseMargin: 60.0000

C_pi是apidController object that represents a PI controller. The fields of信息证明调整算法选择了约0.52 rad/s的开环交叉频率。

检查受控系统的闭环步骤响应(参考跟踪)。

T_pi = feedback(C_pi*sys, 1); step(T_pi)

图包含一个轴对象。轴对象包含一个类型行的对象。此对象表示t \ _pi。

To improve the response time, you can set a higher target crossover frequency than the result thatpidtuneautomatically selects, 0.52. Increase the crossover frequency to 1.0.

[[C_pi_fast,info] = pidtune(sys,'pi',,,,1。0)
C_pi_fast = 1 Kp + Ki * --- s with Kp = 2.83, Ki = 0.0495 Continuous-time PI controller in parallel form.
信息=带有字段的结构:稳定:1跨频率:1 phasemargin:43.9973

The new controller achieves the higher crossover frequency, but at the cost of a reduced phase margin.

Compare the closed-loop step response with the two controllers.

t_pi_fast =反馈(c_pi_fast*sys,1);步骤(t_pi,t_pi_fast)轴([0 30 0 1.4])传奇('pi',,,,'PI,fast'

图包含一个轴对象。轴对象包含2个类型行的对象。These objects represent PI, PI,fast.

性能结果的降低是因为PI控制器没有足够的自由度来在1.0 rad/s的交叉频率下实现良好的相位边缘。添加衍生作用可改善响应。

设计一个PIDF控制器GCwith the target crossover frequency of 1.0 rad/s.

[[C_pidf_fast,info] = pidtune(sys,'pidf',,,,1。0)
c_pidf_fast = 1 s kp + ki * ---- + kd * --------------------- s tf * s + 1 with kp = 2.72,ki = 0.985,kd = 1.72,tf = 0.00875连续pidf Controller in In平行形式。
信息=带有字段的结构:稳定:1跨频率:1 phasemargin:60.0000

信息领域表明,控制器中的派生动作允许调整算法设计一个更具侵略性的控制器,该控制器可以以良好的相位边距实现目标交叉频率。

Compare the closed-loop step response and disturbance rejection for the fast PI and PIDF controllers.

T_pidf_fast = feedback(C_pidf_fast*sys,1); step(T_pi_fast, T_pidf_fast); axis([0 30 0 1.4]); legend('PI,fast',,,,'PIDF,fast');

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象代表PI,快速,PIDF,快速。

You can compare the input (load) disturbance rejection of the controlled system with the fast PI and PIDF controllers. To do so, plot the response of the closed-loop transfer function from the plant input to the plant output.

S_pi_fast = feedback(sys,C_pi_fast); S_pidf_fast = feedback(sys,C_pidf_fast); step(S_pi_fast,S_pidf_fast); axis([0 50 0 0.4]); legend('PI,fast',,,,'PIDF,fast');

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象代表PI,快速,PIDF,快速。

该图表明,PIDF控制器还提供更快的干扰拒绝。

为以下工厂设计标准形式的PID控制器。

sys = 1 (( s + 1 3

To design a controller in standard form, use a standard-form controller as theC0争论pidtune

sys = zpk([],[ -  1 -1 -1],1);C0 = PIDSTD(1,1,1);c = pidtune(sys,c0)
c = 1 1 kp *(1 + ---- * --- * --- + td * s)ti s with kp = 2.18,ti = 2.57,td = 0.642连续时间PID控制器,以标准形式为单位

Design a discrete-time PI controller using a specified method to discretize the integrator.

如果您的工厂在离散时间pidtuneautomatically returns a discrete-time controller using the default Forward Euler integration method. To specify a different integration method, usepidorpidstdto create a discrete-time controller having the desired integration method.

sys=C2d(tf([1 1],[1 5 6]),0.1); C0 = pid(1,1,'ts',0.1,'iformula',,,,'BackwardEuler');c = pidtune(sys,c0)
C = t * z Kp +吻  * ------ z 1 Kp = -0.0658, Ki = 1.32, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PI controller in parallel form.

使用C0作为输入原因pidtune设计控制器Cof the same form, type, and discretization method asC0。The display shows that the integral term ofC使用向后的Euler集成方法。

Specify a Trapezoidal integrator and compare the resulting controller.

C0_tr = pid(1,1,'ts',0.1,'iformula',,,,“梯形”);Ctr = pidtune(sys,C0_tr)
ctr = ts*(z+1)ki*-------- 2*(z-1),ki = 1.32,ts = 0.1示例时间:0.1秒离散时间I-仅I-仅I-仅限控制器。

为通过转移函数给出的植物设计一个2-DOF PID控制器:

G (( s = 1 s 2 + 0 5 s + 0 1

使用1.5 rad/s的目标带宽。

WC = 1.5;g = tf(1,[1 0.5 0.1]);c2 = pidtune(g,'PID2',,,,wc)
C2= 1u = Kp (b*r-y) + Ki --- (r-y) + Kd*s (c*r-y) s with Kp = 1.26, Ki = 0.255, Kd = 1.38, b = 0.665, c = 0 Continuous-time 2-DOF PID controller in parallel form.

使用类型'PID2'Causespidtuneto generate a 2-DOF controller, represented as aPID2目的。The display confirms this result. The display also shows thatpidtunetunes all controller coefficients, including the setpoint weightsbandC,,,,to balance performance and robustness.

Tips

  • By default,pidtunewith thetype输入返回apidController in parallel form. To design a controller in standard form, use apidstdController as input argumentC0。For more information about parallel and standard controller forms, see thepidandpidstdreference pages.

  • 有关Live编辑器中的交互式PID调整,请参阅Tune PID控制器实时编辑任务。此任务使您可以交互式设计PID控制器并自动生成MATLAB®Code for your live script.

一个lgorithms

有关数学的信息®PID tuning algorithm, seePID调整算法

备择方案

参考

Åström,K。J。和Hägglund,T。高级PID控制,,,,Research Triangle Park, NC: Instrumentation, Systems, and Automation Society, 2006.

版本历史记录

在R2010b中引入