• 沒有找到結果。

Chapter 3 Real-Time Control of Planetary Inverted Pendulum 15

3.4. Hardware Implementation

I. Hardware platform DS 1104 R&D control board

We will implement a controller to control this uncertain nonlinear system by using on-line intelligent optimally adaptive control method. In the beginning, we design the controller in SimuLink and generate the control program and then sent it into the hardware platform, DS 1104 R&D control board, to control the inverted pendulum system. The overall control process is shown in Figure 3-13.

Figure 3-13. Overall hardware configuration using DS 1104

SimuLink is an interactive environment for modeling an off-line simulation with easy-to-use diagram. In MATLAB, Real-Time Workshop can automatically generate C code from SimuLink block diagrams. Together with dSPACE’s Real-Time Interface, these tools can transfer the C code generated from our block diagram to dSPACE’s Real-Time hardware. Here, DS 1104 R&D Controller Board is selected.

dSPACE system is the platform for electronic control unit (ECU) development. It provides the V-cycle concept in the development process, in which control design is involved. In dSPACE system, control design is model-based so that we can work with a single model of a complete system in an integrated software environment, as SimuLink. dSPACE hardware includes a powerful processor and numerous I/O interfaces. The processor can calculate our models in real time, and these I/O interfaces can connect to outside world. The hardware, DS 1104 R&D Controller Board, can run directly in the PC.

For the implementation of the controller for the planetary inverted pendulum system,

planetary inverted pendulum through the dSPACE system interface.

II. Design flow

We have presented the simulation for the inverted pendulum system via the on-line intelligent adaptive control approach. The control block for the planetary inverted pendulum system has been built in SimuLink. But, from (22), the input of the system is torque. In the real planetary inverted pendulum system, the input is voltage. The mathematical relation between torque and voltage is unknown, so that the mathematical relation between the voltage and the angle of inverted pendulum is uncertain and nonlinear.

Step (1) Specify the closed-loop poles as -2 and -1.5.

Step (2) Define the membership function and estimate the initial weighting matrices.

Because the order of the TS-type FNN model is two and the number of input is one, we have to measure three outputs to estimate the initial matrices. The controller is applied in the second stage, so we have to get the estimated initial matrices when θ0 is between 10° and -10°. But, when θ0 is between 10° and -10°, it is difficult to apply u = 10sin (t) to the inverted pendulum system to measure θ& and0 θ&& . Therefore we apply three step 0 commands (u = 10 volts) as the inputs to the system to get sufficient data ( θ& and0 θ&& ) to estimate the initial matrices with least square 0 estimation-technique. For this uncertain nonlinear system, when θ0 equals to 10°(= 0.1745rad), 15°(= 0.2018rad), 20°(= 0.3491rad) respectively, we apply u = ±10V to electric motor 29 to drive the pendulum for measurements of θ& and0 θ&& . The membership functions for 0 θ& and θ0 0 can be defined as the follows:

Figure 3-14. MF of θ& (rad/s)

Figure 3-15. MF of θ0 (rad)

There are four nominal operating points. The nominal operating points and the initial weighting matrices are shown in the Table 3-2.

Table 3-2. Four nominal operating points with initial weighting matrices

R [ θ& 0 θ0 ]

Step (3): Design controller with pole placement technique for the closed-loop poles as -2 and -1.5.

Step (4): Apply Adaptive Rules to update the TS-type FNN model and the controller to stabilize the closed-loop system.

III. Building the control block

According to the two stages mentioned in section 3.2 for the overall control of this system, we create the dSPACE inverted pendulum control block (Figure 3-16) which can fling and stabilize the pendulum.

Figure 3-16. The dSPACE control block diagram for inverted pendulum

Figure 3-17 shows the blocks with proper timings [7] to fling the pendulum upward in the first stage.

Figure 3-17. Block diagram of “Select output timing” in Figure 3-16

From Figure 3-18, we can see that the angles of the pendulum (θ0), starts at 180° and

the swing amplitude is enlarged gradually.

Figure 3-18. Trajectory of θ0 for flinging pendulum upward in Figure 3-16

When θ0 is smaller than 10°, the inverted pendulum system is controlled by the “FNN controller”. Figure 3-19 shows the detail of the “FNN controller” block.

Figure 3-19. Block diagram of “FNN controller” in Figure 3-16

In Figure 3-19, the “Trained TK-Model” block produces the inferred (Af, Bf) system matrices to represent the inverted pendulum system and the “Design Controller”

Figure 3-20. Block diagram of “Trained TK-Model” in Figure 3-19

Figure 3-21. Block diagram of “Design Controller” in Figure 3-19

Figure 3-22. Trajectory for θ0 in Figure 3-16

Figure 3-23 shows the partial trajectory of θ0 from Figure 3-22 after the stabilization of the pendulum.

We let the on-line intelligent optimal controller control the inverted pendulum, when θ0 is smaller than 15°. The on-line intelligent adaptive control is also able to control the inverted pendulum. Figure 3-24 shows the trajectory of θ0 during the stabilization of the pendulum with the application of the control method as θ0<15°.

Figure 3-24. Trajectory of θ0 during the stabilization of the pendulum with the application of the control method as θ0<15°

