Fuzzy Logic Exercise: Fan Speed Control
Interactive fuzzy logic exercise demonstrating fan speed control based on temperature and humidity. This system uses min-max operators for rule evaluation and centroid method for defuzzification.
Exercise Problem
Task: Design a fuzzy system to control fan speed based on temperature and humidity.
Example Rules:
- IF temperature is High OR humidity is High THEN fan speed is Fast
- IF temperature is Medium AND humidity is Medium THEN fan speed is Medium
- IF temperature is Low AND humidity is Low THEN fan speed is Slow
Worked Example (Solution Guide)
Example Inputs: Suppose the crisp inputs are: Temperature = 30°C and Humidity = 70%. During fuzzification, these inputs are mapped to degrees of membership, for example: µ(Temp=Medium)=0.4, µ(Temp=High)=0.6, µ(Humid=Medium)=0.3, µ(Humid=High)=0.7.
Rule Evaluation: The fuzzy rules are then evaluated using min–max operators:
- Rule 1 (OR): degree = max(0.6, 0.7) = 0.7
- Rule 2 (AND): degree = min(0.4, 0.3) = 0.3
- Rule 3 (AND): degree = min(0.0, 0.0) = 0.0
Output: These truth values are applied to the output membership functions (Fast, Medium, Slow), and then aggregated. Finally, during defuzzification using the centroid method, the crisp output might result in a value corresponding to around 80% fan speed, meaning the system decides to run the fan fairly fast.
Note: Use the interactive controls below to explore how different temperature and humidity values affect the fuzzy inference process. Set the inputs to 30°C and 70% to see this example in action.
Input Variables
Adjust the sliders to change the temperature and humidity values and observe how they affect the fuzzy inference process.
Step 1: Fuzzification
Convert crisp inputs (temperature and humidity) into fuzzy membership values.
Temperature Membership Functions
μ(Temp=Low) = 0.00
μ(Temp=Medium) = 0.67
μ(Temp=High) = 0.33
Humidity Membership Functions
μ(Humid=Low) = 0.00
μ(Humid=Medium) = 1.00
μ(Humid=High) = 0.60
Step 2: Rule Evaluation
Evaluate fuzzy rules using min (AND) and max (OR) operators to determine rule firing strengths.
Rule 1: IF Temp=High OR Humid=High THEN Fan=Fast
Calculation: max(μ(Temp=High), μ(Humid=High)) = max(0.33, 0.60) = 0.60
Firing Strength: 0.60
Rule 2: IF Temp=Medium AND Humid=Medium THEN Fan=Medium
Calculation: min(μ(Temp=Medium), μ(Humid=Medium)) = min(0.67, 1.00) = 0.67
Firing Strength: 0.67
Rule 3: IF Temp=Low AND Humid=Low THEN Fan=Slow
Calculation: min(μ(Temp=Low), μ(Humid=Low)) = min(0.00, 0.00) = 0.00
Firing Strength: 0.00
Step 3: Aggregation
Apply firing strengths to output membership functions (clipping) and aggregate using MAX operation.
Step 4: Defuzzification (Centroid Method)
Convert the aggregated fuzzy output into a crisp value using the centroid (center of gravity) method.
Final Crisp Output:
Recommended Fan Speed = 64.6%
Calculation Breakdown:
Numerator = Σ(speed × μ(speed))
= 31 × 0.05 + 32 × 0.10 + 33 × 0.15
= 1.55 + 3.20 + 4.95 + ...
= 2151.08
Denominator = Σ(μ(speed))
= 0.05 + 0.10 + 0.15 + ...
= 33.32
Output = 2151.08 / 33.32 = 64.56%
Summary
- Fuzzification: Temperature 30°C → μ(Temp=Low)=0.00, μ(Temp=Medium)=0.67, μ(Temp=High)=0.33
- Fuzzification: Humidity 70% → μ(Humid=Low)=0.00, μ(Humid=Medium)=1.00, μ(Humid=High)=0.60
- Rule Evaluation: Rule 1 (OR) = 0.60, Rule 2 (AND) = 0.67, Rule 3 (AND) = 0.00
- Aggregation: Combined output using MAX operation
- Defuzzification: Centroid method → Fan Speed = 64.6%