Pasko70
Hi everyone,
first i want to stay, that your project is really awesome. Iam a student and im working on a project to build a HMI for a plc that we currently dont have. But openplc helps getting used to the modbus tcp protocol before the real deal arives.

Im talking via Labview to the virtual plc, which ist running on the same pc as openplc. 
The connection seems to be wokring fine:
Runtime Log .png 
First im not quite sure if the plc is acting as a slave here (because im running the master via labview) or the other way around.

Seccond i wanted to read a simple coil via modbus tcp. So i created this simple ladder logic and im running it on the plc:
Simple PLC .png 
When i read the coil at adress 0 via Labview im getting a false state. 
I thought the IEC-Adress %QX0.0 should be the modbus adress for 0.

For Hardware im using Blank btw..

Edit: Ok im guessing Labview is running as slave because if i terminate the connection via labview, i get the Log Message:
"client ID: 7 has closed the connection"

So maybe i run into problems because i initiate a master in labview and it runs as a slave. If I write any coil via labview, it gets true for one read cycle and turns back false after that.
Is there anyway to run openplc as a slave?

Thank you for your time.
Greeting Pasko
Quote 0 0
thiagoralves
Hi Pasko,

There is a lot of confusion with the Modbus/TCP "master" "slave" terminology. In Modbus terms, a "master" device is the one that initiates the communication, and the "slave" device is the one that responds to that request. Now, in TCP/IP network terms, a "client" is the device that connects to a "server" to make a request, and therefore the "server" is the one that responds to that request. So, in summary, OpenPLC is a Modbus slave, TCP server, and your Labview software should be the Modbus master, TCP client.

The messages you see on the log are related to the TCP/IP side of the connection, so it uses the terms "server" and "client". I'm not familiar with Labview, but couldn't it be that instead of reading the coil status from OpenPLC, it is reading the status from an internal buffer and then writing it back to OpenPLC as zero all the time? Because you said that when you write the coil it goes true for one cycle and then back to zero. Also, there is some confusion in Modbus addressing terminology, where some software starts counting from address 1 and others from address 0. This is because the old Modbus serial protocol had addresses starting from 1, but Modbus/TCP (OpenPLC case) defines in the standard that the address starts at zero. So maybe you can check the address scheme used by Labview as well.

A last tip would be to use Radzio Modbus software to read/write the coils and compare with whatever you're seeing on the Labview side.
Quote 0 0
Pasko70
First of all, thank you for your fast response.
So it seems like there is a problem in my ladder logic programm. Labview is also starting at index 0 and i even tried reading all coils,checking in a loop if any is true.
 Radzio Modbus is also giving me 0 for all coils.
RMM.png  Runtime Log rmm.png 
And i used KOP as the programm language.

Update: Im not sure what the problem was, but i compiled my programm again now it is actually showing the true value.
Thank you for your time and the explanation about the server/client mechanism, it helped me alot.

Greetings Pasko
Quote 0 0
thiagoralves
I believe what happened is that you were probably running the Blank Program instead of yours. When you run OpenPLC the name of the active program appears on the top bar. Make sure that this is the program you want. 
Quote 0 0
Pasko70
I actually have another question. It would be really kind iof you, f you could help me with that.
So modbus communication is just working fine and write/read coils/registers is no problem. But im now converting my single float in labview into two words, so i can write them into 
the registers of the openplc. Now i acutally want to convert it back to a "real" on the plc side. Is there any function that can acutally do that? There are many conversion types, but they all only take in one variable. Else i could maybe convert my two words into a dword and then into real. 
Or do i have to write a function for the conversion myself?
Greetings Pasko
Quote 0 0
thiagoralves
Write your real numbers on registers 2048-2049 (%MD0 range) and then on your PLC program, add a variable located at %MD0 of type REAL
Quote 0 0
Pasko70
Thank you for your help, worked perfectly.
I guess this address range is specific to openplc?
Is there any documentation to the addresses of the openplc?
Quote 0 0
thiagoralves
http://www.openplcproject.com/scada
Quote 0 0
Pasko70
Thank you for your help
Quote 0 0