As the result presented in Figures 3-23 and 3-24, we have achieved the objective to apply on-line intelligent adaptive control method to stabilize the planetary inverted pendulum. Then, in order to consider the time delay in the real system, we add the

“Integer Delay” block to Figure 3-16. Figure 3-24 shows the dSPACE inverted pendulum control block with “Integer Delay” block.

Figure 3-25. The dSPACE inverted pendulum control block diagram with “Integer Delay” block.

Figure 3-25 shows the trajectory of θ0 for the stabilization of the pendulum with time delay = 0.014s.

Figure 3-26. Trajectory of θ0 to stabilize the pendulum with time delay = 0.014s

Figure 3-26 shows the trajectory of θ0 for the stabilization of the pendulum with time delay = 0.019s.

Figure 3-27. Trajectory of θ0 to stabilize the pendulum with time delay = 0.019s

Figure 3-27 shows the trajectory of θ0 for the stabilization of the pendulum with time delay =0.020s.

Figure 3-28. Trajectory of θ0 to stabilize the pendulum with time delay = 0.020s

From Figure 3-26, 0.019s is almost the maximum allowed time delay for the real inverted pendulum control system with on-line optimal trained controller in the dSPACE control platform. The maximum allowed delay time for the inverted pendulum control system in simulation is about 0.022s. If we assume the maximum time delay from simulation is correct, then the computational time for the on-line controller is less than 0.003s (=0.022s-0.019s). This will change when different hardware platform is applied. Thus it is obvious that we can still use slower hardware platform to control the planetary inverted pendulum system to reduce the cost.

CHAPTER 4 Conclusion

The on-line adaptive intelligent control for uncertain nonlinear systems by using TS-type FNN models proposed in [1] has been fully implemented using real hardware platform, i.e., DS 1104 R&D control board, under MatLab SimuLink. The planetary inverted pendulum was adopted as the real example to be controlled. The initial perturbation was done by various step commands to get the initial TS-type FNN model matrices. Then the on-line optimal training algorithm was implemented in SimuLink to drive the DS 1104 R&D control board to control the planetary inverted pendulum. Excellent results have been obtained to show the feasibility of hardware implementation of the control algorithm in [1]. The computational time delay to obtain the control signal has also been studied using real hardware emulations. The computational time delay of the planetary inverted pendulum using DS 1104 R&D control board has been estimated to be 0.003 seconds. This is within the maximum allowable computational time of 0.022 seconds, which is assumed to be correct by a pure computer simulation. This result can be very meaningful for industrial applications by choosing cheaper hardware platform with less cost to achieve the same control purpose.

REFERENCES

[1] Shi-Hao Ker, “On-Line Intelligent Adaptive Control for Uncertain Nonlinear Systems using Optimally Trained TS-Type Fuzzy Models”, MS Thesis, Department of Electrical and Control Engineering, National Chiao-Tung University, Hsin-Chu, Taiwan, 2002.

[2] T. Takagi and M. Sugeno, “Fuzzy Identification of Systems and Its Applications to Modeling and control,” IEEE Trans. Syst., Man, Cybern., Vol. 15, pp. 116-132, Jan./Feb., 1985.

[3] Chi-Hsu Wang, Han-Leih Liu, Chin-Teng Lin, “Dynamic optimal learning rates of a certain class of fuzzy neural networks and its applications with genetic algorithm”, IEEE Transactions on Systems, Man and Cybernetics, Part B, Vol. 31, p.p. 467 -475 June 2001.

[4] T. C. Hsia, “System Identification”, Lexington Books, 1977.

[5] Shing-Jen Wu and Chin-Teng Lin, “Optimal Fuzzy Controller Design: Local Concept Approach,” IEEE Trans. On Fuzzy Systems, Vol. 8, No. 2, pp. 171-183, April 2000.

[6] Shing-Jen Wu and Chin-Teng Lin, “Optimal Fuzzy Controller Design in Continuous Fuzzy System: Global Concept Approach,” IEEE Trans. On Fuzzy Systems, Vol. 8, No. 6, pp. 713-729, Dec. 2000.

[7] Shuang-Yuan Chen and Chen-Ren Lin, “Design and Control System Simulation of a Planetary Train Type Inverted Pendulum Mechanism,” 第六屆機構與機器設計 學術研討會暨海峽兩岸機構學術研討會, Nov. 2003.

[8] “DS1104 R&D Controller Board, Installation and Configuration Guide”, dSPACE, July 2001.

[9] “DS1104 R&D Controller Board, ControlDesk Experiment Guide”, dSPACE, July 2001.

[10] M. Malek-Zavarei and M. Jamshidi, “Time-Delay Systems, Analysis, Optimization and Applications,” Elsevier Science Publishers B.V., 1987

[11] R. N. Bateson, “Introduction to Control System Technology,” Prentice Hall International, Inc, 2002

[12] 林群超, “自動控制系統設計與 MATLAB 語言,” 全華科技圖書股份有限公司, 1999

[13] William J. Palm III, “Introduction to MATLAB 6 for Engineers,” McGraw-Hill Education, Jan. 2003.

相關文件