Timer Inside Subroutine

zblum

Member
Join Date
Mar 2016
Location
Ohio
Posts
38
I am trying to use a TOF function inside of a subroutine for a MicroLogix 1200. However, as soon as I download the program and the PLC starts to scan, the accumulated value immediately jumps up to the preset value, despite the conditions not being met for it to begin timing. If I put a first scan timer reset in the main program, the timer will never start.
Any ideas?
Thanks
 
I might be wrong for your application but I would suggest ladder logic plus a TON outside the subroutine and trigger it when necessary when the subroutine is called.
 
Welcome...Read up on the TON, it may be more of what you're looking for. This is a WAG since I don't know what the timer is intended to do.
HTH
 
Never use the TOF...well almost never. It is just counter intuitive that the timer starts out DN and then stays DN until a preset amount of time after the timer instruction goes false.

In a very few cases using a TOF in place of a TON, can clean up a messy rung, but in 99.9% of cases, the TON will do what you need it to do and be easier to write and follow.
 
To the OP, you need to read up on the TOF. It is doing exactly what it is supposed to do. It starts with the ACC = PRE so it doesn't start timing automatically on a power cycle. Since it begins timing when it is false it needs to see a TRUE to FALSE transition.

========================


Okie this is not intended to teach you, I know you know what you are doing! This is just for public consumption.

I do use the TOF and the TON. It's actually real simple and believe it or not they work almost identically.

First thing I ask, "Do you want to make something happen FOR a duration or AFTER a duration".

FOR a duration means you want to use the TT bit and while either timer can work I always use a TON.

AFTER a duration means you want to use the DN bit. Then the next question is do you want to turn something ON or OFF after a duration. That answer tells you which timer to use.

If you want to turn the DN bit on, make the rung true. If you want to turn the DN bit off, make the rung false. It works the same for both types of timers. The difference is in where the delay factors in. Do I delay turning on (TON) the DN bit and some associated output, or do I want to delay turning off (TOF) the done bit and some associated output.

I have seen people struggle and waste far too much time pushing a square peg into a round hole.

OG
 
Last edited:

Similar Topics

kindly help me to make a timer inside the FB S7 300
Replies
8
Views
4,487
Hi all, Another question relating to my difficulties with translating my S7-1200 FB's to S7-300 FB's :) In my S7-1200 FB I have two IEC timers...
Replies
5
Views
6,803
Hello, I am new to PLC(R3Xi) and proficy machine edition.I will really appreciate a help about the following issue. I built a UDFB using and it...
Replies
0
Views
1,924
I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO...
Replies
2
Views
89
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
308
Back
Top Bottom