10-02-2015 06:15 AM
I have been using LabVIEW for over 20 years but until now, I have not needed to use Modbus or OPC, so, this is a Newbie question for these items. After some reading I understand Modbus serial and TCP pretty well.
I am using LabvIEW 2015 (RT, FPGA) with the built-in supported NI Modbus vis and I'm trying to connect to a NI OPC server. The code I inherited expects the OPC server (TCP) to connect to the LabVIEW application as the Modbus master (thus the PC is the Modbus slave). I don't know if this is the correct setup because
a) the code I have isn't the most recent (supplier lost it)
b) I don't know if this code ever worked (no one knows how recent it is)
c) I can't get the OPC server to connect (as a master) to the PC (slave) using simple vis (as used by the Modbus exmaple from NI)
I may eventually convert the code and hardware to cDAQ RT-Linux or cRIO, so I'd really like to keep LabVIEW I/O with the OPC server Modbus-based.
I can connect and update tags if the PC is the Modbus master, but I don't believe that is how the supplier setup the communication.
I tried over and over to make the (working OPC setup used in the lab) OPC server connect to the LabVIEW slave, but I have not had any luck.
So, my question is, shouldn't the OPC server be able to act as a master on Modbus (TCP) and connect to the PC (slave)? From what I read, this is how it is supposed to work.
Thanks,
Todd
10-05-2015 04:19 PM
Hi Todd,
The OPC Server is like a bridge to communicate in this case LabVIEW (cRIO, PC, etc) with another device, usually PLC. When we create the communication, for example Modbus, we choose which device would be the slave and which one the master. We cannot choose or select that the OPC server be the master or the slave.
I do not know if this is the answer that you are looking for, but the OPC server cannot act neither as a slave or as a master, it just is a software program that converts the hardware communication protocol used by a PLC into the OPC protocol (in this case LabVIEW).
Regards
10-06-2015 05:17 AM
The OPC Server has to operate as as a master on Modbus if the target is setup as a slave since Modbus is a poll/response protocol, the master has to initiate the request...I don't believe slaves can talk to slaves.
I found what the issue was by accident...the OPC Server needs a connected OPC client that wants the data that comes from the Modbus slave...the OPC server isn't going to query the Modbus slave if no one wants the data. Once I realized that yesterday, it makes sense but I couldn't find any documentation that says this...I burned 3 days trying to figure this out.
So, my tester can successfully act as a TCP Modbus slave to whomever wants the data (in my case, the OPC server). The next problem is to figure out why a single-precision float sent via modbus is incorrectly interpreted by the OCP server (type = float, 32 bit single precision)...the numbers are slightly off. Such as 123.456 is received as 123, 1.2345 is received as 1.23438, and 1975 is received as 1968. I have a support ticket with NI and will update this post if an asnwer is found.
Thanks,
Todd
08-16-2017 05:41 AM
I forgot to update the fix for the problem of reading a 32 bit float...my goof, was indexing incorrectly.