This lesson is part of the Tags in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off

LESSON

Reference and Derived Tags

Description

In lesson we'll look at Derived and Reference Tags. Two types of Tags that can mirror the value of another Tag, providing a layer of buffering between the value received by an OPC address and configurations in Ignition.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] <v Instructor>In this lesson,</v> we will cover derived tags and Reference Tags. A reference tag is a tag that pulls its value from a source tag. In other words, there's some other tag in the system that the reference tag is referencing to obtain its value. A derived tag references the value of another tag as well. However, a derived tag's value can have an expression tied to it, allowing you to perform calculations to derive the tags actual value. Additionally, you're able to configure a write expression, which is used to evaluate the value that will be written back to the source tag. Here I have an OPC tag named status. What I will do is create a reference tag for this guy. I will right click on my tag browser, on the location where I want my tag to be added. I will go down to New Tag, and select the option to add a Reference Tag. I will name it status_ref, status_reference, set it's Data Type to be the same as my Status Tag Integer, and set it's source to point to my status OPC tag like so. I will hit OK to finish my configuration and I will see both my OPC tag and my newly created reference tag, holding the same value.

[01:09] If my status tag changes value, my status reference tag will reflect this change. Why is this useful? Well, generally speaking, when you're developing a project, OPC tag paths may change. I could very well have my status tag bound to an LED display like so. If I move my status tag to be inside this new folder here, my LED displays tag minding will break. So will my reference tag for that matter since its source tags path just changed. If I wanted to fix this problem, I would have to go to my LED display's value property and change its binding to point to my status tag's new location. I would actually have to do this for every component bound to my status tag, which can be very slow and painful. Let's put a status tag back to where it was. What I can do instead is bind my LED display to my status reference tag. Now, if I move my status tag again, both my LED display and my reference tag will break as expected.

[02:04] However, instead of having to reconfigure bindings in my vision or perspective resources, I can simply re-point my reference tag to my status tag's new location. And just like that, I can fix the problem without having to rework any bindings. And of course, for the reference tag here, you can set the source path to a memory tag or other types of tags. If you're trying to develop a project and you don't have access to live PLC data, you could just create a number of reference tags with an equal number of memory tags to be used as source tags. Then, when you're deploying the project live, you can replace the memory tags with OPC tags and simply update your reference tags to point to the new OPC tags instead. That way, you don't have to touch any of your screens at all to reconfigure any bindings. How do Derived Tags difer? To find out, let's first create a memory tag named mem1. I will leave this data type as integer and set its value to 20. I will create a new derived tag. I will name it mem1_derived, and set it's source path to point to my mem1 tag.

[03:09] I will click OK to finish my configuration and I will see both tags here. So if my design is read and write mode, I can write to my memory tag or source tag and my derived tag will reflect this change. And of course, if the derived tag changes in some way, that change will be written back to the source tag. So right now, derived tags are looking pretty similar to reference tags. If we go back to the derived tag settings, you will begin to see the differences. Derived tags have a read expression and a write expression. The read expression determines the value that should appear on the derived tag itself. The write expression allows us to configure what value should be written back to the source tag, should the derived tag change in value. Let's explore how this will work a little further. Let's imagine that my mem1 tag holds a temperature value in degrees Fahrenheit, and I want my derived tag to show this temperature in degrees Celsius. Well, to do that, I will need to configure my derived tags read expression to take in my source tag's value and convert it from Fahrenheit to Celsius.

[04:08] The expression will look like this. Now if I write to my derived tag a temperature in Celsius, I don't want the Celsius reading to be written back to my source tag which expects this value temperature in Fahrenheit. So I have to first convert that write back value to Fahrenheit before it is written back to the source tag. This means my read expression must take in a value and convert it to Fahrenheit. This will make my expression look like this. What we have done, is configured my derived tag to always see my source text temperature reading in degrees Celsius. But if I write back to my derived tag, that value will be converted back to Fahrenheit and then written back to the source tag. I will click OK to complete my changes. I will then write a 32 to my mem1 tag, my derived tag shows a value of zero which is exactly 32 degrees Fahrenheit converted to degrees Celsius. If I write a 42 my derived tag, a 104 will be written back to my mem1 tag because 104 is 40 degrees Celsius converted to Fahrenheit.

[05:04] Both my read and write expressions have use of the entire expression language. So my expressions have infinite configurability as far as what value should be shown on the derived tag, and what value should be written back to the source tag, the ability of tag referencing and the ability to configure read and write expressions, make reference and derived tags a useful part of the tag system.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.