lfautsch
Hello! I believe I have a bit of a disconnect in my understanding of how open PLC utilizes drivers.
 
I would like to create a function block that can be used in OpenPLC Editor and will call functions in a .cpp driver but I'm not sure how to do that. I believe I understand how to have the runtime utilize the drivers, but making these functions available in the editor is where my knowledge gap is.
 
I've seen plenty of resources regarding PSM but not for C++ and, unfortunately, I cannot accept the latency issues that PSM has for my application.  
 
Any help would be greatly appreciated. Apologies if there is a C++ resource I have missed.
Reply 0 0
thiagoralves
If all you want is to write some C++ code that runs alongside your PLC programs, just create an Arduino Extension on the grey plus icon at the left panel. This is the easiest way to add C++ code to your project.
 
If you really want to create a new block that will be available for all your projects, then the procedure is more complicated. Check the documentation here for more details: https://autonomylogic.com/docs/3-3-adding-new-blocks-to-openplc-editors-library/
Reply 1 0
lfautsch
Will I need to add the .cpp driver to the OpenPLC_Editor folder somehwere? Or does the editor only need to know that the functions exist in the header folder?
Reply 0 0
thiagoralves
No, for the Arduino extension everything is done automatically. You just click on the plus icon and write the code
Reply 0 0
fg71
To make things clear.
 
PSM is part of OpenPLC_v3 runtime its a SoftPLC running on SBC or general purpose computer. OpenPLC Editor is PLC IDE able to program IEC-61131-3 supported program language. It also include extension to be able to include C/C++ and use Arduino API. Any header you use in Arduino IDE you could include top of your Arduino extension program. For example you could directly include protocol as Arduino extension code and build a bridge between PLC program to other protocol.
 
Arduino extension is POU (Program Organization Unit) meaning if you like to build Function Block and use Arduino extension its possible.
You only need to use the class external to define your variable to be used in your Function Block. You couldn't directly assign a input or output as you do in Function Block to Arduino extension variable. That why you do not see the column class in table in Arduino extension. So you need to define your input and output from Function Block and from your logic block you assign your Arduino extension variable.
Reply 0 0
Reply