Logix5K - Possible to Enable/Disable a Periodic task programmatically?

skyfox

Lifetime Supporting Member
Join Date
Nov 2006
Location
CA
Posts
276
Can this be done based on a pre-selected condition while the PLC is in Run mode?

(Logix 5K V20 - Compactlogix L43 CPU)
 
From the Allen Bradley manual;
One downside of a periodic task is t
hat it always executes regardless of whether or not the input that it is monitoring changes state. This over-execution burdens the controller and lowers the performance of the remaining tasks. To alleviate this situation, event tasks provide a more effective way of balancing the need for high-speed processing with CPU performance.
 
The SSV instruction can modify the execution properties of a task, including whether it's Enabled or Disabled, and whether it processes outputs or not, or to change its execution rate.

Look at the drop-down options in the SSV for the Task Object, and you'll find both then EnableTask attribute and the DisableUpdateOutputs attribute and the Rate attribute.

Can I ask why you want to do that ?
 
A note: strictly speaking, Periodic and Event tasks are different because they're triggered by different things in the operating system.

In the ControlLogix operating system, there is only one Continuous Task, and different CPUs support different numbers of non-periodic tasks. Each of those can be either Periodic or Event type.

The 1768-L43 controller supports up to 16 Tasks.
 
You can terminate the execution of the rest of the periodic task by programming a TND instruction, driven by your control bit, as the first rung of the MainProgram of the periodic task.

Pretty fast, effective, and wholly visible to an observer of the code.
 
Diving even deeper, any Periodic task is going to contain one or more Programs, and each of those Programs can be Inhibited by means of an SSV.

Thus the OP could leave the Task alone, but kill one program and leave others running.

Or do as daba suggested, and disable a Routine within the Program by use of a TND, or a conditional JSR.

But all of these techniques, while they will work, obscure the bigger picture of "Why?". These practices of enabling and disabling code, are more common in other programming languages, like C++, than in PLC programming.

In "disabled" code, OTEs don't reset their outputs, particularly real-world ones, which lead to "duplicate destructive bit" coding. TONs that have been enabled still keep track of time, even if the .ACC isn't "ticking", and so forth.

Not good programming technique.
 
Diving even deeper, any Periodic task is going to contain one or more Programs, and each of those Programs can be Inhibited by means of an SSV.

Thus the OP could leave the Task alone, but kill one program and leave others running.

Or do as daba suggested, and disable a Routine within the Program by use of a TND, or a conditional JSR.

But all of these techniques, while they will work, obscure the bigger picture of "Why?". These practices of enabling and disabling code, are more common in other programming languages, like C++, than in PLC programming.

In "disabled" code, OTEs don't reset their outputs, particularly real-world ones, which lead to "duplicate destructive bit" coding. TONs that have been enabled still keep track of time, even if the .ACC isn't "ticking", and so forth.

Not good programming technique.

May not be, but when asked the questions, you always try to think of why would someone want to do that....

.... I'm still thinking ....

I'd have to research whether a disabled task, or an unscheduled program, is "pre-scanned", My vote would be not, but I'll find out.

The TND solution does mean that the code in the periodic (or event) tasks are pre-scanned.

I have just thought of a scenario where you might want to disable period tasks....

Say you had flow totalisers that had a lot of math in them, you don't need to execute that code if the system isn't running, so it could be taken out of the scan.
 
The "PLC way" to disable code is to put a -|/|- contact on the rungs that you're interested in.

Like you correctly are concerned about, is the logic prescanned or not, and what are the consequences. Neither one of us knows the answer off the top of our heads, and that fact in itself raises red flags that this path isn't a good way to go.

I understand that sometimes, "desperate times call for desperate measures", but proper DESIGN alleviates headaches later on. Too often, people don't want to design (c.f., "why can't AOI's be edited online?") -- they just want to throw a bunch of code at something, get it working, and move onto the next fire / code-sling.
 
OTEs don't reset their outputs, particularly real-world ones,

Maybe I'm not understanding what you mean by "OTEs don't reset their outputs".

