Opc interface to the pi system



Yüklə 0.9 Mb.
səhifə7/28
tarix14.08.2018
ölçüsü0.9 Mb.
1   2   3   4   5   6   7   8   9   10   ...   28

Transformations and Scaling


While OPC Servers can perform their own transformations and scaling, some users have found that the desired functions are not filled by their server. In this case, configure the PI points so that the interface will perform transformations and scaling. Note that transformation and scaling happens before the value is compared to the exception parameters for the tag, so the exception parameters are applied to the value that would be sent to PI, rather than to the raw value.
Scaling

Scaling is fairly complex and is controlled by the TotalCode and SquareRoot properties of the tag. Since we're limited in what information we can get about the tag, the Convers attribute is used to carry the Span of the device, and the ExDesc does further duty to carry the device Zero (DZero). The interface can then translate a value from the scale of what the device can send to the scale of the actual tag.

If TotalCode is zero, the only scaling performed is based on the value of SquareRoot. If Square Root is a 1, the value read will be squared before sending it to PI, and for an output value the square root will be taken before writing to the device. If SquareRoot is a 2, the opposite happens: for values read from the device, the square root of the value read will be sent to PI, while output values will be squared before sending them to the device.

If TotalCode is non-zero, some other scaling may be performed, either to transform the value read into another scale of measurement or to apply an offset or conversion factor. Just as the value stored in the tag ranges from (Zero) to (Zero + Span), so too the values read from or written to the device can range from (DZero) to (DZero + Convers). This allows the value stored in PI to be a simple transformation from one scale to another. The SquareRoot attribute can be used to specify that the square or square root of the value should be used rather than the value itself. In other cases, the Convers value may be added to or subtracted from the value, or may be used as a multiplier, or applied as a bit mask. Again, the SquareRoot attribute may specify using the square or square root of the value, rather than the raw value, as the input to the formula.

Scaling is only supported for numeric tags. A tag may be defined in PI as a number, yet the OPC Server reads and writes the Item as a string, and those tags would support scaling. But if the PI tag is defined as a string, any scaling will be ignored.

The table below covers all the scaling formulas currently used. Again, if SquareRoot is a 1 or a 2, the square root or square of the value will be calculated first, and then the formula will be applied.



Convers

TotalCode

SquareRoot

DZero

Operation

0

0

0

Don't care

Value = value

0

0

1

Don't care

Input tags:
Value = (Value)2
Output tags:
Value = (Value)0.5

0

0

2

Don't care

Input tags:
Value = (Value)0.5
Output tags:
Value = (Value)2

Not 0

1

0

Defined

Input tags:
Value = [ (Value – DZero) / Convers ] * Span + Zero
Output tags:
Value = [ (Value - Zero) / Span] * Convers + DZero

Not 0

1

1

Defined

Input tags:
Value = [ ((Value)2 – DZero) / Convers ] * Span + Zero
Output tags:
Value = [ ((Value)0.5 - Zero) / Span] * Convers + DZero

Not 0

1

2

Defined

Input tags:
Value = [ ((Value)0.5 – DZero) / Convers ] * Span + Zero
Output tags:
Value = [ ((Value)2 - Zero) / Span] * Convers + DZero

Not 0

2

0

Don't care

Input tags:
Value = Value * Convers
Output tags:
Value = Value / Convers

Not 0

2

1

Don't care

Input tags:
Value = (Value)2 * Convers
Output tags:
Value = (Value)0.5 / Convers

Not 0

2

2

Don't care

Input tags:
Value = (Value)0.5 * Convers
Output tags:
Value = (Value)2 / Convers

Not 0

3

0

Defined

Input tags:
Value = (Value / Convers) – DZero
Output tags:
Value = (Value + DZero) * Convers

Not 0

3

1

Defined

Input tags:
Value = ((Value)2 / Convers) – DZero
Output tags:
Value = ((Value)0.5 + DZero) * Convers

Not 0

3

2

Defined

Input tags:
Value = ((Value)0.5 / Convers) – DZero
Output tags:
Value = ((Value)2 + DZero) * Convers

Not 0

4

0

Defined

Input tags:
Value = (Value - DZero)/ Convers
Output tags:
Value = (Value * Convers) + DZero

Not 0

4

1

Defined

Input tags:
Value = ((Value)2 - DZero)/ Convers
Output tags:
Value = ((Value)0.5 * Convers) + DZero

Not 0

4

2

Defined

Input tags:
Value = ((Value)0.5 - DZero)/ Convers
Output tags:
Value = ((Value)2 * Convers) + DZero

Not 0

5

0

Don't care

Input tags:
Value = Value + Convers
Output tags:
Value = Value - Convers

Not 0

5

1

Don't care

Input tags:
Value = (Value)2 + Convers
Output tags:
Value = (Value)0.5 - Convers

Not 0

5

2

Don't care

Input tags:
Value = (Value)0.5 + Convers
Output tags:
Value = (Value)2 - Convers

Not 0

6

Don't care

Don't care

Input tags:
Value = Value AND Convers
Output tags:
Value = Value AND Convers

Not 0

7

Don't care

Don't care

Input tags:
Value = Value OR Convers
Output tags:
Value = Value OR Convers

Not 0

8

Don't care

Don't care

Input tags:
Value = Value XOR Convers
Output tags:
Value = Value XOR Convers




Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   10   ...   28


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©muhaz.org 2017
rəhbərliyinə müraciət

    Ana səhifə