Early warning data communication method for cigarette packet rejection based on appearance visual inspection of packaging machine
By establishing TCP protocol communication between CCD appearance visual inspection and OPC operating screen industrial control machine in the ZB45 packaging unit, the problem of lack of early warning function in the existing technology is solved, timely detection and early warning of appearance defects of tobacco bags is realized, and production efficiency and quality control are improved.
Patent Information
- Application Number
- CN202310276839.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-21
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-03-21
AI Technical Summary
The CCD appearance visual inspection system of the existing ZB45 packaging unit lacks early warning function, resulting in untimely removal of unqualified cigarette packs, which is difficult to attract the attention of operators, resulting in waste of production costs and quality hazards. Moreover, due to the software systems developed by different companies and the complex workshop network environment, communication protocols are difficult to achieve smooth operation.
By writing client and server programs, Socket communication based on TCP protocol is established between CCD appearance visual detection and OPC operation screen industrial control machine by using functions such as Socket(), Connect(), Send(), Receive() to establish Socket communication based on TCP protocol to realize data transmission, and issue a real-time warning on the OPC operation screen, combining the database to store the elimination information for traceability.
It realizes timely warning and inspection of appearance defects of tobacco bags, reduces residual tobacco bags into the next process, improves the workshop quality control level and equipment stability, reduces the labor intensity of manual inspection, and provides data support for product quality traceability.
Smart Images

