Programmable logic controller communication method and device based on TCP protocol

By implementing a TCP protocol-based communication method between Mitsubishi programmable logic controller and the Dannykor tightening machine, the problem of data interaction through the TCP protocol in the prior art is solved, and the stable communication and tightening result data transmission is realized, which improves the production intelligence level and quality monitoring capabilities.

CN120017733APending Publication Date: 2025-05-16HARBIN SHIMADA BIG BIRD IND
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510132235.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-06
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

In the prior art, data interaction between the Denikkor tightening machine and the Mitsubishi programmable logic controller cannot be performed through the TCP protocol, and in particular, the final tightening result data of the tightening machine cannot be read, which limits the monitoring of tightening quality and the improvement of production efficiency.

Method used

A programmable logic controller communication method based on TCP protocol is proposed, including configuring connection parameters, presetting MID codes, building data packets, setting communication status flags, sending and receiving data packets through TCP protocol, realizing effective data communication between the programmable logic controller and the target device.

Benefits of technology

It realizes stable TCP communication between Mitsubishi programmable logic controller and the Dannykor tightening machine, supports the transmission of tightening result data, improves the level of production intelligence, and provides reliable data support for quality monitoring and production optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120017733A_ABST
    Figure CN120017733A_ABST
Patent Text Reader

Abstract

The invention discloses a communication method and device of a programmable logic controller based on a TCP (Transmission Control Protocol), relates to the technical field of equipment communication, and is used for solving the technical problem that a Mitsubishi programmable logic controller cannot communicate with a Dannikel tightening machine by using the TCP in the prior art. According to the technical scheme, the method mainly comprises the following steps: configuring connection parameters of a programmable logic controller to establish communication with target equipment; constructing a data packet containing a control instruction by using the MID code; setting a communication state flag bit and a sending request flag bit; the sending connection opening request and the data packet are sent to target equipment through a TCP protocol; the target equipment performs data analysis, executes the control instruction, constructs a response data packet and returns the response data packet to the programmable logic controller; and analyzing the response data packet and extracting data to complete communication. Communication between the programmable logic controller and the equipment is realized based on the TCP protocol, simple signal interaction is expanded to accurate data communication, and a traditional communication mode between the programmable logic controller and the equipment is broken through.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of device communication, and in particular to a communication method for device data transmission. Background Art

[0002] At present, it has never been possible for the Dannicker tightening machine to communicate with the Mitsubishi programmable logic controller through the TCP protocol, monitor the tightening process in real time, and output the tightening result data. In practical applications, the communication method between the Dannicker tightening machine and the Mitsubishi programmable logic controller still has limitations. Usually, they can only interact through IO signals. This interaction method based on IO signals only supports simple switch signal transmission, which is difficult to meet the modern industry's needs for data real-time and further availability. For example, in a tightening task, obtaining the final tightening result is crucial to ensuring tightening quality and improving production efficiency, but it is impossible to read key data such as the tightening machine torque value, tightening angle, and task status through IO signals.

[0003] The deficiency of the prior art is the lack of an effective solution, which makes it impossible for the Dannick tightening machine and the Mitsubishi programmable logic controller to exchange data through the TCP protocol, especially the inability to read the final tightening result data of the tightening machine, which limits the monitoring of tightening quality and the improvement of production efficiency. Summary of the invention

[0004] The invention solves the technical problem in the prior art that the Mitsubishi programmable logic controller cannot communicate with the Dannick tightening machine by using the TCP protocol.

[0005] The present invention proposes a programmable logic controller communication method based on the TCP protocol, the method is implemented based on a programmable logic controller, and the method includes:

[0006] S1. Configure the connection parameters of the programmable logic controller to establish communication with the target device;

[0007] S2 preset MID code, using the MID code to construct a data packet containing control instructions;

[0008] S3 writes the data packet into the transmit register;

[0009] S4. Set the communication status flag and the send request flag to establish TCP communication with the target device;

[0010] S5. When the connection status with the target device is completed normally, a connection opening request and the data packet are sent to the target device via the TCP protocol;

[0011] S6. The target device receives the data packet, performs data parsing, executes the control instructions in the data packet, and constructs a response data packet to return to the programmable logic controller;

