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

LESSON LIST

Autoplay Off
Take topic challenge

Supplemental Videos

Description

Expression tags utilize Ignition's Expression Language to derive a value. They are useful when referencing another tag's value, or when you simply need to apply some conditional logic to your tags.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] In this lesson, we'll talk about Expression Tags. Expression Tags utilize Ignition's expression language to derive their value. Over here we see that I have an OPC tag that's bringing in a temperature in Celsius. I would like to create another Tag and then convert the Celsius value to Fahrenheit, so an Expression Tag would be a good tag in this case. I'll go ahead and select my Tags folder. I'll place this at the root. I'll hit the Add Tag dropdown up top. We'll select New Standard Tag and an Expression Tag. Let's give this tag a name here. So, how about Temp_F for temperature Fahrenheit. I'll change the data type to a floating point number just because of the calculations we're about to do. Similar to how an OPC tag needs an OPC item path to figure out which device connection to pull its value from, an Expression Tag needs an expression. To type an expression, you can click on the little edit icon here and I'll slide over to our little expression editor allowing me to type something. So, to start with, I could just click in here and type the integer 100 which is a valid expression. If I hit Commit down below, you can see that it's applying the setting to the property. I can hit OK here and we see our new Tag and it's statically set to 100 so it's not actually changing or really related to my Temp_C tag at all. So, let's double-click on this tag here and let's modify that expression. So, for that expression property, we'll hit the edit button again. And when we come over here, let's go ahead and make a slight little change. So, we'll start with opening parenthesis here. I'll click on the little Tag button and this will allow us to grab a reference to another Tag in our system. So, if we go to our Tags folder here, we can see that we have our Temp_C Tag which I'll select. I'll hit OK and it will place a reference to that other Tag inside of this expression. So, now we can just type the rest of our formula here. And in all honesty, this is one of the reasons you would want to use an Expression tag if you wanted to take the values on some other Tags, run some sort of calculation and then output some number. So, now that we've updated our expression here, we can hit Commit, we'll hit OK again and you'll see as the value on Temp_C changes, the value on our Temp_F tag is automatically changing and also scaling. Now let's go back to that Temp_F tag there and we can see that there's this Execution Mode property down below. Now full descriptions of these will be in the user manual, but you have three options right now. So, Event Driven, the top item there, basically means that there's something inside of the expression that's going to change. We want to run this expression whenever that changes. So, in this case, the value of our Temp_C Tag is changing which is causing the expression to fire. You can also set it to Fixed Rate, the middle option here, which allows you to determine how often this tag should be updated. Or you could select Tag Group and just simply use the tag group setting above. So, really three ways to determine how to update the value on this one tag.

You are editing this transcript.

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