Main Content

pidstd

创造a PID controller in standard form, convert to standard-form PID controller

Syntax

c = pidstd(kp,ti,td,n)
C = pidstd(Kp,Ti,Td,N,Ts)
C = pidstd(sys)
C = PIDSTD(KP)
c = pidstd(kp,ti)
C = PIDSTD(KP,TI,TD)
C = pidstd(...,Name,Value)
C = pidstd

Description

C= pidstd(KP,Ti,Td,N)creates a continuous-time PIDF (PID with first-order derivative filter) controller object in standard form. The controller has proportional gainKP、积分和微分时间sTiTd, 和first-order derivative filter divisorN:

C = K p ( 1 + 1 T i 1 s + T d s T d N s + 1 )

C= pidstd(KP,Ti,Td,N,Ts)creates a discrete-time controller with sample timeTs。The discrete-time controller is:

C = K p ( 1 + 1 T i I F ( z ) + T d T d N + D F ( z ) )

如果(z) andDF(z)是discrete integrator formulasfor the integrator and derivative filter. By default,

I F ( z ) = D F ( z ) = T s z 1

To choose different discrete integrator formulas, use the如果或者mulaDFormula输入。(看Properties更多的information about如果或者mulaDFormula)。IfDFormula='前锋'(the default value) andNInf, thenTs,Td, 和Nmust satisfyTd/N > Ts/2。This requirement ensures a stable derivative filter pole.

C= pidstd(sys)转换动态系统systo a standard formpidstd控制器对象。

C= pidstd(KP)creates a continuous-time proportional (P) controller withTi=Inf,Td= 0, andN=Inf

C= pidstd(KP,Ti)creates a proportional and integral (PI) controller withTd= 0 andN=Inf

C= pidstd(KP,Ti,Td)creates a proportional, integral, and derivative (PID) controller withN=Inf

C= pidstd(...,,名称,价值)creates a controller or converts a dynamic system to apidstd控制ler object with additional options specified by one or more名称,价值pair arguments.

C= pidstdcreates a P controller withKP= 1。

输入参数

KP

比例收益。

KPcan be:

  • 真实和有限的价值。

  • An array of real and finite values.

  • A tunable parameter (realp) or generalized matrix (Genmat)。

  • 可调表面用于增益安排的调整,使用TunablesUrface

Default:1

Ti

Integrator time.

Tican be:

  • 真正的积极价值。

  • 一系列真实和积极的价值。

  • A tunable parameter (realp) or generalized matrix (Genmat)。

  • 可调表面用于增益安排的调整,使用TunablesUrface

Default:Inf

Td

Derivative time.

Tdcan be:

  • 真实,有限和非负值。

  • 一系列真实,有限和非负值。

  • A tunable parameter (realp) or generalized matrix (Genmat)。

  • 可调表面用于增益安排的调整,使用TunablesUrface

WhenTd= 0,控制器没有衍生作用。

Default:0

N

导数滤波器分裂。

Ncan be:

  • 真正的积极价值。

  • 一系列真实和积极的价值。

  • A tunable parameter (realp) or generalized matrix (Genmat)。

  • 可调表面用于增益安排的调整,使用TunablesUrface

WhenN=Inf, the controller has no filter on the derivative action.

Default:Inf

Ts

Sample time.

To create a discrete-timepidstd控制ler, provide a positive real value (Ts > 0)。pidstddoes not support discrete-time controller with undetermined sample time (Ts = -1)。

Tsmust be a scalar value. In an array ofpidstd控制lers, each controller must have the sameTs

Default:0 (continuous time)

sys

SISO动态系统转换为标准pidstdform.

sys必须代表一个有效的控制器,可以用标准形式编写Ti> 0,Td≥ 0, andN> 0。

sys也可以是SISO动态系统的一系列。

Name-Value Arguments

Specify optional comma-separated pairs of名称,价值arguments.Name是the argument name and价值是相应的值。Name必须出现在引号中。您可以按任何顺序指定几个名称和值对参数Name1,Value1,...,NameN,ValueN

利用名称,价值syntax to set the numerical integration formulas如果或者mulaDFormula的a discrete-timepidstd控制ler, or to set other object properties such asInputName输出名称。有关可用属性的信息pidstd控制ler objects, seeProperties

Output Arguments

C

pidstdobject representing a single-input, single-output PID controller in standard form.

控制器类型(P,PI,PD,PDF,PID,PIDF)取决于KP,Ti,Td, 和N。For example, whenTd=InfKPTiare finite and nonzero,C是a PI controller. EntergetType(C)to obtain the controller type.

When the inputsKP,Ti,Td, 和N或者the inputsysare arrays,C是一个数组pidstd对象。