[0012] S7. The programmable logic controller receives the response data packet to the receiving register, parses the response data packet and extracts data to complete the communication.

[0013] Furthermore, the connection parameters in S1 include the IP address, port number, TCP protocol and connection mode of the target device; the connection mode includes Active mode and SUMP mode, wherein the Active mode is a mode in which the programmable logic controller actively initiates a communication connection to the target device, and the SUMP mode is a mode in which the programmable logic controller waits for the target device to initiate a communication connection.

[0014] Furthermore, the process of S2 includes:

[0015] S21. Preset MID code; the MID code is:

[0016] MID code 0001, operation type R, establish communication connection;

[0017] MID code 0002, operation type R, disconnect;

[0018] MID code 0102, operation type W, download Pset parameters to the electric gun;

[0019] MID code 0103, operation type W, Pset selection;

[0020] MID code 0201, operation type R, operation status Ready / Running / OK / NG / Err;

[0021] MID code 0202, operation type R, final tightening result;

[0022] MID code 0203, operation type R, real-time curve data;

[0023] MID code 0204, operation type W / R, Pset data read;

[0024] MID code 0301, operation type W, motor stop enable ON / OFF;

[0025] S22 organization data domain; the MID code and parameters as a request instruction embedded in the data field of the data packet;

[0026] S23. Assemble data packet; the data packet is 0x02 0x000x000x000x05 0x52 0x300x300x300x31 0x03. The data meaning of the data packet, from left to right, are:

[0027] The first byte is the frame header: 0x02;

[0028] The 2nd to 5th bytes indicate the length of the data field: 0x000x000x000x05;

[0029] The sixth byte indicates the operation mode: 0x52, read operation;

[0030] The 7th to 10th bytes are the data field: 0x300x300x300x31, corresponding to the MID code, where the MID code 0001 request instruction is to establish a communication connection;

[0031] The 11th byte is the frame end: 0x03.

[0032] Furthermore, the sending register in S3 is a D8000 sending register specified by the programmable logic controller.

[0033] Furthermore, the communication status flag SD1504.0 described in S4 is ON, and the sending request flag B_data sending request is ON.

[0034] Furthermore, in S5, the communication status flags SD1505.0 and SD1504.0 indicating that the connection is completed normally are ON, and the flag M2080 remains OFF.

[0035] Furthermore, the connection status with the target device in S5 also includes:

[0036] Disconnected state: Communication status flags SD1505.0 and SD1504.0 are OFF;

[0037] Connection abnormal completion: Flag M2080 turns ON in the scan END processing completed by the SP.SOCOPEN instruction, and flag M2080 is reset to OFF in the next END processing.

[0038] Furthermore, the response data packet in S6 is: 0x02 0x00 0x00 0x00 0x08 0x41 0x300x300x31 0x41 0x43 0x4B 0x03; wherein 0x41 0x43 0x4B in the data field indicates that the response data packet includes an ACK response flag and the connection is successfully established; 0x300x300x31 corresponds to the MID code, carrying control instructions and data parameters.

[0039] Furthermore, the method for parsing the response data packet and extracting data in S7 includes:

[0040] Extract the data domain and obtain the target device data; read the PID value of the data domain corresponding to the MID code 0202 in the response data packet as 00010, and store the final tightening result value in D8004. The corresponding parameters of the device data include: final torque, monitoring angle, final time and final angle.

[0041] The present invention proposes a programmable logic controller communication device based on the TCP protocol, the device is implemented based on a programmable logic controller, and the device includes:

[0042] A communication establishing unit, used for configuring connection parameters of the programmable logic controller to establish communication with a target device;

[0043] A data acquisition unit, used to preset a MID code and construct a data packet containing a control instruction using the MID code;

[0044] A cache unit, used for writing the data packet into a sending register;

[0045] A communication connection unit, used to set a communication status flag and a send request flag, and establish TCP communication with a target device;

[0046] A data sending unit, used for sending a connection opening request and the data packet to the target device through the TCP protocol when the connection status with the target device is that the connection is completed normally;

[0047] A data processing unit, used for the target device to receive the data packet, perform data analysis, execute the control instructions in the data packet, and construct a response data packet to return to the programmable logic controller;

