Modelica_LinearSystems2.Controller

Continuous and discrete input/output blocks. Easy to switch from continuous to discrete representation.

Information


This library provides input/output blocks where every block is available in a continuous and a discrete (sampled) representation. A block is defined via its continuous parameterization. By specifying a discretization method and a sample time, the discrete representation is automatically derived from the continuous form. The defaults of the most important options for all blocks are set in the global SampleClock component (via inner/outer). As a result, it is, e.g., easy to switch quickly between a continuous and a discrete representation of all blocks of a controller.

Examples to demonstrate the technique are given in sublibrary Examples. Especially, the continuous or discrete control of a simple flexible drive with a P-PI cascade controller is demonstrated in example SimpleControlledDrive.

Extends from Modelica.Icons.Library (Icon for library).

Package Content

NameDescription
Modelica_LinearSystems2.Controller.UsersGuide UsersGuide Users Guide
Modelica_LinearSystems2.Controller.Examples Examples Demonstrate the usage of package Controller
Modelica_LinearSystems2.Controller.SampleClock SampleClock Global options for blocks of Controller library (in particular sample clock)
Modelica_LinearSystems2.Controller.Sampler Sampler Sample the input signal if discrete block or y=u if continuous block
Modelica_LinearSystems2.Controller.StateSpace StateSpace Continuous or discrete state space system block
Modelica_LinearSystems2.Controller.TransferFunction TransferFunction Continuous or discrete, single input single output transfer function
Modelica_LinearSystems2.Controller.ZerosAndPoles ZerosAndPoles Continuous or discretized, single input single output block described by a ZerosAndPoles object
Modelica_LinearSystems2.Controller.Filter Filter Continuous or discretized analog low or high pass IIR-filter (CriticalDamping/Bessel/Butterworth/Chebyshev)
Modelica_LinearSystems2.Controller.FilterFIR FilterFIR Discrete finite impulse response low or high pass filter
Modelica_LinearSystems2.Controller.Integrator Integrator Output the integral of the input signal (continuous or discrete block)
Modelica_LinearSystems2.Controller.Derivative Derivative Approximate derivative (continuous or discrete block)
Modelica_LinearSystems2.Controller.FirstOrder FirstOrder First order (continuous or discrete) transfer function block (= 1 pole)
Modelica_LinearSystems2.Controller.SecondOrder SecondOrder Second order (continuous or discrete) transfer function block (= 2 poles)
Modelica_LinearSystems2.Controller.PI PI Proportional-Integral controller (continuous or discrete block)
Modelica_LinearSystems2.Controller.PID PID PID-controller in additive description form
Modelica_LinearSystems2.Controller.LimPID LimPID P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting
Modelica_LinearSystems2.Controller.UnitDelay UnitDelay Delay the input by a multiple of the base sample time if discrete block or y=u if continuous block
Modelica_LinearSystems2.Controller.ADconverter ADconverter Analog to digital converter (including sampler)
Modelica_LinearSystems2.Controller.DAconverter DAconverter Digital to analog converter (including zero order hold)
Modelica_LinearSystems2.Controller.MatrixGain MatrixGain Output the product of a gain matrix with the input signal vector. The matrix can be loaded from a file optionally
Modelica_LinearSystems2.Controller.Noise Noise Block that generates a uniform distributed noise output signal at sample instants if discrete and y=0 if continuous
Modelica_LinearSystems2.Controller.Icons Icons  
Modelica_LinearSystems2.Controller.Interfaces Interfaces Interfaces (partial blocks) of Controller library
Modelica_LinearSystems2.Controller.Templates Templates Templates of control structures
Modelica_LinearSystems2.Controller.Types Types Constants and types with choices, especially to build menus
DataDir=Modelica_LinearSystems2.DataDirAbsolute path to directory containing utilitiy files for this package, such as images

Modelica_LinearSystems2.Controller.SampleClock Modelica_LinearSystems2.Controller.SampleClock

