Yukkotete
Hi all,
I am working with a UniPi Board connected to a Rpi and I am working o a project involving an image recognition system.
I know that I cannot work with my camera using PLCopen Editor, but I would like to know if there is some way I can make my program in PLC editor work with some external source, like a txt file or if it is possible to change some memory parameters of the program if it is sharing memory with the RPi and it is possible to have access to those memory registers.
thiagoralves
The answer for that is Modbus. OpenPLC talks Modbus/TCP out of the box. Your external program can send Modbus messages to read and write to the PLC memory.
Reply 0 0
Yukkotete
Any examples of it? Because I have never worked with Modbus and PLC.
Maybe some project where i can see how it works?
I will try to find some information about it, I know how Modbus communication works but I have never worked with it.
Reply 0 0
thiagoralves
If you want to know more about Modbus, this is a great site: http://www.simplymodbus.ca/FAQ.htm

They have all Modbus function codes (FC) on the left menu with examples for you to explore. Another good thing to do is to download the Radzio Modbus software and connect to OpenPLC to read and write values. You can let the software read inputs and then play with the RPi physical inputs to see how the numbers change.
Reply 0 0
Yukkotete
Do i need to uninstall the OpenPLC drivers and re-install them using the modbus config? Because i am working with an UniPi board.

If yes, will modbus config be ok with my UniPi board and its analogical output?

I need to use the UniPi board and make the comunications with the internal program that will be controlling the RPI camera.
Reply 0 0
thiagoralves
You don't need to change or do anything. OpenPLC is a Modbus slave device out of the box, no matter which driver you selected at the installation. This means that other programs or devices can control OpenPLC (read and write to it's  memory) over Modbus/TCP. Just start OpenPLC on your UniPi and connect to it using the Radzio Modbus software. You'll see that you will be able to read and write to PLC memory from it.

The Modbus driver you can choose at installation is to make OpenPLC a Modbus Master device, and therefore control other slave devices. It is like an I/O extension for OpenPLC over Modbus. As far as I know, this is not what you want.
Reply 1 0
Yukkotete
Thaks, it worked fine with Radzio to see Input and Coil status, but i also want to see memory registers and work with them.
Where are they located?
I asked also on this post, cause it seems to be related with my question:
https://openplc.discussion.community/post/some-modifications-for-modbusmaster-cpp-and-the-config-file-8521337?pid=1295821568
Reply 0 0
thiagoralves
On the drop down menu select "Holding Registers"
Capture.PNG 

For Holding Registers you can read and write to them. If whatever you write conflicts to what the ladder logic program is writing, the ladder logic will prevail (i.e. you write 10 to register 0 but ladder logic is writing 20 to the same register 0, at the end register 0 = 20)

You can also read Input registers. You can not write to Input registers because they reflect whatever the PLC read from sensors on its analog inputs.

To know the addressing, check http://www.openplcproject.com/scada
Reply 1 0
Yukkotete
OH WOW OK. 
I din't know that i had to locate my variables on PLC Open Editor.

One more question, can I work with Holding Registers as if they were digital registers (BOOL type)?
Reply 0 0
thiagoralves
You can, but on your ladder logic it can be a little messy, because you will have to use compare blocks to know if the register value is 1 or 0. As opposed to boolean types, holding registers can hold a 16-bit value (integer from 0 to 65,535). Therefore instead of "true" or "false", this register stores numerical values. If you want to use them you will have to compare them all the time.

However, if you're looking for memory bit variables, you can use coils that are far away from the usable coils. Something like %QX99.0 won't reflect anything on your physical device but will still work.
Reply 0 0
Reply