Real-Time Implementation
Algorithm 21 - Implementing the system clock WHILE TRUE
6.4.3 The plant
This process executes in an Inmos T800 transputer [15] with a clock frequency of 25 MHz. It performs the following tasks:
i) At each sampling instant, the current value of the output, computed during the previous iteration, is sent to the controller process.
ii) The current input of the plant is afterwards received from the controller processor.
Both the current values of the input and output are sent to two channels of a DAC.
iii) The output value for the next sample is computed by solving the difference equation representing the plant.
iv) Whenever there is a change in either the sampling frequency or in the plant transfer function, the digital equivalent of the plant is recomputed.
The plant is discretized using a zero-pole mapping equivalent [177]. If the Laplace transform of the plant is:
(6.42)
then its Z-transform, using a zero-pole mapping equivalent can be obtained as:
(6.43)
where k is given by:
(6.44)
and n is the nearest integer to L/Ts. 6.4.4 The adaptation
This block of operations, as will be explained shortly, is divided into two processes, each one executing in a T800 Inmos transputer [15], running at 25MHz. The purpose of this block is to determine the new set of PID values, based on the analysis of the response of the system to an input step. This requires several operations.
If the system is in adaptive mode, it receives from the controller process at each sampling instant, the values of the reference and the control or the output, according to the current loop configuration (closed or open loop).
The reference is used to detect the occurrence of a step and to compute its amplitude.
As the reference is a square wave, the PID values are computed at the instant when a new input step is detected. Before doing so, the response associated with the previous step (used to identify the plant) must have settled within a user-specified tolerance. If this did not happen, the previous step cannot be employed to identify the plant, and neither can the current step because the system response is now a mixture of the transients associated with the last and the current steps; consequently an accurate computation of the identification indices cannot be guaranteed.
To ensure settling, the present and the last n values of the control or the output are checked, within each sampling interval. The arithmetic mean of these samples is computed,
G z( ) k
recursively. It is then determined whether they all lie within a certain range (a user defined percentage) around the computed mean. If this condition is satisfied, it is accepted that settling has occurred; otherwise the same process is repeated at the next sampling interval. The number n of past samples is initialized to a user predefined constant. Whenever an underdamped response is detected, n is updated to the number of samples within the period of the signal.
Another task performed by this process is the computation of the scaling factor TT, defined by (3.74). To calculate TT, the integrals S(0), defined by (3.78), or Su(0), defined by (3.83), are computed recursively, using a trapezoidal formula.
S(0) for example (the computation of Su(0), for the closed loop case, is analogous) is obtained using (6.45):
(6.45) The summation in (6.45) is computed recursively. Currently, the computation of S(0) is continued until a new step is detected. Consequently, TT, the identification measures , and the PID values are only computed after the new step has been detected. This should be changed, so that the actual computation of S(0) takes place when settling has been detected.
After obtaining S(0), TT can be computed. In the open-loop case eq. (3.79) is used; in the closed-loop case, (3.84) is employed.
The operations described so far can be performed within one sample period, without affecting the performance of the overall system. The same, however, can not be said about the rest of the operations that the adaptation block must perform, the computation of and subsequently, the PID parameters.
We note that, as or (which are needed to compute the identification measures) depend on TT, they cannot be computed recursively. As a large amount of data is normally required to compute these integrals, this operation cannot be performed within one sampling period. As there were several transputers available, this problem was solved by splitting the adaptation block between two processes (running on different T800 transputers), the second of these being responsible for the actual computation of , and subsequently, the PID parameters.
This second process receives from the first one the values of Ts, TT, kp and or , according to the loop configuration. Additionally it also receives the samples of the output or the control signal. At present, the number of these samples is either the total number
S 0( ) y ∞( )kTs Ts y i[ ] y i 1+ [ – ] ---2
i=1 k
∑
≈ –
F( )σ
F( )σ
S( )σ Su( )σ
F( )σ
y( )∞ u( )∞
of samples within the previous step or a user predefined maximum. In the same way as remarked when describing the computation of S(0), this should be modified so that would be computed using the samples available until settling had been detected.
To compute the identification measures, the integrals , defined by (3.78), or , defined by (3.83), are computed, using a trapezoidal formula.
Illustrating for the open loop case, is calculated as:
(6.46)
After the integrals have been obtained, the values are computed either using (3.80) or (3.85), according to the current loop configuration.
Using these last values, the scaled PID values are obtained by executing, concurrently, three processes which implement the recall operation of multilayer perceptrons. This code was already available from the work described in Chapter 5. The scaled PID values are output by the MLPs. They are then transformed back to their original form, using (3.96), and transmitted to the first adaptation process. This last process sends them to the controller process, where they are employed as the current PID parameters.