If a rung isn't executing, it doesn't affect the status of an OTE instruction at all. It can be stuck at 1 or 0. It doesn't matter what method of "not executing" you are using. Disabling code that controls real outputs directly is very tricky and I don't really see much use for it.

However, if you are referring to how an OTE resets on power failure, it doesn't matter if the code is ever executed. Any tag referenced by an OTE is reset on power up or program to run transition. Unscheduled? Hmmm. not so sure.
 
Last edited:
Any tag referenced by an OTE is reset on power up or program to run transition. Unscheduled? Hmmm. not so sure.

Guess I'm going to have to bite the bullet and test this, I did say I would..... but it's late now, been out for dinner, and just finishing a nice bottle of wine, so now is not a good time I think.

Besides, it's the weekend, so no-one is gonna read this till they get back to work, right ?
 
You're forgetting that we upside-down folk get to Monday morning a lot earlier than you right-way-up folk, daba :p

Fortunately for you, I remember that we had this discussion last year, and you quite comprehensively tested many scenarios, including unscehduled tasks: http://www.plctalk.net/qanda/showthread.php?t=110282&page=4

See posts 56 and onward

Yes indeed, ASF. It's a good job one of us has got some memory left, I had forgotten all about that discussion. 🍻
 
Sorry for the delayed reply. Thank you all for your responses. Reason wanting to Disable/Enable this is customer wants an option to log data from 10 tags at a rate of 100 samples a second for a short period of time at a time of their choosing vs the normal data log rate of 10 samples a second where a test can run for several days. Even though the entire program has a scan time of less than 4ms including the 10ms and 100ms periodic tasks running concurrently with the main task. However, one of the periodic task will be logging data at any given time. Just wanting to figure out a way to disable the 10ms task as they would may be run that for few hours once every six months where as the 100ms task logging data takes place on a daily basis.

Thanks again for everyone's help.

Cheers.
 
Last edited:
Sorry for the delayed reply. Thank you all for your responses. Reason wanting to Disable/Enable this is customer wants an option to log data from 10 tags at a rate of 100 samples a second for a short period of time at a time of their choosing vs the normal data log rate of 10 samples a second where a test can run for several days. Even though the entire program has a scan time of less than 4ms including the 10ms and 100ms periodic tasks running concurrently with the main task. However, one of the periodic task will be logging data at any given time. Just wanting to figure out a way to disable the 10ms task as they would may be run that for few hours once every six months where as the 100ms task logging data takes place on a daily basis.

Thanks again for everyone's help.

Cheers.

Whoa !!

Hold on a minute.....

10 tags, sampled every 10mS isn't going to give you much recording time.

Say each tag was a DINT or a REAL, they are 32-bits, or 4 bytes each.

100 samples per second will therefore be 400 bytes per second.

400 bytes per second is 24,000 bytes per minute, or 1,440,000 bytes per hour.

But that is only 1 tag, you want to store 10 tags, so that would need 14,400,000 bytes per hour.

Your L43 Controller only has 2MB of memory, so clearly you are not going to be able to do this, even for 1 hour, let alone "... a few hours... ". A few minutes is all you are going to get, and that is with not much code and other tags in the controller. Also each data-point will need its own array tag, since the size limit of a single tag is 2MB.

You are going to need an external data capture/historian to achieve this.
 

Similar Topics

Hi all, I'm starting work on a system and the processor for said project is a Control Logix 1756-L82. When I open Logix, however, that CPU is...
Replies
9
Views
2,897
Hello, I have been working on an alarm tracking routine. I take several bits to get a status of a device and load then into an INT Dev_Stat. When...
Replies
0
Views
999
Hi all, I'm working on some Control and Compact Logix A&B PLCs, running Logix5K version 24. I've been doing online edits just fine, but I've...
Replies
6
Views
2,378
From what I can tell, AB's Connected Component Workbench (CCW) does not support CompactLogix L43 with RsLogix v20.xx Software. What are my...
Replies
6
Views
2,655
Hello PLCs.Net! I am trying to use RSLogix5k via windows command line. I would like there to be a script which automatically opens a project...
Replies
1
Views
1,233
Back
Top Bottom