"STEP VARIATION STUDIES OF ARM7 MICROCONTROLLER BASED FUZZY LOGIC"
INTERNATIONAL JOURNAL OF ELECTRICAL ENGINEERING International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME & TECHNOLOGY (IJEET) ISSN 0976 – 6545(Print) ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), pp. 405-415 IJEET © IAEME: www.iaeme.com/ijeet.asp Journal Impact Factor (2013): 5.5028 (Calculated by GISI) ©IAEME www.jifactor.com STEP VARIATION STUDIES OF ARM7 MICROCONTROLLER BASED FUZZY LOGIC CONTROLLER FOR WATER-IN-TANK LEVEL CONTROL L. Shrimanth Sudheer, P. Bhaskar and Parvathi C. S. Department of Instrumentation Technology, Gulbarga University Post Graduate Centre, RAICHUR –584133, Karnataka, INDIA, ABSTRACT Design and development of ARM7 microcontroller based fuzzy logic controller (FLC) for water-in-tank level system is presented in this paper. A continuous tank of 100cm X 20cm X 20cm dimension with one inlet and one outlet is considered. The outlet flow of water is let open continuously to a reservoir and inlet flow is controlled by a pneumatic actuated valve. The valve opening is controlled according to the water level in the tank in order to make the deviation zero. The necessary hardware and software is developed indigenously. FLC algorithm is written in embedded C in KEIL µV4 integrated development environment. The main objective of the experimental work is to improve the performance of the conventional PID controller by replacing it with modern FLC. The proposed controller is subjected to both step and step-variation (stair-case) inputs. The performance is compared with PIDC and necessary performance indices are found from the plots and tabulated. It is observed that FLC outperforms the conventional PID in terms of quicker rise-time and better tracking of the input. Keywords: ARM7, Microcontroller, Water-Level, PIDC, FLC. 1. INTRODUCTION The liquid level control systems play an important role in industries, for example, the raw materials stock of the chemical works, the mixture raw materials process of the lithification works, and the output products reaction of biochemical and petrochemical plants, liquid level control of a steam generator in power plants, and pulp level control in paper and 405 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME pulp industry. Typically, many works using liquid tank level systems are using on-off loop control scheme, which contain only the relay device and the limit switch. For precision control, performance is limited by using this control; it is difficult to achieve accurate level control for improving manufacturing quality of the products. The recent development in the microcontroller, as single chip solution for many of industrial control applications, has made the author to select and implement the control algorithm on ARM7 microcontroller for liquid level control. The fuzzy logic control is emerged over the years and become one of the most active and fruitful areas of research in the intelligent control applications in industries as well as home appliances. Fuzzy logic controller is a non linear controller and based on intuition and experience about the plant to be controlled. Therefore it does not require the precise mathematical model of the plant. Level of liquid being an important process parameter has to be maintained at the desired level for smooth running of the process and for better quality products. There have been many books/papers reported on the subject of controlling and monitoring liquid level in different industrial processes [1-5]. Miao Wang and Francesco Crusca  designed and implemented a gain scheduling controller for water level control in a tank. It was observed that the system achieved a better performance over the conventional controller like P, PI, and PID. Weidong Zhang, et al  proposed a new two-degree-of-freedom level control scheme for processes with dead time. T. Heckenthaler and S. Engell  developed level controller for a nonlinear two-tank system based on fuzzy control. Similarly, application of fuzzy logic for water level control of small-scale hydro-generating units was reported by T. Niimura and R. Yokoyama , for water level control of steam generator was reported by X. Liu, and T. Chai , and a fuzzy sliding mode controller for two cascaded tanks level control was reported by N. Waurajitti, et al . The recent work by W. Chatrattanawuth, et al  reported a level control system using a fuzzy I-PD controller. Their simulation results showed that the proposed fuzzy I-PD controller performed better over the conventional. C. Li and J. Lian  reported the application of genetic algorithm in PID parameter optimization for level control system. They simulated the proposed strategy on MATLAB and later tested using LabVIEW. Another LabVIEW based water level control is also reported by L. Gao and J. Lin . A DCS based water level control of boiler drum is reported by Y. Qiliang, et al . A similar work is also reported by H-M Chen, et al . They designed a sliding mode controller for a water tank liquid level control system. In most of the research work reported earlier and recently, the studies have been either simulation, based on MATLAB, or implementation using LabVIEW with PC as the platform. The use of a single chip, advanced microcontroller with fuzzy logic control algorithms for liquid level control is rather scarce and nowhere found in the papers reported. So this is a novel approach and motivated us to employ an advanced, industry standard, ARM7 microcontroller based control system for liquid level control. The proposed work is not only advanced, but achieves low cost and high efficiency in terms of size, speed, performance, and development time. 2. WATER-IN-TANK SYSTEM A continuous linear tank made of stain less steel with external dimensions of 100cm X 20cm X 20cm is considered. The process tank has one inlet and one outlet. The outlet flow of water is let open to a reservoir and inlet flow is controlled by a pneumatic actuated valve (PCV). A differential pressure transducer, placed at the bottom of the process tank, senses the 406 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME liquid level in terms of pressure and converts into proportional voltage. The valve opening is controlled according the water level in the process tank in order to maintain the measured value as close to set point as possible i.e., to make the deviation zero. The water from reservoir is pumped to process tank by means of a pump through a PCV which in turn controlled by the fuzzy logic algorithm run by the microcontroller to maintain the water level of tank at the set-point. The set-point of the tank can be changed by user through host computer connected to ARM7 microcontroller. The water-in-tank system is shown in Fig. 1. Process Tank 1 mtr Water under Level Indicator Process Level Actuator DPT 0 PCV Excitation HV1 HV2 Reservoir Pump Fig. 1. Water-in-tank system 3. METHODOLOGY The principle and block diagram of ARM7 microcontroller based water-in-tank level control system is shown in Fig. 2. Level of water in process tank is measured in terms of pressure-head developed in the capillary attached to the tank at the bottom. The other end of the capillary is attached to a level sensor which is basically a differential pressure transducer (DPT). As the water level increases in the tank, the pressure due to air trapped inside the capillary also increases. Hence, the pressure, directly proportional to the water level, is sensed and converted into equivalent voltage by the sensor. The microcontroller measures the voltage proportional to level through the transducer, instrumentation amplifier (IN-AMP), and on-chip analog to digital converter (ADC), converts into actual level in cm and displays it on LCD. ARM7 based microcontroller LPC2129 from Philips is used. The inlet flow of water 407 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME from reservoir to the process tank through a pump is controlled by a pneumatic valve which in turn controlled by the microcontroller through on-chip PWM unit, PWM to voltage converter, voltage to current and a current to air (I/P) converter connected to PCV. The I/P converter is supplied with a pressurized air (through air regulator) with the help of air compressor. LCD ARM7 Microcontroller Liquid On-chip PWM to V V to I I to P Level PCV Process PWM1 Converter Converter Converter Tank FLC Algorith Pump Reservoir On-chip IN-AMP DPT UART1 ADC Fig. 2. Block diagram of proposed water-in-tank level control system The LPC2129 from Philips Semiconductor  consists of an ARM7TDMI-S CPU with real-time emulation and 256KB of embedded high speed flash memory available in compact 64 pin package. The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high performance and low power consumption. Its architecture is based on RISC principle. It includes the following components: 16KB on-chip SRAM, 256KB Flash, 2- channel CAN interface, 4-channel 10-bit ADC, 32-bit timers with PWM units and RTC, 46 GPIO ports, I2C bus interface, and on-chip crystal oscillator. The technical specifications of equipment used in the experimental setup are given in Table 1. Table 1: Technical specifications of experimental setup Part Name Specifications Process Tank Material: Stainless Steel (Rectangular/cylindrical) Dimension: 100x20x20 cm Reservoir Material: Stainless Steel Volume: 100 Liters Pump Centrifugal (Single-Phase, ¼ HP) Control Valve Size ¼”, Pneumatic Actuated Type: Air to open Input: 3-15 psi Air Regulator Input: 400 psi (max) Output: 2-150 psi I/P Converter Input: 4-20 mA Output: 3-15 psi Pressure Gauge Range: 0-30 psi, 0-100 psi Compressor Output: 200 psi (max) Differential Pressure Type: Diaphragm Transducer Range:0-5 psi Output: 3mV/V/psid 408 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME 3.1 Design of Fuzzy Logic Controller A fuzzy logic controller (FLC) incorporates fuzzy logic for decision making, or rather to produce control action, as required by the process or plant. FLCs are knowledge based controllers consisting of linguistic “IF-THEN” rules that can be constructed using the knowledge of experts in the given field of interest [18-19]. The fuzzy inference engine is the heart of the FLC comprises both the knowledge base and decision-making logic. The knowledge base consists of data base with necessary linguistic variables (rule set) and decision-making logic used to decide what control action to be taken. The outputs of inference engine, which are fuzzy linguistic terms, are converted into real (crisp) numbers in the defuzzification stage [20-21]. A two input and one output fuzzy logic controller is designed as shown in the Fig. 3. The error (e) and change-in-error (ce) are the two inputs, and control action (ca) is the corresponding output of the FLC. A triangular membership function with nine members (linguistic variables) termed as negative large (NL), negative medium (NM), negative small (NS), negative zero (NZ), zero error (ZE), positive zero (PZ), positive small (PS), positive medium (PM), and positive large (PL) are used to map the crisp input to universe of discourse (-1 to +1). The universe of discourse is the range over which the fuzzy variables are defined. The nine-member triangular functions of error, change-in error, and control action are shown in Fig. 4. The control rules are constructed to achieve the best performance of FLC. With nine members, we obtain 81 rules. The max-min method is used for inference engine. The defuzzification is done using centre of gravity (COG) method. FLC r + e=r-y ca y Level Process - Defuzzifier Rule Base Fuzzifier z-1 + Inference - ce Engine Fig. 3 Fuzzy logic control system The e input to the FLC is obtained by subtracting measured value/process variable (y) from the reference (r), and the ce which is the difference between present and previous errors. The output of the controller i.e., change in control action (ca) is applied to the process. The reference input r, which is also the desired value, is entered by the operator in the beginning. This is a closed loop control where the process variable is being continuously monitored to maintain the error zero. 409 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME Membership Grade µ(e) 1.0 NL NM NS NZ ZE PZ PS PM PL 0.5 0.0 -1.0 -0.5 0.0 0.5 +1.0 error (e) Membership Grade µ(ce) 1.0 NL NM NS NZ ZE PZ PS PM PL 0.5 0.0 -1.0 -0.5 0.0 0.5 +1.0 change-in-error (ce) Membership Grade µ(ca) 1.0 NL NM NS NZ ZE PZ PS PM PL 0.5 0.0 -1.0 -0.5 0.0 0.5 +1.0 Control action (ca) Fig. 4. Nine-member triangular functions of error (e), change-in-error (ce), and control action (ca) 3.2 Software Details The complete software for data acquisition, display, processing, and controlling the liquid level is developed in embedded C language using KEIL’s µV4 Integrated Development Environment. After compiling and debugging the code in PC, the output .hex file is downloaded to LPC2129 microcontroller through serial port (COM1). The stored data in on-chip flash of microcontroller is sent back to PC for storing, plotting and further analysis. The flowchart of the complete program is shown in Fig. 5. The program consists of five major subroutines of data acquisition (A/D conversion), LCD update, FLC algorithm, PWM generation, and serial communication. 410 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME Start Declare & Initialize LCD, ADC, PWM, & FLC variables, members, & functions Initialize hardware (LCD, on-chip ADC, PWM1, and UART1) Send valve-open & motor-on commands Call ADC & LCD subroutine to measure and display the initial level on LCD Read reference command (step/ staircase) from the user Call ADC and LCD subroutine to display present level in cm Compute the error, change-in error and apply to FLC algorithm Scale FLC o/p & load in PWM1 register to generate control action Update FLC variables Store and send the control action to PC through UART1 Fig. 5. The complete flowchart of level control program 411 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME 4. RESULTS The liquid level control system is subjected to step and step variation inputs. Before subjecting the system to various test commands, the system initial conditions are met. Under initial conditions, the process tank outlet is let open at a fixed (constant) flow rate. The supply air to I/P converter is provided by an air regulator at a pressure of 30psi from a compressor. For a step input, a desired level command of 15cm is applied. The corresponding responses of the controllers are plotted as shown in Fig. 6. The rise time and settling time of FLC are found to be respectively 52.77 sec and 65.56 sec as shown in Table 2. The steady state error is found to be zero. FLC achieves superior performance when compare to the traditional PIDC (best tuned with KP=390.0, KI=0.45, KD=0.1, & T=1). Table 2. Performance comparison for a step input of 15 cm Performance Indices→ Rise Settling Steady state Overshoo Controller Type↓ time (tr) time (ts) error (ess) t (MP) PIDC 67.39 sec 120.50 sec 0.4 cm 4% FLC 52.77 65.56 sec 0 0.6% In case of step variation studies, a stair-case command is applied to the controller. The input command is varied for three values, in a step of 15cm from 0 to 15cm, 15 to 30cm, and 30 to 45cm. The corresponding output responses of both PIDC and FLC are plotted as shown in Fig. 7. It is evident from the plot that FLC performs better than PIDC in tracking the step variation of the input. PIDC performs sluggishly to the input. The standard performance indices of PIDC and FLC at different liquid levels are tabulated in Table 3. Table 3. Performance comparison for stair-case input Liquid Level→ 15 cm 30 cm 45 cm Performance Indices↓ Rise time (sec) PIDC 67.39 67.60 68.00 FLC 52.77 53.10 51.80 Settling time (sec) PIDC 120.5 134.6 111.5 FLC 65.56 65.80 64.40 Overshoot (%) PIDC 4 0.6 0.6 FLC 0.6 0.6 0.6 In both the cases fuzzy logic controller outperformed the PID controller. Hence, we say that FLC is a robust controller when compare to PIDC and can be easily implemented replacing the existing PIDC. 412 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME 15 12 FLC PIDC 9 Level in Cm 6 3 1 0 50 100 150 200 250 300 Time in Sec Fig. 6. Step response of PIDC and FLC (from 0 to 15 cm) 50 45 40 PIDC REF FLC 35 30 Level in cm 25 20 15 10 5 0 0 100 200 300 400 500 600 700 800 900 Time in sec Fig. 7. Staircase response of PIDC and FLC (from 0 to 45cm in a step of 15 cm) 413 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME 5. CONCLUSIONS The real time implementation of fuzzy logic controller on an advanced ARM7 based LPC2129 microcontroller for liquid level control is discussed. The performance comparison between conventional PIDC and proposed FLC is made for a standard step, and step variation inputs. It is observed that FLC performed better than the conventional PIDC. FLC was found to be quick in reaching the set point, and settling, besides robust for step variations. So, it can be concluded with the present work that FLC is superior over PIDC. Also, incorporation of ARM7 microcontroller has increased the performance and greatly reduced the cost and space in terms of few interfacing circuits. REFERENCES  Lipták, Béla G., Process Control: Instrumentation Engineers’ Handbook, 3rd ed., Butterworth-Heinemann, Oxford, 1999.  Considine, Douglas M., Process/Industrial Instruments & Controls Handbook, 4th ed. McGraw-Hill, International Editions 1993.  Levine, William S., The Control Handbook, CRC Press, 1996.  Hamilton, J. A., and Guy, P. J., “Pulp level control for floatation-options and a csiro laboratory perspective,” Minerals Eng, vol. 14, pp.77-86, 2001.  G. Sakthivel, T. S. Anandhi, S. P. Natarajan, “Design of fuzzy logic controller for a spherical tank system and its real time implementation,” International Journal of Engineering Research and Applications, vol. 1, issue 3, pp. 934-940.  Miao Wang and Francesco Crusca, “Design and implementation of a gain scheduling controller for a water level control system,” ISA Transactions, vol.41, no.3, pp.323-331, 2002.  Weidong Zhang, Xiaoming Xu, and Yugeng Xi, “A new two-degree-of-freedom level control scheme,” ISA Transactions, vol.41, no.3, pp.333-342, 2002.  Thomas Heckenthaler and Sebastian Engell, “Approximately time-optimal fuzzy control of a two-tank system,” IEEE Control Systems, pp. 24-30, 1994.  Takahide Niimura and Ryuichi Yokoyama, “Water level control of small-scale hydro- generating units by fuzzy logic,” IEEE, pp. 2483-2487, 1995.  Xiangjie Liu and Tianyou Chai, “A weighted algorithm of fuzzy logic strategy on water level control of steam generator,” Proc. of the 36th Conference on Decision and Control, pp. 3357-3362, San Diego, USA, 1997.  Nawaporn Waurajitti et al, “Adaptive fuzzy sliding mode controller for two cascaded tanks level control,” IEEE, pp. II-592- II-597, 2000.  Wicharn Chatrattanawuth et al, “Fuzzy I-PD controller for level control,” SICE-ICASE International Joint Conference 2006, Bexco, Busan, Korea, pp. 5649-5652, 2006.  Chengwei Li and Jiandong Lian, “The application of immune genetic algorithm in PID parameter optimization for level control system,” Proc. of the IEEE Int. Conf. On Automation and Logistics, Jinan, China, pp. 782-786, 2007.  Ling Gao and Jianqun Lin, “LabVIEW and internet based remote water level control laboratory,” IEEE, pp. 187-188, 2007.  Yang Qiliang et al, “Water level control of boiler drum using one IEC61131-3 based DCS,” Proc. of the 26th Chinese Control Conference, Zhangjiajie, Hunan, China, pp-252- 255, 2007. 414 International Journal of Electrical Engineering and Technology (IJEET), ISSN 0976 – 6545(Print), ISSN 0976 – 6553(Online) Volume 4, Issue 2, March – April (2013), © IAEME  Hong-Ming Chen, Zi-Yi Chen, and Juhng Perng Su, “Design of a sliding mode controller for a water tank liquid level control system”, Proc. 2nd Int. Conf. on Innovative Computing, Information & Control, ICICIC ’07, Vol. 4, No. 12, pp. 3149-3159, Dec 2008.  Philips LPC2129 User Guide  John Yen, Reza Langari, “Fuzzy Logic: Intelligence, Control and Information”, Prentice Hall, Englewood Cliffs, NJ, 1999.  E. Cox, Fuzzy Fundamentals, IEEE Spectrum, vol. 29, no.10, pp. 58-61, 1992.  Chun Chen Lee, “Fuzzy logic in control systems: Fuzzy logic controller – Part I, II,” IEEE Transactions on Systems, Man and Cybernetics, vol. 20, no.2, 1990.  Li Zheng, “A practical guide to tune of PI like fuzzy controllers,” IEEE Int. Conf. on Fuzzy Systems, pp.633-640, 1992.  L. Shrimanth Sudheer, Immanuel J., P. Bhaskar and Parvathi C. S., “Arm7 Microcontroller Based Fuzzy Logic Controller for Liquid Level Control System”, International Journal of Electronics and Communication Engineering & Technology (IJECET), Volume 4, Issue 2, 2013, pp. 217 - 224, ISSN Print: 0976- 6464, ISSN Online: 0976 –6472.  Dr Amged S. El-Wakeel, Dr A.E. Elawa and Y.S. Eng. El-Koteshy, “Position Control of a Single ARM Manipulator Using Ga-Pid Controller”, International Journal of Electrical Engineering & Technology (IJEET), Volume 4, Issue 2, 2013, pp. 120 - 135, ISSN Print : 0976-6545, ISSN Online: 0976-6553.  VenkataRamesh.Edara, B.Amarendra Reddy, Srikanth Monangi and M.Vimala, “Analytical Structures for Fuzzy Pid Controllers and Applications”, International Journal of Electrical Engineering & Technology (IJEET), Volume 1, Issue 1, 2010, pp. 1 - 17, ISSN Print : 0976-6545, ISSN Online: 0976-6553. 415