主要内容

p一世d

以并行形式创建PID控制器,转换为平行形式的PID控制器

句法

C= pid(kp,,,,k一世,,,,kd,,,,tF)
C = PID(KP,KI,KD,TF,TS)
C= pid(sys)
C= pid(kp)
C= pid(kp,,,,k一世)
C= pid(kp,,,,k一世,,,,kd)
C= pid(。。。,,,,name,Value)
C= pid

description

C= pid(kp,,,,k一世,,,,kd,,,,tF创建了一个连续时间PID控制器与道具ortional, integral, and derivative gainskp,,,,k一世,,,,andkdand first-order derivative filter time constanttF

C = k p + k 一世 s + k d s t F s + 1

这个表示形式在parallel form。如果all ofkp,,,,k一世,,,,kd,,,,andtFare real, then the resultingC一世sap一世d控制器对象。如果one or more of these coefficients is tunable (realporgenmat),,,,thenC一世sa tunable generalized state-space (Genss)model object.

C= pid(kp,,,,k一世,,,,kd,,,,tF,,,,tscreates a discrete-time PID controller with sample timets。这controller is:

C = k p + k 一世 F (( z + k d t F + d F (( z

我F((z)andDF((z)are thed一世screte integrator formulasFor the integrator and derivative filter. By default,

F (( z = d F (( z = t s z 1

要选择不同的离散集成商公式,请使用我FormulaandDFormulaproperties. (SeePropertiesFor more information about我FormulaandDFormula)。如果DFormula='ForwardEuler'(默认值)和tF≠ 0, thentsandtFmust satisfytF> Ts/2。此需求确保稳定的导数滤杆。

C= pid(sysconverts the dynamic systemsysto a parallel formp一世d控制器对象。

C= pid(kpk一世= 0,kd= 0,andtF=0。

C= pid(kp,,,,k一世与使用比例和积分(PI)控制器kd= 0和tF=0。

C= pid(kp,,,,k一世,,,,kd与使用比例,积分和衍生(PID)控制器一起使用tF=0。

C= pid(。。。,,,,name,Valuecreates a controller or converts a dynamic system to ap一世d控制器对象,其中一个或多个指定的其他选项name,Value配对参数。

C= pid使用kp=1。

我nput Arguments

kp

Proportional gain.

kp可:

  • A real and finite value.

  • 真正的和有限的值的数组。

  • A tunable parameter (realp)或广义矩阵(genmat)。

  • A tunable surface for gain-scheduled tuning, created usingtunableSurface

Whenkp= 0,控制器没有比例动作。

默认:1

k一世

积分增益。

k一世可:

  • A real and finite value.

  • 真正的和有限的值的数组。

  • A tunable parameter (realp)或广义矩阵(genmat)。

  • A tunable surface for gain-scheduled tuning, created usingtunableSurface

Whenk一世= 0,控制器没有积分动作。

默认:0

kd

derivative gain.

kd可:

  • A real and finite value.

  • 真正的和有限的值的数组。

  • A tunable parameter (realp)或广义矩阵(genmat)。

  • A tunable surface for gain-scheduled tuning, created usingtunableSurface

Whenkd= 0,the controller has no derivative action.

默认:0

tF

t一世me constant of the first-order derivative filter.

tF可:

  • A real, finite, and nonnegative value.

  • An array of real, finite, and nonnegative values.

  • A tunable parameter (realp)或广义矩阵(genmat)。

  • A tunable surface for gain-scheduled tuning, created usingtunableSurface

WhentF= 0,the controller has no filter on the derivative action.

默认:0

ts

采样时间。

创建离散时间p一世dcontroller, provide a positive real value (ts> 0)。p一世ddoes not support discrete-time controller with unspecified sample time (ts=-1)。

tsmust be a scalar value. In an array ofp一世dcontrollers, each controller must have the samets

默认:0(连续时间)

sys

SISO动态系统转换为平行p一世dForm.

sysmust represent a valid PID controller that can be written in parallel form withtF≥ 0.

syscan also be an array of SISO dynamic systems.

名称值参数

Specify optional comma-separated pairs ofname,Valuearguments.name一世sthe argument name andValue一世sthe corresponding value.namemust appear inside quotes. You can specify several name and value pair arguments in any order asNAME1,Value1,...,Namen,Valuen

Usename,Valuesyntax to set the numerical integration formulas我FormulaandDFormula离散时间p一世d控制器,或设置其他对象属性,例如输入名andOutputName。For information about available properties ofp一世dcontroller objects, seeProperties

Output Arguments

C

PID控制器,表示为p一世dcontroller object, an array ofp一世d控制器对象,一个Genssobject, or aGenssarray.

  • 如果all the gainskp,,,,k一世,,,,kd,,,,andtF具有数字值,然后C一世sap一世d控制器对象。当收益是数字阵列时,C一世san array ofp一世d控制器对象。控制器类型(P,I,PI,PD,PDF,PID,PIDF)取决于收益的值。例如,当kd= 0,butkpandk一世are nonzero,C是PI控制器。

  • 如果one or more gains is a tunable parameter (realp),,,,generalized matrix (genmat),,,,or tunable gain surface (tunableSurface),,,,thenC一世sa generalized state-space model (Genss)。

Properties

KP,KI,KD

PID controller gains.

kp,,,,k一世,,,,andkdproperties store the proportional, integral, and derivative gains, respectively.kp,,,,k一世,,,,andkd是真实的和有限的。

tF

导数滤波器时间常数。

tFproperty stores the derivative filter time constant of thep一世d控制器对象。tF一世sreal, finite, and nonnegative.

我Formula

离散集成商公式我F((z)For the integrator of the discrete-timep一世dcontrollerC

C = k p + k 一世 F (( z + k d t F + d F (( z

我Formulacan take the following values:

  • 'ForwardEuler'-我F((z)= t s z 1

    this formula is best for small sample time, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sample time, the向前的人即使在连续时间稳定的系统离散时,公式也会导致不稳定。

  • 'BackwardEuler'-我F((z)= t s z z 1

    一个优势BackwardEuler公式是使用此公式离散稳定的连续时间系统总是会产生稳定的离散时间结果。

  • 'Trapezoidal'-我F((z)= t s 2 z + 1 z 1

    一个优势trapezoidal公式是使用此公式离散稳定的连续时间系统总是会产生稳定的离散时间结果。Of all available integration formulas, thetrapezoidalFormula yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system.

WhenC一世sa continuous-time controller,我Formula一世s''

默认:'ForwardEuler'

DFormula

离散集成商公式DF((z)用于离散时间的导数滤波器p一世dcontrollerC

C = k p + k 一世 F (( z + k d t F + d F (( z

DFormulacan take the following values:

  • 'ForwardEuler'-DF((z)= t s z 1

    this formula is best for small sample time, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sample time, the向前的人即使在连续时间稳定的系统离散时,公式也会导致不稳定。

  • 'BackwardEuler'-DF((z)= t s z z 1

    一个优势BackwardEuler公式是使用此公式离散稳定的连续时间系统总是会产生稳定的离散时间结果。

  • 'Trapezoidal'-DF((z)= t s 2 z + 1 z 1

    一个优势trapezoidal公式是使用此公式离散稳定的连续时间系统总是会产生稳定的离散时间结果。Of all available integration formulas, thetrapezoidalFormula yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system.

    trapezoidal价值DFormula一世snot available for ap一世dcontroller with no derivative filter (tF=0)。

WhenC一世sa continuous-time controller,DFormula一世s''

默认:'ForwardEuler'

inputdelay

t一世me delay on the system input.inputdelay一世salways 0 for ap一世d控制器对象。

OutputDelay

系统输出的时间延迟。OutputDelay一世salways 0 for ap一世d控制器对象。

ts

采样时间。对于连续时间模型,ts=0。For discrete-time models,ts是代表采样期的正标量。该值在由t一世meUnitproperty of the model. PID controller models do not support unspecified sample time (ts=-1)。

Changing this property does not discretize or resample the model. Usec2dandd2cto convert between continuous- and discrete-time representations. Used2d更改离散时间系统的示例时间。

默认:0((continuous time)

t一世meUnit

Units for the time variable, the sample timets,,,,and any time delays in the model, specified as one of the following values:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • “秒”

  • 'minutes'

  • 'hours'

  • 'days'

  • “周”

  • 'months'

  • 'years'

Changing this property has no effect on other properties, and therefore changes the overall system behavior. UsechgTimeUnitto convert between time units without modifying system behavior.

默认:“秒”

输入名

我nput channel name, specified as a character vector. Use this property to name the input channel of the controller model. For example, assign the name错误to the input of a controller modelCas follows.

C。输入名='错误';

You can use the shorthand notation指的是输入名财产。例如,C。你等同于C。输入名

我nput channel names have several uses, including:

  • 在模型显示器和图上识别频道

  • Specifying connection points when interconnecting models

默认:Empty character vector,''

我nputUnit

我nput channel units, specified as a character vector. Use this property to track input signal units. For example, assign the concentration unitsmol/m^3to the input of a controller modelCas follows.

C。我nputUnit ='mol/m^3';

我nputUnithas no effect on system behavior.

默认:Empty character vector,''

我nputGroup

输入通道组。PID控制器模型不需要此属性。

默认:structw一世th no fields

OutputName

Output channel name, specified as a character vector. Use this property to name the output channel of the controller model. For example, assign the namecontrol输出控制器模型Cas follows.

C。OutputName ='control';

You can use the shorthand notationy指的是OutputName财产。例如,C。y等同于C。OutputName

我nput channel names have several uses, including:

  • 在模型显示器和图上识别频道

  • Specifying connection points when interconnecting models

默认:Empty character vector,''

outputunit

Output channel units, specified as a character vector. Use this property to track output signal units. For example, assign the unitVolts输出控制器模型Cas follows.

C。outputunit='Volts';

outputunithas no effect on system behavior.

默认:Empty character vector,''

OutputGroup

Output channel groups. This property is not needed for PID controller models.

默认:structw一世th no fields

name

系统名称,指定为字符向量。例如,'System_1'

默认:''

notes

Any text that you want to associate with the system, stored as a string or a cell array of character vectors. The property stores whichever data type you provide. For instance, ifsys1andsys2are dynamic system models, you can set theirnotesproperties as follows:

sys1。notes =“ sys1有一个字符串。”;sys2。notes ='sys2 has a character vector.';sys1。notes sys2.Notes
ans =“ sys1具有字符串。”ANS ='SYS2具有字符向量。

默认:[0×1 string]

UserData

您要与系统关联的任何类型的数据,指定为任何MATLAB®data type.

默认:[]

SamplingGrid

Sampling grid for model arrays, specified as a data structure.

对于通过采样一个或多个自变量来得出的模型阵列,此属性跟踪与数组中每个模型关联的变量值。this information appears when you display or plot the model array. Use this information to trace results back to the independent variables.

将数据结构的字段名称设置为采样变量的名称。将字段值设置为与数组中每个模型关联的采样变量值。所有采样变量均应为数字和标量值,所有采样值的阵列应与模型数组的尺寸匹配。

例如,s你ppose you create a 11-by-1 array of linear models,sysarr,,,,by taking snapshots of a linear time-varying system at timest = 0:10。以下代码将使用线性模型存储时间样本。

sysarr.SamplingGrid = struct('time',,,,0:10)

Similarly, suppose you create a 6-by-9 model array,m,,,,by independently sampling two variables,zetaandw。以下代码附加了((zeta,w)值为m

[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',,,,zeta,'w',W)

When you displaym,,,,each entry in the array includes the correspondingzetaandwvalues.

m
m((:,,,,:,,,,1,,,,1)[zeta=0.3, w=5] = 25 -------------- s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25 ---------------- s^2 + 3.5 s + 25 ...

对于通过线性化simulink生成的模型阵列万博1manbetx®model at multiple parameter values or operating points, the software populatesSamplingGridautomatically with the variable values that correspond to each entry in the array. For example, theSimulink Control Design™commandslinearize(万博1manbetxSimulink控制设计)andslLinearizer(万博1manbetxSimulink控制设计)populateSamplingGrid这样。

默认:[]

Examples

collapse all

创建一个具有比例和导数增益的连续时间控制器,并在导数项上创建一个过滤器。为此,将积分增益设置为零。将其他收益设置为所需值。

kp=1;k一世=0;% No integratorkd=3;tF=0。5; C = pid(Kp,Ki,Kd,Tf)
C=skp+kd* -------- Tf*s+1 with Kp = 1, Kd = 3, Tf = 0.5 Continuous-time PDF controller in parallel form.

这d一世splay shows the controller type, formula, and parameter values, and verifies that the controller has no integrator term.

Create a discrete-time PI controller with trapezoidal discretization formula.

创建离散时间PI controller, set the value oftsand the discretization formula usingname,Value句法。

C1= pid(5,2.4,'ts',0.1,'iformula',,,,'Trapezoidal'% Ts = 0.1s
c1 = ts*(z + 1)kp + ki*------- 2*(z-1),kp = 5,ki = 2.4,ts = 0.1样本时间:0.1秒离散时间PI控制器并行形式。

Alternatively, you can create the same discrete-time controller by supplyingts作为所有四个PID参数之后的第五个输入参数,kp,,,,k一世,,,,kd,,,,andtF。Since you only want a PI controller, setkdandtF零。

C2= pid(5,2.4,0,0,0.1,'iformula',,,,'Trapezoidal'
C2=ts*(z+1) Kp + Ki * -------- 2*(z-1) with Kp = 5, Ki = 2.4, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PI controller in parallel form.

这d一世splay shows thatC1andC2是相同的。

创建PID控制器时,设置动态系统属性输入名andOutputName。例如,当您使用其他动态系统模型将PID控制器互连时,这很有用连接command.

C= pid(1,,,,2,,,,3,,,,'InputName',,,,'e',,,,'OutputName',,,,'u'
C=1kp+k一世* --- + Kd * s s with Kp = 1, Ki = 2, Kd = 3 Continuous-time PID controller in parallel form.

显示器未显示PID控制器的输入和输出名称,但是您可以检查属性值。例如,验证控制器的输入名称。

C。输入名
ans =1x1 cell array{'e'}

Create a 2-by-3 grid of PI controllers with proportional gain ranging from 1–2 across the array rows and integral gain ranging from 5–9 across columns.

to build the array of PID controllers, start with arrays representing the gains.

kp=[1 1 1;2 2 2]; Ki = [5:2:9;5:2:9];

When you pass these arrays to thep一世dcommand, the command returns the array.

p一世_array = pid(Kp,Ki,'ts',0.1,'iformula',,,,'BackwardEuler');s一世ze(pi_array)
2x3 array of PID controller. Each PID has 1 output and 1 input.

Alternatively, use the命令构建PID控制器数组。

C= pid(1,,,,5,0.1)% PID controller
C=1kp+k一世* --- + Kd * s s with Kp = 1, Ki = 5, Kd = 0.1 Continuous-time PID controller in parallel form.
CF= pid(1,,,,5,0.1,0.5)% PID controller with filter
Cf = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = 1, Ki = 5, Kd = 0.1, Tf = 0.5 Continuous-time PIDF controller in平行形式。
p一世d_array = stack(2,C,Cf);% stack along 2nd array dimension

这se commands return a 1-by-2 array of controllers.

尺寸(pid_array)
1x2 array of PID controller. Each PID has 1 output and 1 input.

All PID controllers in an array must have the same sample time, discrete integrator formulas, and dynamic system properties such as输入名andOutputName

Convert a standard formp一世dstdcontroller to parallel form.

Standard PID form expresses the controller actions in terms of an overall proportional gainkp,积分和衍生时间常数t一世andtd和过滤器除数n。您可以使用p一世dcommand. For example, consider the following standard-form controller.

kp=2;t一世=3;td=4; N = 50; C_std = pidstd(Kp,Ti,Td,N)
C_std = 1 1 s Kp * (1 + ---- * --- + Td * ------------) Ti s (Td/N)*s+1 with Kp = 2, Ti = 3, Td = 4, N = 50 Continuous-time PIDF controller in standard form

Convert this controller to parallel form usingp一世d

C_PAR = PID(C_STD)
c_par = 1 s kp + ki * --- + kd * ----------------------------- s tf * s + 1 with kp = 2,ki = 0.667,kd = 8,tf = 0.08连续时间pidf控制器平行形式。

将代表PID控制器的连续时间动态系统转换为并行p一世dForm.

以下动态系统,具有积分器和两个零,等效于PID控制器。

H (( s = 3 (( s + 1 (( s + 2 s

Create aZPKmodel ofH。这n use thep一世dcommand to obtainH根据PID的收益kp,,,,k一世,,,,andkd

H=ZPK(([-1,-2],0,3); C = pid(H)
C=1kp+k一世* --- + Kd * s s with Kp = 9, Ki = 6, Kd = 3 Continuous-time PID controller in parallel form.

Convert a discrete-time dynamic system that represents a PID controller with derivative filter to parallelp一世dForm.

Create a discrete-time zpk model that represents a PIDF controller (two zeros and two poles, including the integrator pole atz=1)。

sys=ZPK(([-0.5,-0.6],[1 -0.2],3,'ts',0.1);

When you convertsysto PID form, the result depends on which discrete integrator formulas you specify for the conversion. For instance, use the default,向前的人,,,,For both the integrator and the derivative.

CFe = pid(sys)
CFe = Ts 1 Kp + Ki * ------ + Kd * ----------- z-1 Tf+Ts/(z-1) with Kp = 2.75, Ki = 60, Kd = 0.0208, Tf = 0.0833, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PIDF controller in parallel form.

now convert using thetrapezoidal公式。

Ctrap = pid(sys,'iformula',,,,'Trapezoidal',,,,'DFormula',,,,'Trapezoidal'
ctrap = ts *(z + 1)1 kp + ki * --------- + kd * ------------------------------ 2 *(z-1))tF+ts/2*(z+1)/(z-1) with Kp = -0.25, Ki = 60, Kd = 0.0208, Tf = 0.0333, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PIDF controller in parallel form.

显示器显示了结果系数值和功能形式的差异。

For this particular dynamic system, you cannot writesys以平行的pid形式使用BackwardEulerFormula for the derivative filter. Doing so would result inTF <0,不允许。在这种情况下,p一世dreturns an error.

d一世scretize a continuous-time PID controller and set integral and derivative filter formulas.

Create a continuous-time controller and discretize it using the zero-order-hold method of thec2dcommand.

Ccon = pid(1,2,3,4);% continuous-time PIDF controllerCDIS1 = C2D(CCON,0.1,'zoh'
CDIS1=ts1kp+k一世* ------ + Kd * ----------- z-1 Tf+Ts/(z-1) with Kp = 1, Ki = 2, Kd = 3.04, Tf = 4.05, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PIDF controller in parallel form.

这d一世splay shows thatc2d计算离散时间控制器的新PID增益。

这d一世screte integrator formulas of the discretized controller depend on thec2dd一世scretization method, as described int一世ps。For theZoh方法,两者我FormulaandDFormulaare向前的人

CDIS1。我Formula
ans ='forwardeuler'
CDIS1。dFormula
ans ='forwardeuler'

如果you want to use different formulas from the ones returned byc2d,,,,then you can directly set thets,,,,我Formula,,,,andDFormulaproperties of the controller to the desired values.

CDIS2=Ccon; Cdis2.Ts = 0.1; Cdis2.IFormula ='BackwardEuler';CDIS2。dFormula ='BackwardEuler';

但是,这些命令不会为离散控制器计算新的PID收益。要看到这个,请检查CDIS2and compare the coefficients toCconandCDIS1

CDIS2
CDIS2=ts*z 1 Kp + Ki * ------ + Kd * ------------- z-1 Tf+Ts*z/(z-1) with Kp = 1, Ki = 2, Kd = 3, Tf = 4, Ts = 0.1 Sample time: 0.1 seconds Discrete-time PIDF controller in parallel form.

t一世ps

  • Usep一世dto:

    • Create ap一世dcontroller object from known PID gains and filter time constant.

    • Convert ap一世dstdcontroller object to a standard-formp一世d控制器对象。

    • 将其他类型的动态系统模型转换为p一世d控制器对象。

  • 要设计特定工厂的PID控制器,请使用p一世dtuneorp一世dt你ner。要创建可调PID控制器作为控制设计块,请使用tunablePID

  • 创建阵列p一世d控制器对象:

    • Specifying array values forkp,,,,k一世,,,,kd,,,,andtF

    • 指定一系列动态系统systo convert top一世dcontroller objects

    • 使用to build arrays from individual controllers or smaller arrays

    我n an array ofp一世dcontrollers, each controller must have the same sample timetsand discrete integrator formulas我FormulaandDFormula

  • to create or convert to a standard-form controller, usep一世dstd。Standard form expresses the controller actions in terms of an overall proportional gainkp,,,,一世ntegral and derivative timest一世andtd和过滤器除数n

    C = k p (( 1 + 1 t 一世 1 s + t d s t d n s + 1

  • 这re are two ways to discretize a continuous-timep一世dcontroller:

    • 使用c2dcommand.c2d计算离散控制器的新参数值。离散控制器的离散集成器公式取决于c2dd一世scretization method you use, as shown in the following table.

      c2dd一世scretization Method 我Formula DFormula
      'zoh' 向前的人 向前的人
      'foh' trapezoidal trapezoidal
      'tustin' trapezoidal trapezoidal
      'impulse' 向前的人 向前的人
      “匹配” 向前的人 向前的人

      有关有关的更多信息c2d离散方法,请参阅c2dreference page. For more information about我FormulaandDFormula, 看Properties

    • 如果您需要不同的离散集成符公式,则可以直接设置控制器离散ts,,,,我Formula,,,,andDFormulato the desired values. (Seed一世scretize a Continuous-Time PID Controller)。然而,这种方法不计算新的收获and filter-constant values for the discretized controller. Therefore, this method might yield a poorer match between the continuous- and discrete-timep一世d控制器比使用c2d

版本历史记录

我ntroduced in R2010b