Global options for blocks of Controller library (in particular sample clock)

Information


Global block that defines options for all components of the Controller library that are on the same or on a lower level as the sampleClock component. In particular it is defined whether the blocks shall be used by default in a continuous or a discrete representation. In the latter case, the default discretization method and the base sample time is defined. The sample time of a block is an integer multiple of the base sample time defined in the SampleClock component.

Parameters

NameDescription
blockTypeType of Sampled blocks (Continuous or Discrete)
methodTypeDiscretization method for discrete blocks
sampleTimeBase sample time for discrete blocks [s]
initTypeType of initialization of Sampled blocks

Modelica_LinearSystems2.Controller.Sampler Modelica_LinearSystems2.Controller.Sampler

Sample the input signal if discrete block or y=u if continuous block

Information


If discrete block, the output y is sampled according to sample time sampleClock.sampleTime * sampleFactor, where sampleClock.sampleTime is defined globally in the outer component sampleClock and sampleFactor is an Integer parameter of component Sampler.

If continuous block, the output y is identical to the input u.

Extends from Interfaces.PartialSISO_equality (Partial Single Input Single Output (continuous or discrete) control block of Controller library where usually y=u if continuous block).

Parameters

NameDescription
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.StateSpace Modelica_LinearSystems2.Controller.StateSpace

Continuous or discrete state space system block

Information


Extends from Interfaces.PartialSampledBlock (Partial block of Sampled library (icon + default parameters)).

Parameters

NameDescription
systemContinuous linear time-invariant system
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_start[nx]Initial or guess values of states
y_start[ny]Initial values of outputs (remaining states are in steady state if possible)

Connectors

NameDescription
u[size(system.B, 2)]Continuous or discrete input signals of block
y[size(system.C, 1)]Continuous or discrete output signals of block
x[nx]State vector of continuous system

Modelica_LinearSystems2.Controller.TransferFunction Modelica_LinearSystems2.Controller.TransferFunction

Continuous or discrete, single input single output transfer function

Information


Extends from Modelica_LinearSystems2.Controller.Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
systemTransfer function
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_start[nx]Initial or guess values of states
y_startInitial value of output (derivatives of y are zero upto nx-1-th derivative)

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block
x[nx]State of continuous transfer function

Modelica_LinearSystems2.Controller.ZerosAndPoles Modelica_LinearSystems2.Controller.ZerosAndPoles

Continuous or discretized, single input single output block described by a ZerosAndPoles object

Information


This function transforms a zeros-poles-gain system representation into state space representation. To achieve well numerical condition the ZerosAndPoles transfer function is transformed into state space form by creating first and second order blocks that are connected together in series. Every block is represented in controller canonical form and scaled such that the gain from the input of this block to its output is one (i.e. y(s=0) = u(s=0)), if this is possible. Details are given below.

Algorithmic details

The ZerosAndPoles transfer function is defined as:

         product(s + n1[i]) * product(s^2 + n2[i,1]*s + n2[i,2])
  y = k*--------------------------------------------------------- * u
         product(s + d1[i]) * product(s^2 + d2[i,1]*s + d2[i,2])

This is treated as a series connection of first and second order systems. If size(n1) == size(d1) and size(n2) == size(d2) this gives the following sequence of operations:

        s^2 + n2[1,1]*s + n2[1,2]
  y_1 = ------------------------- * u
        s^2 + d2[1,1]*s + d2[1,2]
 
        s^2 + n2[2,1]*s + n2[2,2]
  y_2 = ------------------------- * y_1
        s^2 + d2[2,1]*s + d2[2,2]
 
     ...
 
        s + n1[..]
  y_n = ---------- * y_(n-1)
        s + d1[..]
 
    y = k*y_n

Based on this representation, evrey block with transfer function G(s) could be transformed into

  G(s) = k * F(s)

