OPC Items

An OPC Item represents a single data point that can be read from or written in a specific PLC address. Each OPC Item consists of a unique Tag Name and Tag Address (PLC address), which identifies the location of the data for OPC Server to retrieve on behalf of the OPC Client. MES extends this standard OPC functionality by enabling OPC Items to be associated with other entities in the master data configuration. This allows to record the data against the appropriate Machine, Production Counter, Stop Reason, and Variable.

Some entities that can be mapped to OPC Items are dependent on the data that is being captured. For example, when capturing Machine Events, Stop Reasons are used to map to the PLC values or codes with the corresponding event. Regardless of the OPC Item Type, each OPC Item is linked to a Machine, and all captured data is timestamped when the item is read by the OPC Client.

OPC Items are classified with an OPC Type, which determines the additional information required to configure the OPC Item successfully.

Each OPC Item is configured to sit within a single OPC Group. In addition to the Tag Name and Tag Address, several properties are available across most OPC Item Types, including:

  • Multiplier: Applies a constant scaling factor to the raw value. For example, if the value is read in tenths of a degree, a multiplier can convert the multiplied value to degrees.
  • Formula: Performs transformations on the OPC value using mathematical expressions and references to other OPC items. See Formulas topic below.

Counter

OPC Counters are used to capture count-based data and map the captured counts to counters, including:

  • Production Counters
    • Production
    • Rework
  • Scrap Counters
    • Scrap Reasons

A counter increases from a defined starting value (typically 0) to a maximum value, after which the counter rolls over and begins again from the starting value.

Note: OPC Counters must never reset manually. Operators sometimes reset the counter at the beginning of a production run or a shift. This is not required as the counts are now stored and viewed in MES.

If a resettable count is required for operational purpose, configure an additional PLC tag to track the same value without performing manual resets.

The following settings are specific to Counter-type OPC Items:

  • Offset: Offsets the raw value by a specific number, if required.
  • Low Value & High Value: Define the valid operating range of the counter to enable accurate count calculations:
    • Low value: Usually set to 0, 1, or another value, depending on the PLC implementation.
    • High value: (rollover):
      • Usually the size of the datatype.
      • For example, if the integer is 16-bit, the count increases to 32,768 before rolling over.
      • An incorrect High value definition can cause rollover detection to occur too early or too late, resulting in inaccurate production counts.
  • Production Counter or Scrap Reason: Maps the count that is read from the OPC item to the target counter. Select the Counter Type to indicate whether the item maps to a production counter (or rework) or to a scrap reason on the Counter Type field.
  • Acceptable Rate of Change: Defines the maximum expected change between consecutive readings. See Acceptable Rate of Change topic below.
  • Delta Mode: Determines how to handle negative movements in the counter value. The delta is the difference between any two sequential readings. There are two options available for negative counts:
    • Interpret negative movement as roll-over.
      • The count is never negative.
      • The rollover value is used to calculate the difference.
      • If the counter is manually reset, a large incorrect number is calculated as the value because the system will roll over at the rollover value.
    • Allow negative movements.
      • This option allows negative counts to be recorded.
      • Useful in specific production scenarios where for example the sensor could detect a reverse movement (a reel, for example), and treating this as a rollover would be incorrect.

Machine Event

OPC Machine Events are primarily used to automatically capture downtime through OPC signals. In addition to downtime tracking, Machine Events can be used with OPC Actions to trigger automated processes, such as starting a production run, or printing an inventory label.

A single OPC item per machine is configured to track the status of the machine. MES does not support multiple OPC Items as status sources for the same machine, nor can a basic status be read from one OPC Item and a detailed reason code be read from one or more other OPC items.

The status code read from the PLC is mapped to downtime reasons. See Reason Code Mapping to Machine Events topic below.

The following settings are specific to Machine Event–type OPC Items:

  • Lookup Job Details: Required when OPC Actions are triggered from this OPC Item. When OPC Actions are not used, this setting can be disabled to provide a small performance improvement.
  • Machine Stop Recording Mode: Defines how MES records downtime when machine status values change. Although, the same setting exists on the plant settings, individual OPC Items can override the plant setting when required. The available options include:
    • Write Every Stop Reason: Records every transition in the signal value received from the PLC as a separate downtime period. Transitions within a single period of physical downtime are represented as separate, however, contiguous downtime periods. This option is useful to track the detailed history of behavior.
    • Write First Slow To Stop Reasons Only: Records the first transition from a slow state to stopped state. Freeze the initial downtime reason while continuing to track movements between slow speed and stopped states.
    • Write Last Stop Reason Only: Records the last reason derived from the most recent stop signal. The downtime period is updated whenever the stop reason changes. This option is useful when the transitions are not relevant, and the latest reason represents the actual cause of the stoppage.

Reason Code Mapping to Machine Events

Reason Code Mappings are used to map PLC status codes to the appropriate machine operating state for Machine Event OPC Items. Each PLC code is mapped to a running state or to a specific downtime reason, to accurately record machine status and downtime events.

