Result
Understand how to use a calculated tag to apply a scaling factor, such as when handling unit of measure changes from a retrieved data source item.
Tutorial steps
- Steam Production Tag (kg/s) - Create a tag to determine the steam production of the boiler
- Steam Production Tag (ton/s) - the difference between this tag and the one above is the Unit Of Measure (UOM, or Unit)
- Apply a Scaling Factor - Use the scaling factor field to change the steam production from kg/s to tons
- Preview the calculated tag's data - Confirm the effect of the scaling factor on the results
Unit Conversion with Calculated Tags
Now that you have a measure specifying the Boiler’s design rating, you are going to create a tag for the Boiler’s actual production.
Locate the 010-FT-001.PV Boiler Steam Output tag from the Historian, drag it across to the Model View, and drop it onto the "Steam" metric. Rename the new tag to "Production". Double-click the new tag …
Notice the unit of measure has been set to kg/s since this is the engineering unit of the 010-FT-001.PV tag in the Historian. You need to compare the Boiler’s design rating in ton/hr to the Boiler’s actual output. To do this you are going to convert the actual output from kg/s to tons, and you are going to use a Calculated Tag to achieve this.
A Calculated Tag is a tag that can reference other tags and apply a calculation to the value/s of the source tag/s. The calculation can be simple or complex, with the possibility of applying your own functions (which you'll learn more about later).
In this case, you want to convert the values in the Steam Production (kg/s) to ton/hr. The first conversion will be from kg/s to ton/s
To do this, drag the Production tag you created from the Model View onto the Calculator icon in the Flow Zone.
Note what has happened...
Flow has created another tag for you and has named it Steam, after the metric name. In the bottom left of this new tag's icon, you can also see that the Retrieval Type is different from the source tag - the icon is an "=" symbol, which represents a calculated tag/measure in Flow.
The tag also has a fault, indicated by the red dot in the top left corner. If you hover your mouse over something that has a fault, Flow will explain what the problem is in a tooltip, in this case, the problem is that the "Calculation has not been validated". This means that you have not confirmed that the calculation expression that is configured has no errors. Of course you haven't confirmed the expression - you didn't even type it in! Let's see what expression has been configured for you by double-clicking this new tag to open its Editor, and then expand the Retrieval tab ...
By default, the calculation is expression is the source tag multiplied by 1. The unit of measure is also taken from the source tag. Change the Unit from kg/s to ton/s
Then, update the calculation to convert from kg to ton, by dividing the kg/s tag by 1000. That is, Steam.Production (kg/s).Value / 1000
The checkmark in the top right corner of the calculation editor is blue, which indicates that the expression requires validation (this aligns with the fault that we noted in the Model View for this calculated tag). Click the blue checkmark to validate the calculation - this will confirm that the expression you entered can be processed by Flow (it does not check that your unit conversion is indeed accurate!)
Now hit the Refresh Now button in the Chart View ...
Now, the chart line has changed to 0.0 ton/s. The problem is that we are only formatting to 1 decimal place, while the value in ton/s is smaller than can be displayed with a single decimal place. Change the format to 0.000 and hit the Refresh Now again. Note that the value is now displayed - you may need to Zoom Out to see more data points.
Right-click in the whitespace of the Chart View, and you will see the option to add the "Steam.Production (kg/s)" source tag as a trend/pen on this chart. Go ahead and select it ...
If there was more than one source tag to this calculated tag, you would have the option to add any/all of them as pens to the chart. This is very useful when you want to verify that your calculation expression is correct. In this case, it looks like we are indeed converting from kg/s to ton/s
Remember, the values that you see in a tag are not being stored in the Flow database; they are being retrieved from the data source and, in the case of a calculated tag, the calculation expression is being applied in real-time and then displayed on the chart view. The advantage of this is that you can combine tags from different data sources that you require for a calculation without using any licensed measures. It is only when you use your tags/calculated tags in a measure that you use a single licensed measure.
At the same time, you can display the values of your tags and calculated tags in Pass-through charts and you can even use the Flow API to read these values from your data sources via Flow (more about that in the Flow Advanced Training).
Close the editor and rename this tag "Production".
Note that you now have two tags named "Production". This is allowed only because they have different Units (one is kg/s and the other is ton/s) - if you forgot to change the unit of this tag, Flow will give you an error explaining that you cannot have two tags with the same Name and Unit.
You are now going to create another calculated tag from the calculated tag you just created! Drag your Production (ton/s) measure onto the Calculator Icon in the Flow Zone. Accept the default name of "Steam" for now.
Open the tag's Editor, and change the Unit to ton/hr. Then update the calculation expression to be Steam.Production (ton/s).Value * 3600
Validate the expression, close the editor, and rename the measure to Production. Note that this is now the third Production tag/measure that you have, and they all have different Units. Rearrange your tags in the Model View by dragging them and dropping them to create the following structure.
Looking at this model, you can see how each tag "builds up" its information - the first tag retrieves the data from the data source in kg/s, the second tag converts this data from kg/s to ton/s, and the third tag converts the ton/s values to ton/hr. All of these conversions are done at execution time - to "persist", or store, values, you need to aggregate them into an interval measure (e.g. a minutely/hourly/shiftly/etc measure).
Our end goal is to calculate the Hourly boiler efficiency, and to do this we need to compare the actual hourly boiler production to the boiler rating (which we already have in our Hourly Production Rating measure).
To complete this tutorial, create the Hourly Production (ton/hr) by dragging the Production (ton/hr) tag onto the Hourly icon in the Flow Zone (similar to what you did in Tutorial 9 to create the Hourly Temperature measure). Open the measure's editor after you've created it and look at the Retrieval Tab.
Here you see that this hourly measure is going to take the values from the source tag Production (ton/hr) and it is going to apply a time-weighted Average to the values every hour for that hour, resulting in a single value per hour that is the number of tons produced in that hour, i.e. the ton/hr
There is also the option to apply a Scaling Factor at this point - by default, this is 1.
But wait, you may wonder if you could have just applied the Scaling Factor to the original Production (kg/s) tag? Couldn't you just have applied a scaling factor of 3.6 (3600s/hr / 1000kg/ton)? The answer is yes! For training purposes, and to show how Calculated Tags can be used, you've built your model the way you did.
Deploy this new measure. Confirm that it is retrieving data and creating an hourly summary value of Production.