From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus communication problem

Hi all!

 

We have a Unitronics PLC as slave and it's connected via ethernet cable in a switch. In the switch is also connected the PC (master) using Modbus protocol to communicate with the PLC. The PLC communicates with a labview application version 8.6.

 

In the application we want when the connection is lost to be recreated automatically. When the application is launched the connection is created automatically (using "TCP open connection" with time out value 10000msec). when the connection is lost (checked by "error out" of modbus functions) application closes the lost connection using "TCP close connection" and then tries to reconnect using "TCP open connection" with time out value the same as before. PLC's time out value is 1000msec.

 

The connection might get lost if for example 1) we remove the connection cable or restart the PLC or the PC. 2) because of TCP, modbus or something else error. The problem is that sometimes it reconnects and sometimes it doesn't. Could you please tell us why that might happen and how could we solve it, or should we do a communicaton check in the PLC?

 

 

Thanks,

0 Kudos
Message 1 of 6
(7,221 Views)

Dionysis,

 

Hello! When your application doesn't reconnect, what is the behavior? Do you get an error message? Does it just not work? etc?

 

Check out this example on how to Reconnect TCP Connections from LabVIEW.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 2 of 6
(7,189 Views)

Hi Ben S

 

When it doesn't reconnect the program is running in a loop until it creates a connection. I have checked this debugging it. "TCP Open connection" error output varies, sometimes is 62, 63 or 66.

I downloaded the "Reconnect TCP Connections" but it's too old to be converted to Labview 8.6

0 Kudos
Message 3 of 6
(7,158 Views)

Dionysis,

 

Here is the Reconnect TCP Connections VI saved for LabVIEW 8.x and 2009. If you could post screenshots of the errors that would be great! 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 4 of 6
(7,125 Views)

Hi Ben S

 

Thanks for the example but,  in the example you have sent me labview program works as a listener.  My program creates connection with the PLC. The PLC is slave.


About the error screenshots

I'm not in the installation but even if I was, i couldn't easily produce an error because these errors are occured rarely and even more if this error is not occured from cable removal and then reconnecting it. I only know the labview error descriptions which are:


Warning 62 occurred at an unidentified location

Possible reason(s):

LabVIEW:  Serial port overrun error.
=========================
LabVIEW:  The system caused the network connection to be aborted.



Warning 63 occurred at an unidentified location

Possible reason(s):

LabVIEW:  Serial port receive buffer overflow.
=========================
LabVIEW:  The network connection was refused by the server. For TCP/IP, make sure the server is running and listening on the port you are trying to use. Firewalls can also cause a server to refuse a connection. For VI Server, make sure you have enabled VI Server from Tools>>Options>>VI Server:Configuration.



Warning 66 occurred at an unidentified location

Possible reason(s):

LabVIEW:  The network connection was closed by the peer. If you are using the Open VI Reference function on a remote VI Server connection, verify that the machine is allowed access by selecting Tools>>Options>>VI Server:Machine Access on the server side.



I post you these (i don't know if this might help you)

A very simple diagram of the application about the connection is the following

 

 

 image 2.JPG

 

 

 

Here is the case structure with the reconnection loop (image 1)

 

 

 

 

 image 1.JPG

 

 

 

Thanks

0 Kudos
Message 5 of 6
(7,107 Views)

Dionysis,

 

Thanks for the information! After doing some more looking I found this document, TCP/IP Error Codes and Related Time-out Issues in LabVIEW, which indicates that TCP error 66 is often a result of the user timeout expiring. You could try extending that timeout or placing a delay in your code before each re-establishment attempt. 

 

To prove that your PLC wasn't the issue, you could right a small LabVIEW program to run on another computer as a slave and talk with it instead of your PLC.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ben Sisney
FlexRIO V&V Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 Kudos
Message 6 of 6
(7,081 Views)