Git Product home page Git Product logo

plc-omron-standard's Introduction

PLC Omron Standard

MIT NuGet

This project was created to have an easy to use, .NET Standard library to communicate with Omron PLCs. The following features are available:

  • Read from PLC memory areas
  • Write to PLC memory areas
  • Read and write with single values or arrays
  • Read and write with typed values (options are byte, bool, short, int, float, string)
  • Receive events during communications

Getting Started

These instuctions can be used to acquire and implement the library.

Installation

To use this library either clone a copy of the repository or check out the NuGet package

Usage

TCP Example

The following example provides a basic use case for TCP based communications.

using PLC_Omron_Standard;

public class MyClass() 
{
    public bool Test() 
    {
        // Create PLC connection
        var plc = new PlcOmron("192.168.1.100");

        plc.Connect();

        // Read data
        var data = plc.ReadString(123); // Assumes value is "Hello"

        // Write data
        return plc.Write(123, $"{data}, World!");
    }
}

UDP Example

The following example provides a basic use case for UDP based communications.

using PLC_Omron_Standard;

public class MyClass() 
{
    public bool Test() 
    {
        // Get node addresses
        var ip = "192.168.1.100";
        var remote = byte.Parse(ip.Split('.').Last());

        var local = byte.Parse("101"); // This can be any non-zero value, but using the final part of your local IP address is recommended
        
        // Create PLC connection
        var plc = new PlcOmron(ip, 9600, false, remote, local);

        plc.Connect();

        // Read data
        var data = plc.ReadString(123); // Assumes value is "Hello"

        // Write data
        return plc.Write(123, $"{data}, World!");
    }
}

Events Example

The following example provides a use case where events are subscribed to and handled.

using PLC_Omron_Standard;

public class MyClass() 
{
    private readonly ILogger Logger;

    public bool Test(ILogger<MyClass> logger) 
    {
        // Store logger
        Logger = logger;

        // Create PLC connection
        var plc = new PlcOmron("192.168.1.100");

        plc.NotifyCommandError += LogError;
        plc.Connect();

        // Read data
        var data = plc.ReadString(123); // Assumes value is "Hello"

        // Write data
        return plc.Write(123, $"{data}, World!");
    }

    private void LogError(string message) 
    {
        Logger.LogError("{Message}", message);
    }
}

Authors

  • NF Software Inc.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

Parts of this library have been inspired by:

Thank you to:

plc-omron-standard's People

Contributors

thirstyape avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.