Dynamic "Device connection" inside a UDT "OPC Item Path"

Hello everyone,

I’m making my first project in Ignition and the first thing I’m doing is preparing all the different UDT of the different objects I use inside my Siemens 1500 PLC (like valves, motor, analog signal etc…).

The problem I’m having right now is the dynamization of the device connetion at the start of the device connection since I’ll be using all these UDT in multiple project.

What I thought of doing was creating a “Memory tag” in the project called “PLC_Connection” and use the string inside this tag as the name of the Opc connection but it gives me error and I can’t understand why.

Here’s the “OPC Item Path” of one tag inside my UDT:

ns=1;s=[{PLC_Connection}]PLC.Blocks.DB_SPV_AIN.{InstanceName}.Bipolar

If I write manually the name of the plc connection inside the expression the tag work just fine, while if I change the tag “PLC_Connection” to the same value and add the tag in the expression, it doesn’t work.

Mirko Cerin

In a UDT, {PLC_Connection} is, in this case, expected to be a UDT parameter, which you can create a default value for, and override for the UDT instance as needed. Is there a particular reason you're not using the UDT parameters?

I’m not using a UDT parameter because I usually have around 20 to 30 object of this istance of this UDT in every project I make, not counting the other UDTs, so I was looking for a way to change the connection only once instead of doing it in every istance.

Make all the UDTs, export the tags to file, open in a text editor, Find/Replace "[device]" then reimport tag file. Super simple, super easy. You're only setting this up once, so why make it recalculate every time?

1 Like

It simply didn’t cross my mind abount exporting all the udts, and I also thought in case I add new instances while working it would be faster to do with the connection already set in the project.

You can export only select tags if you want, then when you bring them back in you can use the import tool to define how they come back in. That way you make your new UDTs, export only them and modify those ones and reimport.
Having random tags that are embedded in paths of other tags leaves a maintenance nightmare as none of the people following you will realise what the tag is, so maybe they delete the "unused" tags and everything disintegrates.

1 Like

I gave it a quick test in my own ignition designer, and only parameters are allowed to be bound in the OPC Item Path.

Your options are either using UDT params and updating them on every instance as necessary, or exporting, running find/replace on the json, and reimporting like Dave suggested.

If your naming convention has a decent pattern, you could also use the multi-instance wizard while doing the bulk setup.

1 Like

Ok, then I’ll procede with the export/import of these tags.

Thanks both of you for your help.

1 Like

Alternatively you could make a derived UDT that overrides the default parameter for each device that this UDT will connect to.

For instance The UDT Block would be the base then you could have Block_A and Block_B that are derived from the base UDT and override the default PLC_Connection parameter to “A” and “B” respectively. Then make all your instances for A and B from those derived UDTs.

1 Like

Hi,

I tried it and it’s a pretty good workaround, thank you.

There’s only one problem, somehow, when I added the derived parameter to Block_Awith the same name let’s say, I removed the overrided parameter in Block_A and now all the tag don’t work. Is this a problem already known? And if it is, is there a solution to it?

No, don’t remove it, don’t create a new one. Just change the value. You’re essentially creating a derived UDT (connected copy) that has a different default value.

Ah ok, I tried but a couple of instances didn’t work, but there was an error with the Symbol name.

Thank you again for your suggestion.