Scan Class Optimization

Hi everyone,

I have a bit of a unique situation with a couple potential solutions and wanted to get some feedback.

There is a template that could be dropped on many different windows. That template is reading a bunch of tags at a relatively fast rate through scripting and storing them in a local dataset. By “bunch of tags” I mean roughly 250 instances of a UDT with about 10 tags each so 2,500 every second. I would like those tags’ scan classes to only be running when a window with this template is open.

What I’ve tried:

  • I don’t think I can use the leased scan class as my understanding is I’d need all 2,500 tags bound to something on the template / window
  • I tried a driven scan class where I increment / decrement a memory tag in scripting as things open and close and the driving tag is this memory tag being greater than 0. I’ve tried this on the template itself looking at the “componentRunning” property value changing as well as the “internalFrameActivated/Closed” events of the window. Both kind of work but if I kill the project in task manager the closed events don’t seem to fire. I tried handling this in a client shutdown script but that didn’t fire either. So I think as long as I can’t reliably handle a force close then this path won’t work at all.

Thanks in advance,

If you’re reading the values through scripting, why not just use system.opc.readValues() in your script instead of (I’m guessing) system.tags.readAll() ?

Hi Pat,

Thanks for your reply. You are correct that my script is using using system.tag.browseTags then .readAll.

The main goal is to minimize the interaction between the gateway and AB ControlLogix as I’m nervous the load this would put on it might affect some of the other things it’s doing. If I take this approach would I have each client hitting those 2500 tag on the PLC directly? I was taking the tag / scan class approach as I thought despite the number of clients it would give me a steady baseline of how much the gateway reads are affecting the PLC.

Use the Leased scan class. The Leased scan class executes at the fast rate when any of the tags it contains are subscribed and visible in a Client window. So, create a Seconds tag that reads the seconds value from your PLC, add it to your UDT Scan Class and bind the Seconds tag to your window.

I have a smart conveyor system that reports values from the PLC and those values specify the location of 256 carriers on the conveyor. Each carrier on the conveyor is an instance of my Ignition UDT. The script is reading 2 OPC tags in each those 256 instances to populate a local dataset which is then used to draw the carriers on a paintable canvas and show them move in realtime. So I wouldn’t have any of the tags visible on the window.

When I tried using the leased scan class I set each of the UDT properties up to use it but I didn’t see them go “Leased” on the Tag Provider status window unless I went into a single property of a single instance and bound it to something on the window.

I don’t think I’m doing a great job explaining this so maybe these pics will help. In this example I only set one property of my UDT up with the leased scan class. So across my 256 UDT instances I have 256 tags with the leased scan class and obviously right off the bat none of them are leased because I’m not doing anything with them yet besides reading them in my script:

[attachment=3]no leased tag.png[/attachment]

[attachment=2]no binding.png[/attachment]

When I create a label bound to just one instance’s property that has the leased scan class, I only see that tag of that particular instance go leased:

[attachment=1]leased tag.png[/attachment]


So like I said in my original post, it seems like I would need to bind each property of each instance to something on the window. Unless I completely misunderstood your suggestion.

I’m a bit confused. I’m guessing that your script is reading the SQLTags values and storing it in a local dataset. Why not create a custom property on the window and bind the SQLTag/s to that property. That should tell Ignition to run a Leased scan class at the subscribed rate.

I think that makes two of us on the confused front :scratch:

My template does have an internal dataset property that gets populated from the script. But if those tags are set to the leased scan class then the script isn’t reading anything because the scan class is not getting leased.

What type of property are you suggesting I create and what property of what UDT instance or instances would I bind? Again, my understanding of these is I’d need to bind a tag from each of my 256 instances to accomplish what you’re suggesting and I don’t want 256 custom properties. I created a single string custom property on my template and bound a value from one UDT instance which makes me only see data from that particular instance.

Just a thought on your driven scan class idea. What if you changed the tag that your window writes to, to be a memory tag of type “Date” and then set up an expression tag of type boolean that compares the the current time (now) to the Date tag? If the current time exceeds the Date memory tag by some set amount of time, the boolean tag switches to false. You would have to have the client window periodically writing to the Date memory tag in order to prevent the expression tag from evaluating to false.

As long as your gateway is running the scan class will stop after the set amount of time, it doesn’t matter how the Client is shutdown.


Nice and simple - works perfectly. Thank you!