novice question about timers...

briana banks

Member
Join Date
Jul 2005
Posts
242
Hi All

i have 2 questions In RSLogix 5000.

1.
how can i do a reverse timer (timer that counts down)?
i.e. turn the TON to count from .PRE to 0.
i need to calculate .ACC/.PRE backwards.

2.
i need to insert a value to sample_1 when the timer begins and
insert a value to smaple_2 when the timer done.
(sample each 30 seconds)
 
Haven't migrated to RS5k yet, but:
1.
how can i do a reverse timer (timer that counts down)?
i.e. turn the TON to count from .PRE to 0.
i need to calculate .ACC/.PRE backwards.

Use subtraction .PRE - .ACC = time remaining


2.
i need to insert a value to sample_1 when the timer begins and
insert a value to smaple_2 when the timer done.
(sample each 30 seconds)

Use the timer enable bit and a OSR for sample_1 and the done bit for sameple_2.


The above answers are based on the older platforms and may not be applicable to RSLogix5K.

Regards,
Ken
 
sample13.jpg


timer_inv is the backward count. The branch is necessary because the timer.acc can and will exceed the pre. The next rungs move the values using a one shot so they only occur once at the beginning and end of the time cycle.
 
create a UDT (user defined data type) of type COUNT_DOWN_TIMER

Place the following elements in the UDT
Tmr - TIMER
TimeLeft - DINT

If you want, throw your samples in with the UDT (only if it makes sense to) as an array. OkiePC gave a good example of applying the one shot at the beginning and ending of timing - so if you follow his sample, then also throw the oneshots into the UDT.

Samples - Dint[2]
Oneshot - BOOL[32] <-may as well use the full 32 bits because the compiler is going to allocate 4 bytes anyways.

Create a tag MyTimer of type COUNT_DOWN_TIMER
The elements of it are accessed as
MyTimer.TimeLeft
MyTimer.TMR.ACC
MyTimer.TMR.PRE
MyTimer.TMR.DN
MYTimer.TMR.TT
MyTimer.TMR.EN

Exectue the timer normally, but right after perform a SUB instruction to Sub the ACC from the PRE and place the result in MyTimer.TimeLeft. The DN bit is Mytimer.Tmr.DN and will be on when TimeLeft<=0.


timedown.JPG



BTW, that is a legal rung in the CLX - though it might look funny to SLC programmers.
 
Last edited:

Similar Topics

I'm self taught so far, so hang with me as I try to explain my issue. I've got an archived program file for a PVP6 that I'm opening on FT ME ver...
Replies
13
Views
2,521
Hi All I dont have the sofware, so asking a small question. when installing FT SE Client,on PC, does it require sharing folders with the...
Replies
3
Views
6,240
Hi All register REG of type integer. i wish to know when each bit is "on" (or "off") by comparison of the total value. each bit in the register...
Replies
11
Views
2,597
Hi and Happy new year. I need to calculate the time in min & sec format from rate which is in real format. the rate is quantity/min so i...
Replies
2
Views
2,323
Hi All RSLogix 5000 How do i caculate duration in one equation. for instance 23:45 (PM) to 2:33 (AM) and 13:45 (AM) to 15:45(AM)? Duration...
Replies
1
Views
2,211
Back
Top Bottom