I have a lot of tags, nearly 42,000 that I would like to clear the value of before writing to them. These are memory tags with a mix of Integer, Boolean, String, and Float datatypes. Before I explain why let me lay out the design.
Note: I will probably end up mixing terms trying to explain without divulging any protected information. I am in the testing phase so these tags aren’t being written to the PLC, yet.
These tags make up the “recipe system”. I have block transactions set up to pull recipes from our SQL database to these tags.
There are 2 types of block items
Header
This has 23 folders and each folder has Tag 1...99
Recipe_#
There are 70 Recipes Recipe_1_ to Recipe_70_ each one has 14 folders with Tag 1..99
These are used in SQL-Bridge block transactions. There are triggers used to cascade from one block to the next. That works fine to write the tags that have records in the SQL database. It takes some time but that’s not a concern. My current solution is an Excel spreadsheet that uses VBA and RSLINX to write the values.
The header structure holds some basic data about the recipe. Each Recipe_# folder holds up to 99 steps for the recipe. However, not all 99 steps are used and the database only contains the records for defined steps. I.E. there aren’t blank placeholder records. Recipes can change from time to time and steps may be changed, removed, added.
If a recipe is changed and steps are removed the previous values don’t get cleared when the block transactions are performed.
Let's say Recipe 42 has 23 steps. A change come down and the recipe now only has 18 steps. The transaction will overwrite steps 1-18 but the tag values for 19-23 are not overwritten/cleared/erased/set to default as there is no record in the database for those steps.
They just don’t get written. I don’t see a way to have the block transaction “write default value if no record returned”. This functionality appears to be different than the options:
Set NULL tags values to default
set NULL DB values to default
as these appear to only perform their action if a record is returned with NULL values.
Due to the design by others previous to me there is no ‘end step’ defined for a recipe , the PLC just goes till it runs out of commands. This would mean the PLC would attempt to run steps 19-23 as there would be data.
My goal is to allow a “user” in Ignition to perform this entire procedure via 1 button if I’m not available. Ignition will also have the ability to view each recipe which will be new to them.
SOLUTIONS?
As I see it the only option available would be to create a script that iterates through all these tags and sets its value to the default value. This would probably be nested loops but I haven’t convinced myself this is right way.
edit:
It may be easier to add an ‘end step’. However, that requires many changes to the PLC, SQL, current “recipe builder”.
The logic that looks for the value = 0 to indicate end of recipe is “locked” in an AOI. While I change the AOI it will require a download which will require shutting down pretty much the entire facility.
Anybody got a better idea?