1. Ethernet master station communication binding remote IP command DESTIP

1. Ethernet master station communication binding remote IP command DESTIP

1.1. Instruction Description

This instruction is used to establish a connection between the local IP of the PLC and the remote server IP. Ethernet communication can only be carried out after a successful connection is established. At present, up to 6 TCP connections can be established simultaneously, which means that as an Ethernet client, PLC can establish connections with up to 6 Ethernet servers simultaneously. However, the remote IP parameters of this instruction can be changed. When 6 connections have already been established and a connection needs to be established with a new remote IP, the command can be disabled, one of the remote IP parameters can be modified, and be reconnected to enable again. The PLC will establish a connection with the newly IP and the original connection will be disconnected. Before using the MBUSTCP command to communicate with an external server via Ethernet, it is necessary to first establish a connection with the external server using the DESIIP command.

  1. First address of parameter: Set the first address of the remote IP and port number parameters, and refer to the example for the parameter format;

  2. Client ID: Set the connection ID between the local IP and the remote IP, ranging from K0 (seckcot0) to K5 (seckcot5);

  3. Reconnection times: Set the number of connections between the local IP and the remote IP. The input parameters represent K0: no reconnection, K1~K65534: reconnection range, K65535: continuous reconnection, and the time interval for reconnection is set to the "connection timeout" parameter in the master station parameter settings;

  4. Return code: Returns the current TCP connection status, with a total of 8 states, as shown in the table below:

Return code Status description
0x00 TCP connection successful status
0x01 TCP connection start status
0x02 TCP is currently connecting
0x03 TCP connection timeout status
0x04 TCP connection failure status (fault)
0x05 TCP Not Connected Status
0x06 TCP socket connection count exceeds limit
0x07 TCP master station function not enabled

Attention:

  1. To establish a connection between PLC and external server devices, they need to be in the same local area network, with the same IP address and network number;

  2. After enabling the command, if the enabling condition is disconnected, the previously established connection will be disconnected. Modify IP parameters, re enable, and establish a new connection;

  3. When setting the reconnection parameter using DESTIP, if K0 is set to not reconnect, it will default to connecting once and will no longer attempt to connect after timeout; If set within the range of K1~K65534 reconnection times, when the cumulative number of connection timeouts exceeds the set reconnection times, the connection will no longer continue. Both settings need to be disconnected and the DESTIP command enabled again before reconnecting. Please be careful when using! If K65535 is set to always reconnect, it will automatically reconnect after the connection timeout. Please choose a reasonable setting according to the scenario requirements. If there are no special applications, it is recommended to use K65535 to always reconnect.

1.2. Example

As shown in the following figure, D5000 is the first address of the instruction parameter, where the remote server IP parameter is 192.168.1.200 and the port number is 2000. Assign this parameter to D5000~D5004, connect M0, establish a connection, and number the connection as 0.

Instruction table:

NETWORK 000

LD M0

MPS

MEP

MOV K192 D5000

MOV K168 D5001

MOV K1 D5002

MOV K200 D5003

MOV K2000 D5004

MPP

DESTIP D5000 K0 K0 D5006

POP

LAD:

DESTIP

图1 DESTIP