mprymek
Hello,

if it's of any interest to you, I have made a PoC port of OpenPLC core to PlatformIO/Arduino. It's tested on ESP32 but it's easily portable to any other MCU.
  • you can run Structured Text code right on the MCU (MCU is not a slave, it acts really as a PLC itself)
  • no communication protocols support for now, just GPIO & ADC
  • no web, program upload etc., you just compile your ST program and run it on the MCU
  • it runs on Linux x86_64 also (for debugging mostly)
You can download it from here:  https://github.com/mprymek/mcu-plc

It's really just a PoC but I thing it could be interesting for students, researchers, makers etc. at least as a starting point.

Any comments, suggestions and pull requests are warmly welcome.

Thanks for your excellent work on OpenPLC!
Quote 2 0
thiagoralves
Great work mprymek! I’ll take a better look at this and, perhaps, include it on the main OpenPLC runtime. My idea is to use this to allow hosts running the full runtime to program slave devices with small ladder logic files. Then slave devices will be able to run some computation independently of the hosts.
Quote 2 0
mprymek
Update:
- experimental communication implementation using CAN bus and UAVCAN protocol (https://uavcan.org/)
- ESP32 or STM32 slaves

Demo: 


Code needs some cleaning and commenting, hopefully will be published soon.
Quote 1 0
kortenbach
Sadly I don't have the skills to compile matiec myself, but this seems like a very good idea. I hope that, at some point, i'll be able to use this to build controls with open PLC and ESP32. Great work!
Quote 0 0
mprymek

kortenbach wrote:
Sadly I don't have the skills to compile matiec myself, but this seems like a very good idea. I hope that, at some point, i'll be able to use this to build controls with open PLC and ESP32. Great work!


I'm very glad you find this idea interesting. Actually, in the meantime I've decided to make a "whole line" of experimental MCU-based PLC system intended for hackers. Including hardware assembly guides, simple 3D-printable cases, firmware and even HTML-based HMI. The first protoype is in fact already working, I'm using it to control a small indoor garden (it's kind of a showcase, of course it would not be a problem to implement it in a simpler manner). You can see a quick&dirty demo video here: https://www.youtube.com/watch?v=B7nvxWdvMAc

You can follow the project here:
https://github.com/mprymek/PeaLC
https://hackaday.io/project/168188-pealc-easy-diy-modular-plc-system

Sadly, the published documentation is still behind the project - I didn't have much time lately to complete it. But I'm going to publish detailed hardware and software assembly guides so everyone with moderate hacking skills can build it. It's totally a hobby project so please be patient little bit and follow the project progress 😉

Quote 0 0
kortenbach
wow! I'm so glad to hear this. I've been searching for such a project for a long time. If you want I can give you feedback when I will start using it. Do you plan on having an HTML server on the ESP device itself? 
Quote 0 0
mprymek
kortenbach wrote:

If you want I can give you feedback when I will start using it.

Of course! I highly appreciate any feedback. But please do not expect the documentation to be complete sooner than in about february.

kortenbach wrote:

Do you plan on having an HTML server on the ESP device itself?

I don't think this would be very wise. For now, I'm using Android tablet as a web broswer + very small virtual machine on my home NAS server running MQTT broker and serving HMI web pages. The web is developed using Vue.js, so it's highly dynamic but still the files served are strictly static, there's no backend logic, only frontend one + websockets for MQTT communication.

Of course, this could customized. Maybe some OrangePi + HDMI touch panel could be a good solution for somebody. This is up to the user to experiment and find a suitable solution 😉
Quote 0 0
kortenbach
About ESP as webserver:
The reason for this is that it would be a fully self-contained system with it's own web interface. You wouldn't need any additional hardware. Still it would be possible to merge the different web pages into one bigger overview. Every device will have it's own settings that can be changed on the device itself instead of some central server. I've made this using Flash once, worked very well. Sadly no one likes Flash anymore, SVG would be a logical successor I guess...
Quote 0 0
mprymek
kortenbach wrote:
About ESP as webserver:
The reason for this is that it would be a fully self-contained system with it's own web interface.

Yes, I understand but it's not the direction I'm thinking of. If you want this, the better would be to use some cheap Linux computer (OrangePi?) and standard OpenPLC.

Anyways, as soon as the full documentation is ready, you can customize it to your needs freely 🙂
Quote 0 0
thiagoralves
The problem of having such “self contained” system is that if you let the esp32 serve hmi webpages it will most likely affect the plc real time processing and your control logic will break.
Quote 1 0
kortenbach
That is true, but only for fast systems. Maybe it's possible to use the 2nd core of the esp32 for that(?)
Quote 0 0
thiagoralves
Why not use an Orange Pi (or Raspberry Pi Zero) with OpenPLC + ScadaBR installed. It would be a self contained system with PLC runtime + web based HMI on a board almost the same price as the esp32, and yet a lot more powerful.
Quote 0 0
kortenbach
You've got a point there... I was starting out using esp32 and then I came across open PLC. I like the fact that it has WiFi and everything I need in a really small package for a great price. I PI zero would probably be fine as well except for the WiFi...
Quote 0 0
thiagoralves
Get a Pi Zero W then. It comes with WiFi for just a little bit more (usually sold for $10)
Quote 0 0
kortenbach
You are right, but it just feels weird to use a complex linux-based system for a very simple Control-Task. Somehow it doesn't feel right. I feel that a simple task should be controlled by a simple controller. All the simple controllers can then be supervised by a bigger linux-based controller with scada. 
Quote 0 0