Xinjie PLC uses TCP/IP protocol to communicate



foreword

The Ethernet model of Xinjie PLC is equipped with RJ45 interface. This article takes the XDME series as an example to describe the communication between Xinjie PLC and the host computer through TCP/IP protocol.
It should be noted that some models of Xinjie have RJ45 interface but do not support Ethernet function, and its RJ45 interface is used for EtherCAT to connect with the servo drive.


1. The advantages/disadvantages of the advantages of TCP/IP communication

Advantages:
1. Since the TCP/IP physical layer is connected by a network cable, the anti-interference performance and transmission stability of the network cable are excellent under the condition of shielding.
2. Compared with ModbusTcp communication, parameters such as address and scan cycle do not need to be configured, and the ease of use is high.
3. Good real-time communication.
Disadvantages:
1. Since the internal data of the PLC are all stored in the registers, and the upper computer such as the computer or the mechanical arm is transmitted through ASCII, the data needs to be translated before it can be used.
2. PLC cannot directly read coils and registers using TCP/IP, and needs to write a response program to read the specified data.

2. TCP/IP communication configuration of PLC

1. First determine the IP of the PLC

The default IP of Xinje PLC is 192.168.6.6. If you need to modify it, you can modify it in the network settings on the left side of the seat.
(The dual-port PLC also has only one IP, and the two network ports communicate with each other, which is equivalent to a dual-port switch)

If you need to modify the IP address of the PLC on the touch screen, you must use the IPSET command

2. The program establishes a connection

Whether the PLC is a TCP server or a TCP client function, it needs to be opened through the program.

The code is as follows:
Configure TCP/IP Connection Ladder Diagram
The configuration of the S_OPEN command is as shown in the figure below: 1. The socket S_OPEN configuration
in Figure 2
is equivalent to a label (serial number) for the PLC to the communication device, and provides operations for sending and receiving commands when establishing communication with multiple devices at the same time object.
2. The register referred to by the parameter address, including the device's IP, error code, etc. If the PLC is used as the client, the target IP and port information can be modified through the touch screen.
3. The flag start address Mn—M(n+9) all need to be occupied, and the meaning of each flag bit can be found in the manual. The manual is attached at the end of the article.
4. Receiving timeout refers to the total time from when the PLC generates a request to receive data to when the action is terminated. The value range is 0-65536, and the unit is 10ms.

For example: set the receiving timeout to 300ms: the request generation starts to wait for the response of the other party for 300ms, and terminates immediately after successfully receiving data, and ends the current command and reports a receiving timeout error if no valid data is received after 300ms. Setting it to 0 means that the receive timeout is not enabled and data is received continuously.

In the first line of the ladder diagram, after the network cable is inserted and initialized, if the target device does not establish a connection, execute the connection establishment command with a cycle of 100ms.
In the second line, when the connection is established, the continuously received data is stored in the last 400 registers of D2600, and the data in the designated register is sent once per second.

3. Examples

Next, establish a connection with the PLC through the network debugging assistant.
The ladder diagram in the figure is written by hand and is not for reference.
Example 1
Network debugging assistant
After the connection is established, send data to the PLC through the network debugging assistant. It can be seen that each character received by the PLC is stored in an independent register in ASCII form . This is actually not conducive to our data processing.
At present, the way I use to communicate with the upper computer is to use specific characters as flags, and make conditional judgments in the PLC program to realize the control of the upper computer to the PLC.
If you need to transfer data, you need to write translation code in advance. This step is recommended to use the c language function block function of PLC to realize.

For the use of Xinjie's C language function block, please refer to the Xinjie C language function block application I wrote before.


Attach the flag register function table mentioned above

S_OPEN configuration
List of Ethernet communication errors

Xinjie Communication Related Coils

Guess you like

Origin blog.csdn.net/canmianlaida/article/details/129483070