Author Topic: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)  (Read 11392 times)

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« on: November 27, 2019, 03:29:44 AM »

Offered AS IS.
Not recommended for production use of any sort.
Designed for Windows and intended as a quick testing tool (it also runs in Mono, see replies #7 and #8).


The attached pictures might differ from current design (see pictures in reply #6 for the latest design and the link to the latest app).

It requires that the plctag.dll file be either in the folder with the app itself or somewhere where the OS normally looks for files.
The easiest thing to do is run the app from the Debug folder or place a shortcut on the desktop.
Reply #6 offers a slightly different approach by embedding the libraries into the exe file.

The app is using libplctag library and modified C# Wrapper by Mesta Automation, here is where you can find more info about them:

- https://github.com/kyle-github/libplctag , licensed under LGPL license ( https://www.gnu.org/licenses/lgpl-3.0.en.html )
- https://github.com/mesta1/libplctag-csharp, licensed under MIT license ( http://opensource.org/licenses/mit-license.php )

Both licenses by the authors can be found in the "License" folder of this project.

Packet delay code for even reads was adopted from AdvancedHMI drivers.

Useful Info: https://www.mesta-automation.com/how-to-communicate-to-an-allen-bradley-plc-with-c-and-libplctag-ethernet-ip-library/

Tips for using this app with SLC (as tested with MicroLogix 1100 PLC):

1) Timer / Counter / Control data types are currently set to work for reading from SLC with the following format and its variants:

     T4:0.PRE, Timer, 1                        C5:0.ACC, Counter, 1                        R6:0.POS, Control, 1
     T4:0.TT, Timer, 1                          C5:0.CU, Counter, 1                          R6:0.LEN, Control, 1
     T4:0.EN, Timer, 1                          C5:0.CD, Counter, 1                          R6:0.EU, Control, 1

     Polling either of Timer / Counter / Control without sub-element specified will show 3 x 16-bit values for either.

If you really need to write then use Int16 as a Data Type instead, for example the tag would be "T4:0.PRE; Int16; 1".

2) Each Read/Write transaction Is limited to 236 bytes of data (for example, you can read up to 2 strings of 84 bytes each).

3) Bit count starts at 0 (ex. N7:0/0) and character count starts at 1 (ex. ST9:0/1). This is applicable to all PLCs.

4) An experimental support for 128-bit values (Int128 and Uint128) was also included, so you can read/write them with addressing like this: N7:0; Int128; 1


Tips for ControlLogix PLC:

1) You can get the list of Controller & Program tags with the newly added button and combobox. Program tags will be listed without "Program:MainRoutine." prefix, which you will still need to use in order to Read/Write to these tags.

2) For Timer/Counter/Control in Logix PLCs you should use addressing similar to this:

     Controller_Tag_Counter_1.PRE, DINT, 1          Controller_Tag_Timer_1.PRE, DINT, 1
     Controller_Tag_Counter_1.ACC, DINT, 1         Controller_Tag_Timer_1.ACC, DINT, 1
     Controller_Tag_Counter_1.CU, BOOL, 1          Controller_Tag_Timer_1.EN, BOOL, 1
     Controller_Tag_Counter_1.CD, BOOL, 1          Controller_Tag_Timer_1.TT, BOOL, 1
     Controller_Tag_Counter_1.DN, BOOL, 1          Controller_Tag_Timer_1.DN, BOOL, 1

This approach might work a bit faster than when using address like this: Controller_Tag_Timer_1.PRE, Timer, 1

3) Even UDT elements can be accessed individually for as long as you know the type, these would be examples from this topic https://www.advancedhmi.com/forum/index.php?topic=2545.0 :

     Orders_Pool[0].ID, DINT, 1
     Orders_Pool[0].Name, String, 1
     Orders_Pool[0].Plan_QTY, DINT, 1
     Orders_Pool[0].Time_Est, DINT, 1
 
4) The latest library version provides packet size negotiation so there is no hard limit as with SLC.


The app will rely on your knowledge of data types and tags in your PLC as well as the correct path to your device.


The attached pictures show the example of addressing, which is in the format of: Tag + Data Type + Element Count.

Arrays [x,y] and [x,y,z] are supported as well with the addressing format of: Tag + Data Type + Element Count + X + Y + Z.

Reply #6 has the link to the latest app which eliminated the need for " + X + Y + Z" part as well as some other fixes.

The attached pictures in this post also show an error caused by selecting an incorrect Data Type and typing an incorrect tag.

Also attached is the full solution.

For either of Bit/Character/BOOLArray/Array operations, the Element Count will represent the number of consecutive bits/characters/array elements.

You can Read/Write bits just by using a slash ("/") in the tag, like this:

- "Controller_Tag_DINT/5, DINT, 6" <-- request to read 6 consecutive bits starting at bit 5 (for Logix PLCs)
- "B3:0/0; Int16, 1" <-- request to read bit 0 (for SLC PLCs)

