How do I build a scheduled task script

Hi everyone,

I’m new to ignition and am setting up my first system with it. I’m replacing an old SCADA system and am trying to replicate some of the old functionality right now.

On our old system, we were able to have the operators schedule a command (2 actually) to be sent to one of the PLCs. First they would select a time and date in the future (08:00:00 03/28/2016 local time, for example). They would then specify a recipe number (86 [integer]). Finally, I had a boolean for an ‘enable’ to prevent an event from accidentally firing if they entered the current date and time (the default provided by the old SCADA was the current timestamp, so this was an occasional accidental entry). These three items were stored in what ignition would call Memory tags.

The system would compare the current time to the set time and if they were equal and the ‘enabled’ tag was true, it would write two items to the PLC in separate writes. First it would write the recipe number integer to a specific register in the PLC. Then, it would set a bit (coil) in the PLC to command it to actually start. After this, it would clear the ‘enabled’ memory tag.

What would be the best way to replicate this functionality in ignition? Something somewhat flexible would be good. We had 4 different pieces of equipment that we could set to start recipes like this, but I could see that expanding to more equipment in the future. I would also need this to run regardless of client status, so I’m assuming I will need some sort of gateway script to handle this. I’m running 7.8.2 if it makes a difference.

Thanks in advance,
Brian

Hi, Brian. Welcome to the forums! :slight_smile:

Ignition, you’ll find, is a very powerful system. I could think of two ways right off the bat, and a third one came to me as I’m typing. I’ll stick to the first two. :wink:

The first way (very briefly) is to make a separate tags for everything (OPC tags, recipe inputs, triggers, enables) and script through a gateway timer script (or tag change script). Tag change scripts can also be attached directly to tags so it blurs a bit in that instance. This method works, but can get a bit messy if you don’t organize your tags.

So option 2 is my recommendation.

You can do this by using a User Data Type (UDT). UDT’s can let you put all your pertinent tags for a machine in one data type. All tag types can be used in a UDT and organized. As an example:
[attachment=4]2016-03-25_9-17-34.jpg[/attachment]
The “Trigger” tag is an expression tag that compared the date/time and if it is enabled:
[attachment=3]2016-03-25_9-21-08.jpg[/attachment]
The scripting is in a tag event script that runs if the value has changed.
[attachment=2]2016-03-25_9-22-03.jpg[/attachment]
Now, you can create a new instance of the UDT for each machine. In each instance, you just point the OPC tags to the desired location.
[attachment=1]2016-03-25_9-28-29.jpg[/attachment]
[attachment=0]2016-03-25_9-32-39.jpg[/attachment]

Hope this helps!

Regards,

I would probably create a table in the database that you would insert the schedule to, then have a gateway timer script running to check if any runs are due. You could even have a column that marks a run completed after the script runs. Like this you could have an table full of runs that can easily be queried for completed runs by machine and can see any upcoming runs.

Thanks for the warm welcome and ideas, guys!
I think for now I will implement Jordan’s method. It’s easier for me to see all the moving parts, and I need to get this function running ASAP. I will definitely keep the database method mentioned by diat150 in mind. I think I will have uses for that style of scheduling down the road.

Thanks again!
Brian

1 Like