//Code automatically generated with fuzzylite 6.0. FUNCTION_BLOCK tipper VAR_INPUT service: REAL; food: REAL; END_VAR VAR_OUTPUT mTip: REAL; tsTip: REAL; END_VAR FUZZIFY service RANGE := (0.000 .. 10.000); TERM poor := Trapezoid 0.000 0.000 2.500 5.000; TERM good := Triangle 2.500 5.000 7.500; TERM excellent := Trapezoid 5.000 7.500 10.000 10.000; END_FUZZIFY FUZZIFY food RANGE := (0.000 .. 10.000); TERM rancid := Trapezoid 0.000 0.000 2.500 7.500; TERM delicious := Trapezoid 2.500 7.500 10.000 10.000; END_FUZZIFY DEFUZZIFY mTip RANGE := (0.000 .. 30.000); TERM cheap := Triangle 0.000 5.000 10.000; TERM average := Triangle 10.000 15.000 20.000; TERM generous := Triangle 20.000 25.000 30.000; METHOD : COG; ACCU : MAX; DEFAULT := nan; END_DEFUZZIFY DEFUZZIFY tsTip RANGE := (0.000 .. 30.000); TERM cheap := 5.000; TERM average := 15.000; TERM generous := 25.000; METHOD : COGS; DEFAULT := nan; END_DEFUZZIFY RULEBLOCK mamdani AND : PROD; OR : ASUM; ACT : MIN; RULE 1 : if service is poor or food is rancid then mTip is cheap RULE 2 : if service is good then mTip is average RULE 3 : if service is excellent or food is delicious then mTip is generous with 0.5 RULE 4 : if service is excellent and food is delicious then mTip is generous with 1.0 END_RULEBLOCK RULEBLOCK takagiSugeno AND : PROD; OR : ASUM; RULE 1 : if service is poor or food is rancid then tsTip is cheap RULE 2 : if service is good then tsTip is average RULE 3 : if service is excellent or food is delicious then tsTip is generous with 0.5 RULE 4 : if service is excellent and food is delicious then tsTip is generous with 1.0 END_RULEBLOCK END_FUNCTION_BLOCK