Example 20 Fuzzy Control Lecture L10.2.

Slides:



Advertisements
Similar presentations
Fuzzy Logic 11/6/2001. Agenda General Definition Applications Formal Definitions Operations Rules Fuzzy Air Conditioner Controller Structure.
Advertisements

Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Agile Development & Companies
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Introduction to Fuzzy Control Lecture 10.1 Appendix E.
Memory and Files Dr. Andrew Wallace PhD BEng(hons) EurIng
Fuzzy logic Fuzzy Expert Systems Yeni Herdiyeni Departemen Ilmu Komputer.
Topic 9C – Multiple Dimension Arrays. CISC105 – Topic 9C Multiple Dimension Arrays A multiple dimension array is an array that has two or more dimensions.
Fuzzy Logic Control Systems Ken Morgan ENGR 315 December 5, 2001.
Fuzzy Expert System.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
Fuzzy Control Lecture 6.1. Fuzzy Control Fuzzy Sets Design of a Fuzzy Controller –Fuzzification of inputs: get_inputs() –Fuzzy Inference –Processing the.
CS Oct 2006 Chap 6. Functions General form; type Name ( parameters ) { … return value ; }
Fuzzy Control. Fuzzy Sets Design of a Fuzzy Controller –Fuzzification of inputs: get_inputs() –Fuzzy Inference –Processing the Rules: find_rules() –Centroid.
Fuzzy Control Chapter 14. Fuzzy Control Fuzzy Sets Design of a Fuzzy Controller –Fuzzification of inputs: get_inputs() –Fuzzy Inference –Processing the.
Fuzzy Logic Dave Saad CS498. Origin Proposed as a mathematical model similar to traditional set theory but with the possibility of partial set membership.
Introduction to Fuzzy Logic Control
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
Fuzzy Control. Fuzzy Sets Design of a Fuzzy Controller –Fuzzification of inputs: get_inputs() –Fuzzy Inference –Processing the Rules: find_rules() –Centroid.
CSC241 Object-Oriented Programming (OOP) Lecture No. 10.
C Tokens Identifiers Keywords Constants Operators Special symbols.
 Definition Definition  Bit of History Bit of History  Why Fuzzy Logic? Why Fuzzy Logic?  Applications Applications  Fuzzy Logic Operators Fuzzy.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 10 – Programming with Java Datatypes Type Casting.