with F(s) has unit gain. This leads to representations of the forms

           a2 + a1*s + s^2       a2      b2 + a1*b2/a2*s + b2/a2*s^2         
  G(s) = -------------------- = ---- * ------------------------------ = k * F(s),  k = a2/b2  (1)
           b2 + b1*s + s^2       b2           b2 + b1*s + s^2                 
 
for second order systems and 
 
           a + s     a     b + b/a*s       
  G(s) = -------- = --- * ---------- = k * F(s),   k = a/b
           b + s     b      b + s           

for first order systems respectively.

The complete system is now considered as the series connections of all the single unit gain transfer functions and an overall gain k with

  k = product(ki).

In the general case, the following system structures and the corresponding state space systems can appear (note, 'c' is the reciprocal local gain 1/k):

(1)
          a2 + a1*s + s^2           der(x1) = x2
    y = ---------------------  -->  der(x2) = -b2*x1 - b1*x2 + b2*u
          b2 + b1*s + s^2                 y = c*((a2-b2)*x1 + (a1-b1)*x2 + u),  c = b2/a2
 
(2)
             s + a                 der(x1) = x2
    y = ---------------- * u  -->  der(x2) = -b2*x1 - b1*x2 + b2*u 
        b2 + b1*s + s^2                  y = k*(a1/b2*x1 +x2/b2),  c = b2/a
 
(3)
               1                  der(x1) = x2
    y = --------------- *u   -->  der(x2) = -b2*x1 - b1*x2 + b2*u
        b2 + b1*s + s^2                 y = c*x1/b2,  c = b2
 
(4)
       a + s                       der(x) = -b*x + b*u
   y = ----- * u             -->        y = c*((a-b)/b*x + u),  c = b/a
       b + s
 
(5)
         1                 
   y = ----- * u             -->   der(x) = -b*x + b*u
       b + s                            y = x,  c = b

If the sizes of the numerator and denominator polynomials do not match, the small systems are built in the following way:

(1) Build systems of form (1) by combining
    - 1 d2 and 1 n2 
      (= 1 second order denominator and 1 second order numerator) or
    - 1 d2 and 2 n1 or
    - 2 d1 and 1 n2
(2) Build at most one system of form (2) by combining
    - 1 d2 and 1 n2
(3) Build systems of form (3) by
    - 1 d2
(4) Build systems of form (4) by combining
    - 1 d1 and 1 n1
(5) Build systems of form (5) by 
    - 1 d1 

The numeric properties of the resulting state space system depends on which first and second order polynomials are combined and connected together. From a numerical point of view, it would therefore be useful to combine the polynomials based on the numeric values of the polynomial coefficients, (e.g., in a first step the polynomials could be sorted according to their cut-off frequency).

However, this has the disadvantage that the structure of the resulting state space system depends on the numeric values of the polynomial coefficients. Since Modelica environments perform symbolic pre-processing on equations, this would mean that a change of a polynomial coefficient requires to newly compile the state space system.

If, on the other hand, the structure of the state space system depends only on dimension information of the n1,n2,d1,d2 arrays, then the polynomial coefficients can be changed without a new translation of the model. This is the major reason why the structure of the state space system in the implementation of this block is based only on dimension information.

This is, e.g., not critical for the provided filters: The dimension of the n1,n2,d1,d2 arrays depend for filters only on the filter characteristics (Bessel, Butterworth etc.), the filter type (low pass, high pass etc.) and on the filter order. If any of this data is changed, the model has to be newly compiled. All the other filter data, such as cut-off frequency or ripple amplitude, can be changed without re-compilation of the model. The ZerosAndPoles transfer function is now constructed for the filters in such a way that the filter zeros and poles are appropriately sorted to give better numerical properties.

Another alternative implementation of the state space system would be to use the function controller canonical form that directly results from the transfer function. The severe disadvantage of this approach is that the structure of the state space system from above is lost for the symbolic preprocessing. If, e.g., index reduction has to be applied (e.g. since a filter is used to realize a non-linear inverse model), then the tool cannot perform the index reduction. Example:

