Android phone app for communication with Allen Bradley programmable logic controllers (PLC) via WiFi on a local network.
Intended to be used solely as a testing tool (not fit for any production environment).
Minimum requirement is Android 4.1 (API level 16) while targeting Android 11 (API level 30). This should cover lots of old Android phones as well as new.
Designed for portrait orientation and also designed to hide the status bar and keep the screen turned on. In order to work as designed, it uses permission to access Internet and Network State (see app/src/main/AndroidManifest.xml file).
It is using the following open source libraries, added to the app in the form of AAR modules:
Newer versions of the libplctag library, v2.2.0+, will probably break some functionality of this app (I am currently aware of MicroLogix PID not working so it will not show as an option if you update the library). The AAR folder was added and has a couple of library versions just for the convenience.
This is the procedure for changing the library (upgrade or downgrade):
- Right-click the
libplctag
folder and selectLoad/Unload Modules
, with libplctag highlighted clickUnload
andOK
. - Right-click the "libplctag" folder again and select "Remove Module", confirm removal.
- Right-click the
libplctag
folder again and selectDelete
, confirm deletion. - On the menu select
File/Project Structure
, in theModules
window click+
and selectImport .JAR/.AAR Package
, browse to the folder where the new library is, select it and clickFinish
. - On the menu select
File/Save All
and then doFile/Sync Project with Gradle Files
(this will make the newly createdlibplctag
folder name go bold) - In the project tree, open
settings.gradle
file and delete the duplicate line that saysinclude ':libplctag'
.
The app is also using a modified version of the Tag.java wrapper, part of the libplctag project, so a tag_id for every tag created could be mapped and used in the software. Other modifications would be related to added methods for unsigned integers, previously mentioned in the related libplctag4android project (see below) as well as an additional experimental 128-bit support. All the modifications can be seen just by openning this project, navigating to the "libplctag" project, openning the AAR file and navigating through classes.jar.
Related project: libplctag4android
This app is as experimental as the above mentioned related project but a bit more elaborate. The above mentioned related project can be used to compile the latest prerelease version of the libplctag library.
See this link for instructions on how to create libplctag AAR.
- Only a single value will be displayed per tag entered, either of string / char / integer / float ... etc.
- The default PLC values are set in the
MainActivity.java
file (variables: abCPU, abIPAddress, abPath, abProgram, abTimeout, boolDisplay) and can be changed to match any specific setup. - The app provides automated READ (
Auto ON
) while, during this operation, unused tag spots can be populated and used to write in parallel. - The
Write
buttons are enabled when the tag is present AND the value to write is present. - The
Get Tags
button will fetch ControlLogix tags and selecting any of the fetched tags will copy it to the clipboard. - The Custom String Length has to be specified when the
custom string
data type is selected. - The
Gauge
screen is to demo AndroidUserControls but does allow setting the PLC Tag for either or both: the green LED and the gauges (multiple data types supported). The red and blue LEDs are only visible and functional in the Demo mode. - Modbus functionality of the libplctag library is not included in this app.
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.
Screenshots folder has pictures of this app running inside the Android x86 emulator phone (Pixel 3a API 30) as well as BlueStacks emulator. The app was also tested as working on an old Samsung phone with arm processor and Android 4.4.2.
All it takes is to:
- Download and install Android Studio.
- Download and extract the zip file of this project.
- Open this as an existing project in Android Studio and, on the menu, do a Build/Rebuild Project.
- Locate created APK file in this folder: app/build/outputs/apk/free/debug.
- Copy the APK over to your phone and install it (you might need to enable the "Install from Unknown Sources" option).
You could achieve any orientation on the tablet and prevent the MainActivity and GaugeActivity from restarting when orientation changes. Just make the following changes within the AndroidManifest:
- remove all
android:screenOrientation="sensorPortrait"
entries - add
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
just below each of the following linesandroid:name=".MainActivity"
andandroid:name=".GaugeActivity"
Otherwise it will be portrait orientation only.
This is all dual licensed under Mozilla Public License 2.0 and GNU Lesser/Library General Public License 2.1 to cover for the use of libplctag and jna libraries.
Any and all trademarks, either directly or indirectly mentioned in this project, belong to their respective owners.
Other open source projects: