OPC Gateway Resources
Click Here to see the OPC Gateway Console layout.
Click Here for more information about OPC Bridging and Data Transfer
Data transforms are configured using mathematic expressions that you type, import, or construct using the expression editor. You can define one expression for each mapping between a source and target point (called an Item Mapping).
The screen shot below shows the expression editor with a quadratic expression defined for an Item Mapping. When the source point changes and/or is polled, the quadratic equation is executed, substituting the X with the current source point value. The result is written to the target point.
After entering your expression, click on the Test Expression tab to validate the expression syntax and execute the expression using sample data you provide. The screen shot below illustrates the Test Expression tab.
Data Transform Examples
For a comprehensive list of sample transformations, download and install the OPC Gateway demonstration software and read the on-line help topic Gateway Configuration Tool > Reference > Data Transforms > Data Transform Examples.
Engineering Unit Conversion Example
To convert a value to/from engineering units, use the following expression: ( ( (X – Xlow) * (Yhigh – Ylow) ) / (Xhigh – Xlow) ) + Ylow
Where:
Xhigh = high range limit for the source item value Xlow = low range limit for the source item value Yhigh = high range limit for the target item value Ylow = low range limit for the target item value
Return to Examples List
String to Integer Conversion Example
To convert a string to an integer value, use the following expression as an example:
if ( X = 'AUTO', 0, if ( X = 'RSP', 1, if ( X = 'CASC', 2, if ( X = 'MAN', 3, -1 ) ) ) )
This example uses a sequence of nested If statements to convert the mode of the loop from the string label to the equivalent integer value. If a match is not found, the function returns the value ‘-1’.
Return to Examples List
Bit Masking to Retrieve a Logical State Example
To extract the value of an individual bit in an integer value, use the following expression as an example:
X & @20
This example extracts a single bit (6th bit from the LSB) from the input value. If the bit is set, the function returns a non-zero value. If the bit is not set, the function returns zero (0). The resultant value can then be coerced and written to a target item with a boolean data type.
Return to Examples List
Square Root Extraction Example
To linearize an exponential value, use the following expression as an example:
sqrt( X / 32000 ) * 90 + 10
This example converts the raw input value from a range of 0..32000 to a range of 0..1. The square root of the value is then calculated. Finally, the value is converted to engineering units with a range of 10..100.
Return to Examples List
|