Assume, a generic first order state space system is present

   der(x) = a*x + b*u
        y = c*x + d*u

and the values of the scalars a,b,c,d are parameters that might be changed before the simulation starts. If y has to be differentiated symbolically during code generation, then

      der(y) = c*der(x) + d*der(u)
      der(x) = a*x + b*u

As a result, u needs to be differentiated too, and this might not be possible and therefore translation might fail.

On the other hand, if the first order system is defined to be a low pass filter and the state space system is generated by keeping this structure, we have (see form (5) above):

   der(x) = -b*x + u
        y = x

Differentiating y symbolically leads to:

     der(y) = der(x)
     der(x) = -b*x + u

Therefore, in this case, the derivative of u is not needed and the tool can continue with the symbolic processing.

Extends from Modelica_LinearSystems2.Controller.Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
systemData defining the ZerosAndPoles object
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_start[nx]Initial or guess values of states
y_startInitial or guess values of output

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block
x[nx]State of continuous block

Modelica_LinearSystems2.Controller.Filter Modelica_LinearSystems2.Controller.Filter

Continuous or discretized analog low or high pass IIR-filter (CriticalDamping/Bessel/Butterworth/Chebyshev)

Information


This block has to be improved for discrete mode. At present, this function seems not to be reliable. Please use "criticalDamping instead

Extends from ZerosAndPoles (Continuous or discretized, single input single output block described by a ZerosAndPoles object).

Parameters

NameDescription
systemData defining the ZerosAndPoles object
analogFilterAnalog filter characteristics (CriticalDamping/Bessel/Butterworth/Chebyshev)
filterTypeType of filter (LowPass/HighPass)
orderOrder of filter
f_cutCut-off frequency [Hz]
gainGain (= amplitude of frequency response at zero frequency)
normalized= true, if amplitude of low pass filter at f_cut is 1/sqrt(2) (=3db)
A_ripplePass band ripple for Chebyshev filter (otherwise not used) [dB]
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_start[nx]Initial or guess values of states
y_startInitial or guess values of output

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block
x[nx]State of continuous block

Modelica_LinearSystems2.Controller.FilterFIR Modelica_LinearSystems2.Controller.FilterFIR

Discrete finite impulse response low or high pass filter

Information

Extends from Interfaces.PartialSISO_equality (Partial Single Input Single Output (continuous or discrete) control block of Controller library where usually y=u if continuous block).

Parameters

NameDescription
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor
specTypeSpecification type of FIR filter
LLength of mean value filter
filterTypeType of filter
orderOrder of filter
f_cutCut-off frequency [Hz]
windowType of window
betaBeta-Parameter for Kaiser-window
a[:]FIR filter coefficients

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.Integrator Modelica_LinearSystems2.Controller.Integrator

Output the integral of the input signal (continuous or discrete block)

Information


This blocks defines the transfer function between the input u and the output y as integrator:

          k
     y = --- * u
          s

The block can be continuous or discrete (with continuous parameterization).

It is not possible to initalize a continuous integrator in steady state. For this reason, option "initType = SteadyState" is ignored for a continuous integrator block and interpreted as "initType = InitialState".

Extends from Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
kIntegrator gain
withDelay 
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
y_startInitial or guess value of output (=state)

Connectors

NameDescription
uContinuous or discrete input signal of block

Modelica_LinearSystems2.Controller.Derivative Modelica_LinearSystems2.Controller.Derivative

Approximate derivative (continuous or discrete block)

Information


This blocks defines the transfer function between the input u and the output y as approximative derivative (DT1):

             k * s
     y = ------------ * u
            T * s + 1

The block can be continuous or discrete (with continuous parameterization).

If k=0, the state space realization of the block is specially constructed, in order that the D-part of PID controllers can be set to zero without introducing numerical problems.

If you would like to be able to change easily between different transfer functions (FirstOrder, SecondOrder, ... ) by changing parameters, use the general model class TransferFunction instead and model a DT1 system with parameters
n = {k,0}, d = {T,1}.