C Programming Laboratory I. Introduction to C Language /* the first program for user */ #include int a=0; int main(void) { printf(“Hello World\n”); return.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
Fuzzy Systems Michael J. Watts
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
PART 9 Fuzzy Systems 1. Fuzzy controllers 2. Fuzzy systems and NNs 3. Fuzzy neural networks 4. Fuzzy Automata 5. Fuzzy dynamic systems FUZZY SETS AND FUZZY.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
Fuzzy systems. Calculate the degree of matching Fuzzy inference engine Defuzzification module Fuzzy rule base General scheme of a fuzzy system.
Homework 5 Min Max “Temperature is low” AND “Temperature is middle”
Quiz // // The function exchanges the two parameters. // Param: ( ) // Param:
Fuzzy Expert System n Introduction n Fuzzy sets n Linguistic variables and hedges n Operations of fuzzy sets n Fuzzy rules n Summary.
Data Types Storage Size Domain of all possible values Operations 1.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Class Method Read class Student { private: string id; string firstName, lastName; float gpa; public: // Will the method change any data members? // Yes!
Review (before the 1 st test): while (conditions) { statements; } while loop: if/else if/else statements: if (conditions) { statements; } else if (different.
CS 1430: Programming in C++ 1. Test 2 Friday Functions Arrays For Loops Understand Concepts and Rules Memorize Concepts and Rules Apply Concepts and Rules.
Chapter 10 FUZZY CONTROL Chi-Yuan Yeh.
Basic Concepts:- Invalid use of Address Operator &75 &(‘a’) &(a+b)
Lecture 11: Pointers B Burlingame 13 Apr Announcements Rest of semester  Homework Remaining homework can be done in pairs, turn in one paper with.
Introduction to Fuzzy Logic and Fuzzy Systems
Fuzzy Systems Michael J. Watts
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
FUZZY NEURAL NETWORKS TECHNIQUES AND THEIR APPLICATIONS
Fuzzy Control Design of Embedded Systems
Fuzzy Logic 11/6/2001.
Fuzzy Logic and Fuzzy Sets
Homework 8 Min Max “Temperature is low” AND “Temperature is middle”
Introduction to Fuzzy Logic
CS 1430: Programming in C++.
Lecture 22.
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Introduction to Robots and the Mind - Methods -
Homework 9 Min Max “Temperature is low” AND “Temperature is middle”
Slope and Rate of Change
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Fuzzy Logic Colter McClure.
CS150 Introduction to Computer Science 1
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Java for Beginners University Greenwich Computing At School DASCO
Fuzzy Logic Fuzzy Control Solution: Homework 8.
Fuzzy Logic Fuzzy Control Solution: Homework 12.
Programming Language C Language.
CS150 Introduction to Computer Science 1
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Data in a C++ Program Numeric data and character data
Presentation transcript:

Example 20 Fuzzy Control Lecture L10.2

Fuzzy Control Design of a Fuzzy Controller Fuzzification of inputs MEM and fill_weights() Processing the Rules REV and fire_rules(…) Output Defuzzification WAV and calc_output(…)

Fuzzy Rules IF A AND B THEN L * * Fuzzy Control Inputs Map to Fuzzy Sets get_inputs(); Fuzzy Rules IF A AND B THEN L * * fire_rules(); Defuzzification find_output(); Output

Plexiglas tube Ping-pong ball Problem: Maintain ping-pong ball floating at a specified height Ultrasonic transducer Muffin fan

Input membership functions for floating ping-pong ball

Output membership functions for floating ping-pong ball

Fuzzy K-map for floating ping-pong ball

Fuzzy Control Design of a Fuzzy Controller Fuzzification of inputs MEM and fill_weights() Processing the Rules REV and fire_rules(…) Output Defuzzification WAV and calc_output(…)

A membership function is defined in terms of u1, u2, u3, and u4

Data structure used by the HCS12 MEM instruction point_2 point_1

unsigned char memb_pos[20]; static int maxsize = 20; void main(void) { // input membership functions const unsigned char ball_position[] = { 0, 0, 30, 60, // neg_far 40, 60, 80,110, // neg_close 90,120,135,165, // zero_pos 150,175,185,220, // pos_close 200,220,255,255 // pos_far }; unsigned char memb_pos[20]; get_slopes(ball_position,memb_pos,maxsize);

unsigned char memb_speed[20]; const unsigned char ball_speed[] = { 0, 0, 20, 60, // neg_fast 35, 60, 80,110, // neg_slow 80,130,130,180, // zero_speed 155,175,185,215, // pos_slow 195,220,255,255 // pos_fast }; unsigned char memb_speed[20]; get_slopes(ball_speed,memb_speed,maxsize);

void get_slopes(const unsigned char ball[],unsigned char memb[], int maxsize) { int j; unsigned char diff; for(j = 0; j < maxsize; j=j+4){ memb[j] = ball[j]; // point_1 memb[j+1] = ball[j+3]; // point_2 diff = (ball[j+1] - ball[j]); if(diff == 0) memb[j+2] = 0; else memb[j+2] = 255/diff; // slope_1 diff = (ball[j+3] - ball[j+2]); memb[j+3] = 0; memb[j+3] = 255/diff; // slope_2 }

// The fuzzy controller while(1) { // x1 = get_position(); // (user defined) x1 = 100; // test case -- remove fill_weights(ptr_weight_pos,ptr_memb_pos,num_memb_pos,x1); // x2 = get_speed(); // (user defined) x2 = 150; // test case -- remove fill_weights(ptr_weight_speed,ptr_memb_speed,num_memb_speed,x2);

Fuzzy Control Design of a Fuzzy Controller Fuzzification of inputs MEM and fill_weights() Processing the Rules REV and fire_rules(…) Output Defuzzification WAV and calc_output(…)

Pseudocode for fire_rules()

The HCS12 REV Instruction if x1 is neg_far and x2 is neg_fast then y is pos_high

Fuzzy K-map inout_array[] indicies

unsigned char inout_array[] = { 0, // weight_pos[] 0 neg_far 0, // 1 neg_close 0, // 2 zero_pos 0, // 3 pos_close 0, // 4 pos_far 0, // weight_speed[] 5 neg_fast 0, // 6 neg_slow 0, // 7 zero_speed 0, // 8 pos_slow 0, // 9 pos_fast 0, // out[] 10 neg_high 0, // 11 neg_low 0, // 12 zero_motor 0, // 13 pos_low 0, // 14 pos_high };

unsigned char rules[] = { 0,5,0xFE,14,0xFE, // if x1 is neg_far && x2 is neg_fast then y is pos_high 0,6,0xFE,14,0xFE, 0,7,0xFE,14,0xFE, 0,8,0xFE,13,0xFE, 0,9,0xFE,12,0xFE, 1,5,0xFE,14,0xFE, // if x1 is neg_close && x2 is neg_fast then y is pos_high 1,6,0xFE,14,0xFE, 1,7,0xFE,13,0xFE, 1,8,0xFE,12,0xFE, 1,9,0xFE,11,0xFE, 2,5,0xFE,14,0xFE, // if x1 is zero_pos && x2 is neg_fast then y is pos_high 2,6,0xFE,13,0xFE, 2,7,0xFE,12,0xFE, 2,8,0xFE,11,0xFE, 2,9,0xFE,10,0xFE, 3,5,0xFE,13,0xFE, // if x1 is pos_close && x2 is neg_fast then y is pos_low 3,6,0xFE,12,0xFE, 3,7,0xFE,11,0xFE, 3,8,0xFE,10,0xFE, 3,9,0xFE,10,0xFE, 4,5,0xFE,12,0xFE, // if x1 is pos_far && x2 is neg_fast then y is zero_motor 4,6,0xFE,11,0xFE, 4,7,0xFE,10,0xFE, 4,8,0xFE,10,0xFE, 4,9,0xFE,10,0xFF };

unsigned char* ptr_memb_pos; unsigned char* ptr_memb_speed; unsigned char* ptr_weight_pos; unsigned char* ptr_weight_speed; unsigned char* ptr_inout_array; unsigned char* ptr_out; unsigned char* ptr_rules; unsigned char x1; // input x1 unsigned char x2; // input x2 unsigned char y; // output y ptr_memb_pos = memb_pos; ptr_memb_speed = memb_speed; ptr_weight_pos = inout_array; ptr_weight_speed = inout_array+num_memb_pos; ptr_inout_array = inout_array; ptr_out = inout_array+num_memb_pos+num_memb_speed; ptr_rules = rules;

// The fuzzy controller while(1) { // x1 = get_position(); // (user defined) x1 = 100; // test case -- remove fill_weights(ptr_weight_pos,ptr_memb_pos,num_memb_pos,x1); // x2 = get_speed(); // (user defined) x2 = 150; // test case -- remove fill_weights(ptr_weight_speed,ptr_memb_speed,num_memb_speed,x2); fire_rules(ptr_inout_array,ptr_rules,ptr_out,num_memb_motor);

Fuzzy Control Design of a Fuzzy Controller Fuzzification of inputs MEM and fill_weights() Processing the Rules REV and fire_rules(…) Output Defuzzification WAV and calc_output(…)

Pseudocode for find_output(…) HCS12 WAV instruction computes numer and denom

// output membership functions unsigned char cent[] = { 5,65,128,175,22 }; unsigned char* ptr_cent; unsigned char y; // output y ptr_cent = cent;

// The fuzzy controller while(1) { // x1 = get_position(); // (user defined) x1 = 100; // test case -- remove fill_weights(ptr_weight_pos,ptr_memb_pos,num_memb_pos,x1); // x2 = get_speed(); // (user defined) x2 = 150; // test case -- remove fill_weights(ptr_weight_speed,ptr_memb_speed,num_memb_speed,x2); fire_rules(ptr_inout_array,ptr_rules,ptr_out,num_memb_motor); y = calc_output(ptr_out,ptr_cent,num_memb_motor); // adjust_motor(y): // (user defined) }