# I cannot reset multiple timers from one program

**URL:** <https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949>\
**Category:** Programming\
**Tags:** structured-text\
**Created:** [August 1, 2024, 1:48pm UTC](https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949 "2024-08-01T13:48:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![c601154](https://avatars.discourse-cdn.com/v4/letter/c/FF8800/32.png) [@c601154](https://community.br-automation.com/u/c601154)\
**Post date:** [August 1, 2024, 1:48pm UTC](https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949/1 "2024-08-01T13:48:27Z")

</div>

I have the following code:  
PROGRAM \_INIT  
(\* Insert code here \*)

END\_PROGRAM

PROGRAM \_CYCLIC  
(\* Insert code here \*)  
FOR i := 0 TO 11 DO  
IF i = 0 THEN  
Timers\_v[i].IN := TRUE;  
ELSE  
Timers\_v[i].IN := Timers\_v[i-1].Q;  
END\_IF;  
Timers\_v[i].PT := 100;

```
IF Timers_v[i].Q = TRUE THEN
	DO_V[i] := TRUE;
	IF i > 0 THEN
		DO_V[i-1] := FALSE;
	END_IF;
ELSE
	DO_V[i] := FALSE;
END_IF;
	Timers_v[i]();
END_FOR;

Timer_TOT.IN := Timers_v[11].Q;
Timer_TOT.PT := 100;
IF Timer_TOT.Q THEN
	FOR i := 0 TO 11 DO
		DO_V[i] := TRUE;
	END_FOR;
END_IF;
Timer_TOT();

Timer_TOT_STINS.IN := Timer_TOT.Q;
Timer_TOT_STINS.PT := 100;
IF Timer_TOT_STINS.Q = TRUE THEN
	FOR i := 0 TO 11 DO
		DO_V[i] := FALSE;
		Timers_v[i].IN := FALSE;
	END_FOR;
	Timer_TOT.IN := FALSE;
	Timer_TOT_STINS.IN := FALSE;
END_IF;
Timer_TOT_STINS();

```

END\_PROGRAM

PROGRAM \_EXIT  
(\* Insert code here \*)

END\_PROGRAM

When I inject it on the plc it works as required but only once, then the timers are not reset except for the last one which ends up running by itself in an infinite loop, but I want the whole process to start over.

---

<div class="post-metadata">

**Author:** ![ghizonid](https://avatars.discourse-cdn.com/v4/letter/g/FF8800/32.png) [@ghizonid](https://community.br-automation.com/u/ghizonid)\
**Post date:** [August 1, 2024, 2:10pm UTC](https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949/2 "2024-08-01T14:10:09Z")

</div>

Hey there - I don’t see a reset condition for the “Timers\_v” array of timers. The Timers\_v[i].IN are set to TRUE, but not reset afterwards.

---

<div class="post-metadata">

**Author:** ![c601154](https://avatars.discourse-cdn.com/v4/letter/c/FF8800/32.png) [@c601154](https://community.br-automation.com/u/c601154)\
**Post date:** [August 1, 2024, 2:12pm UTC](https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949/3 "2024-08-01T14:12:00Z")

</div>

IF Timer\_TOT\_STINS.Q = TRUE THEN  
FOR i := 0 TO 11 DO  
DO\_V[i] := FALSE;  
Timers\_v[i].IN := FALSE;  
END\_FOR;  
Timer\_TOT.IN := FALSE;  
Timer\_TOT\_STINS.IN := FALSE;  
END\_IF;

I have it here at the end of the code.

---

<div class="post-metadata">

**Author:** ![c601154](https://avatars.discourse-cdn.com/v4/letter/c/FF8800/32.png) [@c601154](https://community.br-automation.com/u/c601154)\
**Post date:** [August 1, 2024, 2:18pm UTC](https://community.br-automation.com/t/i-cannot-reset-multiple-timers-from-one-program/3949/4 "2024-08-01T14:18:37Z")

</div>

I solved the problem with this assignment:  
Timers\_v[i].IN := TURE I had to replace TRUE with NOT Timer\_TOT\_STINS.Q;

Thank you!
