Reference tag in same UDT

I want to reference value from another tag in the same UDT. It is possible? I have experiment with {[.]…/TagPath} but it’s not working…


Make an expression tag within the UDT. Edit the expression with the little pencil icon. You can then add references to other tags within the UDT to the expression (use “Insert Tag” icon).

hm I might have expressed myself a little strange. I have in the UDT scaling tags - high and low (fskalningLag and fSkalningHog), and I want my process value (PV) to be scaled after those tags. How do I create a reference to another tag within a property, see image.

I think I understand your intent now. You’re wanting to use those scaling tags as the lower and higher scaling limit for your OPC tag?

You’ll have to do the scaling manually using an expression within a derived tag. Start with one tag in the UDT as the raw value from OPC. Then use a derived tag with that tag’s value and scale within the expression using references to your min/max scaling values. Don’t forget to add your out-of-range cases as well.

That’s exactly what I want to do. Will test your solution tomorrow. If I do not manage to make it work, I have to add two parameters - low and high, and then you have to manually enter scaling values. The UDT is intended to represent a sensor with process value, alarm, etc. It would have been nice with an automatic solution for scaling. I have a “OPCItemPath” parameter that specifies the path to a structured data type in the PLC, which contains process value, scaling high, scaling low, alarm levels, and so on.
In the PLC, the value is between 0-65535 (uint) and what it really reflects is scaled in HMI

Another problem is that alarm levels must also be scaled. For example. a sensor that is 0-5m (0-65535) and you set an alarm level of 2.5m which then must be 32767 before it is sent to the PLC

I’m wondering if it might be possible to use tag change script …

I believe you might be able to bind numeric value tag props to udt parameters now in later versions eg 8.1.10, although I could be wrong. You couldn’t before. Would that help you at all? Then you could specify the scaling once in the UDT instance parameters

Wouldn’t you want to also have a scaled value within the PLC for use in your control loops? Use a simple SCP and store it in an internal address and access that via OPC.


This is what we use for all of our PLCs as well. It also provides a single source of truth, rather than multiple sources (consider if you have an HMI and a SCADA system reading the same data). Let the graphic interface do scaling if you must, but make it scale not to engineering units but decimal places for accuracy

For some reason we do not do any scaling in the PLC. So the PV value of a PID controller is between 0-65535 and so is the setpoint. Maybe it’s a strange way to program, but I did not do the program

Even if the scaled values are not used within the PLC, it would still be best to calculate that value in the PLC. Otherwise, you will have to do the expression tag with references to your read value and in/out min/max.

Or just override the rawLow/rawHigh, scaledLow/scaledHigh, and engLow/engHigh props for all relevant tags in the instances… It’s ugly, but better than having duplicate tags imo as these reference tags will all add to the CPU load. The best solution however is obviously still to have engineering values in the PLC… I don’t think I’ve ever seen a PLC program that uses raw unscaled values. Can you go back to the programmer and ask them to fix it for your and everyone else’s sanity?

solved the problem with a tag change script on the tags that contains the value for scaling (high/low). When an instance is created, the script is triggered and updates the parameter. My alarm limit tags then use the parameter for scaling. Maybe not the most beautiful solution, but it works :slight_smile:

1 Like

I think it is the right approach to use Tag Event Scripts.

For what it is worth, it might be more simple to write directly to the scaledHigh property of the tag.

For example in an UDT like this:
Screenshot 2021-11-18 at 17.01.35

The Tag Event Script on the New Folder 1/New Tag will reference the scaledLow of New Folder/New Tag like this:

system.tag.writeAsync(["[.]../New Folder/New Tag.scaledLow"],[currentValue.value])

I would suggest using the Tag Browser interface here! It will build the indirect path for you!

1 Like