Omron EIP Tag Reader

High-performance EtherNet/IP CIP communication library for Omron NX/NJ PLCs

Introduction

The OmronEipReader.dll is a .NET Standard 2.0 library designed for dynamic interaction with Omron Sysmac controllers. It uses CIP Explicit Messaging to read and write variables directly by their Tag Names, eliminating the need for hardcoded memory addresses.

Key Capabilities:

  • Read/Write by variable name (Global Variables).
  • Automatic data type conversion (.NET ↔ CIP).
  • Parsing of Sysmac Studio variable export files (.txt / .csv).
  • High-performance asynchronous polling engine.
  • Handled data alignment for Omron memory structure (BOOL padding).

Setup & Initialization

Add the OmronEipReader.dll as a reference to your C# project. The library targets netstandard2.0, compatible with .NET Framework 4.6.1+ and .NET Core / .NET 5+.

using OmronEipReader;

// Create an instance
var reader = new OmronTagReader("192.168.250.1");

Connection Management

Async Method

ConnectAsync()

Establishes TCP connection and registers an EtherNet/IP session.

await reader.ConnectAsync();
if (reader.IsConnected) {
    Console.WriteLine("Connected!");
}
Method

Disconnect()

Gracefully closes the session and TCP socket.

reader.Disconnect();

Reading Tags

Method

ReadTag(string tagName)

Reads a single tag and returns a TagValue object.

TagValue result = reader.ReadTag("MyVariable");
if (result.Success) {
    Console.WriteLine($"Value: {result.Value}");
    Console.WriteLine($"Type: {result.DataTypeName}");
}
Method

ReadTags(IEnumerable<string> tagNames)

Reads multiple tags sequentially.

var names = new[] { "StartBtn", "MotorSpeed" };
List<TagValue> results = reader.ReadTags(names);

Writing Tags

Important: To write to a tag, it must be set to "Publish Only" or "Output" in Sysmac Studio Network Publish settings.
Method

WriteBool(string name, bool value)

Writes a boolean value. Handles Omron's 2-byte alignment requirement automatically.

reader.WriteBool("CMD_Start", true);
Method

WriteInt / WriteDint / WriteReal

Type-specific helpers for common numeric types.

reader.WriteInt("SetPoint", 1500);
reader.WriteReal("TargetTemp", 25.5f);
Method

WriteTag(string name, CipDataType type, object value)

Generic write method for any supported CIP type.

reader.WriteTag("MyTag", CipDataType.DINT, 12345);

Continuous Polling

The library includes an event-driven polling engine that runs on a background thread.

// 1. Subscribe to events
reader.OnTagsUpdated += (s, e) => {
    foreach (var val in e.Values) {
        Console.WriteLine($"{val.TagName}: {val.Value}");
    }
};

// 2. Start polling
var tagsToWatch = new[] { "Sensor1", "Sensor2" };
reader.StartPolling(tagsToWatch, 500); // 500ms interval

// 3. Stop when done
reader.StopPolling();

Variable File Parsing

You can load tags directly from Sysmac Studio export files (CX-Designer .txt or Network Configurator .csv).

Method Static

ParseVariableFile(string path)

List<TagDefinition> tags = OmronTagReader.ParseVariableFile("Export.txt");
foreach (var t in tags) {
    Console.WriteLine($"Found: {t.Name} ({t.DataTypeName})");
}