Advertisement
Guest User

TestController

a guest
Sep 20th, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.49 KB | None | 0 0
  1. FUNCTION_BLOCK VentCtrl
  2.   VAR_OUTPUT
  3.     pwrOUT : BOOL;
  4.     stOUT : BOOL;
  5.   END_VAR
  6.   VAR_INPUT
  7.     pwrIN : BOOL;
  8.     stIN : BOOL;
  9.     fbIN : BOOL;
  10.     OnTime : TIME := T#10s;
  11.     OffTime : TIME := T#20s;
  12.   END_VAR
  13.   VAR
  14.     CtrlTime : TIME := T#500ms;
  15.     TON0 : TON;
  16.     TOF0 : TOF;
  17.     TOF2 : TOF;
  18.     TOF1 : TOF;
  19.     NOT23_OUT : BOOL;
  20.     NOT30_OUT : BOOL;
  21.     OR25_OUT : BOOL;
  22.     OR26_OUT : BOOL;
  23.     AND24_OUT : BOOL;
  24.   END_VAR
  25.  
  26.   TON0(IN := pwrIN, PT := OnTime);
  27.   TOF0(IN := TON0.Q, PT := OffTime);
  28.   pwrOUT := TOF0.Q;
  29.   NOT23_OUT := NOT(TOF0.Q);
  30.   TOF1(IN := NOT23_OUT, PT := CtrlTime);
  31.   NOT30_OUT := NOT(fbIN);
  32.   OR25_OUT := OR(TOF1.Q, NOT30_OUT);
  33.   TOF2(IN := TOF0.Q, PT := CtrlTime);
  34.   OR26_OUT := OR(TOF2.Q, fbIN);
  35.   AND24_OUT := AND(OR25_OUT, OR26_OUT, stIN);
  36.   stOUT := AND24_OUT;
  37. END_FUNCTION_BLOCK
  38.  
  39. PROGRAM Main
  40.   VAR
  41.     OnOffTrig : BOOL := False;
  42.   END_VAR
  43.   VAR_EXTERNAL
  44.     BtnON : BOOL;
  45.     BtnOFF : BOOL;
  46.   END_VAR
  47.   VAR CONSTANT
  48.     OnTime1 : TIME := T#1s;
  49.     OnTime2 : TIME := T#31s;
  50.     OnTime3 : TIME := T#61s;
  51.     OffTime1 : TIME := T#61s;
  52.     OffTime2 : TIME := T#31s;
  53.     OffTime3 : TIME := T#1s;
  54.   END_VAR
  55.   VAR_EXTERNAL
  56.     Vent1 : BOOL;
  57.     Vent2 : BOOL;
  58.     Vent3 : BOOL;
  59.     Ctrl1 : BOOL;
  60.     Ctrl2 : BOOL;
  61.     Ctrl3 : BOOL;
  62.   END_VAR
  63.   VAR
  64.     VentCtrl1 : VentCtrl;
  65.     VentCtrl2 : VentCtrl;
  66.     VentCtrl3 : VentCtrl;
  67.   END_VAR
  68.   VAR_EXTERNAL
  69.     NoErrors : BOOL;
  70.   END_VAR
  71.  
  72.   VentCtrl1(pwrIN := OnOffTrig, stIN := NoErrors, fbIN := Ctrl1, OnTime := OnTime1, OffTime := OffTime1);
  73.   Vent1 := VentCtrl1.pwrOUT;
  74.   VentCtrl2(pwrIN := OnOffTrig, stIN := VentCtrl1.stOUT, fbIN := Ctrl2, OnTime := OnTime2, OffTime := OffTime2);
  75.   Vent2 := VentCtrl2.pwrOUT;
  76.   VentCtrl3(pwrIN := OnOffTrig, stIN := VentCtrl2.stOUT, fbIN := Ctrl3, OnTime := OnTime3, OffTime := OffTime3);
  77.   Vent3 := VentCtrl3.pwrOUT;
  78.   NoErrors := VentCtrl3.stOUT;
  79.   OnOffTrig := BtnOFF AND (BtnON OR OnOffTrig);
  80. END_PROGRAM
  81.  
  82.  
  83. CONFIGURATION config
  84.   VAR_GLOBAL
  85.     LedGreen AT %QX4.1 : BOOL;
  86.     LedRed AT %QX4.0 : BOOL;
  87.     BtnON AT %IX1.3 : BOOL;
  88.     BtnOFF AT %IX1.2 : BOOL;
  89.     Ctrl1 AT %IX1.5 : BOOL;
  90.     Ctrl2 AT %IX1.6 : BOOL;
  91.     Ctrl3 AT %IX1.7 : BOOL;
  92.     Vent1 AT %QX1.1 : BOOL;
  93.     Vent2 AT %QX1.2 : BOOL;
  94.     Vent3 AT %QX1.3 : BOOL;
  95.     NoErrors AT %QX1.0 : BOOL := True;
  96.   END_VAR
  97.  
  98.   RESOURCE resource1 ON PLC
  99.     TASK TmrMain(INTERVAL := T#100ms,PRIORITY := 0);
  100.     PROGRAM InstMain WITH TmrMain : Main;
  101.   END_RESOURCE
  102. END_CONFIGURATION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement