Logopaede
Hello,

I have a very basic problem and don't know where to start, because I don't understand the basic concept.

I have two separate OPLC programs that I can run on my Raspberry Pi 4B.
Program_A is two buttons and a LED.
Program_B is fetching a temperature wirelessly from a NodeMCU via Modbus IP.

On a small HMI I have a graphical representation of the states of the buttons and the LED when Program_A is running.

Now I want to "merge" both programs to a new Program_C, so I can also monitor the temperature on the HMI besides the states of the buttons and LED.

How to do that? How can I combine the ladder logic of Program_A and Program_B?
Program_B contains a Function Block, that converts the analog input of a NTC sensor to a temperature in °Celsius.

Although I guess it is a FAQ I can't find a starting point, sorry.
Reply 0 0
thiagoralves
Copy paste?
Reply 0 0
Logopaede
Copy paste?


Ok thanks, that brings me one step further, no import/export thing, just copy&paste 🙂

Just? ...
I can only open one single project into OpenPLC Editor v1.0 (Linux). So I have to start two instances of the OpenPLC Editor to copy something from project A to B, I guess (is this correct?). Here my two windowsopenplc-program-combination?.png :


I cannot mark and copy program0 for example to copy it over to my Project 'Unnamed'.
Even if that would be possible -- how to handle the other contents ADC2Celsius, A0, Tc, etc.?

Is it documented somewhere? Or is it necessary to copy & paste on the filesystem layer?
Reply 0 0
thiagoralves
You can only copy/paste the contents of a POU, not an entire POU object. So, in that case, you will have to manually create the Program / Function Blocks (or any other POU) you want to copy and then paste the contents inside.
Reply 0 0
Logopaede
I'm still not sure, if two instances of a running OpenPLC Editor are allowed, because one instance became unresponsible while playing around with copy/paste actions (or just accident?).

So I opened just one instance at a time and tried to follow your advice, thank you. I began with the Function Block. I copied its name 'ADC2Celsius' and the function code to a text-editor.

Then I closed the Project_A and opened Project_B.
In Project_B I created a new Function Block with the name 'ADC2Celsius' and
into the new Function Block I copied and pasted the function code I had in my text editor.

My problem remains the table with all the variables of the FB (screenshot attached). I don't know how to copy this. Do I really have to create every variable again and to fill each field by typing on my keyboard?
The table has 6 x 14 = 84 cells. A lot of stupid work :/
Really?

Function-Block-variables_example.png
Reply 0 0
thiagoralves
That’s how it is right now. About having two instances open at the same time, it should be totally fine. At least on Windows it works great
Reply 0 0
Logopaede
That’s how it is right now. About having two instances open at the same time, it should be totally fine. At least on Windows it works great


With your help I got it running, thank you!
I have the OpenPLC Editor running on a weak netbook with a Celeron N3050 and a small 11"-display. With the touchpad I got mad to copy cells between two tiny windows of the OpenPLC Editor, but with an attached USB-mouse it was doable. I felt kind of a papyrus copyist thousands years ago ;-). I wonder, how powerusers scale this process, when they want to reuse programs and function blocks in several projects.

For other noobs like me some of the hurdles:
* Two programs can run parallelly. I didn't know that 🙂. Obviously the whole project is compiled to one *.st.
* Variables and their types have to be copied or created field by field. Exception was the variable for the function block, it appeared in the table when I copied the graphical elements in the Editor.
* Both combined programs can run with individual cycles by assigning two tasks and instances in Res0.

Here the result of my digital and analog combination:Monitoring-oplc-runtime-two-programs.png oplc-two-programs-combined.png 
Reply 0 0
thiagoralves
For function blocks you can actually copy/paste the entire block from one window to the other. This will copy the entire block including its internal variables and code. For that you will have to right click on the Function Block at the left panel tree and select "Copy POU". Then open the second project, right click on your project's name (the top item at the tree hierarchy on the left panel) and select "Paste POU".
Reply 0 0
Logopaede
Yes, it works to copy the Function Block completely using "Copy POU"!
And "Copy POU" even works with a program POU, yet tested!!
That is exactly what I needed initially. Face palm :-)

Thank you, you're the man!
Reply 0 0
Reply