Coder Social home page Coder Social logo

githubdragonfly / ab-modbus-master Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 4.0 1.22 MB

Standalone Windows application - Master for Allen Bradley, some Omron and Modbus PLCs. It is using libplctag library and C# Wrapper. Also included is the Mono version for Mac OS X (which should work fine in Windows as well as Linux Mono - see notes).

License: Mozilla Public License 2.0

Visual Basic .NET 100.00%
allen-bradley c-sharp macos modbus mono omron plc vb-net windows libplctag modbus-master modbus-simulator

ab-modbus-master's Introduction

AB-Modbus-Master

Standalone Windows application - Master for Allen Bradley, some Omron and Modbus PLCs, using libplctag library v2.1.22 (created by Kyle Hayes) and a modified C# Wrapper (originally created by Michele Cattafesta).

Intended to be used solely as a testing tool (not fit for any production environment). Try to resort to READING only, unless you really need to WRITE (which could potentially be dangerous when dealing with PLCs attached to some machines).

It is designed to use embedded dll libraries (added to resources): unmanaged plctag.dll and managed LibplctagWrapper.dll. This was done so the app can be in the form of a standalone executable file, which might be considered as somewhat unorthodox approach.

Once run, this app is supposed to create a copy of the plctag.dll file in the application folder, load it in memory when needed and delete the file when the app is closed (all this is required because this is unmanaged library).

Possible BUG: The app might hang on a still active TCP connection so give it a few seconds before deciding to close the app. Always check the Task Manager to see if the app is still running, force close the app if necessary and delete the file manually.

WORKAROUND would be to comment out all the code within the AppShutdown sub inside the ApplicationEvents.vb file. This way the extracted plctag.dll library will remain in the application folder. If you do ever update the plctag library to newer version then the app will overwrite the old file.

An easy alternative to use instead would be the AdvancedHMI software since it is highly functional and free.

Important Note:

~ Some AntiVirus software might detect this behavior of extracting the library as a Trojan, that's why you get the whole solution ~

AB Screenshot

AB Screenshot

Modbus Screenshot

Modbus Screenshot

Functionality

  • Either a single or multiple values can be displayed per tag entered, either of string char integer float ...etc.
  • The app provides automated READ while, during this operation, unused tag spots can be populated and used to WRITE in parallel
  • Here is a brief explanation of the screenshots above:
    • Using the address of N7:0; Int8; 8 is equivalent of saying "Read 8 consecutive Int8 values starting at address N7:0"
    • Using / in the address indicates either bit or character reading:
      • Using the address of B3:1/0; Int16; 16 is equivalent of saying "From the address B3:1 read 16 consecutive bits of Int16 value starting at bit 0"
      • Using the address of hr0/7; String; 5; 20 is equivalent of saying "From holding register 0 and starting at character 7 read 5 consecutive characters of 20-character long string"
  • The Get Tags button will fetch ControlLogix tags and selecting any of the fetched tags will copy it to the clipboard.
  • You can specify the name of the Program to get tags for (the default is set to MainProgram).
  • Boolean Display defaults to showing boolean values as True:False but can also use either 1:0 or On:Off
  • MicroLogix PID addressing is also a part of this app (ex. PD10:0 or PD10:0.PV), might not work with newer versions of the libplctag library
  • As for AB tags, you will need to specify the Custom String Length when the custom string data type is selected.
  • As for Modbus tags, you will need to specify the String Length when the string data type is selected.
  • Modbus addressing: CO = Coil, DI = Discrete Input, IR = Input Register, HR = Holding Register (all these are set by 0, 1, 3 and 4 xxxxx addressing).
  • Modbus byte/word swapping is a bit tricky but I hope most of it functions correctly.
  • Some error handling has been built into the app but it is also relying on the libplctag library itself for additional error handling.
  • Either or both dll files can be updated via the project's Properties/Resources page, where new dll(s) are added as existing resource files to the Files section. Depending on the changes made to the new versions of the plctag library, this app might lose some functionality (like MicroLogix PID addressing or some other).
  • There is also an experimental support for 128-bit values.

The Modbus part of this app can be tested with the ModbusSlaveSimulation simulator.

There might be bugs in the app. Not everything could be tested by me, since I don't have access to all the different PLCs supported by the libplctag library. See the libplctag website for all PLCs supported by the library. Read comments inside the Form1 for any additional information.

Build

All it takes is to:

For Windows

  • Either use Windows executable files from the exe folder or follow the instructions below to build it yourself.
  • Download and install Visual Studio community edition (ideally 2019).
  • Download and extract the zip file of this project.
  • Open this as an existing project in Visual Studio and, on the menu, do:
    • Build/Build Solution (or press Ctrl-Shift-B).
    • Debug/Start Debugging (or press F5) to run the app.
  • Locate created EXE file in the /bin/Debug folder and copy it over to your preferred folder or Desktop.

If you need to run this app on an x86 based Windows computer then you will need to replace the plctag library with its x86 version.

For Mono

  • Mac Mono version is executable file of slightly modified version of this project, which has both libraries separated from the executable file (because Mono is a bit finicky).
  • You can also create it yourself just by modifying this project.
  • The libplctag.dylib library file is version 2.1.22, compiled on iMac G5 PowerPC (32-bit), while version 2.3.6 of the library is available in the Python_libplctag_Mac_PPC project
  • You can try replacing it with 64-bit Mac library available on the libplctag releases page, which should be for Intel based cpu
  • Running it from terminal should work fine with standard user account but if it doesn't then switch to superuser account (sudo su)
  • This particular version should work fine in Windows, as it is, and also in Linux Mono (most distributions) for as long as you replace the libplctag.dylib library with the correct version of either libplctag.dll or libplctag.so file.

Licensing

This is all licensed under Mozilla Public License 2.0 (the MIT license of the C# Wrapper is included in the Resources folder as well as its zip file).

Trademarks

Any and all trademarks, either directly or indirectly mentioned in this project, belong to their respective owners.

Useful Resources

  • The AdvancedHMI project offers FREE software with a bunch of different drivers available. It should be considered as a master application for multiple PLC brands, like AB or Modbus or Omron ... etc. It also has a lots of additional components available in its forum.

ab-modbus-master's People

Contributors

githubdragonfly avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

ab-modbus-master's Issues

Consider using libplctag.NativeImport?

Hey there friend!

Was wondering if you have considered using the wrapper from the libplctag organization: https://www.nuget.org/packages/libplctag.NativeImport/
https://github.com/libplctag/libplctag.NET

The benefit in my view is that you won't need to have library embed/extraction/dll interfacing logic in your solution, you can use what is provided there. I also usually update this wrapper within a few hours of a release of the core library by Kyle unless there are API changes.

If not, are there any features lacking in this wrapper that would prevent you from using it?

timyhac

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.