macbeth
Hello,
I came across OpenPLC some days ago and I love it. 
I am just in the process of building a modular system that I'll use for my own projects. The system is based on a STM32F103RC controller board and "bluepill"-like slave modules.
At the moment the control logic is programmed with the stm32duino toolchain.
After looking at OpenPLC I added a modbus interface to my code and it works great with openPLC.
 
Now my question is: Is there a way to define the modbus addresses with a file rather than manually typing the address ranges?
As for now I used Slave devices / Add new device / Generic Modbus RTU device" and I entered the coil/register addresses myself.
To make things easier for users it would be great to have an option to upload a config file (e.g. XML) rather than filling out the form.
This way I could program a script that generates this config file according to the modules that are currently connected.
 
Here are some pictures.
 
demo_01s.jpgmodules01.jpg
sideViewOpen01.jpeg
Reply 0 0
thiagoralves
Nice hardware! Congrats. On the Modbus configuration, it is actually done through a config file, but there isn't any easy to use interface to upload this config file. The file is automatically generated based on the user input on the web. What you can do however is create templates, like the ones available for Arduino, ESP, etc. You can create a template for your own hardware that automatically fills out the fields accordingly.
Reply 0 0
macbeth
Sounds good. Is there a template prototype I can use to get going? Are the templates the items shown in the "OpenPLC Hardware Layer" dropdown?
Reply 0 0
thiagoralves
No, the templates are on the slave devices screen. Check webserver/ webserver.py at line 1107, and webserver/ pages.py at line 1533 (add_devices_script)
Reply 0 0
macbeth
Ok, I see. these template-parameters are hardcoded in pages.py. That means in oder to add a hardware variant I'll have to write 2 patches (one for the webserver.py and one for pages.py.
I guess this would be an option for a monolithic hardware. But the goal of my hardware approach is to be really flexible. It would be so much easier if there would be an option to upload the modbus parameters from file. But I know this would be quite some work on your side. If you are open for feature requests I'd like to put this into the queue 🙂
We could use the format of the mbconfig.cfg file.
Reply 0 0
thiagoralves
In your case maybe it would be better to fork the runtime and change the slave devices concept entirely to fit your modular structure. Another option would be to run OpenPLC runtime directly in your STM32 CPU, and then develop blocks on the editor to talk to your slave modules. That's the approach taken by Automation Direct with their P1AM PLC.
Reply 0 0
macbeth
Yes, I'd like to have the runtime running on the STM32 directly. But I guess my software skills are not up to that. I made this hardware to be able to use platformio / arduino slangs for programming. A friend of mine introduced me to OpenPLC and I thought a modus interface would be easy to implement. But porting your code to the STM32 and adapting the toolchain sounds a bit to complicated and time consuming at the moment.
Anyone who feels up to that task? Please let me know, I can provide hardware for free 🙂
Reply 0 0
thiagoralves
OpenPLC is already compatible with STM32. No need to port anything. You can compile code for STM32 boards straight from the editor.
Reply 0 0
Tarik2511
Привіт
Кілька днів тому я натрапив на OpenPLC, і він мені подобається.
Я якраз перебуваю в процесі побудови модульної системи, яку буду використовувати для власних проектів. Система базується на платі контролера STM32F103RC і підлеглих модулях, схожих на «bluepill».
На даний момент логіка управління програмується за допомогою інструментарію stm32duino.
Подивившись на OpenPLC, я додав інтерфейс modbus до свого коду, і він чудово працює з openPLC.
 
Тепер моє запитання: чи є спосіб визначити адреси modbus за допомогою файлу, а не вручну вводити діапазони адрес?
На даний момент я використовував Slave devices / Add new device / Generic Modbus RTU" і я сам ввів адреси котушки/регістра.
Щоб полегшити роботу користувачам, було б чудово мати можливість завантажити конфігураційний файл (наприклад.XML), а не заповнювати форму.
Таким чином, я міг би запрограмувати скрипт, який генерує цей конфігураційний файл відповідно до модулів, які зараз підключені.
 
Ось кілька фотографій.
 
demo_01s.jpgмодулі01.jpg
sideViewOpen01.jpeg
Hello. Where can you buy such a controller. If it's not a secret what kind of case it is, maybe there is a link
Reply 0 0
macbeth
Hi Tarik,
as for now we are only using this controller for own projects and we're still testing. If you like you can send me a PN and tell me what you need.
The case is just an aluminum profile (Fischer GB-82), the blue cover is a PCB frontpanel.
Reply 1 0
macbeth
OpenPLC is already compatible with STM32. No need to port anything. You can compile code for STM32 boards straight from the editor.
Ok, I didn't know that OpenPLC is stm32 compatible. I guess I have to read the documentation and find out how to integrate my getData / setData functions into the code. Is there a guideline or template to get me started here?
Reply 0 0
thiagoralves
The procedure is quite simple. You just have to edit the editor/arduino/examples/Baremetal/hals.json file to include your custom platform. On that file you define what type of mcu you’re programming and what .cpp file should be used as a driver (hardware layer). Then you must provide this cpp file at editor/arduino/src/hals.
Reply 0 0
macbeth
It looks like all of these hals are using a fixed number of IOs. What would be a good practice to be able to address a modular system?
One solution would be to set the number of coils/inputs/AIs/AOs to a big number (100) and ignore set/get commands for channels that are currently not present on the system.
But how can I define the max. number of channels? There is a definition in defines.h, but I suppose this file is generated automatically in the build-process?
Any better ideas? Can I call a custom function in the PLC program (e.g. for mapping IOs to the IO-arrays?)
Reply 0 0
thiagoralves
For modular IOs I recommend doing what Automation Direct did with P1AM and Sequent did with their SPI hats: add custom blocks to the editor. On P1AM for example you have a block that initializes and configure all modules, and then you have one block for each IO type to be able to read/write to them. Here is the documentation on how to add new blocks to the editor: https://autonomylogic.com/docs/3-3-adding-new-blocks-to-openplc-editors-library/
Reply 0 0
Reply