Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python "Key Error"
#5
Ballpositioner2.fcl must contain information about PNEU? Because it's in there.


FUNCTION_BLOCK 

VAR_INPUT
  REQ_POS: REAL;
  REQ_ANGLE: REAL;
  DESIRED: REAL;
END_VAR

VAR_OUTPUT
  PNEU: REAL;
END_VAR

FUZZIFY REQ_POS
  ENABLED : TRUE;
  RANGE := (-35.000 .. 35.000);
  TERM FAR := Ramp 0.000 -35.000;
  TERM CENTER := Triangle -35.000 0.000 35.000;
  TERM CLOSE := Ramp 0.000 35.000;
END_FUZZIFY

FUZZIFY REQ_ANGLE
  ENABLED : TRUE;
  RANGE := (-45.000 .. 45.000);
  TERM RIGHT := Ramp 2.000 45.000;
  TERM LEFT := Ramp -2.000 -45.000;
  TERM HORIZONTAL := Triangle -2.000 0.000 2.000;
END_FUZZIFY

FUZZIFY DESIRED
  ENABLED : TRUE;
  RANGE := (-35.000 .. 35.000);
  TERM FAR := Ramp 0.000 -35.000;
  TERM CENTER := Triangle -35.000 0.000 35.000;
  TERM CLOSE := Ramp 0.000 35.000;
END_FUZZIFY

DEFUZZIFY PNEU
  ENABLED : TRUE;
  RANGE := (0.000 .. 255.000);
  TERM LEFT := Triangle 0.000 42.500 85.000;
  TERM NOTHING := Triangle 85.000 127.500 170.000;
  TERM RIGHT := Triangle 172.500 215.000 255.000;
  METHOD : COG;
  ACCU : HSUM;
  DEFAULT := nan;
END_DEFUZZIFY

RULEBLOCK 
  ENABLED : TRUE;
  AND : MIN;
  OR : MAX;
  ACT : MIN;
  RULE 1 : if REQ_POS is FAR and REQ_ANGLE is LEFT and DESIRED is FAR then PNEU is LEFT
  RULE 2 : if REQ_POS is FAR and REQ_ANGLE is LEFT and DESIRED is CENTER then PNEU is LEFT
  RULE 3 : if REQ_POS is FAR and REQ_ANGLE is LEFT and DESIRED is CLOSE then PNEU is LEFT
  RULE 4 : if REQ_POS is FAR and REQ_ANGLE is RIGHT and DESIRED is FAR then PNEU is RIGHT
  RULE 5 : if REQ_POS is FAR and REQ_ANGLE is RIGHT and DESIRED is CENTER then PNEU is LEFT
  RULE 6 : if REQ_POS is FAR and REQ_ANGLE is RIGHT and DESIRED is CLOSE then PNEU is LEFT
  RULE 7 : if REQ_POS is FAR and REQ_ANGLE is HORIZONTAL and DESIRED is FAR then PNEU is NOTHING
  RULE 8 : if REQ_POS is FAR and REQ_ANGLE is HORIZONTAL and DESIRED is CENTER then PNEU is LEFT
  RULE 9 : if REQ_POS is FAR and REQ_ANGLE is HORIZONTAL and DESIRED is CLOSE then PNEU is LEFT
  RULE 10 : if REQ_POS is CENTER and REQ_ANGLE is LEFT and DESIRED is FAR then PNEU is RIGHT
  RULE 11 : if REQ_POS is CENTER and REQ_ANGLE is LEFT and DESIRED is CENTER then PNEU is LEFT
  RULE 12 : if REQ_POS is CENTER and REQ_ANGLE is LEFT and DESIRED is CLOSE then PNEU is LEFT
  RULE 13 : if REQ_POS is CENTER and REQ_ANGLE is RIGHT and DESIRED is FAR then PNEU is RIGHT
  RULE 14 : if REQ_POS is CENTER and REQ_ANGLE is RIGHT and DESIRED is CENTER then PNEU is RIGHT
  RULE 15 : if REQ_POS is CENTER and REQ_ANGLE is RIGHT and DESIRED is CLOSE then PNEU is LEFT
  RULE 16 : if REQ_POS is CENTER and REQ_ANGLE is HORIZONTAL and DESIRED is FAR then PNEU is RIGHT
  RULE 17 : if REQ_POS is CENTER and REQ_ANGLE is HORIZONTAL and DESIRED is CENTER then PNEU is NOTHING
  RULE 18 : if REQ_POS is CENTER and REQ_ANGLE is HORIZONTAL and DESIRED is CLOSE then PNEU is LEFT
  RULE 19 : if REQ_POS is CLOSE and REQ_ANGLE is LEFT and DESIRED is FAR then PNEU is RIGHT
  RULE 20 : if REQ_POS is CLOSE and REQ_ANGLE is LEFT and DESIRED is CENTER then PNEU is RIGHT
  RULE 21 : if REQ_POS is CLOSE and REQ_ANGLE is LEFT and DESIRED is CLOSE then PNEU is LEFT
  RULE 22 : if REQ_POS is CLOSE and REQ_ANGLE is RIGHT and DESIRED is FAR then PNEU is RIGHT
  RULE 23 : if REQ_POS is CLOSE and REQ_ANGLE is RIGHT and DESIRED is CENTER then PNEU is RIGHT
  RULE 24 : if REQ_POS is CLOSE and REQ_ANGLE is RIGHT and DESIRED is CLOSE then PNEU is RIGHT
  RULE 25 : if REQ_POS is CLOSE and REQ_ANGLE is HORIZONTAL and DESIRED is FAR then PNEU is RIGHT
  RULE 26 : if REQ_POS is CLOSE and REQ_ANGLE is HORIZONTAL and DESIRED is CENTER then PNEU is RIGHT
  RULE 27 : if REQ_POS is CLOSE and REQ_ANGLE is HORIZONTAL and DESIRED is CLOSE then PNEU is NOTHING
END_RULEBLOCK

END_FUNCTION_BLOCK
Reply


Messages In This Thread
python "Key Error" - by a9balsza - Sep-24-2016, 08:15 AM
RE: python "Key Error" - by ichabod801 - Sep-24-2016, 12:12 PM
RE: python "Key Error" - by a9balsza - Sep-24-2016, 01:23 PM
RE: python "Key Error" - by Yoriz - Sep-24-2016, 01:31 PM
RE: python "Key Error" - by a9balsza - Sep-24-2016, 01:36 PM
RE: python "Key Error" - by Yoriz - Sep-24-2016, 01:43 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020