Design GAFuzzy Controller for Magnetic Levitation Using FPGA

  • Slides: 68
Download presentation
Design GA-Fuzzy Controller for Magnetic Levitation Using FPGA Prepared by Hosam. M Abu Elreesh

Design GA-Fuzzy Controller for Magnetic Levitation Using FPGA Prepared by Hosam. M Abu Elreesh Advisor Dr. Basil Hamed 1

Contents • • Introduction Fuzzy Logic Genetic Algorithm (GA) FPGA and Xfuzzy CAD Tool

Contents • • Introduction Fuzzy Logic Genetic Algorithm (GA) FPGA and Xfuzzy CAD Tool Application and Results Conclusion Future Works 2

Introduction • Control systems have been in use for decades. • Power systems, computer

Introduction • Control systems have been in use for decades. • Power systems, computer control, space technology, robotics, weapon systems and many others. • Types of Control Systems: 1 - Conventional Control Techniques. 2 - Intelligent Control Techniques. 3

Introduction • Conventional Control Techniques: 1 - Classical Control (PID). 2 - Modern Control

Introduction • Conventional Control Techniques: 1 - Classical Control (PID). 2 - Modern Control (deadbeat, sliding mode). 3 - Optimal Control (LQR, H 2 and H∞). • Intelligent Control Techniques: 1 - Knowledge-base-expert systems (fuzzy logic). 2 - Neural networks. 4