[0048] The data extraction unit is used for the programmable logic controller to receive the response data packet to the receiving register, and complete the communication after parsing the response data packet and extracting data.

[0049] Beneficial technical effects of the present invention:

[0050] (1) Realize the communication between Mitsubishi programmable logic controller and Dannicker tightening machine based on TCP protocol; The present invention realizes the efficient communication mode based on TCP protocol by reconfiguring the object device connection configuration in the module parameters on the Mitsubishi programmable logic controller side and writing the program according to the data packet format of Dannicker tightening machine. Compared with the traditional IO signal interaction mode, the TCP protocol can support the rapid integration between different models and tightening equipment, and can support the transmission of multiple data types, including key information such as control instructions and operating status. This communication mode not only realizes the stable connection between Mitsubishi programmable logic controller and Dannicker tightening machine, but also supports the transmission of tightening result data, thereby providing reliable communication guarantee for the linkage of multiple devices in industrial environment. Through the technical solution of the present invention, the communication between Mitsubishi programmable logic controller and Dannicker tightening machine based on TCP protocol is realized, which is expanded from simple signal interaction to precise data communication, breaking through the traditional communication mode between tightening machine and significantly improving the level of production intelligence.

[0051] (2) Acquisition of tightening result data and its application: The present invention successfully realizes the real-time acquisition of the final tightening result data of the Dannick tightening machine through a communication mechanism based on the TCP protocol. The acquired result data includes key parameters such as final torque value, tightening angle, task status and timestamp, etc., which can be directly used to monitor the operating status and tightening quality of the tightening machine. After the tightening result data is transmitted, the system can parse and store the data, providing a reliable basis for quality monitoring of the production line. In addition, these data can also be used as reference input for subsequent process flows, such as in product traceability, quality analysis and optimization of production processes, providing strong support for the optimization and decision-making of intelligent production processes. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a structural diagram of a programmable logic controller communication method based on TCP protocol in implementation mode 1;

[0053] Figure 2 This is a schematic diagram of connection parameter configuration in implementation mode 2;

[0054] Figure 3 A schematic diagram of a communication instruction for presetting a MID code in implementation mode 3;

[0055] Figure 4 A schematic diagram of establishing a connection between a programmable logic controller and a tightening machine in implementation mode 4;

[0056] Figure 5 A schematic diagram of a programmable logic controller and a tightening machine storing data in a fourth implementation mode;

[0057] Figure 6A schematic diagram of disconnecting the programmable logic controller from the tightening machine in implementation mode 6;

[0058] Figure 7 is a schematic diagram of a data packet in implementation mode eight;

[0059] Figure 8 A schematic diagram of a programmable logic controller and a tightening machine receiving data in an eighth implementation mode;

[0060] Fig. 9 This is a schematic diagram of tightening result data in a response data packet in implementation mode nine;

[0061] Fig.10 It is a schematic diagram of successful communication connection and monitoring of the final tightening result data of the tightening machine in implementation mode nine. DETAILED DESCRIPTION

[0062] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0063] Implementation method 1: The programmable logic controller communication method based on TCP protocol described in this implementation method (such as Figure 1 As shown), based on a programmable logic controller, the method includes:

[0064] S1. Configure the connection parameters of the programmable logic controller to establish communication with the target device;

[0065] S2 preset MID code, using the MID code to construct a data packet containing control instructions;

[0066] S3 writes the data packet into the transmit register;

[0067] S4. Set the communication status flag and the send request flag to establish TCP communication with the target device;

[0068] S5. When the connection status with the target device is completed normally, a connection opening request and the data packet are sent to the target device via the TCP protocol;

[0069] S6. The target device receives the data packet, performs data parsing, executes the control instructions in the data packet, and constructs a response data packet to return to the programmable logic controller;

[0070] S7. The programmable logic controller receives the response data packet to the receiving register, parses the response data packet and extracts data to complete the communication.