Properties

KP

比例收益。KPmust be real and finite.

Ti

Integral time.Timust be real, finite, and greater than or equal to zero.

Td

Derivative time.Tdmust be real, finite, and greater than or equal to zero.

N

导数滤波器分裂。Nmust be real, and greater than or equal to zero.

如果或者mula

Discrete integrator formula如果(z)用于离散时间的集成器pidstd控制lerC:

C = K p ( 1 + 1 T i I F ( z ) + T d T d N + D F ( z ) )

如果或者mulacan take the following values:

  • '前锋'如果(z)= T s z 1

    该公式最适合较小的样品时间,与控制器的带宽相比,Nyquist极限很大。在较大的样本时间中ForwardEulerformula can result in instability, even when discretizing a system that is stable in continuous time.

  • 'BackwardEuler'如果(z)= T s z z 1

    An advantage of the后卫formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result.

  • 'Trapezoidal'如果(z)= T s 2 z + 1 z 1

    An advantage of theTrapezoidalformula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result. Of all available integration formulas, theTrapezoidal公式在离散系统的频域特性与相应的连续时间系统之间取得了最接近的匹配。

WhenC是a continuous-time controller,如果或者mula''

Default:'前锋'

DFormula

Discrete integrator formulaDF(z) for the derivative filter of the discrete-timepidstd控制lerC:

C = K p ( 1 + 1 T i I F ( z ) + T d T d N + D F ( z ) )

DFormulacan take the following values:

  • '前锋'DF(z)= T s z 1

    该公式最适合较小的样品时间,与控制器的带宽相比,Nyquist极限很大。在较大的样本时间中ForwardEulerformula can result in instability, even when discretizing a system that is stable in continuous time.

  • 'BackwardEuler'DF(z)= T s z z 1

    An advantage of the后卫formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result.

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

    An advantage of theTrapezoidalformula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result. Of all available integration formulas, theTrapezoidal公式在离散系统的频域特性与相应的连续时间系统之间取得了最接近的匹配。

    TheTrapezoidalvalue forDFormula是not available for apidstd没有衍生过滤器的控制器(N = Inf)。

WhenC是a continuous-time controller,DFormula''

Default:'前锋'

InputDelay

Time delay on the system input.InputDelay是always 0 for apidstd控制器对象。

OutputDelay

Time delay on the system Output.OutputDelay是always 0 for apidstd控制器对象。

Ts

Sample time. For continuous-time models,TS = 0。For discrete-time models,Ts是a positive scalar representing the sampling period. This value is expressed in the unit specified by theTimeUnitproperty of the model. PID controller models do not support unspecified sample time (Ts = -1)。

Changing this property does not discretize or resample the model. Usec2dD2C在连续和离散时间表示之间转换。利用D2Dto change the sample time of a discrete-time system.

Default:0(continuous time)

TimeUnit

Units for the time variable, the sample timeTs,以及该模型中的任何时间延迟,指定为以下值之一:

  • '纳秒'

  • 'microseconds'

  • “毫秒”

  • 'seconds'

  • 'minutes'

  • 'hours'

  • 'days'

  • 'weeks'

  • '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.

Default:'seconds'

InputName

输入通道名称,指定为字符向量。使用此属性命名控制器模型的输入通道。例如,分配名称error输入控制器模型Cas follows.

C.InputName ='error';

您可以使用速记符号uto refer to theInputNameproperty. For example,C.U是equivalent toC.InputName

Input channel names have several uses, including:

  • Identifying channels on model display and plots

  • Specifying connection points when interconnecting models

Default:空字符向量,''

inputunit

Input channel units, specified as a character vector. Use this property to track input signal units. For example, assign the concentration unitsmol/m^3输入控制器模型Cas follows.

C. -inputunit ='mol/m^3';

inputunit对系统行为没有影响。

Default:空字符向量,''

InputGroup

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

Default:结构with no fields

输出名称

输出通道名称,指定为字符向量。使用此属性命名控制器模型的输出通道。例如,分配名称控制to the output of a controller modelCas follows.

C.Outputname ='control';

您可以使用速记符号yto refer to the输出名称property. For example,C.y是equivalent toC.OutputName

Input channel names have several uses, including:

  • Identifying channels on model display and plots

  • Specifying connection points when interconnecting models

Default:空字符向量,''

OutputUnit

输出通道单元,指定为字符向量。使用此属性跟踪输出信号单元。例如,分配单元Voltsto the output of a controller modelCas follows.

C.outputunit ='Volts';

OutputUnit对系统行为没有影响。

Default:空字符向量,''

输出组

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

Default:结构with no fields

Name