Extends from Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
kGain
TTime Constant (T>0 required; T=0 is ideal derivative block) [s]
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_startInitial or guess value of state
y_startInitial or guess value of output

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block
xState of approximative derivative

Modelica_LinearSystems2.Controller.FirstOrder Modelica_LinearSystems2.Controller.FirstOrder

First order (continuous or discrete) transfer function block (= 1 pole)

Information


This blocks defines the transfer function between the input u and the output y as first order system:

             k
     y = --------- * u
         T * s + 1

The block can be continuous or discrete (with continuous parameterization).

Extends from Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
kGain
TTime Constant
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
y_startInitial y if initType=InitialState (else guess)

Connectors

NameDescription
uContinuous or discrete input signal of block

Modelica_LinearSystems2.Controller.SecondOrder Modelica_LinearSystems2.Controller.SecondOrder

Second order (continuous or discrete) transfer function block (= 2 poles)

Information


This blocks defines the transfer function between the input u and the output y as second order system:

                         k
     y = --------------------------------- * u
          ( s / w )^2 + 2*D*( s / w ) + 1

The block can be continuous or discrete (with continuous parameterization).

If you would like to be able to change easily between different transfer functions (FirstOrder, SecondOrder, ... ) by changing parameters, use the general model class TransferFunction instead and model a second order SISO system with parameters
n = {k}, d = {1/w^2, 2*D/w, 1}.

Example:
   parameter: k =  0.3,  w = 0.5,  D = 0.4
   results in:
                  0.3
      y = ------------------- * u
          4.0 s^2 + 1.6 s + 1

Extends from Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
kGain
wAngular frequency
DDamping
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
y_startInitial or guess value of output (= state)
yd_startInitial or guess value of derivative of output (= state)

Connectors

NameDescription
uContinuous or discrete input signal of block
ydFirst derivative of y
yy[2] 

Modelica_LinearSystems2.Controller.PI Modelica_LinearSystems2.Controller.PI

Proportional-Integral controller (continuous or discrete block)

Information


This blocks defines the transfer function between the input u and the output y as integrator:

                     1
      y = k * (1 + ------ ) * u
                    T*s
               T*s + 1
        = k * --------- * u
                 T*s

The block can be continuous or discrete (with continuous parameterization).

It is not possible to initalize a continuous integrator in steady state. For this reason, option "initType = SteadyState" is ignored for a continuous PI block and interpreted as "initType = InitialState".

Extends from Interfaces.PartialSISO2 (Partial Single Input Single Output (continuous or discrete) control block of Controller library).

Parameters

NameDescription
kGain
TTime Constant (T>0 required) [s]
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)
x_startInitial or guess value of state
y_startInitial value of output

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block
xState of block

Modelica_LinearSystems2.Controller.PID Modelica_LinearSystems2.Controller.PID

PID-controller in additive description form

Information


This is the text-book version of a PID-controller. For a more practically useful PID-controller, use block LimPID.

The PID block can be initialized in different ways controlled by parameter initType. The possible values of initType are defined in Modelica.Blocks.Types.InitPID. This type is identical to Types.Init, with the only exception that the additional option DoNotUse_InitialIntegratorState is added for backward compatibility reasons (= integrator is initialized with InitialState whereas differential part is initialized with NoInit which was the initialization in version 2.2 of the Modelica standard library).

Based on the setting of initType, the integrator (I) and derivative (D) blocks inside the PID controller are initialized according to the following table:

initType I.initType D.initType
NoInit NoInit NoInit
SteadyState SteadyState SteadyState
InitialState InitialState InitialState
InitialOutput
and initial equation: y = y_start
NoInit SteadyState
DoNotUse_InitialIntegratorState InitialState NoInit

In many cases, the most useful initial condition is SteadyState because initial transients are then no longer present. If initType = InitPID.SteadyState, then in some cases difficulties might occur. The reason is the equation of the integrator:

   der(y) = k*u;

