Intelligent Control Systems with LabVIEW
Pedro Ponce-Cruz Fernando D. Ramírez-Figueroa Intelligent Control Systems with LabVIEW 123
Pedro Ponce-Cruz, Dr.-Ing. Fernando D. Ramírez-Figueroa, Research Assistant to Doctor Ponce Instituto Tecnológico de Estudios Superiores de Monterrey Campus Ciudad de México Calle del Puente 222 Col. Ejidos de Huipulco Tlalpan 14380, México, D.F. México pedro.ponce@itesm.mx ISBN 978-1-84882-683-0 e-isbn 978-1-84882-684-7 DOI 10.1007/978-1-84882-684-7 Springer London Dordrecht Heidelberg New York British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: 2009933628 Springer-Verlag London Limited 2010 BASIC Stamp is a federally registered trademark of Parallax Inc. Parallax and Ping))) are trademarks of Parallax Inc., http://www.parallax.com Bluetooth word mark is owned by the Bluetooth SIG, Inc. http://www.bluetooth.com EmbeddedBlue is a trademark of A7 Engineering, Inc. http://www.a7eng.com NI refers to National Instruments and all of its subsidiaries, business units, and divisions worldwide. LabVIEW is a trademark of National Instruments. This book is an independent publication. National Instruments is not affiliated with the publisher or the author, and does not authorize, sponsor, endorse or approve this book. National Instruments Corporation, 11500 N Mopac Expwy, Austin, TX 78759-3504, U.S.A. http://www.ni.com Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licenses issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. The use of registered names, trademarks, etc., in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. The publisher and the authors accept no legal responsibility for any damage caused by improper use of the instructions and programs contained in this book and the DVD. Although the software has been tested with extreme care, errors in the software cannot be excluded. Cover design: estudio Calamar, Figueres/Berlin Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com)
This book is dedicated to my mother and son with love. Pedro Ponce To my parents Virginia and Fernando because this would not be possible without their unconditional love and support, and to my advisor and friend, Pedro for giving me the opportunity to prove myself, and to all those who have accompanied me along this wonderful journey of knowledge and creation. David Ramirez
Preface Control systems are becoming more important every day. At the beginning, the industry used sequential controls for solving a lot of industrial applications in control systems, and then the linear systems gave us a huge increase in applying automatic linear control on industrial application. One of the most recent methods for controlling industrial applications is intelligent control, which is based on human behavior or concerning natural process. Nowadays, the topic of intelligent control systems has become more than a research subject to the industry. The number of industrial applications is growing every day, faster and faster. Thus, new software and hardware platforms are required in order to design and develop intelligent control systems. The challenge for these types of systems is to have a novel platform, which allows designing, testing and implementing an intelligent controller system in a short period of time. For the industry and academy, LabVIEW is one of the most important software platforms for developing engineering applications and could be connected with different hardware systems, as well as running standalone programs for simulating the controller s performance (validating the controller by simulation then implementing it). In addition, LabVIEW is a graphical program that is very easy to learn. Taking into account these advantages, the software platform described in this book is LabVIEW from National Instruments. The book is divided into 7 chapters and gives all the information required for designing and implementing an intelligent controller. Chapter 1 provides an introduction to basic intelligent control concepts and concludes by applying LabVIEW for implementing control systems. Chapter 2 covers in deep detail the fuzzy logic theory and implementation. This chapter starts with fundamental fuzzy logic theory for supporting the most important fuzzy logic controllers implemented using LabVIEW. Chapter 3 deals with artificial neural networks. In this chapter a complete set of tools for implementing artificial neural networks is presented. Basic examples of neural networks, such as perceptron, allow the students to understand the most important topologies in artificial neural networks for modeling and controlling systems. In Chap. 4 the reader can find neuro-fuzzy controllers, which combine the vii
viii Preface fuzzy inference systems with an artificial neural network topology. Thus, the neurofuzzy controllers are an interesting option for modeling and controlling industrial applications. Chapter 5 discusses genetic algorithms, which are representations of the natural selection process. This chapter also examines how generic algorithms can be used as optimization methods. Genetic programming is also explained in detail. Chapters 6 and 7 show different algorithms for optimizing and predicting that could be combined with the conventional intelligent system methodologies presented in the previous chapters such as fuzzy logic, artificial neural networks and neuro-fuzzy systems. The methods presented in Chaps. 6 and 7 are: simulated annealing, fuzzy clustering means, partition coefficients, tabu search and predictors. Supplemental materials supporting the book are available in the companion DVD. The DVD includes all the LabVIEW programs (VIs) presented inside the book for intelligent control systems. This book would never have been possible without the help of remarkable people who believed in this project. I am not able to acknowledge all of them here, but I would like to thank Eloisa Acha, Gustavo Valdes, Jeannie Falcon, Javier Gutierrez and others at National Instruments for helping us to develop a better book. Finally, I would like to thank the Instituto Tecnológico de Monterrey campus Ciudad de México for supporting this research project. I wish to remember all my friends and colleagues who gave me support during this research journey. ITESM-CCM México City Dr. Pedro Ponce-Cruz
Contents 1 Intelligent Control for LabVIEW... 1 1.1 Introduction..... 1 1.2 Intelligent Control in Industrial Applications....... 3 1.3 LabVIEW... 4 References... 7 2 Fuzzy Logic... 9 2.1 Introduction..... 9 2.2 Industrial Applications..... 9 2.3 Background..... 10 2.3.1 UncertaintyinInformation... 11 2.3.2 ConceptofFuzziness... 11 2.4 Foundations of Fuzzy Set Theory...... 11 2.4.1 FuzzySets... 12 2.4.2 BooleanOperationsandTerms... 14 2.4.3 FuzzyOperationsandTerms... 15 2.4.4 PropertiesofFuzzySets... 18 2.4.5 Fuzzification... 18 2.4.6 ExtensionPrinciple... 21 2.4.7 AlphaCuts... 23 2.4.8 TheResolutionPrinciple... 24 2.4.9 FuzzinessofUncertainty... 24 2.4.10 Possibility and Probability Theories.... 25 2.5 FuzzyLogicTheory... 26 2.5.1 FromClassicaltoFuzzyLogic... 26 2.5.2 FuzzyLogicandApproximateReasoning... 26 2.5.3 FuzzyRelations... 28 2.5.4 PropertiesofRelations... 28 2.5.5 Max Min Composition... 29 2.5.6 Max Star Composition... 30 2.5.7 Max Average Composition..... 31 ix
x Contents 2.6 Fuzzy Linguistic Descriptions... 31 2.7 TheFuzzyLogicController... 33 2.7.1 Linguistic Variables..... 33 2.7.2 MembershipFunctions... 33 2.7.3 RulesEvaluation... 33 2.7.4 MamdaniFuzzyController... 34 2.7.5 Structure... 34 2.7.6 Fuzzification... 34 2.7.7 RulesEvaluation... 35 2.7.8 Defuzzification... 35 2.7.9 TsukamotoFuzzyController... 35 2.7.10 Takagi SugenoFuzzyController... 36 2.7.11 Structure... 36 2.7.12 Fuzzification... 36 2.7.13 RulesEvaluation... 36 2.7.14 CrispOutputs... 37 2.8 Implementation of the Fuzzy Logic Controllers Using the Intelligent Control Toolkit for LabVIEW..... 37 2.8.1 Fuzzification... 38 2.8.2 RulesEvaluation... 40 2.8.3 Defuzzification:CrispOutputs... 41 2.9 ClassicalControlExample... 43 References... 46 FutherReading... 46 3 Artificial Neural Networks... 47 3.1 Introduction... 47 3.2 ArtificialNeuralNetworkClassification... 55 3.3 ArtificialNeuralNetworks... 56 3.3.1 Perceptron... 57 3.3.2 Multi-layer Neural Network... 60 3.3.3 Trigonometric Neural Networks..... 71 3.3.4 Kohonen Maps.... 79 3.3.5 BayesianorBeliefNetworks... 84 References... 87 FutherReading... 88 4 Neuro-fuzzy Controller Theory and Application... 89 4.1 Introduction... 89 4.2 TheNeuro-fuzzyController... 90 4.2.1 Trigonometric Artificial Neural Networks....... 91 4.2.2 FuzzyClusterMeans... 96 4.2.3 PredictiveMethod... 98 4.2.4 ResultsUsingtheController...100 4.2.5 ControllerEnhancements...101
Contents xi 4.3 ANFIS:AdaptiveNeuro-fuzzyInferenceSystems...106 4.3.1 ANFIS Topology...108 References...122 FutherReading...122 5 Genetic Algorithms and Genetic Programming...123 5.1 Introduction.....123 5.1.1 EvolutionaryComputation...123 5.2 Industrial Applications.....124 5.3 BiologicalTerminology...125 5.3.1 Search Spaces and Fitness......125 5.3.2 EncodingandDecoding...125 5.4 GeneticAlgorithmStages...126 5.4.1 Initialization...127 5.4.2 Selection...128 5.4.3 Crossover...129 5.4.4 Mutation...130 5.5 Genetic Algorithms and Traditional Search Methods.....134 5.6 ApplicationsofGeneticAlgorithms...135 5.7 ProsandConsofGeneticAlgorithms...136 5.8 Selecting Genetic Algorithm Methods...136 5.9 MessyGeneticAlgorithm...137 5.10 OptimizationofFuzzySystemsUsingGeneticAlgorithms...138 5.10.1 Coding Whole Fuzzy Partitions...... 138 5.10.2 StandardFitnessFunctions...139 5.10.3 CodingRuleBases...139 5.11 An Application of the ICTL for the Optimization of a Navigation System for Mobile Robots...140 5.12 Genetic Programming Background.....143 5.12.1 Genetic Programming Definition..... 143 5.12.2 Historical Background....144 5.13 Industrial Applications.....144 5.14 AdvantagesofEvolutionaryAlgorithms...144 5.15 GeneticProgrammingAlgorithm...145 5.15.1 Length...146 5.16 GeneticProgrammingStages...146 5.16.1 Initialization...146 5.16.2 Fitness...147 5.16.3 Selection...147 5.16.4 Crossover...147 5.16.5 Mutation...148 5.17 VariationsofGeneticProgramming...149 5.18 GeneticProgramminginDataModeling...150 5.19 GeneticProgrammingUsingtheICTL...150
xii Contents References...153 FutherReading...154 6 Simulated Annealing, FCM, Partition Coefficients and Tabu Search. 155 6.1 Introduction...155 6.1.1 Introduction to Simulated Annealing......156 6.1.2 Pattern Recognition..... 157 6.1.3 Introduction to Tabu Search...157 6.1.4 Industrial Applications of Simulated Annealing.......158 6.1.5 Industrial Applications of Fuzzy Clustering.....158 6.1.6 Industrial Applications of Tabu Search....158 6.2 SimulatedAnnealing...159 6.2.1 SimulatedAnnealingAlgorithm...161 6.2.2 SampleIterationExample...163 6.2.3 Example of Simulated Annealing Using the Intelligent Control Toolkit for LabVIEW...163 6.3 FuzzyClusteringMeans...166 6.4 FCMExample...170 6.5 Partition Coefficients...... 172 6.6 Reactive Tabu Search.....173 6.6.1 Introduction to Reactive Tabu Search......173 6.6.2 Memory...174 References...189 FutherReading...190 7 Predictors...191 7.1 Introduction to Forecasting.....191 7.2 Industrial Applications....192 7.3 Forecasting Methods......193 7.3.1 Qualitative Methods.....193 7.3.2 Quantitative Methods...194 7.4 RegressionAnalysis...194 7.5 Exponential Smoothing...194 7.5.1 Simple-exponential Smoothing......195 7.5.2 Simple-exponential Smoothing Algorithm......195 7.5.3 Double-exponential Smoothing.....196 7.5.4 Holt WinterMethod...197 7.5.5 Non-seasonal Box Jenkins Models...198 7.5.6 General Box Jenkins Model....199 7.6 MinimumVarianceEstimationandControl...200 7.7 Example of Predictors Using the Intelligent Control Toolkit forlabview(ictl)...202 7.7.1 Exponential Smoothing...202 7.7.2 Box Jenkins Method....203 7.7.3 MinimumVariance...204
Contents xiii 7.8 GrayModelingandPrediction...205 7.8.1 ModelingProcedureoftheGraySystem...206 7.9 ExampleofaGrayPredictorUsingtheICTL...207 References...210 FutherReading...210 Index...211