I've been building a UDT that contains a number of parameters. Is there a way to copy or bind the parameter values to OPC tags? I've been reading the docs and forum most of the day but am coming up empty-handed.
Thank you,
Chris
I've been building a UDT that contains a number of parameters. Is there a way to copy or bind the parameter values to OPC tags? I've been reading the docs and forum most of the day but am coming up empty-handed.
Thank you,
Chris
What exactly do you mean "bind the parameters to OPC Tags"?
Can you show an example of what you are attempting?
I've tried a number of things that didn't work and removed them so I'll just explain what I'm attempting.
I have a number of PLCs in the field running identical programs. They're used for monitoring buildings and controlling lighting. I created a UDT that contains all my alarm tags and other tags I want to monitor. It also contains a number of parameters that define how each building is set up.
For example, I have a parameter called "Area Lighting Enabled." I want to write the parameter's value to the OPC tag for the PLC.
Normally you wouldn't use a parameter for changing data like that. You would set up a UDT for one of these PLCs and use parameters to redirect the OPC paths of the tags to a particular PLC with indirect references.
You then directly access the tags that now all point at the correct PLC.
Is there a reason you are trying to use parameters for this?
I'm not sure I understand what you're describing in the first paragraph.
I started using the UDT so I can define items such as building number, building name, etc., and use the parameters in alarm messages. Every PLC is running the same program and I deploy a new data instance based on that UDT for each building.
It occurred to me I could expand on that and use parameters for far more and simplify what I currently do. Although all the PLCs are running the same program, each building is different. One such difference would be the use of risers vs FM200 systems.
Try posting a screenshot of your UDT and explain what you want to achieve, it's hard to understand without an example.
Sure thing!
Example: I want the value in AREA LIGHTING_Enable to be written to the value in the OPC tag on the right.
What are you using to change the parameter value to enable/disable it?
You would bind the tag (the one on the right) to the parameter, not the other way around, although you can bind some things to parameters... pre-defined parameters and custom parameters. You have to manually type them in.
I do think the parameters are being used here in an odd way that probably isn't optimal, but there will be a full solution to the initial use case if we can get the right picture in front of us.
I haven't created any screens to change those values (yet). I've been modifying the values in the tag browser.
That's what I'm struggling to understand... how to bind the tag to the parameter. I've been through the page you linked to, which I appreciate, at least a dozen times today but can't seem to grasp it for some reason. lol
I'm using parameters to generate alarm messages just fine. I just can't figure out how to write the parameter value to the OPC tag.
Normally a parameter is like a config setting for a UDT, you make a parameter that sets up the UDT in some way, one common example is using a parameter called "PLC" and this would contain the device name you want to reference with the UDT. Then you would write your OPC Tag paths in the UDT using {PLC} in the square brackets so that all your tags update when you manually set the PLC name in the UDT.
Anything you are binding to from your screens in Ignition would be one of the tags, not a parameter.
In your example, you would bind the Ignition component to the Area Lighting Enabled tag and that binding would directly change the tag value over OPC when written to.
Parameters are not normally set by Ignition, tags are routinely written to by Ignition.
It might help if you think about the distinction between tag configuration and tag live data flow. UDTs are tools for configuring lots of tags conveniently, once. After that, the data flows through tag values.
Tag properties control how data flows through tags (and into history, and scaling, and engineering units...), but properties are intended to be constants at runtime. UDT parameters are also intended to be constants at runtime, in part because tag configuration/reconfiguration is expensive.
Scripting can write to UDT parameters at runtime, and write to pretty much any tag properties as desired, but those cause tag reconfiguration. That latter means it is not a good idea. Avoid it.
You'll have to use a script or maybe a combination of derived and memory tags.
The UDTs are my constants that I want to send to the PLCs. I'm not looking to go from PLC to UDT parameters. I'm trying to go the other way with the data.
I suppose I can continue with my other plan...
It's dirty, but it works and it sounds like Ignition isn't capable of doing what I want in this case.
UDTs don't get sent to PLCs. Only tag values can be sent to PLCs. UDT parameters and tag configuration properties are entirely internal to Ignition.
Sounds like you think a UDT can be treated as a recipe for your PLC. They cannot. UDTs are recipes for Ignition.
Thank you, Phil, and you are correct. I was absolutely hoping I could use the UDT parameters as recipes. I'll just continue with my original method.
A parameter change cannot easily (in any straightforward fashion) write its value to an OPC tag, but an OPC tag can be monitored to write its value back to a parameter (via tag change script). Much of your current structure can work within Ignition if you are ok with the OPC tag value being your source of truth, and the parameter value updated automagically thereafter...
If remote configuration (from an HMI) is permitted for your applications, I'm certain that Ignition capable of developing an elegant & straightforward interface.
I came up with a solution that works, although not ideal since I have to create twice the tags. I still need to add more parameter categories but this basically does what I needed to do.
I created a folder in my UDT for Local Parameters (containing reference tags that reference the parameters) and another folder for the PLC tags. I then created the following script that runs periodically:
pathBuildings = "[GR_Buildings]Buildings"
Buildings = system.tag.browse(pathBuildings)
for Building in Buildings:
Categories = ["Area Lighting"]
for Category in Categories:
tags = system.tag.browse(str(Building['fullPath']) + "/Pars/Local/" + Category)
for tag in tags:
valPar = tag['value'].value
tagPLC = str(tag['fullPath']).replace("/Local/", "/PLC/")
valPLC = system.tag.readBlocking(tagPLC)
if str(valPLC[0].quality) == "Good":
if valPar != valPLC[0].value:
system.tag.writeBlocking(tagPLC, valPar)