The steady state equation "der(x)=0" leads to the condition that the input u to the integrator is zero. If the input u is already (directly or indirectly) defined by another initial condition, then the initialization problem is singular (has none or infinitely many solutions). This situation occurs often for mechanical systems, where, e.g., u = desiredSpeed - measuredSpeed and since speed is both a state and a derivative, it is natural to initialize it with zero. As sketched this is, however, not possible. The solution is to not initialize u or the variable that is used to compute u by an algebraic equation.

 

Extends from Interfaces.PartialSampledBlock (Partial block of Sampled library (icon + default parameters)).

Parameters

NameDescription
pidReptype of PID representation: k*(1 + 1/Ti/s + Td*s) or (kp + Ti/s + Td*s)
kGain of controller
TiTime constant of Integrator block [s]
TdTime constant of Derivative block [s]
NdThe higher Nd, the more ideal the derivative block
kpP part parameter of gain representation
kiI part parameter of gain representation
kdD part parameter of gain representation
Initialization
xi_startInitial or guess value value for integrator output (= integrator state)
xd_startInitial or guess value for state of derivative block
y_startInitial value of output
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.LimPID Modelica_LinearSystems2.Controller.LimPID

P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting

Information


Via parameter controllerType either P, PI, PD, or PID can be selected. If, e.g., PI is selected, all components belonging to the D-part are removed from the block (via conditional declarations). The example model Modelica.Blocks.Examples.PID_Controller demonstrates the usage of this controller. Several practical aspects of PID controller design are incorporated according to chapter 3 of the book:

Astroem K.J., and Haegglund T.:
PID Controllers: Theory, Design, and Tuning. Instrument Society of America, 2nd edition, 1995. Information from: http://www.control.lth.se/publications/books/asthagg95.html

Besides the additive proportional, integral and derivative part of this controller, the following features are present:

The parameters of the controller can be manually adjusted by performing simulations of the closed loop system (= controller + plant connected together) and using the following strategy:

  1. Set very large limits, e.g., yMax = Modelica.Constants.inf
  2. Select a P-controller and manually enlarge parameter k (the total gain of the controller) until the closed-loop response cannot be improved any more.
  3. Select a PI-controller and manually adjust parameters k and Ti (the time constant of the integrator). The first value of Ti can be selected, such that it is in the order of the time constant of the oscillations occuring with the P-controller. If, e.g., vibrations in the order of T=10 ms occur in the previous step, start with Ti=0.01 s.
  4. If you want to make the reaction of the control loop faster (but probably less robust against disturbances and measurement noise) select a PID-Controller and manually adjust parameters k, Ti, Td (time constant of derivative block).
  5. Set the limits yMax and yMin according to your specification.
  6. Perform simulations such that the output of the PID controller goes in its limits. Tune Ni (Ni*Ti is the time constant of the anti-windup compensation) such that the input to the limiter block (= limiter.u) goes quickly enough back to its limits. If Ni is decreased, this happens faster. If Ni=infinity, the anti-windup compensation is switched off and the controller works bad.

Initialization

This block can be initialized in different ways controlled by parameter initType. The possible values of initType are defined in Modelica.Blocks.Types.InitPID. This type is identical to Types.Init, with the only exception that the additional option DoNotUse_InitialIntegratorState is added for backward compatibility reasons (= integrator is initialized with InitialState whereas differential part is initialized with NoInit which was the initialization in version 2.2 of the Modelica standard library).

Based on the setting of initType, the integrator (I) and derivative (D) blocks inside the PID controller are initialized according to the following table:

initType I.initType D.initType
NoInit NoInit NoInit
SteadyState SteadyState SteadyState
InitialState InitialState InitialState
InitialOutput
and initial equation: y = y_start
NoInit SteadyState
DoNotUse_InitialIntegratorState InitialState NoInit

In many cases, the most useful initial condition is SteadyState because initial transients are then no longer present. If initType = InitPID.SteadyState, then in some cases difficulties might occur. The reason is the equation of the integrator:

   der(y) = k*u;

