Download presentation
Presentation is loading. Please wait.
Published byArielle Armfield Modified over 9 years ago
1
Fuzzy Logic Control
2
Feedback Control System Plant, u, y Controller, e, u Reference input, r Sensor
3
Classical Controller Design Given mathematical model of plant (i.e. transfer function) Given objectives of Feedback Control System Use standard design techniques to determine controller to meet objectives (root locus, ITAE, Bode, etc.)
4
Fuzzy Logic Controllers Use Experienced operators Construct IF-THEN rules that describe how the operator uses his knowledge of the objectives and the measured outputs to determine inputs to the plant Convert the IF-THEN rules into mathematics (i.e. convert human knowledge into computer knowledge)
5
Elements of FL Controller Fuzzifier –Takes measurement data (crisp numbers) produces fuzzy sets (singleton fuzzifier, membership functions) Rule Base or Knowledge Base –IF-THEN rules from expert operator Inference engine –Choice of AND, OR, NOT. Determines how to interpret (implement) IF-THEN statements De-fuzzifier –Produces single crisp output to be sent to plant
6
IF-THEN rules and Math IF antecedent THEN conclusion –Logical IF-THEN statement IF condition THEN action –Programming IF-THEN statement Programming IF-THEN in FL –To the extent that the condition is true, implement the action (part of inference engine) Collection of rules = Rule Base = Knowledge Base Multiple rules are joined by inference engine and de-fuzzifier
7
FL implementation of functions Any mathematical function can be interpreted as IF- THEN statements Crisp logic interpretation of y = x 2 –IF x = 1 THEN y = 1 –IF x = 2 THEN y = 4 –Etc –One rule active at a time FL interpretation of y = x 2 –IF x is close to 1 THEN y is close to 1 –IF x is close to 2 THEN y is close to 4 –Etc –Many rules active at once. How to blend all active rules?
8
FL implementation of functions FL interpretation of y = x 2 –IF x is close to 1 THEN y is close to 1 –IF x is close to 2 THEN y is close to 4 –Many rules active at once. How to blend all active rules? Consider a number between x=1 and x=2. The extent to which a number, x, is close to 1 is The extent to which a number, x, is close to 2 is The actions of the two rules needs to be blended together to get the value of the function for numbers other than 1 and 2
9
Single Antecedent Formula Consider N fuzzy rules –IF x is in A 1 THEN y is y 1 more similar rules –IF x is in A N THEN y is y n The extent to which x is in A k is measured by the k th membership function The rules are blended together by
10
Examples/Assignments FL version of y = x 2, y = 3x/(x+1) FL version of y = sin(x), y = cos(x), y = tan(x) FL version of (you pick a function) FL version of {(x,y)} experimental data (thermocouple data) Proportional controller with saturation Choices –Membership functions
11
Compound Antecedents Choose implementation of AND –Min or * or etc IF x 1 is A 1,k AND x 2 is A 2,k THEN y is y k Two input linguistic variables Each LV has its term set
12
Compound Antecedent formula Interpret x as a vector with components
13
Examples/Assignments Heat index formula Chill factor index formula PI controller PD controller PID controller You choose a function
14
More complex consequents Constant consequents Linear consequents Quadratic consequents Generic function consequents
15
Re-Discussion of FL controller components Fuzzy logic controllers convert an expert’s collection of IF-THEN rules into a mathematical function that operates similar to the expert Fuzzifier Rule Base Inference Engine Defuzzifier
16
Coding Rules in an Array Each row in array is a rule First N columns –N LV input variables –Entries determine term in term set of LV, hence membership function Last few columns –Determine consequent Programming in Sysquake/Matlab –Persistent variables
17
Examples/Assignments Code the FL functions using arrays –Array –Super Membership function for each LV Membership function for each term –Function Sum Prod Random assignment of functions to students
18
Sysquake Code function y = muz(x,left,right) i=find(x<left);y=ones(size(i)); x = x(length(i)+1:length(x)); i=find(x<right);y =[y (right-x(i))/(right-left)]; x = x(length(i)+1:length(x)); y = [y zeros(size(x))]; return;
19
function y = mus(x,left,right) i=find(x<left);y=zeros(size(i)); x = x(length(i)+1:length(x)); i=find(x<right);y =[y (x(i)-left)/(right-left)]; x = x(length(i)+1:length(x)); y = [y ones(size(x))]; Return;
20
function y = mutri(x,left,center,right) i=find(x<left);y=zeros(size(i)); x = x(length(i)+1:length(x)); i=find(x<center); y =[y (x(i)-left)/(center-left)]; x = x(length(i)+1:length(x)); i=find(x<right); y =[y (right-x(i))/(right-center)]; x=x(length(i)+1:length(x)); y = [y zeros(size(x))]; Return;
21
function y = mu(LV,T,x) // change LV to name of LV temp = 1; humidity= 2; //For each LV, something like: If (LV == temp) N = 1; Z = 2; P = 3 //term set with 3 terms left1 = -1; right1 = 0; // term N left2 = -1 ; center2 = 0; right2 = 1; //term Z left3 = 0; right3 = 1; //term P if (T==N) y = muz(x,left1,right1);//muN if (T==Z) y = mutri(x,left2,center2,right2);//muZ if (T==P) y = mus(x,left3,right3);//muP end //For 2 nd LV (similar to first) if (LV==humidity) end return;
22
Rules as Arrays function y = fuzzyfn(x) N1 = 1; Z1 = 2; P1 = 3; // term set for LV 1 N2 = 1; Z2 = 2; P2 = 3; // term set for LV 2 nLV = 2; // number of linguistic variables A = [N1 N2 10// rule 1 N1 Z2 6// rule 2 N1 P23];// rule 3 // more rules num = 0; den = 0 for i = 1:length(A(:,1));mu = 1; for LV = 1:nLV;mu=mu*mu(LV,A(i,LV),x(LV)); end num = num+mu*A(i,nLV+1); sum = sum+mu; //sum =1? end y = num/sum; // not needed if sum =1 return
23
Assignment Add rules Modify to accommodate linear consequents
24
P Controller u = K P e Rules like –If e = e k then u = u k
25
D controller u =K D (d/dt)e Rules like –If du = du k Then u = u k
26
I Controller If I = I k then u = u k or If e = e k then u = u+u k (or du=du k )
27
PID Controller
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.