mirror of
https://github.com/marcin-szczepanski/jFuzzyLogic.git
synced 2024-12-22 09:25:28 +01:00
39 lines
589 B
Plaintext
39 lines
589 B
Plaintext
FUNCTION_BLOCK Example
|
|
|
|
VAR_INPUT
|
|
temp: REAL;
|
|
END_VAR
|
|
|
|
VAR_OUTPUT
|
|
hot_valve: REAL;
|
|
cold_valve: REAL;
|
|
END_VAR
|
|
|
|
FUZZIFY temp
|
|
TERM hot := (1,0)(70,0)(90,1);
|
|
TERM cold := (1,1)(50,1)(80,0);
|
|
END_FUZZIFY
|
|
|
|
DEFUZZIFY hot_valve
|
|
TERM open := 100;
|
|
TERM closed := 0;
|
|
METHOD : COGS;
|
|
DEFAULT := 0;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY cold_valve
|
|
TERM open := 100;
|
|
TERM closed := 0;
|
|
METHOD : COGS;
|
|
DEFAULT := 0;
|
|
END_DEFUZZIFY
|
|
|
|
RULEBLOCK Control
|
|
AND: MIN;
|
|
ACCU: MAX;
|
|
RULE 1: IF temp IS cold THEN hot_valve IS open;
|
|
RULE 2: IF temp IS hot THEN cold_valve IS open;
|
|
END_RULEBLOCK
|
|
|
|
|
|
END_FUNCTION_BLOCK |