Transformations and scaling
- Last UpdatedNov 22, 2022
- 6 minute read
- PI System
- PI Interface for OPC HDA 1.6.2
- Interfaces
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 point, so the exception parameters are applied to the value that would be sent to PI, rather than to the raw value. The transformation and scaling calculations are the same as the PIOPC interface.
Transformations
To transform the value to another scale of measurement, to apply an offset or conversion factor, or to perform bit masking, configure the settings as shown in the following table. If squareroot is set to 1 or 2, the square root or square of the value is calculated first, then the formula is applied.
If squareroot is set to 1 or 2, the square root or square of the value is calculated first, then the formula is applied.
|
Convers |
TotalCode |
SquareRoot |
Dzero |
Input points |
Output points |
|---|---|---|---|---|---|
|
0 |
0 |
1 |
No effect |
(Value)2 |
(Value)0.5 |
|
2 |
No effect |
(Value)0.5 |
(Value)2 |
||
|
Non-zero |
1 |
0 |
Defined |
[ (Value – Dzero) / Convers ] * Span + Zero |
[ (Value – Zero) / Span] * Convers + Dzero |
|
1 |
Defined |
[ ((Value)2 – Dzero) / Convers ] * Span + Zero |
[ ((Value)0.5 – Zero) / Span] * Convers + Dzero |
||
|
2 |
Defined |
[ ((Value)0.5 – Dzero) / Convers ] * Span + Zero |
[ ((Value)2 – Zero) / Span] * Convers + Dzero |
||
|
2 |
0 |
No effect |
Value * Convers |
Value / Convers |
|
|
1 |
No effect |
(Value)2 * Convers |
(Value)0.5 / Convers |
||
|
2 |
No effect |
(Value)0.5 * Convers |
(Value)2 / Convers |
||
|
3 |
0 |
Defined |
(Value / Convers) – Dzero |
(Value + Dzero) * Convers |
|
|
1 |
Defined |
((Value)2 / Convers) – Dzero |
((Value)0.5 + Dzero) * Convers |
||
|
2 |
Defined |
((Value)0.5 / Convers) – Dzero |
((Value)2 + Dzero) * Convers |
||
|
4 |
0 |
Defined |
(Value – Dzero) / Convers |
(Value * Convers) + Dzero |
|
|
1 |
Defined |
((Value)2 – Dzero)/ Convers |
((Value)0.5 * Convers) + Dzero |
||
|
2 |
Defined |
((Value)0.5 – Dzero)/ Convers |
((Value)2 * Convers) + Dzero |
||
|
5 |
0 |
No effect |
Value + Convers |
Value – Convers |
|
|
1 |
No effect |
(Value)2 + Convers |
(Value)0.5 – Convers |
||
|
2 |
No effect |
(Value)0.5 + Convers |
(Value)2 – Convers |
||
|
6 |
No effect |
No effect |
Value AND Convers |
Value AND Convers |
|
|
7 |
No effect |
No effect |
Value OR Convers |
Value OR Convers |
|
|
8 |
No effect |
No effect |
Value = Value XOR Convers |
Value = Value XOR Convers |
Scaling
Scaling is only supported for numeric points. A point may be defined in PI as a number, yet the OPC Server reads and writes the Item as a string, and those points would support scaling. But if the PI point is defined as a string, any scaling will be ignored.
Scaling is fairly complex and is controlled by the TotalCode and SquareRoot properties of the point. Since we’re limited in what information we can get about the point, 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 point.
If TotalCode is zero, the only scaling performed is based on the value of SquareRoot. If SquareRoot 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 point 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.
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 |
No effect |
Value = value |
|
0 |
0 |
1 |
No effect |
Input points: Value = (Value) 2 Output points: Value = (Value) 0.5 |
|
0 |
0 |
2 |
No effect |
Input points: Value = (Value) 0.5 Output points: Value = (Value) 2 |
|
Not 0 |
1 |
0 |
Defined |
Input points: Value = [ (Value - Dzero) / Convers ] * Span + Zero Output points: Value = [ (Value - Zero) / Span] * Convers + Dzero |
|
Not 0 |
1 |
1 |
Defined |
Input points: Value = [ ((Value) 2 - Dzero) / Convers ] * Span + Zero Output points: Value = [ ((Value) 0.5 - Zero) / Span] * Convers + Dzero |
|
Not 0 |
1 |
2 |
Defined |
Input points: Value = [ ((Value) 0.5 - Dzero) / Convers ] * Span + Zero Output points: Value = [ ((Value) 2 - Zero) / Span] * Convers + Dzero |
|
Not 0 |
2 |
0 |
No effect |
Input points: Value = Value * Convers Output points: Value = Value / Convers |
|
Not 0 |
2 |
1 |
No effect |
Input points: Value = (Value) 2 * Convers Output points: Value = (Value) 0.5 / Convers |
|
Not 0 |
2 |
2 |
No effect |
Input points: Value = (Value) 0.5 * Convers Output points: Value = (Value) 2 / Convers |
|
Not 0 |
3 |
0 |
Defined |
Input points: Value = (Value / Convers) - Dzero Output points: Value = (Value + Dzero) * Convers |
|
Not 0 |
3 |
1 |
Defined |
Input points: Value = ((Value) 2 / Convers) - Dzero Output points: Value = ((Value) 0.5 + Dzero) * Convers |
|
Not 0 |
3 |
2 |
Defined |
Input points: Value = ((Value) 0.5 / Convers) - Dzero Output points: Value = ((Value) 2 + Dzero) * Convers |
|
Not 0 |
4 |
0 |
Defined |
Input points: Value = (Value - Dzero)/ Convers Output points: Value = (Value * Convers) + Dzero |
|
Not 0 |
4 |
1 |
Defined |
Input points: Value = ((Value) 2 - Dzero)/ Convers Output points: Value = ((Value) 0.5 * Convers) + Dzero |
|
Not 0 |
4 |
2 |
Defined |
Input points: Value = ((Value) 0.5 - Dzero)/ Convers Output points: Value = ((Value) 2 * Convers) + Dzero |
|
Not 0 |
5 |
0 |
No effect |
Input points: Value = Value + Convers Output points: Value = Value - Convers |
|
Not 0 |
5 |
1 |
No effect |
Input points: Value = (Value) 2 + Convers Output points: Value = (Value) 0.5 - Convers |
|
Not 0 |
5 |
2 |
No effect |
Input points: Value = (Value) 0.5 + Convers Output points: Value = (Value) 2 - Convers |
|
Not 0 |
6 |
No effect |
No effect |
Input points: Value = Value AND Convers Output points: Value = Value AND Convers |
|
Not 0 |
7 |
No effect |
No effect |
Input points: Value = Value OR Convers Output points: Value = Value OR Convers |
|
Not 0 |
8 |
No effect |
No effect |
Input points: Value = Value XOR Convers Output points: Value = Value XOR Convers |