PLCnext Python and its Library
Dear PLCnext Team,
First, I would like to express my appreciation for the work you’ve done in developing PLCnext. It has truly been a game-changer for us here in Indonesia, allowing us to approach industrial automation in new and innovative ways. We are excited about using Python programming alongside the traditional ladder logic and function blocks.
However, before we can fully implement Python-based solutions, we have some questions regarding how to get our Python programs running on the PLCnext device. Specifically, we are interested in creating our own Docker images that come pre-installed with Python and libraries such as NumPy and TensorFlow Lite.
I came across a post by Paguilar Maker Blog post that mentioned the need to cross-compile TensorFlow Lite for the device, but this process seems quite resource-intensive and requires powerful hardware, which we currently don’t have available at our company.
Could you provide more details on how we can run Python programs on PLCnext and whether there are pre-built Docker images or downloadable files that include the necessary libraries (like Python, NumPy, TensorFlow Lite, etc.)? If cross-compiling is required, is there an alternative method or a simplified process we can use to avoid the need for high-performance PCs?
Your guidance on this matter would be greatly appreciated.
Thank you for your time and support!
Sincerely,
Piko Prasetyo
Comments
Hello Piko Prasetyo,
In generally it is possible to use the Docker solution described above, it is also possible to integrate the Docker image into the PLCnext app. Before starting the integration, the following questions need to be clarified:
Please find the following projects, I think it can help you:
GitHub - PLCnext/Container-App-Template-for-PLCnext: This project aims to create app's. This app's can run on the PLCnext controllers (like the one's that are deployed on the plcnextstore).
GitHub - PLCnext/PLCnext-ROS-bridge: The PLCnext-ROS-bridge enables the whole power of the open source Roboter Operating System (ROS) for the IEC61131 world.
App development: App types
BR Eduard
The python images on docker hub should be suitable, for example:
... for AXC F 1152 and AXC F 2152 controllers.
For pre-compiled python packages for arm32v7, I believe that others have had some success using the piwheels package repository, which intended for 32 bit Raspberry Pi devices.
Phoenix Contact does not support or endorse these docker images or piwheels packages, but hopefully the PLCnext Community can help with any questions on these topics.
Hello Piko Prasetyo,
Here some comments that may help you in what you want to do.
I hope this helps you, remember that this is kind of a “trick”, and that hardware emulation is not (always) perfect (google it). Therefore, you should thoroughly test the libraries obtained in this way using the real hardware and check that the behavior is as expected. This is specially relevant if you intend to use them in production and critical processes.
Finally, if later, when running a library obtained in this way you see the error “illegal instruction”, it means the trick has only taken you so far and the cross compilation needs to be carried out differently.
Thank you for your response! I’ll go ahead and try the suggestions you provided right away.