Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION_BLOCK VentCtrl
- VAR_OUTPUT
- pwrOUT : BOOL;
- stOUT : BOOL;
- END_VAR
- VAR_INPUT
- pwrIN : BOOL;
- stIN : BOOL;
- fbIN : BOOL;
- OnTime : TIME := T#10s;
- OffTime : TIME := T#20s;
- END_VAR
- VAR
- CtrlTime : TIME := T#500ms;
- TON0 : TON;
- TOF0 : TOF;
- TOF2 : TOF;
- TOF1 : TOF;
- NOT23_OUT : BOOL;
- NOT30_OUT : BOOL;
- OR25_OUT : BOOL;
- OR26_OUT : BOOL;
- AND24_OUT : BOOL;
- END_VAR
- TON0(IN := pwrIN, PT := OnTime);
- TOF0(IN := TON0.Q, PT := OffTime);
- pwrOUT := TOF0.Q;
- NOT23_OUT := NOT(TOF0.Q);
- TOF1(IN := NOT23_OUT, PT := CtrlTime);
- NOT30_OUT := NOT(fbIN);
- OR25_OUT := OR(TOF1.Q, NOT30_OUT);
- TOF2(IN := TOF0.Q, PT := CtrlTime);
- OR26_OUT := OR(TOF2.Q, fbIN);
- AND24_OUT := AND(OR25_OUT, OR26_OUT, stIN);
- stOUT := AND24_OUT;
- END_FUNCTION_BLOCK
- PROGRAM Main
- VAR
- OnOffTrig : BOOL := False;
- END_VAR
- VAR_EXTERNAL
- BtnON : BOOL;
- BtnOFF : BOOL;
- END_VAR
- VAR CONSTANT
- OnTime1 : TIME := T#1s;
- OnTime2 : TIME := T#31s;
- OnTime3 : TIME := T#61s;
- OffTime1 : TIME := T#61s;
- OffTime2 : TIME := T#31s;
- OffTime3 : TIME := T#1s;
- END_VAR
- VAR_EXTERNAL
- Vent1 : BOOL;
- Vent2 : BOOL;
- Vent3 : BOOL;
- Ctrl1 : BOOL;
- Ctrl2 : BOOL;
- Ctrl3 : BOOL;
- END_VAR
- VAR
- VentCtrl1 : VentCtrl;
- VentCtrl2 : VentCtrl;
- VentCtrl3 : VentCtrl;
- END_VAR
- VAR_EXTERNAL
- NoErrors : BOOL;
- END_VAR
- VentCtrl1(pwrIN := OnOffTrig, stIN := NoErrors, fbIN := Ctrl1, OnTime := OnTime1, OffTime := OffTime1);
- Vent1 := VentCtrl1.pwrOUT;
- VentCtrl2(pwrIN := OnOffTrig, stIN := VentCtrl1.stOUT, fbIN := Ctrl2, OnTime := OnTime2, OffTime := OffTime2);
- Vent2 := VentCtrl2.pwrOUT;
- VentCtrl3(pwrIN := OnOffTrig, stIN := VentCtrl2.stOUT, fbIN := Ctrl3, OnTime := OnTime3, OffTime := OffTime3);
- Vent3 := VentCtrl3.pwrOUT;
- NoErrors := VentCtrl3.stOUT;
- OnOffTrig := BtnOFF AND (BtnON OR OnOffTrig);
- END_PROGRAM
- CONFIGURATION config
- VAR_GLOBAL
- LedGreen AT %QX4.1 : BOOL;
- LedRed AT %QX4.0 : BOOL;
- BtnON AT %IX1.3 : BOOL;
- BtnOFF AT %IX1.2 : BOOL;
- Ctrl1 AT %IX1.5 : BOOL;
- Ctrl2 AT %IX1.6 : BOOL;
- Ctrl3 AT %IX1.7 : BOOL;
- Vent1 AT %QX1.1 : BOOL;
- Vent2 AT %QX1.2 : BOOL;
- Vent3 AT %QX1.3 : BOOL;
- NoErrors AT %QX1.0 : BOOL := True;
- END_VAR
- RESOURCE resource1 ON PLC
- TASK TmrMain(INTERVAL := T#100ms,PRIORITY := 0);
- PROGRAM InstMain WITH TmrMain : Main;
- END_RESOURCE
- END_CONFIGURATION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement