davenardella
Hello everyone.
Lately I have gained some experience in optimizing Linux processes.
Basically it is possible, in a very simple way:
  • isolate one or more CPU cores preventing processes from being scheduled on them
  • Isolate one or more cores from managing IRQ and RCU.
It is sufficient to insert some kernel parameters in the OS boot line, I tried it with some X86_64 distros and with Raspberry.
 
There is no point in rewriting the whole procedure here, it is explained step by step how to act on GRUB-based systems and on Raspberry. I leave you the link to the article.
 
What is possible to do, once a core is isolated, is to run OpenPLC runtime on it to benefit from an exclusive use of that core, increasing responsiveness and reducing jitter.
 
Just make a small change to ./core/main.cpp
first:
 
#include <sched.h>
 
Then append these lines in the __linux__ section
 
main_mod.png
 
 
The change is active after the next load/update of a program.
And, on starting, you should see this:
 
pinned.png
 
The core is now fixed at 1, maybe in the future it could be included in a "multicore" management as a parameter...
 
You can find the article here
(Notice that OpenPLC already locks its memory and increases the task priority, so you need only to add isolcpus, irqaffinity and rcu_nocbs params).
 
 
Have fun 😉
Reply 0 0
fg71
Thanks, I will try it.
 
Any plans to include Snap7 to OpenPLC 🙂
Reply 0 0
davenardella
Thanks, I will try it.
 
Any plans to include Snap7 to OpenPLC 🙂
It's non a bad idea 😉
But only for Windows/Linux, it would be too heavy for Arduino-like boards.
Reply 0 0
fg71
Its a kind of interesting approach specially when Siemens IoT2050 that is running Linux OS and support Arduino Shield.
It make me to think we could have Arduino shield for Raspberry Pi. https://www.dfrobot.com/product-1211.html
And how that will work I do not know, but it looks like there is ATMega 32u4 on that board.
 
I have never used Siemens IoT2050 but it looks to me it could be the same idea, what do you think?
Reply 0 0
davenardella
Look here, I explain, step by step, how to make an IoT gateway (OpenPLC, Node-RED, MQTT, Web Server, SQL Server, Samba ...) using these boards:
 
Iot.png
 
Arduino shields for IOT2050 I suppose are meant to use sensors and I/O interfaces born for Arduino.
Do you intend to have Raspberry and Arduino working together ?
(but why ?)
Reply 0 0
fg71
Thanks for sharing, 🙂
You are right when I think more about it, it doesn't make any sense. And more I think about I find more useful hats that could be used instead.
I do admit I have looking for IO-Link technology, I believe its Siemens technology. I have seen chips from TI and Framework how to use it. I also like to know more about EtherCat to drive a servo motor. I have Rpi4 and Rpi5 so I'm able to test many things, most of the things is for learning.
 
If I use Raspberry Pi as IoT device I will properly use communication protocols to do the event-driven applications.
If I have a cheap Arduino board connected to sensor, I will use communication protocol to talk to Raspberry Pi. And there are plenty of shields with Ethernet support if that is missing.
 
If you make Snap7 for OpenPLC I would use it to connect Siemens LOGO with Raspberry Pi. I have already done this thru Node-Red and also used OpenPLC PSM to use Snap7 for Python. I have own Siemens LOGO for more and 5 years and still think its amazing product and very cheap for what it does compare to other solutions. Also I'm a big fan of microPLC form factor. 🙂, its looks so nice on the din-rail haha
Reply 0 0
davenardella
"Also I'm a big fan of microPLC form factor"
Have a look at Arduino OPTA,
  • Cheap
  • The same form factor as LOGO
  • Fully IEC 61131-3
  • Programmable with OpenPLC
  • Native Modbus to communicate with Raspberry.
Reply 0 0
fg71
I think the hardware is nice (Arduino Opta) and the lite version is enough, is almost the same price as Siemens LOGO base unit.
What I do not like is PLC IDE (Software), its very confusing and old (I though the idea to put every function in the menu is kind of old idea). Sure you could change many of this things but I have always find it more useful to use tools there simplify things or do distract the users workflow. And when a software have a bad UI design for a laptop it become difficult to use. Other things I consider before I like to invest in anything is support if I need it. Is there any documents that is useful, could I figure it out myself...
 
I do have Giga r1 and it use the same hardware as Opta, so if I decide not to use PLC IDE and instead use OpenPLC it make less sense to get Opta.
 
I do miss Structured text in LSC on other hand LOGO have made me a better FBD programmer. 🙂
 
It could be interesting to understand how to scale 0-5v signal to 0-10v or use 4-20mA for analog signal. To learn how to make voltage divider, amplifier and voltage to current converter circuit. Maybe I will get one before summer to play with it. Lite search on the google gave me this Ti OPA192.
Reply 0 0
thiagoralves
The Opta will be a Giga that comes with all the circuitry ready to use built-in, so you don't have to fiddle with external components for 24V, 4-20mA, 0-10V, etc. Unless you *want* to play with hardware, the Opta is indeed a great option when you use it with the OpenPLC Editor.
Reply 0 0
fg71
It would be interesting to know how Opta Expansion Modules will work in OpenPLC or Arduino IDE.
Its one thing to configure something in IDE and it would be to access it from low level code.
 
If anyone have the opportunity to test it I would be interesting to know if it do works with OpenPLC or need extra configuration.
Reply 0 0
thiagoralves
OpenPLC can't use expansion modules yet. Me - or someone else - need to write Function Blocks that interface the modules, similarly to what's been done for the P1AM
Reply 0 0
fg71
I see, that is not so difficult then, I was curious so I checked the source code. It looks like there are method to getExpansion()
This is I2C address that use Arduino API like digitalRead/digitalWrite... Fron my understanding this could applied in hals.json
to use a specific opta_exp.cpp file or append with the opta.cpp with #ifdef.
 
So it first scan if there is expandtion module attached, next it get its type, next it get I2C address, and no we have object to use Arduino API.
 
You could check OptaBlue.h
Reply 0 0
thiagoralves
This has to be on a function block that the user configures, as the position, type and amount of modules changes from setup to setup. Having the code to interface modules fixed in a driver file might not encompass all scenarios.
Reply 0 0
fg71
I guess you are right, my understanding was it use index to scan the hardware and from it build a index of pins so if the hardware is changing.
The user only need to add to the size of pins or remove. And you only do that when you update your hardware.
 
On other hand function block with 10 inputs will make less for other things to feet the screen without scrolling 😉
Reply 0 0
davenardella
Normally the I/O hardware configuration is known in advance and follows the wiring diagrams.
 
So I agree with Thiago and advise against dynamic mapping.
OPTA allows you to do it, but it is not a very "industrial-aware" feature in my opinion, if used in that way.

Imho, the I/O enumeration is very useful, but it should only be used to verify that all of them work properly according to a map that we should know in advance.
So I think the configuration-FB is the best strategy, and it would also allow, as I said, to do a hardware check.
 
I received the I/O modules from Arduino before the launch to give some impressions and I did some tests/programs and considerations that you can find here.
 
Reply 0 0
Reply