As a minimum, two mappings must be configured:

  • A code representing the running state
  • A code representing the stopped state

Additional mappings can be configured when:

  • The PLC provides enough information to identify specific causes of downtime. For example, separate status codes indicate that a safety guard is open, an emergency stop button has been pressed, or another machine condition has occurred. These codes can be mapped directly to the appropriate downtime reasons in MES.
  • Multiple PLC codes represent the same machine state. For example, if both values 1 and 10 indicate that the machine is running, both codes can be mapped to the same Running state in MES.

Parameter

OPC Parameters are used to capture process parameter values, such as machine speeds, temperatures, and other operational setpoints related to the machine and process.

The following settings are specific to Parameter OPC Items:

  • Variable: Maps the process parameter value to corresponding Variables in MES. Variables must be defined before configuring the OPC Item. Select the Variable that represents the process parameter being captured.
  • Head/Sample/Position Numbers: These identifiers distinguish multiple values of the same parameter from a machine. In most cases, the default value of 1 is sufficient. When multiple measurements exist for the same parameter, assign unique combinations of Head, Sample, and Position values to differentiate the readings. For example, if the temperature is measured on the left side, right side and central areas of a machine, use Position values of 1, 2, and 3 to identify these readings.

Text

Text OPC Items are used to store information that is not mapped directly to in-built OPC Client data capture functionality, however, required as part of OPC Actions.

Typical examples include:

  • A production order number to execute
  • An inventory to consume into a process
  • An operator performing a specific action.
Note: MES does not provide built-in processing or interpretation of data stored in Text OPC Items. Instead, these items act as containers for information that can be referenced and utilized by OPC Actions or custom integrations. This flexibility allows additional operational data to be passed into automated workflows without requiring dedicated OPC Item types.

Digital

Digital OPC Items are used to capture non-downtime events to be logged either as Machine Events in MES mapped to a pre-defined Machine Event Type, or as a one-off Process Parameter reading mapped to a pre-defined Variable.

Digital Machine Event Items can only accept binary values, 1 or 0.

The following settings are specific to Digital OPC Items:

  • Digital Type: Indicates that the destination of the event is a Machine Event or a Process Parameter
  • Event Type: Available when the Digital Type is set to Machine Event. Select the Machine Event Type that MES automatically records when the event is detected.
  • Type: Available for Machine Events only and defines the condition that triggers the recordings of the events. The available options are:
    • On data change: Records an event only when the OPC Item reaches a specified value. Configure the Transition To Value setting to define whether the trigger occurs when the value becomes 0 or 1.
    • On data condition match: Records an event only whenever the value changes, including on a defined value of 1 or 0. Set the Transition To Value in this mode.
  • Variable: Available when the Digital Type is set to Process Parameter. Select the Variable that receives the parameter value when the event is detected.
  • OPC Alarm: Enables alarm generation when the configured event occurs. Alarm generation can be used independently or alongside Machine Event and Process Parameter recording. When this option is enabled, specify the Alarm Text that MES stores with the alarm record.

Meter

Meter OPC Items are used to automatically record energy meter readings, by linking to a pre-defined Meter Item. See Meter Items.

The following settings are specific to Meter OPC Items:

  • Meter Item: Identifies the target source for the energy meter reading.
  • Offset: Applies a fixed value to adjust the raw value, if required.
  • Low Value & High Value: Like Counters, meter readings can be configured with lower and upper boundary limits.
  • Acceptable Rate of Change: Like Counters, Meter Readings can be protected from invalid source data.
  • Convert From Raw Value: Enables the meter readings to be treated as a Counter. When enabled, you can configure the Delta Mode as with Counters. Else, you can disable this option.

Constant

The Constant OPC Item type does not represent a value read from an OPC Server. Instead, Constant are used to define a fixed value that can be used in formulas. This helps avoid hard-coded references to magic numbers in formulas. For example, if a formula requires the number of seconds in an hour, a Constant item can be created with a value of 3600 and referenced wherever required.

The settings for Items of this Type include:

  • Formula Constant: Specifies the fixed value to be used in formulas.
  • Tag Address: A dummy address must be assigned, as Constant items do not retrieve data from an OPC Server.

Speed

Speed items do not store values associated with dedicated target. Instead, Speed items can be captured to support formulas on other items. For example, calculating a production quantity from a speed or for bespoke monitoring, if required.

Acceptable Rate of Change

To protect MES production, scrap, rework counter data from unexpected jumps, resets, or other invalid PLC counter values, you must configure an Acceptable Rate of Change. This setting defines the maximum valid rate at which a counter can increase, expressed as a quantity per second. Any counter value that exceeds the configured rate is automatically ignored as an invalid counter value.

For example, if a counter that can validly increase by a maximum of 2 units per second and the OPC Client reads the counter every 2 minutes, the maximum permissible change between consecutive readings is: 2 × 120 = 240 units. In this case, any increase greater than 240 units is treated as invalid and is rejected.

When the maximum rate is based on normal operating conditions, instead of a strict physical limitation, consider adding a small buffer to the acceptable rate of change for continuous improvement, process optimizations, or higher-than-usual machine throughput.

Appropriate limits vary by process, no single standard can be defined, however, to calculate an appropriate value, review the delta value or estimate the normal process speed of the process, and use that value as a baseline:

(max delta value / read interval) * 1.2

For example:

  • 100 / 120 = 0.83 units/second
  • 0.83 * 1.2 = 1 unit/second

In this example, applying a 20% buffer results in a recommended Acceptable Rate of Change of approximately 1 unit per second.

Formulas

OPC Items can be fed by calculation using other OPC Items, such as adding two counters together to calculate a total count. When configuring formulas, follow these rules:

  • Reference OPC Items using the Tag Name enclosed within double dollar signs ($$). For example: $$Counter_A$$ + $$Counter_B$$
  • OPC Items referenced in a formula must meet the following naming requirements:
    • Do not include spaces in the Tag Name. Instead, use underscores (_).
    • Do not include mathematical or logical characters, such as brackets, +, -, &, =.
    • Do not use special or extended characters, such as (ü).
    • Do not begin the Tag Name with a numeric character, as this causes issues with mathematical operations. For example, using the tag name "1245021_ABCD_B8" in a mathematical formula fails. Instead, use "ABCD_B8_1245021".
  • All OPC Items referenced in a formula must belong to the same OPC Group as the calculated OPC Item.
  • Formula-based OPC Items do not require a valid Tag Address, however, as the field is mandatory, recommendation is to use the Tag Name as the Tag Address.
  • A formula cannot reference the OPC Item in which the formula is defined. When a calculation requires the current item's value, create a second placeholder OPC Item with the same OPC Group and reference that item. The placeholder OPC Item does not require a valid Tag Address.
  • When using the "if" function:
    • Nested ‘if’ statements are not supported.
    • Decimal values are not supported within the function

If results are off by an order of magnitude, use the Multiplier option, to adjust values, as required.

Note: Formulas are not supported for Machine Events.

Formula elements consist of two forms; Operators and Functions.

Operators

Operator Description
= Returns 1 if both sides are equal
< Returns 1 if left side is less than the right
> Returns 1 if left side is greater than the right
<= Returns 1 if the left side is less than or equal to the right
>= Returns 1 if the left side is greater than or equal to the right
<> Returns 1 if the left side is not equal to the right
& Returns 1 if both sides are not equal to 0
?? Returns 1 if one or both sides are not equal to 1

Functions

Function Description
abs Absolute value of a specified value or expression
acos Returns the angle whose cosine is the specified number
asin Returns the angle whose sin is the specified number
atan Returns the angle whose tangent is the specified number
bitwise Returns the AND of two numbers
ceiling Returns the smallest whole number greater than or equal to the specified number
cos Returns the cosine of the specified angle
cosh Returns the hyperbolic cosine of the specified angle
exp Returns e raised to the specified power
floor Returns the largest whole number less than or equal to the specified number
log Returns the logarithm of the specified number
log10 Returns the base 10 logarithm of the specified number
lshift Rotates the left side bits left by the value of the right side
round Returns the value nearest the specified value
rshift Rotates the left side bits right by the value of the right side
sign Returns a value indicating the sign of the specified value
sin Returns the sine of the specified angle
sinh Returns the hyperbolic sine of the specified angle
sqrt Returns the square root of the specified number
tan Returns the tangent of the specified angle
tanh Returns the hyperbolic tangent of the specified angle
min Min (expr1, expr2, expr(n)) Min returns the minimum value among the list of evaluated expressions. The list may contain 2 or more elements. Highest current test uses 50,000 values in the expression list
max Max (expr1, expr2, expr (n)) Max returns the maximum value among the list of evaluated expressions. The list may contain 2 or more elements. Highest current test uses 50,000 values in the expression list
if

If (binary expression, true expression, false expression)

If the value of binary expression is non-zero, the true expression evaluation is returned. Else, the false expression is returned.

testbits Returns 1 if the same left side bits are set as the right side
LastValue LastValue (TagName) returns the previously held value of the specified Tag Name (must convert to Double data type)

OPC Item Actions

An OPC Item Action is a UDI C# script or stored procedure that executes when defined condition is met.

By default, the action is executed only if the value of the OPC Item has changed. Additional settings can be configured to further control the execution criteria. When the specified condition evaluates as true, the configured script or stored procedure runs automatically.

OPC Item Actions provide a powerful and flexible way to extend standard OPC data collection functionality. These actions can be used to perform custom processes in addition to standard data capture activities, such as process parameter recording, downtime recording, and production counting.

OPC Actions are always executed after all standard data capture actions are completed. This sequence allows custom logic to access and process data stored in:

  • OPC Item records
  • OPC Item History records
  • Any other database tables or data sources updated by the standard data capture process