Real-Time Implementation
Algorithm 21 - Implementing the system clock WHILE TRUE
6.4.5 System overview
An overview of the complete real-time system is shown in the next figure. The white boxes denote processors. The dotted boxes denote input and output devices. The dashed boxes represent the digital-to-analog and the analog-to-digital boards.
6.5 Results
When testing the real-time system it was found that a high sampling rate was needed to reproduce the responses obtained in the off-line simulations described in Chapter 3. Using the well known rule of thumb for selecting the sampling frequency of 20 times the closed-loop bandwidth [177] produced, in the great majority of the cases, responses very different from the ones obtained in the off-line simulation.
F( )σ
Fig. 6.9 - Overview of the real-time system
As an example we shall consider a three-pole plant with the transfer function:
(6.47) Using PID parameters derived using the closed-loop Ziegler-Nichols tuning rule, the closed-loop bandwidth is 14 rad/s. Fig. 6.10 compares the continuous closed-loop output and the discrete closed-loop outputs, using different sampling rates.These results were obtained in off-line simulations using MATLAB.
Host Computer
Monitor and keyboard
User Interface
Plant Simulation
Controller Adaptation I
Adaptation II
D/A A/D
Oscilloscope Signal
Generator
G s( ) 1
s+0.8
( ) s 8( + ) s 12( + )
---=
Fig. 6.10 - Responses obtained with different sampling frequencies
The dashed line denotes the output obtained by first calculating the continuous closed-loop transfer function and then applying the MATLAB ‘step’ function, where a sampling frequency 20 times greater than the closed-loop bandwidth was employed. The ‘step’ function first discretizes the continuous transfer function (assuming a zero-order hold in the input) using a exponential matrix and then solves the resulting difference equation. The results shown in Chapter 3, for the cases of plants without delay-time, were obtained using this procedure.
The solid lines in Fig. 6.10 denote the closed-loop outputs obtained by first discretizing each component of the closed-loop, using, for each component, the methods referred to in previous sections, then obtaining the Z-transform of the closed-loop and finally solving the resulting difference equation. The values indicated in Fig. 6.10 denote the multiple of the continuous closed-loop bandwidth used for obtaining the sampling frequency.
By inspection, it is clear that the responses obtained are remarkably different from the continuous case, if a factor less than 60 is used for the sampling frequency. This implies that a high sampling rate must be used in the real-time system, which has the drawback of enlarging the number of samples needed for the plant identification and therefore the computation time.
This problem should be further studied, by employing different discretization methods for each component of the loop and by analysing the closed-loop singularities, in both continuous and discrete cases.
80
40 20 100
60
Time (sec.)
Output
To test the real-time performance of the new PID autotuning technique the parameters of the multilayer perceptrons were initialized with the same values employed in the off-line simulation described in Chapter 3.
Several tests were performed. Four of them are shown here. Fig. 6.11 illustrates the case of the control of a four-pole plant, with transfer function . In this and subsequent figures the solid line denotes the reference signal and the dashed line the output signal. The system was started in open loop, with the option of automatically closing the loop once the PID parameters are obtained. A sampling period of 5ms was employed.
Fig. 6.11 - Example 1
During the second step, the mode was changed from fixed to adaptive. The response of the third step is therefore used to identify the plant. When the fourth step is detected, TT is computed by the first adaptation process and the relevant information is passed to the second adaptation block. Shortly afterwards the PID values are obtained, transmitted to the controller process via the first adaptation process, and the loop automatically closed. The performance of the tuning can be assessed from the last two steps where it is clear that a well damped response is obtained.
The next Figure shows the control of a plant with transfer function . The sampling period employed was 2ms. In this case the system was initialized in closed loop,
G s( ) 1
1+0.1s
( )4
---=
Time (sec.)
Reference / Output
1
2
3
4
5
6
G s( ) e–0.05s 1+0.1s
---=
with the PID parameters manually chosen according to the closed-loop Ziegler-Nichols tuning rule for the specified plant. During the third step the operation mode changed from fixed to adaptive. During the fourth step the plant was identified. Shortly after the fifth step has been detected, the new PID values, have been made active.
Fig. 6.12 - Example 2
Steps six and seven illustrate the performance obtained with the new tuning, where it can be seen that a better damped response has been obtained.
Fig. 6.13 illustrates the application of the new technique to a time-varying four-pole plant. The sampling period used was 5 ms. In this example the system was started in open loop, adaptive mode, with the option of closing the loop automatically once the PID values were obtained. The initial transfer function of the plant is:
In the second step the plant is identified. The PID values are computed in the third step and the loop is automatically closed. Steps four and five illustrate the tuning obtained from open loop identification.
Reference / Output
Time (sec.) 1
2
3
4
5
6
7
G1( )s 1
1+0.1s
( )2(1+0.2s)2
---=
Fig. 6.13 - Example 3
For step six two plant time constants are changed and the transfer function becomes the one employed in the first example:
The response becomes overdamped. The new plant is identified during step seven. Step nine illustrates the response obtained after adaptation has taken place.
Finally Fig. 6.14 shows the control of a plant with varying transfer function. A sampling period of 5 ms was used in this example. As in the previous example, the system was started in open loop, adaptive mode. The transfer function of the plant is first set at:
During the second step the plant is identified, the PID values are obtained in the third step and the loop is automatically closed. Steps four and five denote the responses obtained after adaptation to the three-poles plant has occurred.
At step six the transfer function of the plant is changed. A time-delay plant with two poles, and transfer function
Time (sec.)
Reference / Output
G1(s) G2(s)
1
2
3
4 5
6 7
8 9
G2( )s 1 1+0.1s
( )4
---=
G3( )s 1
1+0.1s
( ) 1 0.2s( + ) 1 0.4s( + )
---=
is now assumed.
Fig. 6.14 - Example 4
An oscillatory response is obtained as result of this change. The new plant is identified during step seven, and the two final steps show the response obtained after adaptation has taken place, where it is clear that again a well damped response is obtained in steps 9 and 10.
6.6 Conclusions
In this Chapter the real-time implementation of the new neural PID autotuning technique is described. To enable different experiments to be performed, in a user-friendly way, a system was built in Occam, using an array of Inmos transputers. The different constituent blocks of the system are described. The system was also built with the purpose of easing the transition to the ultimate phase of this work, i.e., the control of real plants.
Results obtained with the real-time system show that, using the discretization methods currently employed, a high sampling rate needs to be employed to obtain similar results to the ones obtained in the continuous case. This has the drawback of increasing the number of samples required to identify the plant. This problem, however, as demonstrated in the last
G4( )s e–0.1s 1+0.4s
( )2
---=
G3(s) G4(s)
Reference / Output
Time (sec.) 1
2 3
4 5
6 7
8 9
10
section, is related to the discretization of the closed loop, and not to the proposed approach to PID autotuning.
This problem apart, the results show that well damped responses are obtained with this new PID autotuning technique, requiring a processing time less than 1 sec., once the response has settled.
As with any novel proposed technique, different stages must be followed before it becomes a practical proposition. The theoretical basis of this new method was introduced in Chapter 3, where off-line simulations showed promising results. The work described in this Chapter goes one step further towards reality and the technique was implemented in real-time.
The next stage will involve the control of real plants. The method of building the real-time system allows this to be done easily.