[0071] In this embodiment, by configuring the connection parameters of the programmable logic controller and combining the preset MID code to construct a data packet, effective data communication between the programmable logic controller and the target device is achieved based on the TCP protocol. By constructing a data packet based on the MID code, the standardization and pertinence of the communication content are ensured; the communication status flag and the send request flag are used to dynamically determine the connection status and control the communication process, thereby improving the reliability of the connection; the introduction of the data packet parsing and response mechanism enables the accurate reception and processing of the feedback information of the target device, thereby ensuring the real-time and accuracy of the communication. The target device described in the present invention includes a Dannick tightening machine, and the programmable logic controller model is Mitsubishi R08CPU.

[0072] Implementation method 2: This implementation method is a further example of S1 in the programmable logic controller communication method based on the TCP protocol described in implementation method 1. Figure 2 As shown, the connection parameters in S1 include the IP address, port number, TCP protocol and connection mode of the target device; the connection mode includes Active mode and SUMP mode, wherein the Active mode is a mode in which the programmable logic controller actively initiates a communication connection to the target device, and the SUMP mode is a mode in which the programmable logic controller waits for the target device to initiate a communication connection.

[0073] This embodiment further defines the parameter setting method of the device described in S1. In this embodiment, the Active connection device and the SUMP connection device are based on the TCP protocol to realize the communication between the programmable logic controller and the tightening machine or the host computer. The communication of the Active connection device enables the tightening machine or the host computer to actively initiate a communication connection to the programmable logic controller, thereby quickly establishing a data transmission channel; the communication of the SUMP connection device enables the tightening machine or the host computer to actively initiate a connection request to the tightening machine or the host computer to ensure the stability of communication. By specifying port numbers 6000 and 7930, the allocation of communication tasks between the tightening machine and the programmable logic controller is effectively realized, and the ability to use port resources is improved. Based on this embodiment, the programmable logic controller can perform parameter configuration and result data transmission with the tightening machine, ensure the real-time nature of data exchange, improve the overall operating efficiency and operation quality of the connection equipment, and meet the communication requirements in the production process.

[0074] Implementation method 3: This implementation method is a further example of S2 in the programmable logic controller communication method based on the TCP protocol described in implementation method 1. The process of S2 includes:

[0075] The S2 process includes:

[0076] S21. Preset MID code; the MID code is:

[0077] MID code 0001, operation type R, establish communication connection;

[0078] MID code 0002, operation type R, disconnect;

[0079] MID code 0102, operation type W, download Pset parameters to the electric gun;

[0080] MID code 0103, operation type W, Pset selection;

[0081] MID code 0201, operation type R, operation status Ready / Running / OK / NG / Err;

[0082] MID code 0202, operation type R, final tightening result;

[0083] MID code 0203, operation type R, real-time curve data;

[0084] MID code 0204, operation type W / R, Pset data read;

[0085] MID code 0301, operation type W, motor stop enable ON / OFF;

[0086] S22 organization data domain; the MID code and parameters as a request instruction embedded in the data field of the data packet;

[0087] S23. Assemble data packet; the data packet is 0x02 0x000x000x000x05 0x52 0x300x300x300x31 0x03. The data meaning of the data packet, from left to right, are:

[0088] The first byte is the frame header: 0x02;

[0089] The 2nd to 5th bytes indicate the length of the data field: 0x000x000x000x05;

[0090] The sixth byte indicates the operation mode: 0x52, read operation;

[0091] The 7th to 10th bytes are the data field: 0x300x300x300x31, corresponding to the MID code, where the MID code 0001 request instruction is to establish a communication connection;

[0092] The 11th byte is the frame end: 0x03.

[0093] This embodiment further limits the process of S2. In this embodiment, when B_data transmission request is ON, data is transmitted to the designated connected object device. When the transmission is completed normally: M2130 remains in the OFF state; when the transmission is completed abnormally, M2130 turns ON in the END processing of the scan completed by the SP.SOCSND instruction, and turns OFF in the next END processing.

