This C library provides a portable and simple API for accessing Allen-Bradley and Modbus PLC data over Ethernet.
OS | Architecture/CPU | Version | 64-bit | 32-bit |
---|---|---|---|---|
Ubuntu | x86, Arm | 18.04 | Supported | Supported |
Windows | x86, Arm | 10 (Server 19) | Supported | Supported |
macOS | x86, Arm | 11 | Supported | Not Supported |
libplctag is an open source C library for Linux, Windows and macOS using EtherNet/IP or Modbus TCP to read and write tags in PLCs. The library has been in production since early 2012 and is used by multiple organizations for many tasks including controlling radio telescopes, large and precision manufacturing, controlling fitness equipment, food handling and many, many more.
Current Stable Version: 2.5
Old Stable Version: 2.4
Note: PLCs control many kinds of equipment and loss of property, production or even life can happen if mistakes in programming or access are made. Always use caution when accessing or programming PLCs!
We make no claims or warrants about the suitability of this code for any purpose.
Be careful!
Do you know what you want already? Download it from the releases page!
The C library is designed for easy wrapping. Wrappers for many other languages include the following:
The code for the core library is at libplctag. Stable code is on the default release branch. If you check out code from GitHub, it will default to the release branch.
If you want pre-built binaries, we have them available on the releases page. Just pick the one you want and download the ZIP file for your system. We have 32 and 64-bit builds for x86 Linux and Windows and 64-bit builds for x86-64 macOS.
Go to the main project at the libplctag organization to see the other wrappers. We are in a state of transition right now as we move more alternate language wrappers into the GitHub organization.
Oh, wait, you want code! There are many examples in the examples directory.
A good place to start is simple.c.
This code reads several 32-bit signed integers (DINT), updates them, then writes them back out and rereads them from a tag named TestBigArray in a Logix-class Allen-Bradley PLC.
The README file in the examples directory describes some of the more interesting ones.
Most of the functions in the API are for data access. Direct support for single bits, 8-bit, 16-bit, 32-bit and 64-bit words (integer and floating point) are provided by the library.
See the API for more information.
We need and welcome help with the following:
We love contributions! Many users have contributed wrappers, extra functionality and bug fixes over the years. The library is much better for all the help that users have provided. We ask that your code contributions to the core library are under the same dual MPL/LGPL license.
Testing is difficult for us as we do not have access to all the different hardware out there. If you can, a great way to contribute is to test prereleases. These are on the prerelease branch! We appreciate all the help we get from our users this way.
The easiest way to contribute to the core library is to raise a PR on GitHub.
Wrappers in other languages are generally split off into separate projects. Those may have different licenses and contribution processes. Please look at the documentation for the wrapper in question.
See the wiki history page for more details on how libplctag was created and why we built it.
There are two ways to ask for help or contact us.
If you have general questions or comments about the library, its use, or about one of the wrapper libraries, please join the Google group libplctag!
The forum is open to all, but is by request only to keep the spammers down. The traffic is fairly light with usually a small number of emails per month. It is our primary means for users to ask questions and for discussions to happen. Announcements about releases happen on the forum.
If you find bugs or need specific features, please file them on GitHub's issue tracker for the main C library project. Each individual wrapper project has its own issue tracker.
If needed, we will initiate private communication from there.
See the license files (LICENSE.MPL or LICENSE.LGPL) for our legal disclaimers of responsibility, fitness or merchantability of this library as well as your rights with regards to use of this library. This code is dual licensed under the Mozilla Public License 2.0 (MPL 2.0) or the GNU Lesser/Library General Public License 2 or later (LGPL 2+).
This dual license applies to the core C library. Additional wrappers for other languages may be under different licenses. Please see those projects for more information.
PLC5, SLC 500, MicroLogix, Micro8X0, CompactLogix and ControlLogix are trademarks of Rockwell/Allen Bradley. Windows and Visual Studio are trademarks of Microsoft. Apple owns the trademark on macOS.
Please let us know if we missed some so that we can get all the attributions correct!
Have fun and let us know if this library is useful to you. Please send test cases if you run into bugs. As PLC hardware is fairly expensive, we may not be able to test out your test scenarios. If possible, please send patches. We do not ask that you transfer copyright over to us, but we do ask that you make any submitted patches under the same licenses we use. We will not take any patches under the GPL license or licenses that are incompatible with the MPL 2.0 license.
We hope you find this library as useful as we do!