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


Autoplay Off


Tag Scaling


Learn how to configure scaling on tags, to convert their numeric values into more desirable formats.

Video recorded using: Ignition 8.0


(open in window)

[00:00] Sometimes when configuring our tags we might want to represent the value of a tag in a different way than it is being provided by the tag's source. As a simple example, maybe a sensor is giving us a reading in inches when we want it in feet. Ignition offers a set of tag properties to automatically convert a numerical value from one context to another. To demonstrate I've set up two OPC tags here. Notice they both have the same value, this is because they're both pointing at the same OPC address. Now the value we're receiving from the PLC at this address is 250 and it's an integer. However, what the PLC is trying to represent is in fact the value 2.5. That is, the last two digits of this value should come after a decimal point. So for this example I'm going to configure one of my OPC tags to reflect this. So I'm going to right click on my tag, and select edit tag, and I'm going to come down into my numeric properties category and I'm going to find the scale mode property. Now, by default the scale mode is set to off, meaning we aren't doing any conversions on this value, but if I open up the drop down we can see that I have a few different scaling options to choose from. Now the most common scaling option is linear, and in fact, that's what we'll need here, but you could find details on all of our scaling options and the functions that they use, in the user manual. So, when I select my linear scale mode we see that a few more properties appear in the tag editor, notably raw low, raw high, scaled low, scaled high, and clamp mode. These five properties broadly dictate how we want to change our value. Now, 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, so the actual value that our tag will hold. In essence, you could think of linear scaling as uniformly mapping one distribution, the raw distribution, onto another distribution, the scaled distribution. So in essence, by default, if the value from the PLC falls between zero and 100, it will fall between zero and 10 on the tag. Essentially we're dividing by 10. Now in may case, if I move the tag editor a bit here so we can see my tag, the incoming value is 250. So let's just say it can fall between zero, on the low end, and 1,000 on the high end. So I'll change this to 1,000. And now remember, the actual value I'd like to represent is 2.5. So if the highest input value is 1,000, the highest output value should be 10. Meaning I can leave the scaled low and scaled high properties at their defaults. So just to see this in action I'm going to click okay, and we can see that an icon has appeared to indicate that our value is being scaled, and we note that the value on the tag is now three. However, this clearly isn't quite what we wanted. We wanted a value of 2.5 not three. However, we're seeing a value of three because we've neglected to change the data type of our tag. We can't represent 2.5 as an integer so we're rounding it to three. But if I go back into my tag editor and I change the data type from integer to float, and I click okay. We can see that the value is now correctly showing as 2.5. Now there's another caveat as well, and it's the reason I brought in a second OPC tag. So if I update the value on this tag, let's say I set it to four. Note that the value written back to the PLC was not four but 400, as indicated by our unscaled tag below. This is because when you do a tag write on a scaled tag the value is scaled back into the raw range. Meaning our value between zero and 10 was scaled back into a value between zero and 1,000. Now there's one other property I glossed over. I'll go back into my tag, and we see again there's a clamp mode property. Note that 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. Now with a clamp mode of no clamp, we will gracefully continue to scale values even if they fall outside of the raw range. For example, a value of 1,100 will scale to a value of 11. But if I configure our clamp mode, let's say I do clamp both, which clamps both the high and the low values, and then I'll click okay to demonstrate, and now I'll write to the unscaled value just to demonstrate here. So I'll write a value of 1,100. 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. As a result, it's set to the max scaled high of 10. As we can see, tag scaling can be very useful for converting PLC driven values into a human readable format.

You are editing this transcript.

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