Collapse
CollapsingX
  • - or -

Procedure for using the NetworkConnection step


The following provides a basic methodology for using the NetworkConnection step:

  1. To establish the connection, place the NetworkConnection step before the first NetworkReader step or NetworkWriter step. Note that the NetworkConnection step should also be placed before the primary programming loop.

  2. In the Configuration pane, specify a Connection name. Subsequent steps from the Network step category will use the Connection name to access the connection.

  3. Choose a Protocol type. Note that the chosen protocol must be the same for both the network client and your project. Refer to the documentation that came with your connecting device to determine its protocol.

  4. Specify the Operation to be performed (for example, open a connection). Note that the operations available are limited based on the chosen protocol.

  5. Specify the Port number of your runtime platform. By default, this value is set to 5555.

  6. When listening for a TCP connection, the port number specifies the local port that accepts incoming connection requests. When connecting, the port number specifies the port on which your network client is listening for the connection. Refer to the documentation that came with your connecting device to determine your port number.

  7. Specify the IP address or Host name for the connection with your network client. Note that you can learn the name of your development computer and its IP address by running the Matrox Network Client utility. This information is displayed in the utility's title bar.

  8. Modify the Encoding scheme for the data, to match that of your network client, if the default does not match.

  9. Configure your network client.

  10. To close the connection, place a second NetworkConnection step after the last NetworkReader step or NetworkWriter step.

  11. In the Configuration pane, set the Name of the connection to close to the name used when creating the connection.

  12. Set the Operation to close the connection.

Network Client configuration

To configure the Matrox Network Client utility, perform the following:

  1. If listening for a connection, set the IP address or host name to localhost. Otherwise, if opening a connection with your project, set this value to the IP address or host name of your runtime platform.

  2. Set the port number and the encoding type to the value in the NetworkConnection step that establishes the connection.

  3. To listen for a connection when using TCP, click on the Listen button and run your project. If, however, you want your Network Client utility to open the connection, run your project, and then click on the Connect button in the Matrox Network Client utility.

  4. To listen for messages when using UDP, select the Listen on port option and click on the Apply button before running your project.

Connection verification and troubleshooting

Once a connection has been established, Matrox Design Assistant is able to communicate with the network device so long as the connection remains intact. Connections might be terminated intentionally, when one side or the other closes the connection, or unintentionally, for example due to a power cycle or physical cable disconnection.

Properly closed connections will be reported as Disconnected in the Status property of the NetworkConnection step, NetworkReader step, and NetworkWriter step. Unfortunately accidental breaks in the connection are not signaled to the camera, and a NetworkReader step on a broken connection will wait until the Timeout property is reached (which could be infinitely long).

Furthermore, even when the original cause of the disconnection has been fixed, the project will not reconnect unless the flowchart is set up to deal with this possibility.

To maintain robust communication that can handle unforeseen disconnections is a shared responsibility of both sides. It depends on the project and also on the behavior of the computer, PLC or robot controller with which you are communicating, and so is beyond the scope of the User Guide. However the following recommendations will form the base of a more robust setup:

  1. Set the Timeout property in the NetworkReader step to a finite time. If an unplanned disconnection occurs, the NetworkReader step will wait, stalling the project until the timeout expires. Note that if there is a timeout, the Status property value will be TimedOut.

  2. Use a Condition step to check the Status property of a NetworkReader step before accessing the ReceivedData property. If the Status is not equal to DataRead, trying to access the data will cause a runtime error and terminate the project.

  3. It is not necessary to check the Status property of every NetworkWriter step, but verifying periodically that the last NetworkWriter step has a Status of DataWritten can help detect a broken connection.

If a read has timed out, or data has not been written, you can signal the situation through discrete IO or the HMI and let an operator take corrective action or you can add a NetworkConnection step that attempts to reconnect and then checks to see if the connection has succeeded.

Note that the list of possible Status property values in the Verify option includes Connected, which only applies to TCP connections, and Opened, which only applies to the less frequently used UDP protocol.

In some situations a watchdog handshake protocol is used to check the existence of the connection periodically. Similar to a ping, one side writes a short message and waits for a response. If the response is not received it then attempts to close the network connection and try to re-establish a new one. Typically the handshaking is done with a dedicated second connection on a separate port.