Figure CN116532399B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication of cigarette-making machines, and particularly to a data communication method for cigarette packet rejection warning based on the visual inspection of the appearance of a packing machine. Background Art
[0002] The existing ZB45 type packing units are all equipped with CCD visual inspection of the appearance, and are all installed at the rear of the YB45 packing machine. The main activity area of the operator is in front of the locomotive to operate the locomotive and replace the raw and auxiliary materials. There is little time to observe the effectiveness of the CCD cigarette packet appearance inspection and the rejection situation behind the locomotive. The CCD cigarette packet appearance inspection itself has no warning function, which has drawbacks. When rejecting unqualified cigarette packets, it is not easy to attract the attention of the operator; when there are continuous problem cigarette packets, a large number of unqualified cigarette packets are rejected, and it is impossible to stop the machine in time to check the cause of the problem, resulting in a waste of a large amount of production costs and quality hazards.
[0003] If data communication can be achieved between the CCD visual inspection of the appearance and the man-machine interface of the unit, it will enable the operators of the packing machine to conveniently observe the appearance defects of the small boxes in time and perform corresponding inspections and adjustments, further preventing defective cigarette packets from flowing into the next process and improving the quality control level of the workshop.
[0004] However, the reality is that the man-machine interface of the ZB45 type packing unit is developed by a company in Beijing, including information such as the shutdown interface, data interface, and parameter adjustment interface; while the CCD cigarette packet appearance inspection is manufactured by a company in Nanjing. There are technical barriers between the two software systems, and there are difficulties in the communication protocol. At the same time, the workshop network environment is very complex, and there are as many as 5-8 kinds of wireless network addresses arranged in the workshop. At present, it is still impossible to ensure that the communication between the two industrial control computers is smooth, and other detection systems and industrial control computers of the unit are not affected by each other. Summary of the Invention
[0005] In order to overcome the above problems, the present application provides a data communication method for cigarette packet rejection warning based on the visual inspection of the appearance of a packing machine.
[0006] The technical solution adopted by the present invention to solve its technical problems is as follows:
[0007] A data communication method for cigarette packet rejection warning based on the visual inspection of the appearance of a packing machine, comprising the following steps
[0008] S1 Create a client and a server
[0009] Write a client program and a server program for cigarette packet appearance inspection and rejection warning through a programming language, and install them on the industrial control computer for CCD visual inspection of the appearance and the industrial control computer of the OPC operation screen respectively to form a client and a server;
[0010] The client is used to receive signals sent by the industrial control computer of the OPC operation screen, and the server is used to receive signals sent by the client program;
[0011] The client program includes functions Socket(), Connect(), Send(), Receive(), Close();
[0012] The server program includes functions Socket(), Bind(), Listen(), Accept(), Receive(), Send(), Close();
[0013] Among them: The function of the Socket() function is: create a socket file and return the socket file descriptor;
[0014] The function of the connect() function is: use the socket file to initiate a handshake request with the server actively to establish a connection, and the connection is successful when the three-way handshake is successful;
[0015] The function of the Send() function is: perform end-to-end data transmission after monitoring that the session is successfully established;
[0016] The function of the Receive() function is: receive data at the end;
[0017] The function of the Bind() function is: bind the socket file, IP address and port number to establish a corresponding fixed relationship;
[0018] The function of the Listen() function is: change the socket file descriptor to a passive descriptor to passively monitor client connections;
[0019] The function of the Accept() function is: passively monitor the handshake request of the client, the connection is successful when the three-way handshake is successful, and return the communication descriptor;
[0020] The function of the Close() function is: initiate a disconnection request from either end, and the disconnection is successful when the four-way handshake is successful;
[0021] S2 Establish a communication connection
[0022] The client and the server perform Socket communication based on the TCP protocol;
[0023] The client establishes a connection with the server by calling the Connect() function; the purpose of establishing the connection is to ensure that the IP address, port, physical link, etc. are correct and error-free, and open a channel for data transmission;
[0024] When the client calls the Socket() function to create a socket and no connection is established, it enters the closed state;
[0025] After the client calls the Connect() function, the TCP protocol constructs a data packet, sets the SYN flag bit to indicate that the data packet is used to establish a synchronization connection, and generates a number 1000 to fill the "Sequence Number (Seq)" field to represent the sequence number of the data packet. After completing these tasks, it starts to send the data packet to the server, and the client enters the SYN-SEND state;
[0026] After the server receives the data packet and detects that the SYN flag bit is set, the TCP protocol constructs a data packet, sets the SYN and ACK flag bits. SYN indicates that the data packet is used to establish a connection, and ACK is used to confirm the receipt of the data packet sent by the client; the server generates a number 2000 to fill the "Sequence Number (Seq)" field to represent the sequence number of the data packet; the server adds 1 to the sequence number 1000 of the client data packet to get 1001, and uses this number to fill the ACK field; the server sends out the data packet and enters the SYN-RECV state;
[0027] The client receives the data packet and detects that the SYN and ACK flag bits are set. The client checks the ACK field. If its value is 1001, it means the connection is successfully established; the client continues to construct a data packet, sets the ACK flag bit to indicate that the client accepts the confirmation packet sent by the server. At the same time, it adds 1 to the sequence number 2000 of the data packet sent by the server to get 2001, and uses this number to fill the ACK field; the client sends out the data packet and enters the ESTABLISED state, indicating that the connection has been successfully established;
[0028] The server receives the data packet and detects that the ACK flag bit is set. The server checks the ACK field. If its value is
[0029] 2001, it means the connection is successfully established, and the server enters the ESTABLISED state;
[0030] The client and the server successfully establish a communication connection and can normally send and receive data;
[0031] S3 Cigarette Packet Rejection Warning
[0032] When the CCD appearance vision detects a defect in the appearance of the cigarette packet, the industrial computer of the CCD appearance vision triggers a rejection signal, which is transmitted to the server by the client through Socket communication based on the TCP protocol, and a warning is sent out in real time through the OPC operation screen industrial computer;
[0033] Whenever a rejected cigarette case is generated, the industrial computer of the OPC operation screen issues a warning in real time. By clicking on the real-time viewing function of the OPC operation screen control interface, the corresponding defect image can be viewed, prompting the operator to remove the defective cigarette packs of what kind. By corresponding the defective image to the locomotive part, the equipment problem can be found and solved to master the operation of the equipment;
[0034] The operator can retrieve and view the relevant data parameters of the equipment through the industrial computer of the OPC operation screen, and the operation of the equipment and the images of each part are displayed in real time on the control interface.
[0035] As an improvement to the above technical solution:
[0036] The defective image is obtained by a vision sensor to collect the appearance defect image of the cigarette pack at the CCD appearance vision detection position, and the collected image is compressed, and then transmitted to the industrial computer of the OPC operation screen through the data communication between the client and the server for retrieval and viewing.
[0037] As an improvement to the above technical solution:
[0038] The CCD cigarette pack vision detection is connected to a database, and the database automatically stores all the cigarette pack rejection warning information, including picture serial number, photographing date, product brand name, defect information, etc., for subsequent traceability.
[0039] The beneficial effects brought by the present invention:
[0040] This application enables the operators of the packaging machine to observe the appearance defects of the small boxes in a timely and convenient manner and carry out corresponding inspections and adjustments, further preventing defective cigarette packs from flowing into the next process, improving the quality control level of the workshop, stabilizing the product packaging quality, improving the stability of the production operation equipment, and at the same time reducing the labor intensity of frequent manual sampling inspections.
[0041] By establishing a data communication connection between the CCD appearance vision detection and the industrial computer of the OPC operation screen, when a rejected cigarette case is generated, a corresponding prompt will appear on the OPC industrial computer operation screen. Click to view the corresponding defective image, prompting the operator to remove the defective cigarette packs of what kind. By corresponding the defective picture to the locomotive part, the equipment problem can be found and solved, which is convenient for the operator to master the operation of the equipment and can eliminate the problem in time after discovery, thus effectively improving the product quality detection efficiency and equipment reliability.
[0042] In short, the following benefits can be generated after the implementation of this application:
[0043] 1. Improve the appearance detection quality of small boxes;
[0044] 2. Reduce the flow of defective cigarette packs into the next process;
[0045] 3. Improve the work efficiency of the workshop equipment operators;
[0046] 4. Provide data support for subsequent product quality traceability. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present invention will be further described below in conjunction with the drawings and specific embodiments:
[0048] Figure 1 It is a schematic diagram of the data communication structure between the client and the server based on the TCP protocol. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0050] This embodiment describes a method for data communication of cigarette pack rejection warning based on the appearance vision detection of a packaging machine, including the following steps:
[0051] S1 Create a client and a server
[0052] Write a client program and a server program for cigarette pack appearance detection and rejection warning through the C# programming language, and install them on the CCD appearance vision detection industrial control computer and the OPC operation screen industrial control computer respectively to form a client and a server;
[0053] The client is used to receive the signals sent by the OPC operation screen industrial control computer, and the server is used to receive the signals sent by the client program;
[0054] The client program includes functions Socket(), Connect(), Send(), Receive(), Close();
[0055] The server program includes functions Socket(), Bind(), Listen(), Accept(), Receive(), Send(), Close();
[0056] Refer to Figure 1 : The function of the Socket() function is: create a socket file and return the socket file descriptor;
[0057] The function of the connect() function is: use the socket file to actively initiate a handshake request with the server to establish a connection, and the connection is successful when the three-way handshake is successful;
[0058] The function of the Send() function is: to perform end-to-end data transmission after successfully monitoring the establishment of a session;
[0059] The function of the Receive() function is: to receive data at the end, and receive the messages sent in the connection request through a thread loop;
[0060] The function of the Bind() function is: to bind the socket file, IP address, and port number to establish a corresponding fixed relationship;
[0061] The function of the Listen() function is: to change the socket file descriptor to a passive descriptor to passively listen for client connections;
[0062] The function of the Accept() function is: to passively listen for the handshake request of the client. If the three-way handshake is successful, the connection is successful, and a communication descriptor is returned;
[0063] The function of the Close() function is: to initiate a disconnection request from either end. If the four-way handshake is successful, the disconnection is successful, the socket is closed, and the connection listening is stopped;
[0064] S2 establishes a communication connection
[0065] The client and the server perform Socket communication based on the TCP protocol;
[0066] The client establishes a connection with the server by calling the Connect() function; the purpose of establishing the connection is to ensure that the IP address, port, physical link, etc. are correct and error-free, and to open a channel for data transmission;
[0067] When the client calls the Socket() function to create a socket and no connection is established, it enters the closed state;
[0068] When the client calls the Connect() function, the TCP protocol constructs a data packet and sets the SYN flag bit, indicating that the data packet is used to establish a synchronous connection. At the same time, a number 1000 is generated to fill the "sequence number (Seq)" field, indicating the sequence number of the data packet. After completing these tasks, the data packet starts to be sent to the server, and the client enters the SYN-SEND state;
[0069] After the server receives the data packet and detects that the SYN flag bit is set, the TCP protocol constructs a data packet and sets the SYN and ACK flag bits. SYN indicates that the data packet is used to establish a connection, and ACK is used to confirm the receipt of the data packet sent by the client. The server generates a number 2000 and fills the "Sequence Number (Seq)" field, indicating the sequence number of the data packet. The server adds 1 to the sequence number 1000 of the client data packet to get 1001 and fills the ACK field with this number. The server sends out the data packet and enters the SYN-RECV state.
[0070] The client receives the data packet and detects that the SYN and ACK flag bits are set. The client checks the ACK field. If its value is 1001, it means the connection is successfully established. The client continues to construct a data packet and sets the ACK flag bit, indicating that the client accepts the confirmation packet sent by the server. At the same time, the client adds 1 to the sequence number 2000 of the data packet sent by the server to get 2001 and fills the ACK field with this number. The client sends out the data packet and enters the ESTABLISED state, indicating that the connection has been successfully established.
[0071] The server receives the data packet and detects that the ACK flag bit is set. The server checks the ACK field. If its value is 2001, it means the connection is successfully established, and the server enters the ESTABLISED state.
[0072] The client and the server successfully establish a communication connection and can normally send and receive data.
[0073] S3 Cigarette Pack Rejection Warning
[0074] When the CCD appearance vision detects a defect in the appearance of the cigarette pack, the CCD appearance vision industrial control computer triggers a rejection signal, which is transmitted to the server by the client through Socket communication based on the TCP protocol, and a warning is issued in real time through the OPC operation screen industrial control computer.
[0075] Whenever a cigarette box is to be rejected, the OPC operation screen industrial control computer issues a warning in real time. Through the real-time viewing function of the OPC operation screen control interface, click to view the corresponding defect image, prompt the operator to reject what kind of defective cigarette pack, and find and solve equipment problems by corresponding the defect image to the locomotive part to master the operation of the equipment. Defective cigarette packs include unsealed, damaged, slit, scratched, dirty, deformed, misbranded, reversed, connected packs, misdetection, etc. Through real-time information sharing, prompt the operator to pay attention to master the situation of defective cigarette packs.
[0076] The operator can retrieve and view the relevant data parameters of the equipment through the OPC operation screen industrial control computer, and the operation situation of the equipment and the images of each part are displayed in real time on the control interface.
[0077] The defective image is captured by a vision sensor for the appearance defects of the cigarette package at the visual inspection position of the CCD, and the captured image is compressed. Then, it is transmitted to the industrial control computer of the OPC operation screen through data communication between the client and the server for retrieval and viewing. Instead of transmitting the source monitoring image, but the compressed format of the image, it can reduce the amount of image data participating in network transmission, save transmission energy consumption, and solve problems such as large memory requirements and high algorithm complexity.
[0078] The CCD cigarette package visual inspection is connected to a database, which automatically stores all the warning information for cigarette package rejection, including picture serial number, photographing date, product brand name, defect information, etc., for subsequent traceability.
[0079] Based on Figure 1 the client-server TCP protocol data communication structure shown:
[0080] First, the client creates a Socket(), connects to the server according to the given IP (domain name) and port (default is 80), using methods such as Socket.Connect(), Socket.Begin Connect().
[0081] After successful connection, the client sends request data to the server according to the HTTP protocol specification. For "request line", "request headers", and "request data", etc., use methods such as Socket.Send(), Socket.Begin Send().
[0082] Wait for the server to process and return the data;
[0083] After the server uses methods such as Socket.Accept(), Socket.Begin Accept() to monitor the connection from the client, it starts to receive the data sent by the client. After receiving the request data, it parses the data according to the HTTP protocol specification, then processes it, and finally sends the processing result back to the client and displays the relevant processing information in the local UI interface. Here, methods similar to Socket.Send(), Socket.Begin Send() are used;
[0084] After the server sends the processing result, it closes the Socket;
[0085] The client receives the data sent back by the server, verifies whether the data is sent completely and whether the data transmission speed is normal, and displays the return result on the interface. Close the socket.
[0086] It should be noted that the above are only the preferred embodiments of the present invention and are not used to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions recorded in the foregoing embodiments or perform equivalent replacements on some of the technical features. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for data communication of cigarette packet rejection warning based on visual inspection of the appearance of a packaging machine, characterized in that: It includes the following steps: S1 Create a client and a server Write a client program and a server program for cigarette pack appearance detection and rejection warning in a programming language, and install them on the CCD appearance vision detection industrial control computer and the OPC operation screen industrial control computer respectively to form a client and a server; The client is used to receive signals sent by the OPC operation screen industrial control computer, and the server is used to receive signals sent by the client program; The client program includes functions Socket(), Connect(), Send(), Receive(), Close(); The server program includes functions Socket(), Bind(), Listen(), Accept(), Receive(), Send(), Close(); S2 Establish a communication connection The client and the server perform Socket communication based on the TCP protocol; The client establishes a connection with the server by calling the Connect() function; The purpose of establishing the connection is to ensure that the IP address, port, and physical link are correct and error-free, and to open a channel for data transmission; When the client calls the Socket() function to create a socket and no connection is established, it enters the closed state; When the client calls the Connect() function, the TCP protocol constructs a data packet and sets the SYN flag bit, indicating that the data packet is used to establish a synchronous connection. At the same time, a number M is generated and filled in the "Sequence Number (Seq)" field to indicate the sequence number of the data packet. After completing these tasks, the data packet starts to be sent to the server, and the client enters the SYN-SEND state; [[ID=,11]]After the server receives the data packet and detects that the SYN flag bit is set, the TCP protocol constructs a data packet and sets the SYN and ACK flag bits. SYN indicates that the data packet is used to establish a connection, and ACK is used to confirm the receipt of the data packet sent by the client; The server generates a number N and fills it in the "Sequence Number (Seq)" field to indicate the sequence number of the data packet; The server adds 1 to the sequence number M of the client data packet and fills this number in the ACK field; The server sends out the data packet and enters the SYN-RECV state; When the client receives the data packet and detects that the SYN and ACK flag bits are set, the client checks the ACK field. If its value is M+1, it means the connection is successfully established; The client continues to construct a data packet and sets the ACK flag bit, indicating that the client accepts the confirmation packet sent by the server. At the same time, the client adds 1 to the sequence number N of the data packet sent by the server and fills this number in the ACK field; The client sends out the data packet and enters the ESTABLISED state, indicating that the connection has been successfully established; When the server receives the data packet and detects that the ACK flag bit is set, the server checks the ACK field. If its value is N+1, it means the connection is successfully established, and the server enters the ESTABLISED state; The client and the server successfully establish a communication connection and can normally send and receive data; S3 Cigarette pack rejection warning When the industrial control computer for CCD appearance visual inspection detects defects in the appearance of cigarette packs, the industrial control computer for CCD appearance visual inspection triggers a rejection signal, which is transmitted to the server by the client through Socket communication based on the TCP protocol, and an early warning is sent out in real time through the OPC operation panel industrial control computer; Whenever a cigarette box needs to be rejected, the OPC operation panel industrial control computer sends out an early warning in real time. Click on the real-time viewing function of the OPC operation panel control interface to view the corresponding defect images, which prompts the operator to reject cigarette packs with specific defects. By referring to the locomotive parts corresponding to the defect images, the equipment problems can be found and solved to understand the operation status of the equipment; The operator can retrieve and view the relevant data parameters of the equipment through the OPC operation panel industrial control computer, and the operation status of the equipment and the images of each part are displayed in real time on the control interface.
2. The cigarette pack rejection early warning data communication method according to claim 1, characterized in that: The defect images are obtained by the vision sensor to collect the appearance defect images of the cigarette packs at the CCD appearance visual inspection position, and the collected images are compressed. Then, they are transmitted to the OPC operation panel industrial control computer through the data communication between the client and the server for retrieval and viewing.
3. The cigarette pack rejection early warning data communication method according to claim 1, characterized in that: The industrial control computer for CCD appearance visual inspection is connected to a database, which automatically stores all cigarette pack rejection early warning information, including picture serial numbers, photographing dates, product brand names, and defect information, for subsequent traceability.
Citation Information
Patent Citations
User network optimizing method and system
CN104702445A
Online early warning monitoring system of molded cover machine based on gridding image processing technology
CN110802791A