This would be true for tags that do allow writing otherwise it's Read only.


AdvancedHMI is still a far better choice of AB Master application.

No PLC5 features have been tested since I don't have access to that PLC (so everything defaults to SLC).

Auto mode is for reading only but will still allow the manual Read/Write operations that use the "Send" button.
Alternative choice is to have 2 separate instances of the app, one for AutoRead and one to perform writes. These should be run from separate folders and each using its own plctag.dll library.

There might be issues that I didn't notice. Do bother reporting any issues you might encounter.

The project is set to target x86 platform.
Tested as working on both 32-bit and 64-bit Windows computer.

IMPORTANT
When using any of the solutions from this topic, then make sure that it is set for x86 platform when you open it.
If it is set to "AnyCPU" or "x64" then see the reply #7 on how to obtain already compiled x64 library.


There is also an Android version of this project: https://github.com/GitHubDragonFly/TabletTest
« Last Edit: February 09, 2021, 04:43:10 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #1 on: December 03, 2019, 06:46:20 PM »
This post has modified LibplctagWrapper project (part of the C# Wrapper solution by mesta).

These modifications were needed in order to make it work in Visual Studio 2013.
It also includes support for 128-bit signed/unsigned integers and their bits as well as getting tags for LGX CPU.

This post also has the VB Net version of the AB Master executable file, together with the latest x86 version of the plctag.dll file (v2.1.17), to run the app directly from the folder.
« Last Edit: January 10, 2021, 03:27:38 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #2 on: December 20, 2019, 12:05:51 AM »
This post has the C# version of the app.

It does the same things as the VB version.

This post also has the C# version of the AB Master executable file, together with the  latest x86 version of the plctag.dll file (v2.1.17), to run the app directly from the folder.

VB version appears to be establishing the initial connection faster than the C# version.

« Last Edit: September 28, 2020, 01:52:14 AM by Godra »

mohamedazimal27

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #3 on: March 12, 2020, 10:49:42 PM »
Hi Godra,

First of all, thank you for your application. I'm using L32E AB PLC and trying to do some basic functions like Read/Write BOOL, Array, String, etc., but I don't know whether my PLC is connected to the application or not!!!! Also whenever I try to Read/Write I'm getting the following error. I'm sorry for my naive questions.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #4 on: March 12, 2020, 11:31:28 PM »
First of all, it is suggested in my first post that "AdvancedHMI is still a far better choice of AB Master application", so you should be using AdvancedHMI unless you really have a need to use this app.

As for this app, you need to select "LGX" as the CPU Type, probably leave "Backplane" as the Port Type, specify correct IP Address, specify correct Path which is usually "1," + CPU slot number and then make sure to input correct tag with all its parameters (just like all attached pictures from the first post show).

As for the error you are getting, take a look at this post:

https://stackoverflow.com/questions/18007967/net-framework-error-hresult-0x8007000b

Maybe, instead of the solution, try running the exe file from either second or third post.

« Last Edit: April 20, 2020, 01:27:10 AM by Godra »

mohamedazimal27

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #5 on: March 13, 2020, 01:23:43 AM »
Thank you for your reply.
Yeah, I know AdvancedHMI is better than AB Master application and I'm just exploring different options. I figured out its a target platform problem. I changed my target to x86 and it works like a charm.
Thanks a lot.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #6 on: June 08, 2020, 01:41:46 AM »
Here is the link to my GitHub repository with VB solution:

   https://github.com/GitHubDragonFly/AB-Modbus-Master

It has somewhat unorthodox approach, which is to embed the unmanaged "plctag.dll" file as a resource and create a standalone exe file as the output. It is also set for "AnyCPU" instead of "x86".

Make sure to read the whole description and any comments within files.

The attached pictures show what the app looks like.
« Last Edit: February 09, 2021, 04:42:42 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #7 on: August 06, 2020, 06:39:29 PM »
This post has solutions for Mono version of the apps (both VB and C#).

Support for 128-bit values was removed since Mono on the old Linux Kubuntu tablet just didn't have the proper System.Numerics support.

Solutions are intended to be worked with in Visual Studio, so whatever modifications you might make then just copy the resulting exe file over to where the libplctag.so file you might put (see the next post).

Mono on old Linux Kubuntu 14.04 had difficulties with newer versions of the libplctag but worked fine with v2.1.6.
Newer versions are kind of designed for Ubuntu 18.04 and later.
« Last Edit: September 28, 2020, 02:06:04 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: AB Master app for Allen Bradley PLCs (ControlLogix, SLC, PLC5)
« Reply #8 on: August 13, 2020, 09:00:47 PM »
This post has exe files for Mono of the apps (both VB and C#).

In Linux, run the Terminal app as root, browse to the folder and type: mono ABMaster.exe
« Last Edit: September 28, 2020, 01:50:39 AM by Godra »