1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
|