The steady state equation "der(x)=0" leads to the condition that the input u to the integrator is zero. If the input u is already (directly or indirectly) defined by another initial condition, then the initialization problem is singular (has none or infinitely many solutions). This situation occurs often for mechanical systems, where, e.g., u = desiredSpeed - measuredSpeed and since speed is both a state and a derivative, it is natural to initialize it with zero. As sketched this is, however, not possible. The solution is to not initialize u_m or the variable that is used to compute u_m by an algebraic equation.

If parameter limitAtInit = false, the limits at the output of this controller block are removed from the initialization problem which leads to a much simpler equation system. After initialization has been performed, it is checked via an assert whether the output is in the defined limits. For backward compatibility reasons limitAtInit = true. In most cases it is best to use limitAtInit = false.

Extends from Interfaces.PartialSampledBlock (Partial block of Sampled library (icon + default parameters)), Modelica.Blocks.Interfaces.SVcontrol (Single-Variable continuous controller), Interfaces.PartialBlockIcon (Basic graphical layout of discrete/continuous block).

Parameters

NameDescription
pidRepresentationtype of PID representation: k*(1 + 1/Ti/s + Td*s) or (kp + Ti/s + Td*s)
controllerTypeType of controller
kGain of controller
TiTime constant of Integrator block [s]
TdTime constant of Derivative block [s]
kpP part parameter of gain representation
kiI part parameter of gain representation
kdD part parameter of gain representation
yMaxUpper limit of output
yMinLower limit of output
wpSet-point weight for Proportional block (0..1)
wdSet-point weight for Derivative block (0..1)
NiNi*Ti is time constant of anti-windup compensation
NdThe higher Nd, the more ideal the derivative block
Initialization
limitsAtInit= false, if limits are ignored during initializiation
xi_startInitial or guess value value for integrator output (= integrator state)
xd_startInitial or guess value for state of derivative block
y_startInitial value of output
Advanced options
blockTypeType of block (Continuous/Discrete)
methodTypeType of discretization if discrete block
sampleFactorTs=sampleClock.sampleTime*sampleFactor
initTypeType of initialization (no init/initial/steady state/output)

Connectors

NameDescription
u_sConnector of setpoint input signal
u_mConnector of measurement input signal
yConnector of actuator output signal

Modelica_LinearSystems2.Controller.UnitDelay Modelica_LinearSystems2.Controller.UnitDelay

Delay the input by a multiple of the base sample time if discrete block or y=u if continuous block

Information


If discrete block, the output y is sampled and is the value of the sampled input signal u at the previous sample instant, where sample time = sampleClock.sampleTime * sampleFactor and sampleClock.sampleTime is defined globally in the outer component sampleClock and sampleFactor is an Integer parameter of component UnitDelay.

If continuous block, the output y is identical to the input u.

Extends from Interfaces.PartialSISO_equality (Partial Single Input Single Output (continuous or discrete) control block of Controller library where usually y=u if continuous block).

Parameters

NameDescription
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.ADconverter Modelica_LinearSystems2.Controller.ADconverter

Analog to digital converter (including sampler)

Information


If discrete block, the output y is sampled according to sample time sampleClock.sampleTime * sampleFactor, where sampleClock.sampleTime is defined globally in the outer component sampleClock and sampleFactor is an Integer parameter of component Sampler.

The sampled output signal is computed by limiting the input u with the provided y_min and y_max borders and by rounding according to the provided precision of the AD converter defined via parameter bits (e.g. bits = 12 is the precision of simple AD converters).

If continuous block, the output y is identical to the input u, but is limited by y_min and y_max.

Extends from Interfaces.PartialSISO_equality (Partial Single Input Single Output (continuous or discrete) control block of Controller library where usually y=u if continuous block).

Parameters

NameDescription
y_maxUpper limit of output signal
y_minLower limit of output signal
bitsNumber of bits (=0 means no quantization error)
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.DAconverter Modelica_LinearSystems2.Controller.DAconverter

