Applies To: |
|
Summary: |
If you try to trend a Cicode expression or a digital tag, Citect will set the trend scale to 0 - 32000. This is because Citect would normally get the scaling from the tag definition (in the VARIABLE.DBF database), but digitals and simple Cicode expressions do not have a scale. (Also if an expression returns a Real value, this value may get rounded.) |
Solution: |
The following example illustrates how you
can trend an expression. The example uses a REAL value with a scale
of 0 to 4.
First, define a real tag to use for scaling as follows. Variable Tag Name : REALTAG Note : the above tag will use two words, ie V496 and V497. (In this example, the PLC type is TIWAY.) Next, write a Cicode function for the expression as follows. The return type is a REAL (You can use INT if required.): REAL
END Third, define a Trend Tag as follows: Trend Tag Name : TRENDTAG1 (You can use the format and other fields if required.) When Citect finds a variable tag name in the expression field, it will use the scaling of this tag to scale the trend. This is the only use for the tag. If you need to trend several expressions, you can use the same variable tag for the scaling, providing the scale is the same. The following example trends a digital variable Digitals in Citect do not have scales. If a digital is trended, the scale would be set to 0 - 32000 and it would need to be rescaled at runtime. If you use an INT type tag in the trend expression field, Citect can then use the scale of this tag for the trend. A 2 - 2 scale is a suitable scale to use. First, define the Digital Tag as normal, and an Integer Tag as follows: Variable Tag Name : DIGITALSCALE Next, write a Cicode function (that will be used in the Trend expression field) as follows. INT
END Third, define a Trend Tag as follows: Trend Tag Name : TRENDTAG2 (You can use the format and other fields if required.) BIT_1 is the digital to be trended. The value of the digital is simply passed to the function and returned without any manipulation. When Citect finds the first variable tag name in the expression field (DIGITALSCALE), it will use the scaling of this tag, to scale the trend. This is the only use for the tag. |
Keywords: |
Related Links
Attachments