jerry
Hi, all:

Here is my scenario:
* Let's use "Hello_World" as the example.
* I run it on Raspberry-Pi: we push the "button", and "lamp" is on for 2 seconds
* so far so good!

Now I want to do:
* Change the PLC program: -----------------------------------------I know how to do it!
--- disconnect "button" and "lamp".
--- "button" is to be read by a program
--- "lamp" is to be write by a program
* Write a program to talk with this running PLC, so that:-------I do NOT know how to do it
--- It reads "button" value from PLC program (PLC is running)
--- It write "lamp" value to PLC program (PLC is running)

I think I have to: (correct me if I am wrong, please!)
* modify function "glueVars()", so that it can talk with the program.
* but how to write the program?
* what is the best communication mechanism between them?
* Can the Node.js-web-server talk with the running PLC?

Can somebody provide some hints?

Thanks,
Jerry
Reply 0 0
thiagoralves
You don’t have to modify anything on OpenPLC. If you want an external program to read and write to OpenPLC inputs and outputs, simply use Modbus. OpenPLC talks Modbus/TCP out of the box.
Reply 0 0
jerry
Thiagoralves:

Thanks for your response, but now I am confused:
* Isn't Modbus used to simulate hardware I/O? just like Raspberry-Pi I/O?
* I am not talking about physical/virtual hardware I/O, here is what I want:
--- PLC use Raspberry-PI as hardware I/O
--- In the mean time, I want another program to talk with PLC
--- So basically it is:  Program <---> PLC (on RaspberryPI) <---> RaspberryPI-I/O

So you understand what I need, right? 
Do you mean I can do: Modbus(on PC) <---> PLC(on RaspberryPI) <---> RaspberryPI-I/O ?

Thanks!
Reply 0 0
thiagoralves
jerry wrote:
* Isn't Modbus used to simulate hardware I/O? just like Raspberry-Pi I/O?

No, Modbus is used to read/write internal contents of the PLC. For that reason it can be useful to verify the current status of the I/O.

jerry wrote:
Do you mean I can do: Modbus(on PC) <---> PLC(on RaspberryPI) <---> RaspberryPI-I/O ?

Yes. You can even run your Modbus program on the Pi itself if you want. Just keep in mind that Ladder Logic has precedence over Modbus requests, which means that if you have a rung that says your %QX0.0 should be OFF and you try to write it to be ON using Modbus, it will remain OFF.
Reply 0 0
jerry
OK, I will try it.
Now I have further questions:
* I am new to Modbus and don't have any Modbus hardware, any Modbus software to recommend?
* Is the out-of-box Modbus/TCP on Raspberry-PI a master or a slave?

By the way, I just download Radzio Modbus:
* I upload 'Hello_world.st"
* Then I connect Radzio Modbus to IP/port of PLC
* I see nothing no screen of RadzioModbus, what do we suppose to do and see?


Thanks!
Reply 0 0
thiagoralves
jerry wrote:
 any Modbus software to recommend?

Radzio Modbus
jerry wrote:
* Is the out-of-box Modbus/TCP on Raspberry-PI a master or a slave?

slave
jerry wrote:
* I see nothing no screen of RadzioModbus, what do we suppose to do and see?

It might be helpful if you google a bit about Modbus to understand how it works. A good source is the SimplyModbus website. Basically you need to click on file->new to see a new spreadsheet (after you are successfully connected) and then you will see the data on the spreadsheet 
Reply 0 0
jerry
Hi Thiagoralves: Eventually I figured it out!
I may suggest to:
* add screenshots and brief instructions to section "Pin Mapping" of getting-started-page: http://www.openplcproject.com/getting-started-linux
* so that beginners will know what to do and what to expect.

Thanks again!
Reply 0 0
Reply