Digital to analog converter (including zero order hold)

Information

Extends from Interfaces.PartialSISO_equality (Partial Single Input Single Output (continuous or discrete) control block of Controller library where usually y=u if continuous block).

Parameters

NameDescription
y_maxUpper limit of output signal
y_minLower limit of output signal
bitsNumber of bits (=0 means no quantization error)
unitDelay= true, if one sample period delay, = false, if computing time not modelled
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor

Connectors

NameDescription
uContinuous or discrete input signal of block
yContinuous or discrete output signal of block

Modelica_LinearSystems2.Controller.MatrixGain Modelica_LinearSystems2.Controller.MatrixGain

Output the product of a gain matrix with the input signal vector. The matrix can be loaded from a file optionally

Information


This block is similar to Modelica.Blocks.Math.MatrixGain. Additionally this block offers to load the matrix from a MATLAB-file. It computes output vector y as product of the gain matrix K with the input signal vector u:

    y = K * u;

Example:

   parameter: K = [0.12 2; 3 1.5]
 
   results in the following equations:
 
     | y[1] |     | 0.12  2.00 |   | u[1] |
     |      |  =  |            | * |      |
     | y[2] |     | 3.00  1.50 |   | u[2] |

Extends from Modelica.Blocks.Interfaces.MIMO (Multiple Input Multiple Output continuous control block), Interfaces.PartialBlockIcon (Basic graphical layout of discrete/continuous block).

Parameters

NameDescription
ninNumber of inputs
noutNumber of outputs
matrixOnFiletrue if matrix should be read from file
fileName 
matrixNameName of the matrix
K[:, :]Matrix gain

Connectors

NameDescription
u[nin]Connector of Real input signals
y[nout]Connector of Real output signals

Modelica_LinearSystems2.Controller.Noise Modelica_LinearSystems2.Controller.Noise

Block that generates a uniform distributed noise output signal at sample instants if discrete and y=0 if continuous

Information


If discrete block, the output y is sampled according to sample time sampleClock.sampleTime * sampleFactor, where sampleClock.sampleTime is defined globally in the outer component sampleClock and sampleFactor is an Integer parameter of component Noise. At every sample time, a random output signal y in the range y_min .. y_max is generated, where y_min and y_max are parameters. A typical noise signal is shown in the next figure:

The Integer[3] parameter vector firstSeed is used to initialize the basic random number generator. The 3 elements of firstSeed need to be in the range [0, 255]. The use of the same seed vector will lead to the same sequence of numbers when these are computed serially. This is usually not desired. Therefore, for every usage of block Noise a different firstSeed should be defined.

If continuous block, the output y = 0.0, i.e., no noise signal is generated. The reason is that the noise can only reasonably be used in a simulation if it is a discrete signal, i.e., changes its value only at sample instants. Since a continous block is usually used to speed up the simulation, the noise should also be turned off because it will otherwise significantly limit the maximum step size of the integrator.
 

This noise generator is based on a function that generates a random real number uniformely in the semi-open range [0.0, 1.0). The function uses the standard Wichmann-Hill generator, combining three pure multiplicative congruential generators of modulus 30269, 30307 and 30323. Its period (how many numbers it generates before repeating the sequence exactly) is 6,953,607,871,644. While of much higher quality than the rand() function supplied by most C libraries, the theoretical properties are much the same as for a single linear congruential generator of large modulus.

Extends from Interfaces.PartialBlockIcon (Basic graphical layout of discrete/continuous block).

Parameters

NameDescription
y_minLower limit of noise band
y_maxUpper limit of noise band
firstSeed[3]Integer[3] defining random sequence; required element range: 0..255
blockTypeType of block (Continuous/Discrete)
sampleFactorTs=sampleClock.sampleTime*sampleFactor

Connectors

NameDescription
yDiscrete output signal of block

HTML-documentation generated by Dymola Tue Sep 08 18:52:57 2009.