Change OPC Tag to Memory Tag in Data Type Structure

I have a Data Type structure defined in my project that houses all tags for a pad. Most of the tags are OPC tags and read in values from a PLC. One value in particular should be able to be either OPC or a memory tag if that value does not exist in the PLC. Is there any way to modify a tag type within a tag structure for just a single instance? I don’t want to modify the base tag structure as its used 150 times in my project. I’d just like to tweak it for 4 or five instances where the real-time value does not exist and a memory tag would be more appropriate. I could use a holding register in the PLC, but for at least one instance we are not allowed to write to any of the PLC registers which is why I was looking at changing the tag type to a memory tag.

I’m not aware of any way to override a tag type within a UDT. You could, however, make a copy of the base structure with the desired changes and use it for the instances than need the memory tags. You’ll want to use indirect binding to UDT members based on a UDT path (rather than UDT tag binding) on components within your project for this solution to work.

Thanks,

I was afraid of that. By making a copy of the base structure and modifying the handful of tags to be memory based I’ll need to assign the OPC address for the other 75 tags. I am using in-direct tagging everywhere so that shouldn’t be an issue for me.

This might be possible, although I don’t know if I would quite call it supported, in 8.0 via system.tag.configure().

What I can think of is to create 3 tags:
OPC Tag, Memory Tag, Expression Tag

The expression tag can then evaluate the quality (or other properties) of the OPC Tag, and refer to the Memory Tag if the OPC Tag is not available

Thanks , I’ve done something similar to this in other places, But I’m trying to avoid it here if at all possible.

I'm not sure if this helps in your case, but whenever I've got a bunch of similar tags to add I'll use a script something like the code below (you'd use system.tag.configure() instead of system.tag.addTag if you're on version 8). It can get more complex with dictionary lookups, etc. as needed and I find it a lot quicker to tweak the script as needed than to configure tags manually for all but the fewest tags. Even configuration changes are sometimes accomplished more quickly by deleting old tags and creating a new batch configured as desired via scripting.

parentPath = 'Batch/Recipe'
tagType = 'UDT_INST'
accessRights = 'Read_Write'
enabled = True
attributes = {'UDTParentType':'recipeIng'}
parameters = {'server':'Ignition OPC-UA Server', 'rootAddress':'[SLC 5/04]'}
for i in range(1,6) + range(9,14):
	name = 'admix%d' %i
	amountPath = '{rootAddress}F40:%i' %(i+49)
	overrides = {'ingAmount':{'OPCItemPath':amountPath},
		'ingWeighOrder':{'Enabled':False}}
	system.tag.addTag(parentPath=parentPath,
		name=name,
		tagType=tagType,
		accessRights=accessRights,
		enabled=enabled,
		attributes=attributes,
		parameters=parameters,
		overrides=overrides)

P.S. The above is above is far from the way I'd setup batch recipes... but sometimes you have to work with what's there.

2 Likes