Trying to figure out the best way of controlling industrial PLC's with Raspberry Pi/linux server - specifically using python and pymodbus (modbusTCP) over ethernet...
Once the PLC internal registry is mapped properly to modbus, can software written in python take the place of ladder logic programming in the PLC and control it completely?
Or will ladder logic/ native PLC code still need to be written?
You should not replace PLC logic with your linux server. You need real time OS for that. Even running real time OS and controlling PLC with it is a bad idea. PLC-s have all kind of checks built in for controlling inputs/outputs, program cycle, internal diagnostics and so on. They are a tool meant specifically for that task. IMHO ladder logic is easier to learn than real time OS.
You should use your server as HMI - human machine interface, that sends control data to PLC and displays it back to the user.
If your project is for learning experience or personal project then you should of course do whatever you feel like.
I don't know if you can do this in the specific configuration you are discussing; in fact you don't say which PLC you are using so I doubt any respondant can tell you.
But under the assumption you can technically connect the pieces, you will probably discover the performance is not adequate to really carry out reliable mechanical control.
Normally PLCs run through their program hundreds of times per second, each time sampling inputs and computing new outputs. This is fast enough so mechanics effectively see "smooth" control. (5 Hz would likely cause mechanical chatter and jerky movements of hardware).
If you "involve" Python to compute that, somehow you have pay bus communication times to/from the PLC to the Python, the Python wakeup time, Python execution time, and Python message packing/unpacking time. I doubt you can achieve all of this at several hundred times per second reliably (what happens when the OS interrupts Python to write 10M of data onto the disk for some other background process)?
If you insist in involving Python somehow, it should act only in an advisory role. That is, the PLC does all the work (e.g., you need that "ladder logic/..." to be written) but the Python code sends occasional messages to the PLC to change its overall behavior, e.g, control mode, feed rates, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With