[0094] In this embodiment, the MID code is combined with the data domain parameters to flexibly configure the communication content, such as reading the tightening results or sending control commands; by embedding the MID code into the data packet as a control instruction identifier, the communication action can be accurately defined, including establishing a connection, disconnecting a connection, etc., to achieve the standardization and efficiency of the communication process between the programmable logic controller and the tightening machine based on the TCP protocol. The request data packet is transmitted through the TCP protocol, and the dynamic judgment and control of the communication status flag bit are combined to effectively improve the stability and reliability of the communication. Based on the preset MID code, the host computer or the programmable logic controller and the electric gun can accurately establish a communication connection and complete data interaction. The host computer sends a request instruction to the electric gun based on the preset MID code. After receiving the instruction, the electric gun responds and returns a data packet that meets the requirements of the TCP protocol and the Dannick tightening machine, ensuring the correctness and real-time nature of data transmission. The data packet format that meets the requirements of the Dannick tightening machine and the TCP communication is established. The side data transmission must be consistent with the tightening machine requirements to establish communication.

[0095] Implementation mode 4: This implementation mode is a further description of S3 in the programmable logic controller communication method based on the TCP protocol described in Implementation mode 1. The sending register in S3 is the D8000 sending register specified by the programmable logic controller.

[0096] This implementation further defines the method for establishing a connection in S3. In this implementation, Figure 4-5 As shown, after the communication is successfully established, SD1504.0 (open completion status connection No.1) is ON; when the U_MID code request is ON to establish the communication connection, data is received; the received data is stored in the data register starting from D8000.

[0097] Implementation mode five: This implementation mode is a further example of S4 in the programmable logic controller communication method based on the TCP protocol described in implementation mode one, wherein the communication status flag SD1504.0 described in S4 is ON, and the sending request flag B_data sending request is ON.

[0098] This implementation further limits the method for receiving data in S4. In this implementation, the success or failure of the communication status is determined by the ACK flag to ensure effective data interaction.

[0099] Implementation method six: This implementation method is a further example of S5 in the programmable logic controller communication method based on the TCP protocol described in implementation method one, in which the communication status flags SD1505.0 and SD1504.0 indicating that the connection is completed normally in S5 are ON, and the flag M2080 remains in the OFF state.

[0100] This embodiment further defines the disconnection method described in S3, such as Figure 6 As shown in the figure, when the connection is completed normally: M2080 remains in the OFF state, and SD1505.0 (open request state connection No.1) and SD1504.0 (open completion state connection No.1) are ON.

[0101] Embodiment 7: This embodiment is a further description of the connection status determination method of the programmable logic controller communication method based on the TCP protocol described in Embodiment 6. The connection status with the target device described in S5 also includes:

[0102] Disconnected state: Communication status flags SD1505.0 and SD1504.0 are OFF;

[0103] Connection abnormal completion: Flag M2080 turns ON in the scan END processing completed by the SP.SOCOPEN instruction, and flag M2080 is reset to OFF in the next END processing.

[0104] This embodiment further limits the method for determining the connection status. In this embodiment, the communication between the programmable logic controller and the tightening machine is achieved by determining the connection status, thereby ensuring the reliability of the connection. When the U_MID code request, disconnection is OFF, when SD1505.0 (open request status connection No. 1) and SD1504.0 (open completion status connection No. 1) are OFF, a connection opening request is sent once per second. When abnormal completion occurs, M2080 turns ON in the END processing of the scan completed by the SP.SOCOPEN instruction, and turns OFF in the next END processing. When the U_MID code request. disconnection is ON, TCP is sent to perform the closing processing of the specified connection. When the connection is completed normally: M2110 remains in the OFF state, SD1505.0 (open request status connection No. 1) and SD1504.0 (open completion status connection No. 1) are OFF; when abnormal completion occurs, M2110 turns ON in the END processing of the scan completed by the SP.SOCCLOSE instruction, and turns OFF in the next END processing, thereby achieving rapid response and handling of abnormal situations.

[0105] Embodiment 8: This embodiment is a further description of S6 in the programmable logic controller communication method based on the TCP protocol described in Embodiment 1. Figure 7 As shown, the response data packet in S6 is: 0x02 0x00 0x00 0x00 0x08 0x41 0x300x300x31 0x41 0x43 0x4B 0x03; wherein, 0x41 0x43 0x4B in the data field indicates that the response data packet includes an ACK response flag, and the connection is successfully established; 0x300x300x31 corresponds to the MID code, carrying control instructions and data parameters.

[0106] This embodiment further defines the response data packet in S6. In this embodiment, the programmable logic controller receives and parses the data, such as Figure 8 As shown, efficient communication with the tightening machine is achieved, ensuring the feedback of tightening task data results.