System name, specified as a character vector. For example,'system_1'

Default:''

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, ifsys1sys2是动态系统模型,您可以设置他们的Notesproperties as follows:

sys1.notes ="sys1 has a string."; sys2.Notes ='sys2 has a character vector.'; sys1.Notes sys2.Notes
ans = "sys1 has a string." ans = 'sys2 has a character vector.'

Default:[0×1 string]

用户数据

Any type of data you want to associate with system, specified as any MATLAB®数据类型。

Default:[]

SamplingGrid

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

For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array.This information appears when you display or plot the model array. Use this information to trace results back to the independent variables.

Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array.

例如,假设您创建一个11 x-1线性模型的数组,sysarr,通过有时拍摄线性时间变化系统的快照t = 0:10。The following code stores the time samples with the linear models.

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

Similarly, suppose you create a 6-by-9 model array,M,通过独立采样两个变量,zetaw。The following code attaches the(zeta,w)values toM

[zeta,w] = ndgrid(zeta>的<6值,<9值W>的值)m.samplinggrid = struct(struct(struct)('Zeta',zeta,'W',w)

When you displayM,阵列中的每个条目包括相应的zetawvalues.

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 ...

For model arrays generated by linearizing a Simulink®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™commands线性化(Simulink Control Design)Sllinearizer(Simulink Control Design)populateSamplingGridin this way.

Default:[]

Examples

创造Continuous-Time Standard-Form PDF Controller

创造a continuous-time standard-form PDF controller with proportional gain 1, derivative time 3, and a filter divisor of 6.

C = pidstd(1,Inf,3,6);
c = s kp *(1 + td * -------------)(td/n) * s + 1 with kp = 1,td = 3,n = 6连续时间PDF控制器标准格式

The display shows the controller type, formula, and coefficient values.

创造Discrete-Time PI Controller with Trapezoidal Discretization Formula

要创建离散时间控制器,请设置Tsusing名称,价值syntax.

C = pidstd(1,0.5,'Ts',0.1,'IFormula','Trapezoidal')% Ts = 0.1s

This command produces the result:

标准形式的离散时间PI控制器:1 ts *(z + 1)kp *(1 + ----- * ---------------)ti 2 *(z-1),kp = 1,ti= 0.5,ts = 0.1

另外,您可以通过提供相同的离散时间控制器Ts作为所有四个PID参数之后的第五个参数KP,Ti,Td, 和N

C = pidstd(5,2.4,0,Inf,0.1,'IFormula','Trapezoidal');

创造PID Controller and Set System Properties

创造a PID controller and set dynamic system propertiesInputName输出名称

C = pidstd(1,0.5,3,'InputName','e','OutputName','u');

创建标准形式PID控制器的网格

创造a 2-by-3 grid of PI controllers with proportional gain ranging from 1–2 and integral time ranging from 5–9.

创造a grid of PI controllers with proportional gain varying row to row and integral time varying column to column. To do so, start with arrays representing the gains.

KP= [1 1 1;2 2 2]; Ti = [5:2:9;5:2:9]; pi_array = pidstd(Kp,Ti,'Ts',0.1,'IFormula','BackwardEuler');

这些命令产生2 x-3的离散时间pidstd对象。Allpidstdobjects in an array must have the same sample time, discrete integrator formulas, and dynamic system properties (such asInputName输出名称)。

Alternatively, you can use thestackcommand to build arrays ofpidstd对象。

C = PIDSTD(1,5,0.1)%PID控制器CF = PIDSTD(1,5,0.1,0.5)%PID控制器with filterpid_array = stack(2,C,Cf);%沿第二个数组尺寸堆叠

These commands produce a 1-by-2 array of controllers. Enter the command:

size(pid_array)

to see the result

1x2 array of PID controller. Each PID has 1 output and 1 input.

转换并行形式pidController to Standard Form

Parallel PID form expresses the controller actions in terms of an proportional, integral, and derivative gainsKp,Ki, 和Kd, 和a filter time constantTf。You can convert a parallel form controllerparsysto standard form usingpidstd, provided that:

  • parsys是not a pure integrator (I) controller.

  • 收益KP,ki, 和KDparsysall have the same sign.

parsys = pid(2,3,4,5);% Standard-form controllerstdsys = pidstd(parsys)

这些命令产生一个并行形式的控制器:

Continuous-time PIDF controller in standard form: 1 1 s Kp * (1 + ---- * --- + Td * ------------) Ti s (Td/N)*s+1 with Kp = 2, Ti = 0.66667, Td = 2, N = 0.4

创造pidstdController from Continuous-Time Dynamic System

动态系统

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

represents a PID controller. Usepidstdto obtainH(s) to in terms of the standard-form PID parametersKp,Ti, 和Td

H = zpk([-1,-2],0,3); C = pidstd(H)

These commands produce the result:

Continuous-time PID controller in standard form: 1 1 Kp * (1 + ---- * --- + Td * s) Ti s with Kp = 9, Ti = 1.5, Td = 0.33333

创造pidstd离散时间动态系统的控制器

You can convert a discrete-time dynamic system that represents a PID controller with derivative filter to standardpidstdform.

% PIDF controller expressed in zpk formsys = zpk([-0.5,-0.6],[1 -0.2],3,'Ts',0.1);

The resultingpidstdobject depends upon the discrete integrator formula you specify for如果或者mulaDFormula

For example, if you use the defaultForwardEulerfor both formulas:

C = pidstd(sys)

您获得结果:

离散时间PIDF控制器标准形式:1Ts 1 Kp * (1 + ---- * ------ + Td * ---------------) Ti z-1 (Td/N)+Ts/(z-1) with Kp = 2.75, Ti = 0.045833, Td = 0.0075758, N = 0.090909, Ts = 0.1

对于这个特殊sys, you cannot writesysin standard PID form using the后卫公式DFormula。Doing so would result inN<0,不允许。在这种情况下,pidstdreturns an error.

同样,你也不能写sys以标准形式使用Trapezoidal两个集成商的公式。这样做会导致负面TiTd, which also returns an error.

Discretize Continuous-TimepidstdController

首先,使用'zoh'method ofc2d

Cc = pidstd(1,2,3,4);% continuous-time pidf controllerCD1 = C2D(CC,0.1,'zoh')
离散时间PIDF控制器标准形式:1Ts 1 Kp * (1 + ---- * ------ + Td * ---------------) Ti z-1 (Td/N)+Ts/(z-1) with Kp = 1, Ti = 2, Td = 3.2044, N = 4, Ts = 0.1

The resulting discrete-time controller usesForwardEuler(Ts/((z–1)) for both如果或者mulaDFormula

The discrete integrator formulas of the discretized controller depend upon thec2d离散方法,如Tips。To use a different如果或者mulaDFormula, directly setTs,如果或者mula, 和DFormulato the desired values:

Cd2 = Cc; Cd2.Ts = 0.1; Cd2.IFormula ='BackwardEuler'; Cd2.DFormula ='BackwardEuler';

These commands do not compute new parameter values for the discretized controller. To see this, enter:

Cd2

获得结果:

离散时间PIDF控制器标准形式:1Ts*z 1 Kp * (1 + ---- * ------ + Td * -----------------) Ti z-1 (Td/N)+Ts*z/(z-1) with Kp = 1, Ti = 2, Td = 3, N = 4, Ts = 0.1

Tips

  • 利用pidstdeither to create apidstd控制ler object from known PID gain, integral and derivative times, and filter divisor, or to convert a dynamic system model to apidstd目的。

  • To tune a PID controller for a particular plant, usepidtune或者pidTuner

  • 创造arrays ofpidstd控制lers by:

    • 指定数组的值KP,Ti,Td, 和N

    • Specifying an array of dynamic systemssys转换为标准PID形式

    • Usingstack从单个控制器或较小数组构建数组

    在一系列pidstd控制lers, each controller must have the same sample timeTs和离散集成商公式如果或者mulaDFormula

  • To create or convert to a parallel-form controller, usepid。并行形式以比例,积分和衍生品的增长来表达控制器的作用Kp,KiKd, 和a filter time constantTf:

    C = K p + K i s + K d s T f s + 1

  • There are two ways to discretize a continuous-timepidstd控制器:

    • 利用thec2dcommand.c2dcomputes new parameter values for the discretized controller. The discrete integrator formulas of the discretized controller depend upon thec2ddiscretization method you use, as shown in the following table.

      c2dDiscretization Method 如果或者mula DFormula
      'zoh' ForwardEuler ForwardEuler
      'foh' Trapezoidal Trapezoidal
      'tustin' Trapezoidal Trapezoidal
      'impulse' ForwardEuler ForwardEuler
      'matched' ForwardEuler ForwardEuler

      For more information aboutc2ddiscretization methods, See thec2dreference page. For more information about如果或者mulaDFormula, seeProperties

    • If you require different discrete integrator formulas, you can discretize the controller by directly settingTs,如果或者mula, 和DFormula到所需的值。(有关更多信息,请参阅Discretize Continuous-Time pidstd Controller。) However, this method does not compute new gain and filter-constant values for the discretized controller. Therefore, this method might yield a poorer match between the continuous-time and discrete-timepidstd控制lers than usingc2d

Version History

在R2010b中引入