How to reset an array of timers in RSLogix5000

mitch11

Member
Join Date
Mar 2017
Location
Ohio
Posts
26
Hello All,

I was wondering if there is a way to reset an array of timers by using a FLL or similar instruction.

Timer[100]

Thanks:beer:
 
Last edited:
In front of each TON instruction, have a normally closed tag that, when energized, drops the true condition to the TON instruction which will reset it.
 
In front of each TON instruction, have a normally closed tag that, when energized, drops the true condition to the TON instruction which will reset it.
I'm actually using the RTO timers, so the timer will not reset if the conditions prior to the timer go false. I'm trying to manually reset all 100 timers at the same time.

Maybe something like:

FLL
Source: Clear[100]
Dest: Timer[100].ACC

EDIT: From the help menu, it looks like you cannot use timers within the FLL instruction.
 
If you only want to set all of the accumulators to zero, you should also be able to use the FAL instruction for this purpose. That would not be the same as using the RES instruction in a loop, which would be a "safer" approach. I would consider a simple AOI with a LBL/JMP loop.
 
I setup a quick program that had 6 RTO timers (T40[X] with “X” being 0 thru 5) with each one’s done bit enabling the next one. When the last timer was done its done bit enabled an “ADD” function that added “1” to an INT (B30) and moved the result to the same INT B30. ADD functions will add as fast as they can if you leave the rung enabled. I then added a branch around the “ADD” function with a “RES” output. The address of the “RES” was “T40[B30]”. The next branch had a “equal or greater” compare function where when B30 was at or above “6” the rung was true and a “MOV” function moved “0” to B30. It works great. B30 cycles up from 0 to 6 and as it does timers 0 thru 5 reset. This is all happening faster than RSLogix5000 can update so it looks like the timers all reset at once. It’s probably taking a few milliseconds. The only caveat is that whatever enables the ADD function needs to be enabled until all of the timers are reset.
 
Clearing the Accumulators is easy with a FAL instruction (See Pic 1), but that will not clear the .DN bits for any timers that have completed.



Probably the cleanest approach is to use a FOR instruction, calling a subroutine to clear each timer (See Pics 2 and 3)... This is far preferable to using JMPs and LBLs.

Pic 1.jpg Pic 2.jpg Pic 3.jpg
 
Clearing the Accumulators is easy with a FAL instruction (See Pic 1), but that will not clear the .DN bits for any timers that have completed.



Probably the cleanest approach is to use a FOR instruction, calling a subroutine to clear each timer (See Pics 2 and 3)... This is far preferable to using JMPs and LBLs.
This is more of what I was looking for. Thank you!!
 
The problem you face is that you have for an array of TIMER[x], in essence, is an array of DINT[3x]. While the TIMER[x].ACC and .PRE are addressable by word using an FAL, the word the contains the .DN, .EN, .TT and other info is not addressable.

In doing a RES, you essentially want to clear the 1st and 3rd words of the array triple, while leaving the second word, the .PRE, untouched.

If you just clear the .ACC, but don't reset the .DN or .EN, the timers will not necessarily start ticking when re-enabled, which I suspect would be undesirable.

The best recommendation is to do it in a loop, as suggested

The second best would be to create a DINT[3x] array. Initialize the array with a FLL 0, then FAL Timer[R.POS].PRE into DINT[(3*R.POS)+1]. Now the array contains all the control bits reset, your timer PREs, and zeroed .ACC. A simple COP of DINT[x] Timer[x] will effectively reset your RTOs.

When you feel you need to reinitialize the DINT array depends on how often your .PREs change.
 
Clearing the Accumulators is easy with a FAL instruction (See Pic 1), but that will not clear the .DN bits for any timers that have completed.



Probably the cleanest approach is to use a FOR instruction, calling a subroutine to clear each timer (See Pics 2 and 3)... This is far preferable to using JMPs and LBLs.

That's cool- I didn't know that was an instruction in ladder. I'm guessing it increments once per scan?

Edit: Oh, I think I see. It calls the subroutine over and over until the loop is finished?
 
Last edited:
That's cool- I didn't know that was an instruction in ladder. I'm guessing it increments once per scan?

Edit: Oh, I think I see. It calls the subroutine over and over until the loop is finished?


Yes


FOR {Index} = {initial value} to {terminal value} step {step size}

JSR {routine name}
 
Just to make it clear, the FOR instruction calls the subroutine the requested number of times each time the instruction is executed, not once per scan of the ladder logic.


I often use it to "simulate" a much bigger program when doing demonstrations in class. I've often used FOR to execute the subroutine (albeit with nothing in it), something like 100,000 times !
 
The problem you face is that you have for an array of TIMER[x], in essence, is an array of DINT[3x]. While the TIMER[x].ACC and .PRE are addressable by word using an FAL, the word the contains the .DN, .EN, .TT and other info is not addressable.

In doing a RES, you essentially want to clear the 1st and 3rd words of the array triple, while leaving the second word, the .PRE, untouched.

If you just clear the .ACC, but don't reset the .DN or .EN, the timers will not necessarily start ticking when re-enabled, which I suspect would be undesirable.

The best recommendation is to do it in a loop, as suggested

The second best would be to create a DINT[3x] array. Initialize the array with a FLL 0, then FAL Timer[R.POS].PRE into DINT[(3*R.POS)+1]. Now the array contains all the control bits reset, your timer PREs, and zeroed .ACC. A simple COP of DINT[x] Timer[x] will effectively reset your RTOs.

When you feel you need to reinitialize the DINT array depends on how often your .PREs change.
So I will need to add the clear/reset logic to its own routine. Then, from another routine, I will add the for loop to call the clear/reset routine for the desirable number of resets needed?

Thanks for the help.
 
So I will need to add the clear/reset logic to its own routine. Then, from another routine, I will add the for loop to call the clear/reset routine for the desirable number of resets needed?

Thanks for the help.


From Post #7


Pic 2 "calls" the routine 100 times


Pic 3 is what is inside the routine


nothing else needed, all timers will reset in one scan


EDIT : you might want to put OTU Reset_Timers after the FOR instruction so you only need to turn it on, and it will automatically turn off when the timers get reset
 
So I will need to add the clear/reset logic to its own routine. Then, from another routine, I will add the for loop to call the clear/reset routine for the desirable number of resets needed?

There are two different methods here, with two different approaches.

#1 - Daba's FOR instruction, which calls a routine which preforms a RES on each timer.

#2 - My COP DINT[3x] Timer[x] one which puts zeros in the control and ACC words of the timer, but uses a stored value of PREs to overwrite the existing PREs.

Daba's is cleaner, so I would go with that if I were you. I included mine to augment daba's "Pic 1" idea, which at one time you seemed like you were heading towards.
 

Similar Topics

Hello. Looking for the best way to load the preset and then do reset on a 144 position counter array in Controllogix? I'm monitoring 144...
Replies
1
Views
1,280
I've come across an application that might be hard to explain, however I think there might be a simple explanation. I am doing an array of...
Replies
3
Views
3,403
We are using an array of bools for our fault code logic, and I need to reset all the bits in the array when the operator presses the fault reset...
Replies
2
Views
2,128
I was loading a program onto an XE1e2 PLC and it got stuck on these two windows and won't progress. It won't let me connect from the PC to reload...
Replies
0
Views
55
Hi all, i have recieved some 4RF Aprisa SR+ ethernet radios from a customer to configure. Issue is that they are used and have non-default...
Replies
0
Views
54
Back
Top Bottom