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

Supplemental Videos

Description

Learn how to configure child UDTs inside of a parent UDT.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] When configuring UDTs, Ignition offers us the ability to add a UDT instance as a member of another UDT, that is, we have the ability to nest UDTs inside of each other. This can be particularly useful when working with larger or complex UDTs, or when we have a few UDTs that we'd like to combine into one. To demonstrate, I'll be working with the sensor data type we've been exploring in earlier lessons. Our sensor data type has temperature, pressure, and humidity tags, and uses a SensorNum parameter to hook the tags up correctly to OPC items. for this lesson, let's imagine that we're working with sensors for tanks containing some kind of gas. We'll devote this video to creating a new data type for the tank, which includes the sensor data as well as some supplemental tank info. Since we already have our sensor structure sorted out, let's create our tank UDT. So I'm going to find the UDT definitions tab, in the tag browser, and click the plus icon at the top, then select new data type.

[01:05] The first thing that we'll need is a name for our type. So I'm just going to call it tank. Now I want the tank UDT to take a parameter, because it's going to use my sensor type, and my tank will need to know which sensor to use. So next to parameters, I'm going to click the pencil icon, and then I'm going to hit the plus icon, to add a parameter, and let's just call it sensor. It's just going to be a number, but I'm going to resist calling it SensorNum, for reasons that will become clear. And finally, I don't need to set the value inside the definition. It will be set on each instance of the UDT. So I'm just going to hit commit. The first member I'm going to add to my UDT is a volume tag. Something that will just keep track of the capacity of the tank. My PLC isn't giving me this value. So I'm just going to make a memory tag for it. I'll make sure I have the route of my tag structure selected. And then I'm going to click the plus tag icon, and add a new memory tag.

[02:02] Once that tag is added, I'll give the tag a name, so maybe volume, and then I'll just set a sensible default value on the tag. Something like 50. Now that we have some information for the tank, let's add our sensor UDT into the structure. So I'll click the third icon here, the stripes tag icon, which will allow me to select a UDT to embed. So in this dialogue, we have a filter along the bottom if we need to, but I'm just going to select my sensor UDT directly, and click okay. I'll begin by naming this UDT instance. So I'll just find the name field here and set it to sensor. Now remember this sensor UDT, does take a parameter called SensorNum, and we've configured a sensor parameter on our tank UDT that we want to pass through. So to configure this, I'm going to specify a value for the SensorNum parameter in the nested UDT. So I'll click the pencil icon here, and find the SensorNum parameter. Note that when we're referencing a UDT parameter, we need to include it in curly braces.

[03:03] So the reference should be sensor, like this, but that's all that we have to do to pass a parameter from the outer tank UDT into the inner sensor UDT. Now one important note here, I could actually use my outer parameter in my inner UDT directly. I don't necessarily have to do this pass through. However, this allows the sensor UDT to stand on its own if we need it to. On a related note, if my inner and outer parameters have the same name, the inner one would be used, wherever the parameter is referenced inside this nested UDT. I've taken care of how to use different names for the parameters, just to avoid confusion here. So with that, I'm going to hit commit. Now all we have to do to create our data type, is hit okay. And we see that the tank data type has appeared. I'll conclude by creating an instance of my data type. So to create an instance, I'm just going to find the tags tab, then click the plus icon at the top, select data type instance, and then select tank.

[04:04] I could just call this tank two. And then let's specify the sensor parameter. So clicking the pencil icon here, and let's just set a value of two, then we'll hit commit, and then, okay. We can see that our UDT instance has been created. And if I expand it, and then expand the sensor instance, we can see that all of the values are coming through successfully.

You are editing this transcript.

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