Introduction • Fuzzy Logic hardware Implementation: 1 - General-purpose fuzzy processor (µP, µC, digital

Introduction • Fuzzy Logic hardware Implementation: 1 - General-purpose fuzzy processor (µP, µC, digital signal processor (DSP)). 2 -Dedicated fuzzy hardware 3 - FPGA 5

Introduction • Thesis Contribution 1 - This thesis present the design of fuzzy controller

Introduction • Thesis Contribution 1 - This thesis present the design of fuzzy controller of the Magnetic Levitation Model CE 152. 2 - Matlab program for applying the GA to optimize the memberships of the fuzzy controller. 3 - Design the hardware of fuzzy controller using Xilinx Spartan 3 e FPGA. 6

Fuzzy Control Classical Sets Fuzzy Sets 7

Fuzzy Control Classical Sets Fuzzy Sets 7

Fuzzy Control Fuzzy History: • Fuzzy logic idea was born in July 1964. Lotfi

Fuzzy Control Fuzzy History: • Fuzzy logic idea was born in July 1964. Lotfi A. Zadeh father of fuzzy. • 1965 was the birth of fuzzy logic techniques. • 1979 was the first application of the fuzzy logic in industrial world cement kiln controller. • In 1985 Japanese starts to make the first general-purpose fuzzy logic controller. • Japanese start to use it in control systems, and they designed the first automatic subway train controller in 1987. 8

Fuzzy Control Why Use Fuzzy Logic? • Fuzzy logic is used to control the

Fuzzy Control Why Use Fuzzy Logic? • Fuzzy logic is used to control the complex, and nonlinear systems without make analyzing for these systems. • Fuzzy control enables the engineers to implement the control technique by human operators • Fuzzy logic is flexible with any given systems. • Fuzzy logic can be blended with conventional technique, to simplify their implementation. 9

Fuzzy Control Operations of Fuzzy Sets : x AND OR NOT 10

Fuzzy Control Operations of Fuzzy Sets : x AND OR NOT 10

Fuzzy Control Operations of Fuzzy Sets : If there are two fuzzy sets A

Fuzzy Control Operations of Fuzzy Sets : If there are two fuzzy sets A and B, and there is element (x) can be set A and has degree (0. 5), element (x) can be in set B and has degree (0. 7), 11

Fuzzy Control Fuzzy Concepts: • Membership Function. • Linguistic Variables. • IF – THEN

Fuzzy Control Fuzzy Concepts: • Membership Function. • Linguistic Variables. • IF – THEN Rules 12

Fuzzy Control Membership Function: 13

Fuzzy Control Membership Function: 13

Fuzzy Control Linguistic Variables: • Age (old, young, very old). • Tall (tall, short,

Fuzzy Control Linguistic Variables: • Age (old, young, very old). • Tall (tall, short, very tall). • Error( P big, P small, zero, N big, N small) 14

Fuzzy Control IF – THEN Rules • IF (input 1 is MFa) AND (input

Fuzzy Control IF – THEN Rules • IF (input 1 is MFa) AND (input 2 is MFb) ) THEN (output is MFc) • IF (Food is bad) and (Serves is bad ) THEN (Tip is cheap) Antecedent consequent 15

Fuzzy Control Fuzzy Logic Control (FLC) • Mamdani model. • Takagi- Sugeno-Kang (TSK) model.

Fuzzy Control Fuzzy Logic Control (FLC) • Mamdani model. • Takagi- Sugeno-Kang (TSK) model. • Kosko's additive model (SAM). 16

Fuzzy Control Mamdani Model: 17

Fuzzy Control Mamdani Model: 17

Fuzzy Control Mamdani Model: • Fuzzification. • Fuzzy Associative Memory (FAM) 1 - Knowledge

Fuzzy Control Mamdani Model: • Fuzzification. • Fuzzy Associative Memory (FAM) 1 - Knowledge base. (Membership Functions, IF-THEN rules) 2 - Decision-Making. • Defuzzification Ø Mean of Maximum method (MOM). Ø Center of Area (COA). Ø Center of Maximum (Co. M): 18

Fuzzy Control Mamdani Model: 19

Fuzzy Control Mamdani Model: 19

Genetic Algorithm GA • Genetic Algorithms are reliable and robust methods for searching solution

Genetic Algorithm GA • Genetic Algorithms are reliable and robust methods for searching solution spaces. GA must address five issues. 1 - A genetic representation 2 - Initial population 3 - Fitness Function 4 - Genetic operators 5 - Values for the parameters of the GA, such as population size, 20

Genetic Algorithm 21

Genetic Algorithm 21

Genetic Algorithm GA differs from conventional optimization techniques in following ways: • • GA

Genetic Algorithm GA differs from conventional optimization techniques in following ways: • • GA does not deals with data directly but works with encoded data. GA uses least information such as fitness function to solve problems an does not need derivation. • GA uses probability laws rather than certain laws. • GA generate populations of answer not just one answer. • Almost all conventional optimization techniques search from a single point but GA always operate on a whole population of points (parallelism). 22

Genetic Algorithm GA Elements: 1 - Individuals 2 - Population 23

Genetic Algorithm GA Elements: 1 - Individuals 2 - Population 23

Genetic Algorithm Chromosome coding 24

Genetic Algorithm Chromosome coding 24

Genetic Algorithm Fitness Function 25

Genetic Algorithm Fitness Function 25

Genetic Algorithm GA Operations: 1 - Selection (Roulette Wheel Selection). Roulette Wheel Selection 26

Genetic Algorithm GA Operations: 1 - Selection (Roulette Wheel Selection). Roulette Wheel Selection 26

Genetic Algorithm GA Operations: 1 - Selection (Stochastic Universal Selection). Stochastic Universal Sampling 27

Genetic Algorithm GA Operations: 1 - Selection (Stochastic Universal Selection). Stochastic Universal Sampling 27

Genetic Algorithm GA Operations: 2 - Crossover (Single-Point Crossover) Single-Point Crossover 28

Genetic Algorithm GA Operations: 2 - Crossover (Single-Point Crossover) Single-Point Crossover 28

Genetic Algorithm GA Operations: 2 - Crossover ( Two-Point Crossover) Two-Point Crossover 29

Genetic Algorithm GA Operations: 2 - Crossover ( Two-Point Crossover) Two-Point Crossover 29

Genetic Algorithm GA Operations: 3 - Mutation means swap one bit in binary coding

Genetic Algorithm GA Operations: 3 - Mutation means swap one bit in binary coding or changes one number if the chromosome consist of numbers 4 - Elitism 30

A simple example will help us to understand how a GA works. Let us

A simple example will help us to understand how a GA works. Let us find the maximum value of the function (15 x x 2) where parameter x varies between 0 and 15. For simplicity, we may assume that x takes only integer values. Thus, chromosomes can be built with only four genes: 31

Suppose that the size of the chromosome population N is 6, the crossover probability

Suppose that the size of the chromosome population N is 6, the crossover probability pc equals 0. 7, and the mutation probability pm equals 0. 001. The fitness function in our example is defined by f(x) = 15 x x 2 32

33

33

Genetic Algorithm Genetic Fuzzy Systems: 34

Genetic Algorithm Genetic Fuzzy Systems: 34

Genetic Algorithm Genetic Fuzzy Systems: 1 - Genetic Tuning of The Data Base Tuning

Genetic Algorithm Genetic Fuzzy Systems: 1 - Genetic Tuning of The Data Base Tuning scaling gains Tuning fuzzy membership functions. 2 - Genetic Learning of The Rule Base 35

FPGA and Xfuzzy CAD Tool FPGA: FPGA is digital integrated circuits (ICs) that have

FPGA and Xfuzzy CAD Tool FPGA: FPGA is digital integrated circuits (ICs) that have electronics blocks which can be programmed, and these blocks has configurable interconnection between them. 36

FPGA and Xfuzzy CAD Tool 37

FPGA and Xfuzzy CAD Tool 37

FPGA and Xfuzzy CAD Tool 38

FPGA and Xfuzzy CAD Tool 38

FPGA and Xfuzzy CAD Tool 39

FPGA and Xfuzzy CAD Tool 39

FPGA and Xfuzzy CAD Tool The Spartan-3 E Development System 40

FPGA and Xfuzzy CAD Tool The Spartan-3 E Development System 40

FPGA and Xfuzzy CAD Tool: 41

FPGA and Xfuzzy CAD Tool: 41

FPGA and Xfuzzy CAD Tool: 1 - Description Stage 42

FPGA and Xfuzzy CAD Tool: 1 - Description Stage 42

FPGA and Xfuzzy CAD Tool: 2 - Tuning Stage 43

FPGA and Xfuzzy CAD Tool: 2 - Tuning Stage 43

FPGA and Xfuzzy CAD Tool: 3 - Vervication Stage 44

FPGA and Xfuzzy CAD Tool: 3 - Vervication Stage 44

FPGA and Xfuzzy CAD Tool: 4 - Synthesis Stage 1 - Generat VHDLcode. 2

FPGA and Xfuzzy CAD Tool: 4 - Synthesis Stage 1 - Generat VHDLcode. 2 - C code. 3 - sysgen code. 45

Application and Results Magnetic Levitation CE 152 Model 46

Application and Results Magnetic Levitation CE 152 Model 46

Application and Results Magnetic Levitation CE 152 Model 47

Application and Results Magnetic Levitation CE 152 Model 47

Application and Results Magnetic Levitation CE 152 Model open loop poles of the system:

Application and Results Magnetic Levitation CE 152 Model open loop poles of the system: -53492: (Stable pole), -63: (Stable pole), 61: (Unstable pole) 48

Application and Results 1 - Fuzzy controller • All universes of discourses are normalized

Application and Results 1 - Fuzzy controller • All universes of discourses are normalized to lie between – 1 and 1 with scaling • assumed that the first and last membership functions have their apexes at – 1 and 1 respectively. • Triangular, Z and S membership functions are to be used. • The number of fuzzy sets is constrained to be an odd integer greater than unity. • The base vertices of membership functions are coincident with the apex of the adjacent membership functions 49

Application and Results 1 - Fuzzy controller 50

Application and Results 1 - Fuzzy controller 50

Application and Results 1 - Fuzzy controller e ln mn sn z sp mp

Application and Results 1 - Fuzzy controller e ln mn sn z sp mp lp ln ln ln mn sn z mn ln ln ln mn sn z sp sn ln ln mn sn z sp mp z ln mn sn z sp mp lp sp mn sn z sp mp lp lp mp sn z sp mp lp lp ce 51

Application and Results 1 - Fuzzy controller 52

Application and Results 1 - Fuzzy controller 52

Application and Results 1 - Fuzzy controller Fuzzy Subsystem PI Subsystem 53

Application and Results 1 - Fuzzy controller Fuzzy Subsystem PI Subsystem 53

Application and Results 1 - Fuzzy controller 54

Application and Results 1 - Fuzzy controller 54

Application and Results 1 - Fuzzy controller Ts is nearly 0. 15 sec Tr

Application and Results 1 - Fuzzy controller Ts is nearly 0. 15 sec Tr is nearly 0. 106 sec Set Point Time 55

Application and Results 2 - Fuzzy Controller Design with GA some simplification is used

Application and Results 2 - Fuzzy Controller Design with GA some simplification is used in writing GA code: 1 - The interval of the inputs and output will still at [-1 1] range. 2 - The symmetric point will still at zero. 3 - The inputs and output will have the same shape. The number of individuals per one population will be 50. the number of generation will be 100. the crossover probability will be 0. 7 56

Application and Results 2 - Fuzzy Controller Design with GA 57

Application and Results 2 - Fuzzy Controller Design with GA 57

Application and Results 2 - Fuzzy Controller Design with GA overshot is nearly 6%,

Application and Results 2 - Fuzzy Controller Design with GA overshot is nearly 6%, Ts is 0. 046 sec Tr is 0. 023 sec. Set Point Time Set Point 58 Time

Application and Results 3 - VHDL Fuzzy Controller Implementation PIC 16 f 877 as

Application and Results 3 - VHDL Fuzzy Controller Implementation PIC 16 f 877 as ADC DAC 0800. 59

Application and Results 3 - VHDL Fuzzy Controller Implementation 60

Application and Results 3 - VHDL Fuzzy Controller Implementation 60

Application and Results 3 - VHDL Fuzzy Controller Implementation 61

Application and Results 3 - VHDL Fuzzy Controller Implementation 61

Application and Results 3 - VHDL Fuzzy Controller Implementation Error Change of error Time

Application and Results 3 - VHDL Fuzzy Controller Implementation Error Change of error Time 62

Application and Results 3 - VHDL Fuzzy Controller Implementation Set Point Time 63

Application and Results 3 - VHDL Fuzzy Controller Implementation Set Point Time 63

Application and Results 3 - VHDL Fuzzy Controller Implementation 64

Application and Results 3 - VHDL Fuzzy Controller Implementation 64

Application and Results 3 - VHDL Fuzzy Controller Implementation 65

Application and Results 3 - VHDL Fuzzy Controller Implementation 65

Application and Results 3 - VHDL Fuzzy Controller Implementation 66

Application and Results 3 - VHDL Fuzzy Controller Implementation 66

CONCLUSION • Fuzzy logic and fuzzy controller. • GA • FPGA • Xfuzzy CAD

CONCLUSION • Fuzzy logic and fuzzy controller. • GA • FPGA • Xfuzzy CAD tool. • The Magnetic Levitation CE 152. • Fuzzy controller with and without GA are tested. • Implementation of fuzzy controller using FPGA. 67

Thank You 68

Thank You 68