LESSON

Tag Scaling

Description

Learn how to configure scaling on Tags, which converts their numeric values to more desirable formats.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] Sometimes when configuring our tags, we may want to represent the value of a tag in a different way than it's being provided by the tag source. For example, perhaps a sensor is giving us a reading in inches when we really want to see it In feet. Ignition offers a set of tag properties to automatically convert a numerical value from one context to another through tag scaling. Scaling will take the raw value of a tag driven by an external source such as a PLC or SQL Query, apply a mathematical formula and use the resulting converted value as the value of that tag. To demonstrate this process, we'll start with these two pre-configured OPC tags in my tag browser. You'll notice that both of my tags have the same value. This is because they're both pointing at the same OPC item path. The value we're receiving from the PLC is 250, and it's an integer.

[01:02] However, what the PLC is trying to represent is the value 2.5. So for this example, I'm going to configure one of my OPC tags to reflect this. In the tag editor, we can go to the numeric properties to find the scale mode property. The scale mode is set to off, meaning we aren't doing any conversions on this value, but, if I open up the dropdown, I have a few different scaling options to choose from. The most common scaling option is linear, and that's what we'll need here. Depending on your needs, you can find details on all our scaling options and the functions they use in the Ignition User Manual. I've attached links to those resources below this video. So, when I select my linear scale mode, a few more properties appear in the tag editor: raw low, raw high, scaled low, scaled high, and clamp mode. These properties broadly dictate how we want to change our value. Raw low and raw high refer to some typical bounds for the incoming value, while the scaled low and scaled high properties refer to bounds on the output value, the actual value that our tag will hold. Linear scaling maps the raw distribution onto the scaled distribution.

[02:17] By default, if the value from the PLC falls between zero and a hundred, it will fall between zero and 10 on the tag. Essentially, we're dividing by 10. In my case, the incoming value is 250, so let's just say it can fall between zero on the low end and a thousand on the high end. So I'll change this raw high value to a thousand. The actual value I'd like to represent is 2.5, so if the highest input value is a thousand, the highest output value should be 10. This means I can leave the scaled low and scaled high properties at their defaults. To see this in action, I'll click okay, and we can see that an icon has appeared in the tag browser to indicate that our value is being scaled.

[03:04] The value on the tag is now three. But we wanted a value of 2.5, not three. We're seeing a value of three because we've neglected to change the data type of our tag, The data type of the tag must match the data type of the scale value. We can't represent 2.5 as an integer, so we're rounding it to three, currently. To fix this, I'll go back into my tag editor and change the data type for that tag from integer to float. I'll click ok to save the changes, and after a moment, we can see that the value is now correctly showing as 2.5. Now, there's another scenario that might arise as well, and it's the reason we have a second OPC tag. If I update the value on the scaled tag and set it to four, you'll see that the value written back to the PLC was not four but 400 as our unscaled tag below shows. This is because tag scaling works both ways. When you do a tag write to that scaled tag, Ignition will scale that value in the opposite direction, back into the raw range, before writing to the PLC.

[04:12] This means that our value between zero and 10 will scale back into a value between zero and a thousand. There's one other helpful property we can examine. I'll go back into my tag and we'll look for the clamp mode property. This property is important because even though I've specified raw low and raw high values, there is nothing preventing the PLC from giving us a value outside of this range. With a clamp mode of no clamp, we'll scale values gracefully, even if they fall outside of the raw range. For example, a value of 1100 will scale to a value of 11. If we configure our clamp mode and select Clamp_Both, it will clamp both the high and low values. I'll click ok, and now I'll write 1100 to the unscaled tag value, just to demonstrate. You can see that because of the clamp mode, we prevented the value on the scaled tag from going above the scaled high value we configured.

[05:13] As a result, it's set to the max scaled high of 10. As we can see from these examples, tag scaling can be very useful for converting PLC-driven values into a more precise, human readable format.

You are editing this transcript.

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