 ## ModMultiSim help v3.06 - 4.5. Advanced techniques

#### Process models

The controllers section dealt with how the controller output CO is computed from the controlled variable CV (i.e. that section dealt with simulating a controller). This section deals with how the controlled variable CV is computed from the controller output CO and any "disturbance" D (i.e. this section deals with simulating the environment).

The examples in this section model systems that can be approximately described by first-order differential equations.

#### 4.5.1. First-order model

A typical system that can be modelled by a first-order differential equation is a room heated by a heater, but losing heat to the outside world. If the heater output CO and external temperature D are constant, the room temperature CV will gradually rise or fall until the rate of heat loss is equal to the heater output.

A first-order model has three parameters:

• Ks - the "system gain", which determines how much CV changes when CO changes, and in which direction (if Ks is negative, CV will decrease when CO increases).

• Kd - the "disturbance gain", which determines how much CV changes when D changes, and in which direction (if Kd is negative, CV will decrease when D increases).

• Ts - the "system time constant", which determines how quickly CV changes when CO and D change. The greater Ts is, the more slowly CV will change.

From the differential equation, this is programmed in ModMultiSim as:

Table 35. First order model

Property Name Statement
CO
D
Ks
Kd
Ts
CV `\$\$ + (\$Ks * \$CO + \$Kd * \$D - \$\$) * CycleTime / \$Ts`

For those that are interested, the actual differential equation is:

`     Ts.dCV(t)/dt + CV(t) = Ks.CO(t) + Kd.D(t)`

where `t` is time, and the derivative `dCv(t)/dt` is the rate at which CV changes. If the derivative is approximated by the difference between successive values of CV, a "discrete" form of the differential equation is obtained:

`     Ts.(CV[k+1] - CV[k])/T + CV[k] = Ks.CO[k] + Kd.D[k]`

where `T` is the simulation time interval (i.e. `CycleTime`).

This can be re-arranged to produce:

`     CV[k+1] = CV[k] + (Ks.CO[k] + Kd.D[k] - CV[k]).T/Ts`

which is the form of equation used in the simulation example.

#### 4.5.2. First-order integrating model

This model builds on the previous model so for an explanation of terms such as CV, Ks, see first-order model.

The heated room example is "self-regulating": the room temperature CV stabilizes if the controller output CO and disturbance D are constant. However, some systems are not self-regulating. A typical example is a tank being filled by a pump. If the pump flow rate CO and rate of drainage D are constant, the level of fluid CV in the tank will continue to rise or fall (unless the rate of filling and drainage are exactly equal).

This can be programmed in ModMultiSim as:

Table 36. First order integrating model

Property Name Statement
CO
D
Ks
Kd
Ts
CV `\$\$ + (\$Ks * \$CO + \$Kd * \$D) * CycleTime / \$Ts`

This kind of system can be modelled by a first order differential equation that does not have the `CV(t)` term:

`     Ts.dCV(t)/dt = Ks.CO(t) + Kd.D(t)`

A discrete form of this equation is:

`     CV[k+1] = CV[k] + (Ks.CO[k] + Kd.D[k]).T/Ts`

which is the basis for the code segment above in ModMultiSim.

#### 4.5.3. FOPDT model

This model builds on the first model, so for an explanation of terms such as CV, Ks, see first-order model.

In some systems, there may be a significant delay ("dead time") before CV starts to change when CO is changed. This is typically due the "travel time" of material (or energy) from the controller to the sensor. A "First-Order Plus Dead Time" model can be used to describe such systems.

In ModMultiSim this can be programmed as set out in the table below. Notice the use of the delay line technique to simulate a dead time of 5 simulation periods - registers CO1-CO5 and the use of the value CO5, which is the value of the controller output 5 periods earlier, to compute CV

Table 37. FOPDT model

Property Name Statement
CO
D
Ks
Kd
Ts
CO1 \$CO
CO2 \$CO1
CO3 \$CO2
CO4 \$CO3
CO5 \$CO4
CV `\$\$ + (\$Ks * \$CO5 + \$Kd * \$D - \$\$) * CycleTime / \$Ts`

The differential equation for a FOPDT model is:

`     Ts.dCV(t)/dt + CV(t) = Ks.CO(t - Θt) + Kd.D(t)`

where `Θt` is the system dead time.

A discrete form of this equation is:

`     Ts.(CV[k+1] - CV[k])/T + CV[k] = Ks.CO[k - Θt/T] + Kd.D[k]`

which re-arranged produces:

`     CV[k+1] = CV[k] + (Ks.CO[k - Θt/T] + Kd.D[k] - CV[k]).T/Ts`

The term `CO[k - Θt/T]` is the value that CO had `Θt/T` simulation periods earlier. As mentioned, this example uses the delay line technique to simulate a dead time of 5 simulation periods (i.e. `Θt/T` is 5):