TXT

Fuzzy-logic control of an inverted pendulum with vision feedback...

By Monica Knight,2014-05-27 15:37
6 views 0
Fuzzy-logic control of an inverted pendulum with vision feedback...

     ??ÎÄÓÉjhxnjhxn??Ï×

    pdfÎĵµ?ÉÄÜÔÚWAP?Ëä?ÀÀÌåÑé???Ñ????ÒéÄúÓÅÏÈÑ?ÔñTXT???òÏÂÔØÔ?ÎÄ?þµ????ú?é????

     IEEE TRANSACTIONS ON EDUCATION, VOL. 41, NO. 2, MAY 1998

     165

     Fuzzy-Logic Control of an Inverted Pendulum with Vision Feedback

     Mario E. Maga? a and Frank Holzapfel n

     Abstract?ª In this paper we present an experimental setup of a fuzzy-logic controller of an inverted pendulum that uses vision feedback. The experimental testbed is used at Oregon State University in senior and ?rst-year graduate courses on automatic control systems to illustrate the usefulness and limitations of this approach. The results that are obtained support the claim, within certain limits, that it is possible to control an inverted pendulum using fuzzy-logic control and vision feedback. Index Terms?ªControl, fuzzy logic, vision feedback.

     I. INTRODUCTION HE implementation of a fuzzy-logic controller for an inverted pendulum is not new. In fact, one of the ?rst applications of it was to stabilize an inverted pendulum. Our approach differs from previous approaches in the way in which the physical variables are measured. The fact that a human being is able to stabilize an inverted pendulum of reasonable length and mass, along with the knowledge of the brain??s ability to process about 25 images per second, leads one to conclude that this data rate should be suf?cient to control an inverted pendulum using computer vision information. This ??low data rate?? approach is in strong contrast to past research that focused on measurement updates that are two to three times faster. Of special interest is the fact that in certain realworld applications the position of a controlled object cannot be determined with traditional methods. The introduction of video cameras and vision systems to process their images has led to a new way to measure relevant quantities without having to touch or even to come close to the object. The drawback of this approach, on the other hand, is that just 60 half-frames are obtained per second. This leads to problems that result from delays, especially in connection with fast-moving objects. Therefore, one of the goals of the experiment performed in our teaching and research laboratory was to explore critical limits and investigate if the speed and the versatility of the fuzzy controller are suf?cient to deal with them. The paper describes the experimental setup extensively so that it can also be performed at other teaching and research laboratories. Such a setup can be used by both electrical and mechanical engineering students to learn and apply fuzzy-logic control techniques using nontouching sensors such as vision sensors. The theoretical background

    of fuzzy systems with regard to an inverted pendulum is developed in [6] and [12], where it is taken as a benchmark for binary input?Coutput fuzzy associative memory (BIOFAM) systems. Using a similar approach as

     Manuscript received January 13, 1995; revised February 4, 1998. The authors are with Oregon State University, Corvallis, OR 97331 USA. Publisher Item Identi?er S 0018-9359(98)03408-6.

     T

     described in [6], we take two states and one control variable. The ?rst fuzzy state variable is the angle that the pendulum shaft makes with the vertical. The second is the average angular velocity . As output fuzzy variable we use the motor armature current. All three variables can be either positive or negative and are related in the following manner: If the pendulum falls to the left, the motor velocity should be negative to compensate. If the pendulum successfully balances in the middle, the motor current should be zero. Therefore, every variable takes on a certain set of values whose range is limited by practical considerations that result from physical and technological constraints. In the experiment we quantify each set or universe of discourse into seven overlapping fuzzy set values. This choice is based on prior experience.

     II. EXPERIMENTAL PLATFORM The setup of the inverted pendulum fuzzy-logic control with vision feedback experiment consists of the following parts: 1) a mechanical system composed of an inverted pendulum mounted on an ?C table, 2) a video camera and a vision computer that are used as a nontouching sensor to obtain the states of the system, 3) a fuzzy-logic controller that is , implemented on a 386 personal computer using Borland C and 4) an actuator that consists of an armature-controlled dc servo-motor driven by a pulsewidth-modulated ampli?er. A. The Mechanical System A lead screw that is directly coupled to the shaft of a dc motor and is guided by two steel bars using bearings drives the sled. The pendulum itself consists of a 70-cm-long rod and a wooden ball designed in such a way that the center of mass can be assumed to be at the top of the rod. The pendulum rotates in the vertical plane using low friction roller bearings. Possible deviations range up to 90 , but are actually restricted to a much smaller range by the constraints of the system. B. The Vision System In order to control the system, it is necessary to measure the different states. To do this, we use an Intelledex vision system with a relatively low-resolution video camera. The camera is equipped with a 16-mm lens with adjustable aperture to vary the amount of incident light. The vision computer is the HR model with a memory management unit. It allows transferring frames or single rows from the A/D buffer to the main memory without long delays. The information is evaluated and written

     0018?C9359/98$10.00 ? 1998 IEEE

     166

     IEEE TRANSACTIONS ON EDUCATION, VOL. 41, NO. 2, MAY 1998

     Fig. 1. Diagram of the experimental setup.

     to a serial RS 232 port that is set to operate at a 38-kb/s clock rate [4]. C. The Controller The controller is implemented on a 386 personal computer running at 16 MHz. The control commands are sent to a power ampli?er via a 10-V D/A converter. D. The Actuator This part of the system consists of a dc servomotor and a power ampli?er. The analog signal from the D/A converter is translated as a current and fed to the motor. Since the torque of the dc motor is proportional to the armature current, we can control the speed of the sled with a voltage command signal. III. VISION SYSTEM To successfully control the inverted pendulum using vision information it is necessary to separate the whole task into two parts: data acquisition and control. The vision system is responsible for acquiring the data and transmitting them to the PC that determines the control command based on these values. In doing so, routines for I/O and programs to handle the serial communication apart from the main control program are needed. This task is performed using C and small assembly language programs for controlling the serial communication. 1) Vision System Con?guration: The vision system core is an Intel 386 microprocessor running at 20 MHz. Also, the vision computer has a fast A/D unit that samples the RS 170 analog signal and writes the digitized data in a local array that is separated from the main memory of the CPU. Because the camera sends the data of each frame for 15 ms and pauses for 1.25 ms during the vertical blank, we use this window to copy the information that we are interested in to the main memory. This gives us the opportunity to manipulate the data and compute the angle and position of the sled simultaneously before the next image is acquired. Since this process takes place during a relatively short period of time, we can also transmit the position of the sled and the

     Fig. 2. Mechanical system with pendulum.

     angle over an RS 232 serial communication channel without losing image information. The vision application program is written and compiled in the host PC and then downloaded via the RS 232 into the vision computer. 2) Angle Computation: The video picture consists of 480 rows and 512 columns and a vertical blank period to allow the beam to reach the upper left corner again. The easiest way to determine the angle of the pendulum is to take two rows and ?nd the position of the greatest dark/bright transition. This position is represented as the column number. Since we know the distance between the rows (e.g., 400 lines) and the columns (e.g., 10 points) we can determine the angle by using a simple trigonometric function. The following ?gure illustrates the procedure. In order to have reliable values for the

    angle we need a high contrast of the video picture. To ensure this, the pendulum rod

     MAGANA AND HOLZAPFEL: FUZZY-LOGIC CONTROL OF AN INVERTED PENDULUM WITH VISION FEEDBACK

     167

     Fig. 3. Block diagram of vision system.

     TABLE I TRANSMITTED INTEGER VALUES Position Range 0?C90 100?C229 230?C279 280?C399 400?C480 Description inhibit movement sled too far left sled in the middle sled too far right inhibit movement

     0 1 2 3 0

     is painted black and a white background is used. To detect the point with the greatest black/white transition in a row we use a linear search algorithm that compares the contrast of the pixels and returns the position of the one with the greatest dark value. From the coordinates, we calculate the and distances and obtain the angle from dist. hor. dist. vert. To protect the sled from running into its mount, we use the position given in the lower row to determine ?ve areas of the sled position. They are encoded as integer values and transmitted to the control computer. The following table shows the areas in pixels. IV. THE FUZZY LOGIC CONTROLLER The proposed fuzzy-logic controller used to control the experimental inverted pendulum uses conventional triangular membership functions to fuzzify the data measured by the vision system [9]. Furthermore, the fuzzy inference engine implements a set of IF-AND-THEN rules on the angular

     Fig. 4. Angle computation.

     displacement and the angular velocity fuzzy variables whose universe of discourse is the closed interval . These rules are based on heuristic knowledge of the behavior and limitations of the experimental platform. When these rules are executed, they result in the output fuzzy variable labeled out, whose universe of discourse is also the interval . In the actual experiment, we divide all three universes of discourse into seven overlapping fuzzy set values labeled NL (Negative Large), NM (Negative Medium), NS (Negative Small), ZE (Zero), PS (Positive Small), PM (Positive Medium), and PL (Positive Large). The actual shape used for such fuzzy sets is triangular. Fig. 5 shows a ?ow chart of our controller implementation.

     168

     IEEE TRANSACTIONS ON EDUCATION, VOL. 41, NO. 2, MAY 1998

     This matrix has 49 elements and these elements describe the output suggested by the FAM rules. Every value of this matrix can also be seen as an IF-AND-THEN rule triple, or one could say that the whole system has a total of 49 rules. The numerical entries of the FAM matrix represent the seven fuzzy set variables used in the fuzzy-logic controller, i.e., represents NL, represents NM, and so on. Output FAM rule matrix:

     Fig. 5. Flow chart of fuzzy-logic controller.

     Fig. 6.

     Fuzzi?cation and defuzzi?cation rules.

     Fig. 6 shows the location as well as the width of the triangles that we use in the fuzzi?cation of the angular displacement, the angular velocity, and for the defuzzi?cation of the fuzzy variable out. The ?rst and the third numbers of each row represent the range of values that each fuzzy variable takes on. For example, the fuzzy variable PS for theta takes on values . from the interval The rules for the output are stored as text with rows describing input from NL to PL and the columns input

     Using the fuzzy centroid defuzzi?cation scheme, we then directly compute the real-valued output as the combined centroid of all the areas. This combined centroid is the output of the fuzzy controller and written as a binary value to the address of the D/A card. This D/A card maps the values from to into voltage levels ranging from 10 to 10 V. This analog control command is then fed into a servoampli?er. The ampli?er does not just boost the available power of the control command, but controls the current instead of the voltage. The reason for this is that the torque of the dc motor is proportional to the armature current. In the experiment, we not only receive the angle, but also the encoded position to improve the behavior of the system. This is done by adding an offset to the angle before the fuzzi?cation or, if the sled is too far on the edge of the table, we inhibit the movement and terminate the experiment. If we receive a , we know the sled is in the middle and we take the original angle. In case of a , we add degree and ??overcompensate?? the movement. Now, the controller reacts as if the negative 1 is zero and the sled moves over some time angle of periods back to the middle. Unfortunately, the system is not able to stop there and so the sled keeps moving to the right until it enters the region ??sled too far right?? with its numerical equivalent . The offset of 1 is subtracted and the cycle starts again. If for some reason the sled moves into the region , the movement of the sled is stopped by inhibiting the controller output. One problem that always has to be kept in mind is the alignment of the video camera. If the camera is rotated with respect to the zero position, we automatically add an offset that moves the sled to one side. A misalignment of 1 can lead to a total deterioration of the performance. For the purpose of calibrating the experiment, we have written a small C program that reads the values from the serial port and prints them to the screen. Unfortunately, the resolution of the video camera used in the experiment is relatively poor and, in order to have a reasonably wide ?eld of view, we have to tolerate quantization steps of about 0.25 . It should be pointed out at this stage that other fuzzy rules were experimentally tested. Their

    performances were compared against that which was produced by the rules

     MAGANA AND HOLZAPFEL: FUZZY-LOGIC CONTROL OF AN INVERTED PENDULUM WITH VISION FEEDBACK

     169

     Fig. 7. Pendulum angle versus time.

     Fig. 8.

     Sled velocity in relation to a step input signal.

     presented in this paper and it was observed that, given the experiment setup??s equipment limitations, they did not perform any better. V. PERFORMANCE EVALUATION In order to evaluate the performance of our fuzzy-logic control system, all the acquired data are stored in a ?le on the hard disk. To avoid delays in the output of the control signal, the measured values are saved after the output command is computed. The remaining time until the new angle and position measurements are available at the serial port is still suf?cient to store the old values without losing data. To be able to process the data off-line, the angle information is stored with a precision of 0.1 . We can observe in Fig. 7 that the average amplitude that results from the deviation of the pendulum is about 2.7 . We can also see in the same ?gure that the system displays an oscillatory behavior. The amplitude of the oscillations depends on the maximum acceleration, inertia, and other factors. From the same ?gure, we can determine that the period of the oscillations is approximately 400 ms. VI. OBSERVATIONS As with every real-life design, we have also made assumptions that simplify the design procedure described in this paper. Therefore, it is important to verify that such assumptions are valid and that they do not result in an unacceptable system performance. Fig. 8 shows that the response delay is about 25 ms. Also, during the write cycles of the PC, data are lost resulting in a slight time shift. Because of this reason, the time delay of 25 ms can only be determined from the very beginning. The sometimes-sharp changes in the velocity are also caused by missing measurement values. In general, we see that it takes the motor about 100 ms to reverse its movement and several hundred milliseconds to approach top speed. Another problem with the experimental system is that of precision in the data acquisition. Not only is the rate of data measurements very slow (60 measurements per second), but they are also not very exact. This results from the fact that the

     whole ?eld of view that we observe and in which the pendulum moves spans 480 pixels. Noting that two steel bars that are 60 cm long guide the sled, we get a maximal resolution of 1.25 mm/pixel. Since we calculate the angle from the trigonometric relationship between the constant vertical distance and the variable number of pixels in the horizontal direction, we get a resolution of about 0.25 . This means

    that, if the pendulum is 0.2 off center, such a position will go undetected. Last, but not least, is the error contribution due to the coarse quantization of the angle. We know that fuzzy logic is based on membership functions and on the technique of inference. This means that a value is not only a member of a particular set, but also, to some degree, a member of several different sets. Now, with coarse quantization we lose part of the ?exibility of the fuzzy-logic system. In reality, the range of the angle that is used never exceeds 5 . For larger deviations, the system turned out to be too slow to compensate. The output values are therefore ampli?ed to give the maximum output current already in the case when the controller wants to apply a positive or negative MEDIUM control force. Although we matrix with 49 rules, we effectively use implemented a only the core matrix. This leads to another deterioration of the controller performance. VII. SUMMARY

     AND

     CONCLUSION

     The proposed vision feedback fuzzy-logic controller is able to keep the inverted pendulum in the upright position, though for a limited time. In what follows, we will discuss modi?cations that might lead to an improvement in the behavior of the experimental system. The fuzzy-logic controller implementation is entirely written in Borland C . This programming language running on MS-DOS 6.2 operating system does not provide a real-time environment for the experiment and results in re-entry problems of subroutines. This problem could be avoided by introducing real-time subroutines that are not part of the standard C package. To control the inverted pendulum successfully for long periods of time, we would have to make use of not only the angle of the pendulum, but also the position and perhaps the velocity of the sled. Using the position of the sled also will in turn lead to a four-dimensional fuzzy-logic control system.

     170

     IEEE TRANSACTIONS ON EDUCATION, VOL. 41, NO. 2, MAY 1998

     The addition of an extra state, however, will render the manual tuning approach to determine the fuzzy set values a more challenging task. It might even be necessary to implement an adaptive fuzzy-logic controller that obtains suitable control parameters after a period of ??training?? [11], [12]. This will require major changes not only in the controller program, but also in the data acquisition system, since the sled position is not part of the present control strategy. Further problems arise from the fact that we use the difference between two angles as input for the angular velocity. Since the measurements are noisy and have a relatively large quantization error, we end up computing an even noisier estimate of the velocity. Introduction of ?ltering techniques in the vision system can potentially result in a better system

    performance because of a smaller angular velocity error. The mechanical time constants of our experimental system limit the response time and prevent fast changes in the movement of the sled [1], [3], [7]. To achieve an improvement, it would be bene?cial to change the design from the lead screw ?C table to a belt-driven con?guration that is more responsive, has a smaller mass and less friction. Another aspect is the use of a different camera to accelerate the acquisition of data through the vision system. The Intelledex Vision System is able to give a reset pulse to the video camera. This would make it possible to acquire more than just 60 frames per second and also decrease the response time of the system. Also we encounter problems that result from the limited resolution of the video camera. The fact that we have only 480 pixels for the entire horizontal ?eld of view leads to large quantization errors and a low precision. It would be extremely bene?cial to improve the accuracy of the measured angle, since the precision of the input data is of great importance for the controller. After reviewing the experimental results, it seems clear that it would be necessary to make substantial changes to achieve a more satisfactory performance of the vision feedback fuzzy-logic control system. For example, better inference rules (perhaps adaptive) in the fuzzy-logic controller that use position and velocity information of the sled, along with a faster and more precise vision data acquisition system would

     certainly lengthen the time that the pendulum is kept in the upright position. REFERENCES

     [1] M. Anderson and W. Grantham, ??Lyapunov optimal feedback control of a nonlinear inverted pendulum,?? J. Dyn. Syst., Meas. Contr., vol. 111, pp. 554?C558, Dec. 1989. [2] T. Brem and T. Rattan, ??Hybrid fuzzy logic PID controller,?? in 1993 IEEE Nat. Aerospace and Electronics Conf., 1993, pp. 807?C813. [3] A. Ertas and G. Mustafa, ??Real-time response of the simple pendulum: An experimental technique,?? Experimental Techniques, vol. 16, pp. 33?C35, July/Aug. 1992. [4] Intelledex Inc., V-386HR+ User??s Guide, Beaverton, OR, 1992. [5] G. Klir and T. Folger, Fuzzy Sets, Uncertainty and Information. Englewood Cliffs, NJ: Prentice-Hall, 1988. [6] B. Kosko, Neural Networks and Fuzzy Systems. Englewood Cliffs, NJ: Prentice-Hall, 1992. [7] P. Lambrecht and G. Van der Linden, ??H-in?nity control of an experimental inverted pendulum with dry friction,?? IEEE Contr. Syst. Mag., vol. 13, no. 4, pp. 44?C50, 1988. [8] L. Ljung, System Identi?cation. Englewood Cliffs, NJ: Prentice Hall, 1987. [9] E. Mandani and S. Assilian, ??An experiment in linguistic synthesis with a fuzzy logic controller,?? Int. J. Man Mach. Studies, vol. 7, no. 1, pp. 1?C13, 1975. [10] J. Slotine and W. Li, Applied Nonlinear Control. Englewood Cliffs, NJ: Prentice Hall, 1991. [11] T. Takagi and M. Sugano, ??Fuzzy identi?cation of systems and its applications to modeling and control,?? IEEE Trans. Syst., Man,

    Cybern., vol. SMC-15, no. 1, pp. 116?C132, 1985. [12] L. Wang, Adaptive Fuzzy Systems and Control: Design and Stability Analysis. Englewood Cliffs, NJ: Prentice-Hall, 1994.

     Mario E. Magana received the B.S.E.E. degree from Iowa State University, ? Ames, in 1979, the M.S.E.E. degree from Georgia Institute of Technology, Atlanta, in 1980, and the Ph.D. degree in electrical engineering from Purdue University, West Lafayette, IN, in 1987. He was a practicing engineer at both The Harris Corporation and The Boeing Company between June 1980 and August 1986. He is now a faculty member in the Department of Electrical and Computer Engineering at Oregon State University, Corvallis.

     Frank Holzapfel received the M.S.E.E. degree from Oregon State University, Corvallis, in 1995, and the Diploma Ingenieur degree from the University of Stuttgart, Stuttgart, Germany in 1997.

??TXTÓÉ??ÎÄ?â????ÏÂÔØ:http://www.mozhua.net/wenkubao

Report this document

For any questions or suggestions please email
cust-service@docsford.com