Academia.eduAcademia.edu

Simple Tuning of a Fuzzy Pulse Width Modulation Controller

2006

The aim of this work is to evaluate the effectiveness of a Simple Tuning algorithm applied on a Fuzzy Pulse Width Modulation controller in a real situation with DC gear motors. The fuzzy logic model proposed to control motor's no-load speed consists in 25 rules based on Mamdani Fuzzy Inference System. A hardware implementation and an interface are designed for controlling the plant. In addition to the Simple Tuning process, another algorithm is presented to get the vector of operation points of each input and save the new one after applying such process. The experimental results are presented at the end of this paper.

Simple Tuning of a Fuzzy Pulse Width Modulation Controller for a DC Motor Application Miguel Ángel Porta García1,a, Iliana Marlen Meza Sánchez1,b, Oscar Montiel1, Roberto Sepúlveda1, Oscar Castillo2 1 Centro de Investigación y Desarrollo de Tecnología Digital del Instituto Politécnico Nacional (CITEDIIPN) Av. del Parque No. 1310, Mesa de Otay, Tijuana, B. C., México. 2 Department of Computer Science, Tijuana Institute of Technology P.O. Box 4207, Chula Vista CA 91909, USA. Abstract— The aim of this work is to evaluate the effectiveness of a Simple Tuning algorithm applied on a Fuzzy Pulse Width Modulation controller in a real situation with DC gear motors. The fuzzy logic model proposed to control motor’s no-load speed consists in 25 rules based on Mamdani Fuzzy Inference System. A hardware implementation and an interface are designed for controlling the plant. In addition to the Simple Tuning process, another algorithm is presented to get the vector of operation points of each input and save the new one after applying such process. The experimental results are presented at the end of this paper. Keywords: Fuzzy Logic, Simple Tuning Algorithm, DC Motor. 1. Introduction The use of Pulse Width Modulation PWM is a simple way for controlling analogue circuits with processor's digital outputs and is currently the most widely used technique for controlling power in control systems [1]. This powerful technique is employed in a wide variety of applications, ranging from measurement and communications to power control and conversion. In addition, PWM is economical, space saving, and noise immune [2]. The use of well known PID controllers to perform this job is common nowadays, even designs of digital circuits that make this kind of work exists in market, like the Precision Motion Controller LM628/629 of National Semiconductors for DC and brushless DC servomotors, it has a Programmable digital PID filter with 16-bit coefficients to compensate the control loop [3]. Since the tuning of a fuzzy controller is heuristic work, sometimes becomes overwhelming to find the optimal parameters necessaries for a well performance of the controller; then the use of these at industry is not so popular. But it’s possible to apply a simple tuning algorithm where it only needs one parameter [4]. In a,b M.S. Students at CITEDI-IPN this paper is presented experimental results of a simple tuning fuzzy controller of PWM applied to regulate the rpm of a DC motor. The tuning task of the controller has the capacity of modifying the necessary parameters by itself in order to find the desired response, manipulating the settling time of the system. This work is organized as follows. In section 2, a system description including the model design and its hardware implementation is shown. In section 3, we are presenting the description of the system implementation. Section 4 introduces the description of the fuzzy model, with its membership functions and rules. Section 5 describes the methodology of the simple tuning algorithm used to manipulate the settling time of the system. In section 6, we are showing results of the implementation of the simple tuning algorithm for a Fuzzy Pulse Width Modulation controller. Finally, in section 7 we are presenting the conclusions. 2. Hardware Description a) DC motor description. The DC Motor employed for the experiments is a DC motor Pittman GM9413-3 with a reference voltage of 12V and 43 rpm no-load speed [5]. The motor is shown in Figure 1. Figure 1. DC Pittman gearmotor GM9413-3. b) 35mm ROSE Encoder The 35mm ROSE (Reflective Optical Sensing Encoder) is an incremental, non-contacting rotary to digital feedback device of 512 CPR (Cycles Per Revolution). The encoder translates real-time shaft angle, speed and direction of rotation into TTL compatible outputs. The outputs pulses are sent in two channels, A and B, in quadrature with medium resolution encoding performance. The channel A is intended to gather count information and channel B is intended to gather direction information. The channel A leads B during CW (Clockwise) code disc rotation, Channel B leads A during CCW (Counterclockwise) code disc rotation (while viewing top of encoder sensor) [6]. module of Parallax®, which receives the value of the duty cycle (output of the fuzzy controller) from the parallel port of the PC, using a Matlab® function embedded in a Simulink® block (see Figure 4). A second programming board BS2p24 makes the counting process of the encoder pulses, with a sample time of 10 ms. It sends the result via serial port. Another Matlab® function receives this information, which is the positive feedback of the system. The BS2p24 has a program execution speed of 12,000 instructions per second approximately, with a processor speed of 20 MHz. It also includes a 38 bytes (12 I/O, 26 Variable) RAM size and 8 x 2K Bytes, giving an approximated of 4,000 instructions. This circuit has 16 I/O pins plus 2 for dedicated serial. The total number of PBASIC commands on the BS2p is 61. 3. System Description Figure 2. Output waveforms. Figure 2 presents a comparison of the output waveforms of the channel A and B of the encoder. The width of the logic states are the numbers of electrical degrees between a transition in the output of channel A and the neighboring transition in the output of channel B. There are four states per cycle, each 90° nominal. c) Power stage The power stage is based in the National Semiconductor LMD18200® H-Bridge, designed for motion control applications. They are often used to control the speed, position or torque of DC and stepper motors, and it can be employed typically in factory automation robots, numerically controlled machinery, computer printers and plotters [7]. The functional diagram is presented in Figure 3. Fuzzy systems allow to cope with uncertainties due measurement in realistic cases, using techniques inspired in human reasoning [9], and they allow introducing explicit human knowledge [10], but their construction need expert knowledge to be transformed into rules. A fuzzy controller is composed internally by a set of linguistic rules. All the possible values of the input variables necessary for a correctly function of the controller are considered. The issue of designing control systems is reduced to the election of the controller and the necessary adjustments on the parameters for its correct performance [11]. In order to measure the behavior of the controller’s output over the DC motor application, the model was designed in Simulink® of Matlab® (see Figure 4). 1 [uf] 40 z retard uf Desired speed (rpm) Mux error MATLAB Function [ut] From BS2p24 Reading encoder count pulses 3 du/dt error's derivative Gain Fuzzy Logic Controller u(t)=u(t-1)+k du(t) MATLAB Function cde.mat [ut] ut Converting fuzzy output to Duty Cycle Mux [uf] MATLAB Function fuzzy and total control To BS2p24 Duty Cycle to generate the PWM Figure 4. Simulink® system model. 4. Fuzzy Model Description Figure 3. Block diagram of the LMD18200. To generate the PWM signal, it is used a programming board with a Basic Stamp® BS2p24 microcontroller The fuzzy controller consists of 25 rules based on 5 fuzzy regions. This design considers the position error and the change of the error as the input sets. The output is the duty cycle of the PWM signal sent to the power stage so the desired no-load speed is reached. Table I shows the controller fuzzy variables employed. Figures 5, 6, 7 and 8 show the membership functions of the error input variable, the change of error input variable, the duty cycle output variable and the control surface of the fuzzy controller, respectively, under their initial conditions before applying the Simple Tuning algorithm. The fuzzy associative memory, integrated by 25 rules is shown in Table II. TABLE I FUZZY CONTROLLER VARIABLES. Input variables Error NB: Negative Big N: Negative Z: Zero P: Positive PB: Positive Big Error change NB: Negative Big N: Negative Z: Zero P: Positive PB: Positive Big Output variable Control Action (Duty Cycle) 5. Simple tuning algorithm When implementing a fuzzy controller it’s necessary to consider many parameters to compute, like, number and ranges of membership functions, rules, shapes, percentages of overlap, etc. [12]. The algorithm implemented in this system is based on the properties of the control surface, allowing the modification of the controller’s behavior by means of manipulating the ranges of the membership function of the input variables, and it only implies a single variable (instead of a PID controller, which needs to find at least three parameters for tuning), and it only modifies the membership functions of the input variables. The membership functions of the output fuzzy variable remains constant [4]. BD: Big decrease D: Decrease H: Hold I: Increase BI: Big increase Figure 7. Membership functions of the duty cycle output variable. Figure 5. Membership functions of the error input variable. Figure 8. Control surface of the fuzzy controller. TABLE II FUZZY ASSOCIATIVE MEMORY FOR THE CONTROL SYSTEM. ce Figure 6. Membership functions of the change of error of the input variable e NB N Z P PB NB N Z P PB BI BI BI BI BI BI I I H I I H H H D D H D D BD BD BD BD BD BD The main part of the simple tuning algorithm for fuzzy controller applied in the experiments with a real DC gear motor is to have the ability of manipulate the settling time of the system with a single parameter. In general, the method [4] consists basically in four steps: 1. Tuning Factor Selection. A number k ∈ [0,1] is used to define the tuning adjustment level. k = 0 is the biggest settling time, and k = 1 the smallest. 2. Normalization of the ranges of the Fuzzy Controller’s variables. The range of each input fuzzy variable is modified in order to have the lower and upper limits equal to -1 and +1, respectively. 3. Tuning Factor Processing. Once the range is normalized, the new vector of operation points will be given by: Vop final = (Vopinitial ) r ( k ) (1) Where Vopinitial are the values normalized of the membership functions in the x-axis and r(k) is the polynomial: r (k ) = 4. 30k 3 + 37k 2 + 52k + 1 40 Note that for k = 0.5 there is a similarity with the initial conditions of the fuzzy controller. A graph of the system response for k = 0, 0.25, 0.5, 0.75, 0.9, 0.95, 1, is shown in Figure 18. a) Case 1. Tuning factor k = 0. In this case the biggest settling time of the system is approximately 3270 ms. The effect in the membership functions of each input value and the control surface are shown in Figures 9, 10 and 11, respectively. b) Case 2. Tuning factor k = 0.9. The settling time for k = 0.9 it’s around 200 ms, and the system response presents a smooth curve. The effect in the membership functions of each input value and the control surface are shown in Figures 12, 13, 14, respectively. c) Case 3. Tuning factor k = 1. The tuning factor k = 1 gives the fastest system response, but an oscillation before reaching the stable state at 40 rpm is produced. The effect in the membership functions of each input value and the control surface are shown in Figures 15, 16 and 17, respectively. (2) Renormalization of the ranges of the fuzzy variables. Convert the normalized range to the previous range of the system. This can be computed only multiplying the Vop vector by a constant factor. The Matlab® code of the functions to calculate and save the vector which contains the operation points are given in Appendix I. 6. Experimental Results Several experiments were made for different values of k, taking the DC motor’s no-load speed from 0 to 40 rpm. In this section, we are analyzing results obtained from real experiments with the abovementioned motor. We considered to include results with the biggest settling time (k = 0), the smallest settling time (k = 1), and the best results obtained with k=0.9, and k=1. Comparing the two best results, we are considering to take as the best experiment result, the case with k=0.9, because comparing both settling times, the controller’s output of the system has a bigger overshoot with k = 1. Hence, with k=0.9 the controller reaches the desired velocity (rpm) describing a smooth curve and almost at the same time as when k=1. Figure 9. Membership function of the error with k = 0. Figure 10. Membership function of the change of error with k = 0. Figure 11. Control surface for the fuzzy controller for k = 0. Figure 12. Membership function of the error with k = 0.9. Figure 13. Membership functions for change of error with k = 0.9. Figure 14. Control surface for the fuzzy controller for k = 0.9. Figure 15. Membership function of the error with k = 1. Figure 16. Membership function of the change of error with k = 1. REFERENCES [1] Figure 17. Control surface for the fuzzy controller k = 1. Figure 18. System response at different values of tuning factor k. 7. Conclusions The use of fuzzy controllers can be considered as a viable and efficient tool to deal with real systems, since we can achieve a well tuned fuzzy controller by a simple algorithm with the capacity of modify the necessary parameters by itself in order to find the desired response, manipulating the settling time of the system. In agreement to the experimental results obtained in this work, it’s remarkable the fact that the nearest to 1 is the value of the tuning factor k, the fastest systems response is acquired. Due to the low cost implementation of this system, the imprecision of the readings of the encoder pulses increases the chattering effect in the system response, as it can be visible in the graph of Figure 18. For the maximum speed (43 rpm), the count should be 220 pulses at 10 ms sampling time, and every reading had an error of ± 20 counted pulses approximately. Therefore, an adequate data acquisition board should give a more precisely result. Nevertheless, the obtained results were good enough in order to work with the Simple Tuning algorithm. M.N. CIrstea , A. Dinu, J.G. Khor, and M. McCormick, Neural and Fuzzy Logic Control of Drives and Power Systems, Oxford: Newnes, 2002. [2] J. Ganssle and M. Barr, Embedded Systems Dictionary, Lawrence, KS: CMPBooks, July 2003. [3] National Semiconductors, LM628/LM629 Precision Motion Controller, available at: http://www.ortodoxism.ro/datasheets/nationalsemiconductor/D S009219.PDF. [4] Simple Tuning of Fuzzy Controllers, Gómez Ramírez E. International Conference on Fuzzy Systems, Neural Networks and Genetic Algorithms, FNG 2005, Tijuana, Mexico. [5] Pittman, GM9413-3 Lo-Cog® DC Motor Specification Datasheet, available at: http://www.pennmotion.com/part _num _database/pdf/GM9413_3.pdf. [6] 35mm ROSE Encoder Specification Datasheet, available at: http://www.clickautomation.com/PDF/categories/Rose%20Enc oder%20Information.pdf. [7] National Semiconductor, A DMOS 3A, 55V, H-Bridge: The LMD18200, available at: http://www.ortodoxism.ro/datasheets/nationalsemiconductor/D S010568.PDF. [8] Parallax Inc. “Parallax, Inc-StoreFront Product Detail Page” available at: http://www.parallax.com/detail.asp?product_id=BS2P24-IC. [9] P.P. Bonissone, “Discussion: fuzzy logic control tecnology: A personal perspective”, Technometrics, Vol. 37, No. 3, 1995. [10] L. Zadeh, “Fuzzy sets”. Information and Control, Vol. 8, 1965. [11] Autosintonía de controladores borrosos utilizando técnicas clásicas basadas en reguladores PID, S. Dormido, M. Santos, A. P. de Madrid and F. Morilla, Proc. of III EVSFLAT, España, 1993. [12] R. Sepúlveda, O. Montiel, O. Castillo, and P. Melin, Fundamentos de Lógica Difusa, México: ILCSA, 2002. APPENDIX I MATLAB® FUNCTIONS TO COMPUTE AND UPDATE THE OPERATION POINTS’ VECTOR To use this code you need to load the FIS in workspace as global variable named FuzzyCtrler, then call the function OPpointsG(i,mfs) for each input of the FIS. This function obtains the initial vector of operation points before the Simple Tuning algorithm adjustment. Then, call the function saveOPPG(i,opp) for each input in order to update the FIS with the final vector of operation points. function opp = OPpointsG(i,mfs) global FuzzyCtrler % i = input number. % mfs = amount of membership functions % Triangular membership functions in the center and % trapezoidal membership functions in the ends are assumed. for n=1:mfs if n == mfs opp(n) = FuzzyCtrler.input(i).mf(n-1).params(3); else opp(n) = FuzzyCtrler.input(i).mf(n+1).params(1); end end function saveOPPG(i,opp) global FuzzyCtrler % Triangular membership functions in the center and % trapezoidal membership functions in the ends are assumed. for n=1:length(opp) if n==1 FuzzyCtrler.input(i).mf(1).params(3)=opp(n); FuzzyCtrler.input(i).mf(1).params(4)=opp(n+1); else if n==length(opp) FuzzyCtrler.input(i).mf(n).params(1)=opp(n-1); FuzzyCtrler.input(i).mf(n).params(2)=opp(n); else FuzzyCtrler.input(i).mf(n).params=[opp(n-1) opp(n) opp(n+1)]; end end end View publication stats