diff options
Diffstat (limited to 'examples/mamdani/Laundry.fcl')
-rw-r--r-- | examples/mamdani/Laundry.fcl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/examples/mamdani/Laundry.fcl b/examples/mamdani/Laundry.fcl new file mode 100644 index 0000000..a5d5380 --- /dev/null +++ b/examples/mamdani/Laundry.fcl @@ -0,0 +1,56 @@ +FUNCTION_BLOCK Laundry + +VAR_INPUT + Load: REAL; + Dirt: REAL; +END_VAR + +VAR_OUTPUT + Detergent: REAL; + Cycle: REAL; +END_VAR + +FUZZIFY Load + RANGE := (0.000 .. 6.000); + TERM small := (0.000, 1.000) (1.000, 1.000) (2.000, 0.800) (5.000, 0.000); + TERM normal := (3.000, 0.000) (4.000, 1.000) (6.000, 0.000); +END_FUZZIFY + +FUZZIFY Dirt + RANGE := (0.000 .. 6.000); + TERM low := (0.000, 1.000) (2.000, 0.800) (5.000, 0.000); + TERM high := (1.000, 0.000) (2.000, 0.200) (4.000, 0.800) (6.000, 1.000); +END_FUZZIFY + +DEFUZZIFY Detergent + RANGE := (0.000 .. 80.000); + TERM less := (10.000, 0.000) (40.000, 1.000) (50.000, 0.000); + TERM normal := (40.000, 0.000) (50.000, 1.000) (60.000, 1.000) (80.000, 0.000); + TERM more := (50.000, 0.000) (80.000, 1.000); + METHOD : MM; + ACCU : MAX; + DEFAULT := nan; +END_DEFUZZIFY + +DEFUZZIFY Cycle + RANGE := (0.000 .. 20.000); + TERM short := (0.000, 1.000) (10.000, 1.000) (20.000, 0.000); + TERM long := (10.000, 0.000) (20.000, 1.000); + METHOD : MM; + ACCU : MAX; + DEFAULT := nan; +END_DEFUZZIFY + +RULEBLOCK + AND : MIN; + OR : MAX; + ACT : MIN; + RULE 1 : if Load is small and Dirt is not high then Detergent is less + RULE 2 : if Load is small and Dirt is high then Detergent is normal + RULE 3 : if Load is normal and Dirt is low then Detergent is less + RULE 4 : if Load is normal and Dirt is high then Detergent is more + RULE 5 : if Detergent is normal or Detergent is less then Cycle is short + RULE 6 : if Detergent is more then Cycle is long +END_RULEBLOCK + +END_FUNCTION_BLOCK |