Using Tag Value in OPC Item Path

Is it possible to use the value of a tag in a UDT in an OPC Item Path of another tag in the same UDT?

ex: OPC Item Path: [MyDevice]1.HRUS{[.]Address}

If not, is there another way to avoid hard coding Addresses for each tag, when there is a consistent format based on an index.

ie:
Parameter 1 Value is on Register 10, Quality is on Register 11, and ID is on Register 12.
Parameter 2 Value is on Register 20, Quality is on Register 21, and ID is on Register 22.
Parameter 3 Value is on Register 30, Quality is on Register 31, and ID is on Register 32.
etc.

Thank You,
-Trent

I’m not sure I understand your application. You could access the tags directly with scripting and possibly use that to end up with what you need.

[code]index = system.tag.read(“Folder\Index”).value

tagPath0 = (’[PLC]Array[%d].value1’) % index
tagPath1 = (’[PLC]Array[%d].value2’) % index
tagPath2 = (’[PLC]Array[%d].value3’) % index

tag = system.opc.readValues(‘Ignition OPC-UA Server’, [tagPath0,tagPath1,tagPath2])

value1 = tag[0].value
value2 = tag[1].value
value3 = tag[2].value
[/code]

Thanks for the reply Tim.
Your example is helpful.

I’ve found two other threads with similar questions.
[ul][li]Reference UDT Member within same UDT[/li]
[li]Indirect Addressing through an Expression or an OPC tag[/li][/ul]

Similar approach, but with expression tags instead of script.

When you set up a UDT you can specify parameters that will be substituted in the address. Each UDT instance has its own parameter values. In your case, you’d want a parameter for the start address of each unit. The ‘Value’ uses {start} directly, ‘Quality’ uses {start+1}, and ‘ID’ uses {start+2}. The parameter cannot come from a live process values, but it doesn’t sound like you need that. Look at this topic for a similar situation and UDT example file.

I am trying to create a datatype which is able to use parameters to dynamically create an OPC Item Path where parameters are: DB for db number and Size and Index,

Problem is the value of the Item Path is not able to be an expression so Size * Index for the offset gets evaluated a 2*3 rather than 6.

Is there any way around this?

Is scripting the only way? Should I perhaps have an memory array tag for an entire DB that gets updated on a cyclic script? My Data Type tags would the reference indexed values of this array. This sounds revolting. How would I write out values.

Alternatively, does the Siemens driver support arrays at all?

Thanks everyone.

John

Whatever else you come up with (I am not a Siemens expert), you should know that Ignition doesn’t have array tags, regardless what driver is involved. It has what it calls array tags, but they are really just bit arrays expanding the contents of single elements of an integer type.

1 Like