Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Fuzzy logic controllers

Fuzzy logic controllers (FLCs) use fuzzy sets and rule-based inference to convert imprecise sensor inputs into smooth control actions — useful in embedded, robotics, and process control when models are uncertain or nonlinear.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Fuzzy logic controllers (FLCs) let an engineer convert human rules (if–then) into automatic control when precise mathematical models are hard to get. They are used in consumer appliances, automotive systems, robotics and industrial process control where inputs are noisy, nonlinear or only qualitatively known.

Key ideas

  • Fuzzification: converting a crisp input value to membership values in all relevant fuzzy sets. Given x0, compute μA(x0), μB(x0), ...

  • Rule (if–then): an expression of the form “If antecedent then consequent”. The antecedent is a logical combination (AND, OR, NOT) of fuzzy conditions on inputs; the consequent is a fuzzy set (Mamdani) or a function (Takagi–Sugeno).

  • Fuzzy rule base: a collection of rules. Typical controller uses rules constructed from expert knowledge or by tuning.

  • Inference (implication): compute the firing strength (degree to which rule antecedent is true), usually using t-norms for AND and t-conorms for OR. Common choices:

    • Minimum (min) for AND: firing = min(μA, μB).
    • Product for AND: firing = μA · μB.
    • Maximum (max) for OR: sup/maximum of memberships.
  • Aggregation: combine the fuzzy consequents of all fired rules into a single fuzzy set for each output. Common aggregation: pointwise maximum over consequents after implication (clipped with min or scaled with product).

  • Defuzzification: convert aggregated fuzzy set to a crisp output value. Common methods:

    • Centroid (center of gravity): x* = (∫ x·μ(x) dx) / (∫ μ(x) dx).
    • Bisector: value that divides area into equal halves.
    • Mean of maxima: average of x values where μ(x) is maximum.
    • Weighted average (used when consequents are singletons or T–S zero-order): x* = Σ(wi·zi)/Σ(wi) where wi are firing strengths and zi are singleton or rule outputs.
  • Mamdani vs Takagi–Sugeno (T–S):

    • Mamdani: consequents are fuzzy sets; defuzzification usually centroid; intuitive and good for rule-based human knowledge.
    • T–S: consequents are functions (often linear) of inputs; output is weighted average of consequent values using rule firing strengths. T–S is easier to compute and better for optimization and adaptive control.
  • Block diagram to draw and label: one input sensor line going to a Fuzzification block, then to Rule base and Inference Engine (rule base box paired with inference box), then aggregation block, then Defuzzification block, then final crisp Output to actuator. Also show feedback loop from output to plant and a measurement from plant to input.

Assumptions usually made in derivations/exams:

  • Universe and MFs are continuous and bounded.
  • Integrals exist for centroid defuzzification.
  • Rules combine via the chosen t-norm/t-conorm (e.g., min/product for AND and max for OR/aggregation); no probabilistic independence assumption is required.

Derivations often asked:

  • Triangular MF formula and its linear piecewise calculation.
  • Centroid defuzzification formula and its reduction to weighted average when consequents are singletons.
  • T–S weighted average formula from rule outputs and firing strengths.

Formulas

Triangular MF (a,b,c) with a < b < c: μ(x) = 0 for x ≤ a; μ(x) = (x−a)/(b−a) for a ≤ x ≤ b; μ(x) = (c−x)/(c−b) for b ≤ x ≤ c; μ(x) = 0 for x ≥ c — μ dimensionless, x has units of the variable (e.g., °C). Applies to triangular shapes.

Min AND: firing = min(μ1, μ2, ..., μn) — firing dimensionless, applies when using min t-norm.

Product AND: firing = μ1 · μ2 · ... · μn — firing dimensionless, applies when using product t-norm.

Aggregation (max): μagg(x) = max_i μi′(x) — where μi′(x) is the consequent MF after implication (e.g., clipped with min or scaled with product); μagg dimensionless.

Centroid defuzzification: x* = (∫ x · μagg(x) dx) / (∫ μagg(x) dx) — x* has same units as x (e.g., volts, °C). Requires μagg defined over continuous x.

Weighted-average (singleton/T–S): x* = Σ (wi · zi) / Σ (wi) — wi firing strengths (dimensionless), zi consequent crisp values (same units as x*). Applies when consequents are singletons or T–S outputs.

T–S first-order consequent: zi(x) = a0 + a1·x1 + a2·x2 + ... — zi has same units as output; then x* uses weighted-average formula above.

Worked examples

Example 1 — Zero-order T–S (Sugeno) FLC with singleton consequents (numerical, exam-style): Given: two inputs Error E (°C) with universe [-3,3] and rate DE (°C/s) with universe [-2,2]. Define triangular MFs:

  • For E: N = (-3,-2,-1), Z = (-2,0,2), P = (1,2,3).
  • For DE: N = (-2,-1,0), Z = (-1,0,1), P = (0,1,2). Consequents are singletons: NB = −80 (unit: % actuator), Z = 0, PS = +60. Given crisp inputs: E = −1.2 °C, DE = 0.5 °C/s. Steps:
  1. Fuzzify E: using triangular formula
    • μ_N(E) = (c−x)/(c−b) with (a,b,c)=(-3,-2,-1): μ_N = (-1 − (-1.2))/(-1 − -2) = 0.2/1 = 0.2
    • μ_Z(E) = (x−a)/(b−a) with (a,b,c)=(-2,0,2): μ_Z = (-1.2 − -2)/(0 − -2) = 0.8/2 = 0.4
    • μ_P(E) = 0
  2. Fuzzify DE:
    • μ_N(DE) = 0
    • μ_Z(DE) = (c−x)/(c−b) with (-1,0,1): μ_Z = (1 − 0.5)/(1 − 0) = 0.5
    • μ_P(DE) = (x−a)/(b−a) with (0,1,2): μ_P = (0.5 − 0)/(1) = 0.5
  3. Select fired rules (nonzero antecedent degrees). Use these rules and compute firing = min(antecedent memberships):
    • Rule A: If E is N AND DE is Z → NB. firing = min(0.2,0.5) = 0.2
    • Rule B: If E is Z AND DE is P → PS. firing = min(0.4,0.5) = 0.4
    • Rule C: If E is N AND DE is P → Z. firing = min(0.2,0.5) = 0.2
  4. Since consequents are singletons, use weighted-average defuzzification:
    • x* = (0.2·(−80) + 0.4·60 + 0.2·0) / (0.2 + 0.4 + 0.2)
    • x* = (−16 + 24 + 0) / 0.8 = 8 / 0.8 = 10 Answer: Output = +10 % actuator (positive small actuation). (Units: % of actuator range.)

Example 2 — Model-answer long question: design steps and compare Mamdani vs T–S. Question: Describe steps to design an FLC for speed control and discuss Mamdani vs T–S. Model answer (points to include for full marks):

  1. Define control objectives and select inputs/outputs (e.g., input: speed error e and de/dt; output: throttle or PWM duty %). Give units.
  2. Choose universes and partition into fuzzy linguistic terms (e.g., NB, NS, Z, PS, PB) and pick MF shapes and parameters; justify triangular for simplicity, Gaussian for smoothness.
  3. Build rule base from expert knowledge: typical rule form "If e is NB and de is Z then output is PB". Show full rule table or representative rules.
  4. Choose inference (min or product) and aggregation (max). Explain trade-offs: product gives graded scaling; min clips.
  5. Choose defuzzification: centroid for Mamdani gives smooth output but needs more computation; weighted average/T–S is efficient for real-time.
  6. Test by simulation, tune MF parameters and rule weights, and iterate. Comparison Mamdani vs T–S: list pros/cons — Mamdani intuitive but heavier; T–S compact, differentiable and better for optimisation/adaptation (e.g., ANFIS). End with recommendation depending on real-time computation and whether consequents are naturally crisp functions.

Common mistakes

  • Mixing up min and product t-norms and not stating which is used (exam answers must state the chosen operator).
  • Using centroid integrals directly on non-aggregated fuzzy sets (must aggregate first).
  • Confusing Mamdani and T–S defuzzification formulas (T–S uses weighted average of rule outputs, Mamdani uses centroid of aggregated fuzzy set).

For your exam

Types of questions you will see: definitions (fuzzy set, membership function), draw and label block diagram of a fuzzy controller, derive triangular MF formula, a numerical design/evaluation of an FLC (like Example 1), and compare Mamdani vs T–S. What full-marks answers include:

  • Precise definitions of terms used.
  • Clear drawing and labelling for diagrams.
  • Statement of chosen operators (min/product/max) and why.
  • Step-by-step numeric calculation with intermediate membership values and final defuzzified number (units).
  • For theory compare/contrast items, list clear pros and cons and conclude with when to use which approach.

Quick check

  1. Define a fuzzy set in one sentence.
  2. Write the triangular MF formula for x between a and b.
  3. When consequents are singletons, which defuzzification reduces to a weighted average? Answers: 1) A fuzzy set assigns each x a membership μ(x) in [0,1] describing degree of membership. 2) μ(x) = (x−a)/(b−a) for a ≤ x ≤ b. 3) Centroid (for singleton consequents it reduces to a weighted average).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?