Please check the below is my code and I'm able to operate one cycle of up down counter but cannot operate continuously.
Any suggestions?
Declaration:
PROGRAM PLC_PRG
VAR
T1:TON;
C1:CTUD;
SRT:BOOL;
B: BOOL;
A: BOOL;
COUNT: INT;
STP: BOOL;
PRESET: INT;
END_VAR
Code:
T1(IN:= SRT AND NOT T1.Q, PT:=T#1s);
COUNT :=0;
PRESET :=10;
WHILE COUNT<PRESET DO
C1(CU:= T1.Q AND NOT B, PV:=21);
IF C1.QU = TRUE THEN
B:=TRUE;
A:=TRUE;
END_IF;
C1(CD:=T1.Q AND A);
IF C1.CV = 0 THEN
A:=FALSE;
END_IF;
COUNT := COUNT +1;
END_WHILE;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please check the below is my code and I'm able to operate one cycle of up down counter but cannot operate continuously.
Any suggestions?
Declaration:
PROGRAM PLC_PRG
VAR
T1:TON;
C1:CTUD;
SRT:BOOL;
B: BOOL;
A: BOOL;
COUNT: INT;
STP: BOOL;
PRESET: INT;
END_VAR
Code:
T1(IN:= SRT AND NOT T1.Q, PT:=T#1s);
COUNT :=0;
PRESET :=10;
WHILE COUNT<PRESET DO
C1(CU:= T1.Q AND NOT B, PV:=21);
IF C1.QU = TRUE THEN
B:=TRUE;
A:=TRUE;
END_IF;
C1(CD:=T1.Q AND A);
IF C1.CV = 0 THEN
A:=FALSE;
END_IF;
COUNT := COUNT +1;
END_WHILE;
Please read the documentation about the block you use before asking for help.