Jump to content

Recommended Posts

Suppose I place TD coil for 10 seconds in a conditional subroutine that is called once a second (by another timer or asynchronous event).

Q1. Will TD decrement or will it be reset (by the system) due to not being updated every scan cycle?

Q2. If it will decrement - will it actually last exactly 10 seconds or there would be a (significant) timing error due to subroutine not being called majority of the time and TD not getting many chances to decrement?

Thanks.

Link to comment
Share on other sites

  • MVP 2014

Interesting question, and not hard to test.

The timer only counts down while the subroutine is active. So if the subroutine is called for one scan every second, the timer counts down very slowly.

See attached example.

If you want the timer to count normally, put it in Main Routine or a subroutine that will always be active. The in your "1 second" subroutine, check the result of the timer to see if it has timed out or not.

Timer in Subroutine.vlp

Link to comment
Share on other sites

Interesting question, and not hard to test.

The timer only counts down while the subroutine is active. So if the subroutine is called for one scan every second, the timer counts down very slowly.

See attached example.

If you want the timer to count normally, put it in Main Routine or a subroutine that will always be active. The in your "1 second" subroutine, check the result of the timer to see if it has timed out or not.

Thanks for the answer.

Sure it is not hard to test, but that is the point - if I test it now and find out how it behaves then I can build my application around that behavior and it will work - now. But since this behavior is not documented then it may work differently in another PLC (mine is V120-22) or in next firmware update and may break the functionality - would be a hell to remember and debug.

Of course it is possible to run timer unconditionally in some other subroutine (works fine), but that requires some compromise on the logical layout of program structure. I try to move all closely-related functionality in a single subroutine and not scatter it around - it would help to understand the program better few years down the road. This subroutine happens to be conditional as it is run depending on current "recipe" of hardware configuration - I also try to make program universal across different hardware options - makes it harder to write, but considerably easies version control.

So you basically say that timers are decremented by SI0 everytime the timer coil is encountered by a scan? What if I include this same coil several times in a scan? Would it count quicker than normal?

Link to comment
Share on other sites

  • MVP 2014

Firstly, Unitronics are very careful about consistency and compatibility between versions and upgrades. I would expect the same behaviour across all models of Visilogic PLCs. Unitronics also avoid making changes to firmware that would drastically modify the behaviour of a program written on an earlier version. I have had many feature requests knocked back on this principle.

We could launch into a philosophical debate about how timers *should* operate, but... the system is the way it is. If Unitronics change it now, we end up with the exact situation you are afraid of.

IMHO it is logical enough that timers only count when they are called in an active subroutine.

In my "day job" as well as on the forum I meet many who express disappointment that certain features of Unitronics are not to their exact liking. I try to be diplomatic, but in the end you may need to change your approach to suit the platform, bearing in mind that it surely would have other features that make your life easier.

On the final question, yes, the timer will count "n" times faster if you have "n" number of active timer coils linked to the same timer.

If you want multiple conditions to activate a timer, "OR" them together first then use the result to drive a single timer coil.

I hope this helps.

Link to comment
Share on other sites

  • MVP 2023

"What if I include this same coil several times in a scan? Would it count quicker than normal?" Yes it will, as Simon said, but you should adhere to the practice of never have the same coil more than once in a program. That is bad, bad ladder logic programming. One exception to this rule _might_ be when there is a program set up for multiple configurations where the coil might exist in two (or perhaps more) different subroutines that will never both be called.

Link to comment
Share on other sites

Firstly, Unitronics are very careful about consistency and compatibility between versions and upgrades. I would expect the same behaviour across all models of Visilogic PLCs. Unitronics also avoid making changes to firmware that would drastically modify the behaviour of a program written on an earlier version. I have had many feature requests knocked back on this principle.

We could launch into a philosophical debate about how timers *should* operate, but... the system is the way it is. If Unitronics change it now, we end up with the exact situation you are afraid of.

IMHO it is logical enough that timers only count when they are called in an active subroutine.

In my "day job" as well as on the forum I meet many who express disappointment that certain features of Unitronics are not to their exact liking. I try to be diplomatic, but in the end you may need to change your approach to suit the platform, bearing in mind that it surely would have other features that make your life easier.

On the final question, yes, the timer will count "n" times faster if you have "n" number of active timer coils linked to the same timer.

If you want multiple conditions to activate a timer, "OR" them together first then use the result to drive a single timer coil.

I hope this helps.

It does help, thanks. One of my problems is trying to understand more than is needed to make work done. I have made call to subroutines unconditional, leaving timers at the top, but returning immediately after if it is "not the right time" for this subroutine to run. Should be a nice compromise. Thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...