[0107] Implementation method nine, this implementation method is a further description of S7 in the programmable logic controller communication method based on the TCP protocol described in implementation method one, and the method for parsing and extracting data from the response data packet described in S7 includes: extracting the data field to obtain the target device data; reading the PID value of the data field in the response data packet corresponding to the MID code 0202 as 00010, and the final tightening result value is stored in D8004, and the corresponding parameters are the device data including: final torque, monitoring angle, final time and final angle.

[0108] This implementation further defines the method for parsing the response data packet in S7. In this implementation, Fig. 9 As shown, the MID code for reading the tightening result data is 0202. The subscription number 0202 is sent to the electric gun, and the electric gun will return the tightening result when the tightening is completed.

[0109] Embodiment 10: This embodiment is a further example of the method for interacting between a programmable logic controller and a tightening machine based on the TCP protocol described in embodiment 1. Fig.10 As shown, D8000 receives the result: "A0001ACK"; TCP protocol communication is successfully established, the Dannick tightening machine receives the instruction and parses it successfully and returns "ACK" to read and monitor the final tightening result data of the tightening machine; specifically, when the electric gun receives a write request instruction, the instruction is parsed successfully, and "ACK" is returned. When the parsing is wrong, an error signal will be returned in the format of: "ERROR = ComErrID". ComErrriD is the error code of the data packet; when a read request is received, the corresponding data is returned if the parsing is successful, and an error signal is returned if the parsing is wrong, in the format of: "ERROR = ComErrID", and ComErrlD is the error code of the data packet.

[0110] In this embodiment, Mitsubishi programmable logic controller model R08CPU, Dannickel control model OPT-STC-C1-V1-400W, the two are connected and communicated. The system normally supplies power to the Dannickel controller, sets the port number 7930 in Dannickel, configures the module parameters according to the programmable logic controller and tightening machine interaction method based on TCP protocol, and writes a program to realize the communication between Mitsubishi programmable logic controller and Dannickel tightening machine through TCP protocol.

[0111] Embodiment eleven, the programmable logic controller communication device based on the TCP protocol described in this embodiment, the device is implemented based on a programmable logic controller, and the device includes:

[0112] A communication establishing unit, used for configuring connection parameters of the programmable logic controller to establish communication with a target device;

[0113] A data acquisition unit, used to preset a MID code and construct a data packet containing a control instruction using the MID code;

[0114] A cache unit, used for writing the data packet into a sending register;

[0115] A communication connection unit, used to set a communication status flag and a send request flag, and establish TCP communication with a target device;

[0116] A data sending unit, used for sending a connection opening request and the data packet to the target device through the TCP protocol when the connection status with the target device is that the connection is completed normally;

[0117] A data processing unit, used for the target device to receive the data packet, perform data analysis, execute the control instructions in the data packet, and construct a response data packet to return to the programmable logic controller;

[0118] The data extraction unit is used for the programmable logic controller to receive the response data packet to the receiving register, and complete the communication after parsing the response data packet and extracting data.

[0119] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments, and all changes and modifications falling within the scope of the present disclosure.

[0120] Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.

[0121] Finally, it should be noted that the above implementation modes are only used to illustrate the technical solutions of the present disclosure rather than to limit its protection scope. Although the present disclosure is described in detail with reference to the above implementation modes, ordinary technicians in the relevant field should understand that after reading the present disclosure, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation modes of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the disclosed claims to be approved.

Claims

1. A programmable logic controller communication method based on TCP protocol, wherein the method is implemented based on a programmable logic controller and is characterized in that: The method comprises: S1. Configure the connection parameters of the programmable logic controller to establish communication with the target device; S2 preset MID code, using the MID code to construct a data packet containing control instructions; S3 writes the data packet into the transmit register; S4. Set the communication status flag and the send request flag to establish TCP communication with the target device; S5. When the connection status with the target device is completed normally, a connection opening request and the data packet are sent to the target device via the TCP protocol; S6. The target device receives the data packet, performs data parsing, executes the control instructions in the data packet, and constructs a response data packet to return to the programmable logic controller; S7. The programmable logic controller receives the response data packet to the receiving register, parses the response data packet and extracts data to complete the communication.

2. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The connection parameters in S1 include the IP address, port number, TCP protocol and connection mode of the target device; the connection mode includes Active mode and SUMP mode, wherein the Active mode is a mode in which the programmable logic controller actively initiates a communication connection to the target device, and the SUMP mode is a mode in which the programmable logic controller waits for the target device to initiate a communication connection.

3. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The S2 process includes: S21. Preset MID code; the MID code is: MID code 0001, operation type R, establish communication connection; MID code 0002, operation type R, disconnect; MID code 0102, operation type W, download Pset parameters to the electric gun; MID code 0103, operation type W, Pset selection; MID code 0201, operation type R, operation status Ready / Running / OK / NG / Err; MID code 0202, operation type R, final tightening result; MID code 0203, operation type R, real-time curve data; MID code 0204, operation type W / R, Pset data read; MID code 0301, operation type W, motor stop enable ON / OFF; S22 organization data domain; the MID code and parameters as a request instruction embedded in the data field of the data packet; S23. Assemble data packet; the data packet is 0x02 0x000x000x000x05 0x52 0x300x300x300x31 0x03. The data meaning of the data packet, from left to right, are: The first byte is the frame header: 0x02; The 2nd to 5th bytes indicate the length of the data field: 0x000x000x000x05; The sixth byte indicates the operation mode: 0x52, read operation; The 7th to 10th bytes are the data field: 0x300x300x300x31, corresponding to the MID code, where the MID code 0001 request instruction is to establish a communication connection; The 11th byte is the frame end: 0x03.

4. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The sending register described in S3 is the D8000 sending register specified by the programmable logic controller.

5. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The communication status flag SD1504.0 described in S4 is ON, and the sending request flag B_data sending request is ON.

6. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The communication status flags SD1505.0 and SD1504.0 indicating that the connection is completed normally in S5 are ON, and the flag M2080 remains OFF.

7. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The connection status with the target device in S5 also includes: Disconnected state: Communication status flags SD1505.0 and SD1504.0 are OFF; Connection abnormal completion: Flag M2080 turns ON in the scan END processing of the SP.SOCOPEN instruction, and flag M2080 is reset to OFF in the next END processing.

8. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The response data packet in S6 is: 0x02 0x00 0x00 0x00 0x08 0x41 0x300x300x31 0x41 0x43 0x4B 0x03; wherein 0x41 0x43 0x4B in the data field indicates that the response data packet includes an ACK response flag and the connection is successfully established; 0x300x300x31 corresponds to the MID code, carrying control instructions and data parameters.

9. The programmable logic controller communication method based on TCP protocol according to claim 1, characterized in that: The method for parsing and extracting data from the response data packet in S7 includes: extracting the data field to obtain the target device data; reading the PID value of the data field in the response data packet corresponding to the MID code 0202 as 00010, and the final tightening result value is stored in D8004, and the corresponding parameters of the device data include: final torque, monitoring angle, final time and final angle.

10. A programmable logic controller communication device based on TCP protocol, wherein the device is implemented based on a programmable logic controller, and is characterized in that: The device comprises: A communication establishing unit, used for configuring connection parameters of the programmable logic controller to establish communication with a target device; A data acquisition unit, used to preset a MID code and construct a data packet containing a control instruction using the MID code; A cache unit, used for writing the data packet into a sending register; A communication connection unit, used to set a communication status flag and a send request flag, and establish TCP communication with a target device; A data sending unit, used for sending a connection opening request and the data packet to the target device through the TCP protocol when the connection status with the target device is that the connection is completed normally; A data processing unit, used for the target device to receive the data packet, perform data analysis, execute the control instructions in the data packet, and construct a response data packet to return to the programmable logic controller; The data extraction unit is used for the programmable logic controller to receive the response data packet to the receiving register, and complete the communication after parsing the response data packet and extracting data.

Citation Information

Patent Citations

  • A method for acquiring running data of a textile machine based on TCP / IP protocol

    CN108989358A

  • Communication method based on HMI device, HMI device and storage medium

    CN117873942A

  • Programmable logic controller

    JP2014052671A