Python & PLC

Topics about the Software of Revolution Pi
Post Reply
Uncledrive
Posts: 2
Joined: 28 Dec 2023, 17:38
Answers: 0

Python & PLC

Post by Uncledrive »

Hello everyone,
I have a question about using RevPi as a PLC.

I 'm working in an SME where we do:
- retrofits of industrial machines 
- design and development of special ad hoc machines following the customer's needs
- managing Kuka robots externally via PLC.

We usually use the Siemens S7-1200 (both with ladder and scl languages) as a PLC with Profinet protocol for connection with robots or CNC and for remote control to meet the specifications for Industry 4.0.

Since we have often used the Raspberry Pi as a prototype for some of our projects, now that the RevPi has been released, we will be interested in replacing the Siemens S7-1200 PLC with your products.
I wonder if Python could be used to program the RevPi as a PLC and if it is adequate for our needs.

The doubts that have arisen concern the fact that Python does not belong to the programming languages ​​foreseen by the IEC 61131-3 standard.

For this reason I wonder if Python is able to process the main thread without any interrupts on other threads which would cause a significant delay in the response for any actuators.

Briefly, on the RevPi can I use Python as I did with Raspberry Pi (infinite loop that manages inputs and outputs) or it is recommended to use something like Codesys and programming the RevPi in ladder and use Python only for reading inputs and outputs so as to create a web interface or store any data on a database?

While thanking for your kind attention, I wish everyone a good day and a Happy New Year.

Guido
u.biakoup
KUNBUS
Posts: 182
Joined: 14 Apr 2022, 13:04
Answers: 2

Re: Python & PLC

Post by u.biakoup »

Hello Guido,

Thank you for reaching out, and Happy New Year to you as well!

Your interest in utilizing the RevPi for industrial applications is exciting. The RevPi is indeed a powerful platform, and Python can be employed for programming, making it a flexible choice for various applications. Let me address your concerns:
  • Programming in Python:
Yes, you can use Python to program the RevPi, similar to how you've worked with the Raspberry Pi. However, your concern about potential delays in the main thread is valid. Python's Global Interpreter Lock (GIL) can impact real-time performance in a multi-threaded environment.

RevolutionPi Python Introduction

  • RevPiModIO:
To address real-time constraints, I recommend using "revpimodio." This library is tailored for the RevPi and allows you to program in Python while maintaining real-time responsiveness. It provides an abstraction layer for interacting with the RevPi's digital and analog I/Os. More information and installation details can be found here: RevPiModIO Quick Start Guide

  • Integration with CODESYS:
CODESYS Quick Start & CODESYS CHECKLIST
While Python can handle control logic, using CODESYS for ladder logic on the RevPi is also a viable option. You can combine the strengths of both Python and CODESYS, utilizing Python for specific tasks (e.g., web interfaces, database interaction) and CODESYS for traditional PLC programming.
In summary, you have the flexibility to use Python for control logic, especially with tools like RevPiModIO, and combine it with other languages or tools for additional functionalities.

If you have specific requirements for Industry 4.0, remote control, or communication with robots and CNC machines, the RevPi's versatility allows you to tailor the solution to your needs.

If you have further questions or need assistance in getting started, feel free to reach out. We're here to help!

Best Regards

Ulrich Kouatang Biakoup | Technical Support
chao
Posts: 1
Joined: 05 Jan 2024, 11:05
Answers: 0

Re: Python & PLC

Post by chao »

Hi Chao here, sorry to hijack this post.

I am having similar situation to use non traditional controller to control a water treatment plant with a couple of thousand IOs.

We are looking for solutions using python, go and rust on linux controllers.

RP looks very promising in terms of python language.

I am 20 years from PLC background, and 10 years with python. I never had chance to develop a complete industrial control platform using python, but more of IoT programming.

Here's my concerns:
1. can RP handle a couple of thousand IO? the IO will be a combination of smart IO via HTTP and modbus TCP. Ideally I want to read all IOs within 1 sec.
2. does RP has a PLC type of framework that can handle cyclic scan, memory management, error handling, etc. Ideally, I want to be like in a traditional PLC programming situation that the programmer only needs to focus on create the plant control logic and leave the RP to handle the other framework related logic.
3. I saw a module called "revpipycontrol", is it the framework module that I can use for the requirements mentioned in item 2? I don't want to use codesys.
Also there are some of the detailed programming questions:
4. how does python handle timer function in PLC? If I have hundreds of timer running at the same time, like in a traditional PLC, how to achieve it in python? I can multithread timer up to 10~20 in python, but no more. Does RP has solution to it?
5. how to manage global data? In normal python project, I can create a globalvar.py to store all global data, but it's a tedious job, does RP has a better way to manage the variables? for a control system of 1000 IO, the number of variable could be up to 50k.
6. how to exchange data between RP and the SCADA system? I usually will use MQTT or OPC, but does RP has a better solution?
7. how to perform cyclic control? it's similar to item 2, but I want to read the Input, execute the logic (up to 10k line of code), send the output, within 1 sec, is it possible to achieve? if one RP is not enough, what's the limit of RP? for example, a control system of 1k IO and 10k line of code, what's the spec of RP is required?
8. how to online monitor the variable and control logic? can I use VSC to monitor the code? does RP have a mature solution?
9. how to hot update the python code? for a running plant, I don't want to restart the plant everytime I want to make a minor change. Does RP have a solution?
Uncledrive
Posts: 2
Joined: 28 Dec 2023, 17:38
Answers: 0

Re: Python & PLC

Post by Uncledrive »

Hallo Ulrich,
first of all, please, apologize for my late reply.

Thanks for your quick and accurate answer.
To begin with, as you suggested, I will approach the "RevPiModIO" library in order to standardize my project with a single programming language (Python).
If I need any further suggestions in the future, is there a more direct way to contact you or you prefer I continue with this forum?

Best regards.

Guido
Post Reply