A synchronous verification method and device for machine vision equipment

The counting of PC and PLC terminals in machine vision devices is synchronized through PLC serial communication, and the timestamp threshold range is used for checksum correction, which solves the count synchronization problem, avoids missed and missed detection, and ensures the accuracy of product quality.

CN116170546BActive Publication Date: 2025-05-06WAYA (HANGZHOU) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310196858.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2025-05-06
Estimated Expiration
2043-03-03

AI Technical Summary

Technical Problem

On industrial production lines, the counting synchronization problem between the PC end and the PLC end in machine vision equipment leads to false detection and missed inspection, affecting product quality.

Method used

The counting between the PC and PLC terminals is synchronized through PLC serial communication, and the counting checksum correction is performed using the timestamp threshold range to ensure the accuracy of the counting.

Benefits of technology

It effectively solves the problem that the counting of the PC and PLC ends cannot be correctly corresponded, avoids missed and missed inspections, and ensures the accuracy of product quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116170546B_ABST
    Figure CN116170546B_ABST
Patent Text Reader

Abstract

The invention discloses a synchronous verification method and device for machine vision equipment. Based on PLC serial port communication, the counts of a PC and a PLC are synchronized. The PLC controls a camera to take pictures and records the trigger signal. The PC receives the picture taken by the camera and the trigger count of the current camera position sent by the PLC. The timestamps of the two are compared. If the difference between the two is within the timestamp threshold range, it is considered that the count is accurate. Otherwise, it is considered that the trigger signal is abnormal. The count correction is performed, and an offset is added to the picture count. The offset picture count is used to correspond to the trigger count of the PLC until the time difference can fall within the threshold range again. The invention can effectively detect the problem that the image count of the PC does not correspond to the trigger count of the PLC, and restore the count synchronization at the same time, so as to solve the problem of missed detection and wrong detection caused by the inability to correctly correspond the counts on both sides of the PC and the PLC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of machine vision, and in particular relates to a synchronization verification method and device for machine vision equipment. Background Art

[0002] Machine vision equipment is increasingly used in industrial production lines to test product quality. Such equipment generally includes an industrial computer and a PLC. The industrial computer is equipped with machine vision inspection software to analyze and process product images captured by the camera to determine whether the product is defective; the PLC is used to trigger the camera to take pictures when the product passes through the sensor, and to control the defective product rejection mechanism to reject defective products and separate qualified products from unqualified products.

[0003] In general industrial sites, when the machine vision inspection software on the PC detects that the result is a defective product, it will send a level signal to the PLC through the IO card, or send a defined value to the fixed address of the PLC through the serial port or Ethernet port, informing the PLC that the current product is a defective product. This method has the following technical problems: when the camera is triggered to take pictures by the PLC, the signal will be lost or there will be an extra signal, that is, the picture that should be triggered is not triggered, or the picture that should be triggered once is triggered twice, so there is a difference between the trigger count of the PLC and the picture count obtained by the inspection software, and they cannot be correctly matched. As a result, when the PLC should perform the rejection action, it does not receive the bad signal sent by the computer or receives the misplaced signal, resulting in false detection and missed detection of the inspection equipment during operation. In the normal production process, it brings hidden dangers to product quality. Summary of the invention

[0004] In view of the above problems, the present invention proposes a synchronization verification method and device for machine vision equipment. The present invention provides a synchronization verification method and device for machine vision equipment between the PC end and the PLC system inside the machine vision equipment, which can effectively ensure the counting synchronization problem between the two ends and ensure the correct distinction between qualified and unqualified products in normal production.

[0005] To achieve the above object, the present invention adopts the following technical solutions: On the one hand, the present invention provides a synchronization verification method for a machine vision device, which synchronizes the counting of a PC end and a PLC end based on PLC serial port communication, and comprises the following steps:

[0006] (1) When the object to be detected triggers the sensor and transmits it to the input end of the PLC, the PLC controls the camera to take a photo and records the trigger signal. Then, the trigger camera position and trigger count of this trigger are sent to the PC.

[0007] (2) The PC receives the trigger count of the current camera position sent by the PLC. The PC allocates a space of size M according to the memory, calculates the received trigger count according to the modulus M, and corresponds the value to the sequence number of the space, and records the received trigger count and the PC timestamp. When the image of the object to be detected taken by the camera is obtained, the count when the image is received and the PC timestamp are recorded, and the timestamp threshold range is set. The timestamp when the image is received is compared with the timestamp of the trigger count sent by the PLC with the same image count. If the difference between the two is within the timestamp threshold range, the count is considered accurate and step (4) is executed. If the comparison result is outside the timestamp threshold range for multiple consecutive times, it is considered that the trigger signal is abnormal and step (3) is executed.

[0008] (3) When the trigger signal is abnormal, count correction is performed by adding a ±b offset to the image count, with the initial value of b being 1. Then, the offset image count is used to correspond to the trigger count on the PLC end. The absolute value of the offset is increased by 1 each time until the time difference falls within the corresponding range again. In this case, the count correction is successful.

[0009] (4) The PLC receives the qualified result of the corresponding trigger count sent by the PC, and controls the rejection mechanism to reject or not reject the product of the trigger count; the recorded trigger signal will be cleared when the equipment stops and restarts.

[0010] Furthermore, the timestamp threshold range is set according to the actual camera performance, setting parameters and PC connection mode.

[0011] Furthermore, if the offset increase times threshold is exceeded and the picture count cannot be matched with the trigger count on the PLC side, an alarm should be issued.

[0012] On the other hand, the present invention also provides a synchronous verification device for machine vision equipment, the device comprising an industrial camera, a product to be detected, an industrial computer PC and a PLC;

[0013] The PLC is used to record the trigger signal when the sensor detects the product to be detected, control the industrial camera to shoot the product to be detected, and send the trigger camera position and trigger count of this trigger to the industrial computer PC through PLC serial port communication;

[0014] The industrial camera is used to photograph the product to be inspected, and send the corresponding photographed image of the product to be inspected to the industrial computer PC;

[0015] The industrial computer PC is used to receive the trigger count of the current camera position sent by the PLC and the picture count taken by the industrial camera, compare the timestamps of the two, and compare the timestamp when the picture is received with the timestamp of the trigger count sent by the PLC with the same picture count according to the timestamp threshold range. If the difference between the two is within the timestamp threshold range, the count is considered to be accurate, and the qualified result of the corresponding trigger count is sent to the rejection mechanism; otherwise, it is considered that the trigger signal is abnormal, and the count correction is performed, adding a ±b offset to the picture count, the initial value of b is 1, and then the offset picture count is used to correspond to the trigger count of the PLC, and the absolute value of the offset is increased by 1 each time until the time difference can fall into the corresponding range again, and the count correction is successful.

[0016] Beneficial effects of the present invention: The present invention can effectively detect the problem that the image count of the machine vision detection on the PC side and the trigger count on the PLC side do not correspond to each other, and can effectively restore the count synchronization. It can solve the problem of missed detection and wrong detection caused by the inability to correctly correspond the counts on both sides of the PC side and the PLC side. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 The figure is a flow chart of the counting verification method of the present invention.

[0019] Figure 2 Schematic diagram of the counting device of the present invention. DETAILED DESCRIPTION

[0020] The following describes the PC-side machine vision inspection software, the working mode of the PLC side, and the communication rules between the PC and PLC. The actual visual inspection process of a product such as a magnetic tile is used for illustration.

[0021] like Figure 1 As shown, the present invention provides a synchronous verification method for machine vision equipment, which synchronizes the counting of the PC end and the PLC end based on PLC serial port communication, as follows:

[0022] PC:

[0023] Receive the magnetic tile trigger count of the current camera position sent by the PLC, open up a space of size 32, correspond the received trigger count to the sequence number of the space according to modulo 32, and record the received magnetic tile trigger count and the local timestamp; for example, if the magnetic tile trigger count sent by the PLC is 100, and the local timestamp is 1672823063788, then according to the result of 100 modulo 32, 4, the magnetic tile trigger count 100 and the timestamp 1672823063788 are recorded at the position of the sequence number 4 in the space; when the picture of the magnetic tile taken by the camera is obtained, record the count and the local timestamp when the magnetic tile picture is received, and match the timestamp with The received timestamp of the magnetic tile trigger count sent from the PLC end with the same magnetic tile image count is compared; for example, the local count of the received magnetic tile image is 100, and the local timestamp when received is 1672823063795, then the position with sequence number 4 in the above space is searched according to the result 4 of 100 modulo 32 to see if it is the magnetic tile trigger count 100. If it is 100, the difference between the two timestamps is compared, which is 7ms in this scenario, which is within the set range of 5 to 15ms. Therefore, it is considered that this magnetic tile image can correspond to the magnetic tile trigger count of the PLC end, and finally the count 100 and the corresponding result are sent to the PLC end, and the PLC end controls the removal of the magnetic tile.

[0024] When the calculated result is greater than or less than this range for multiple times in a row (usually 3 times), it is considered that the trigger signal is lost or there are too many trigger signals, and the magnetic tile image count on the PC side and the magnetic tile trigger count on the PLC side cannot correspond correctly; for example, the received magnetic tile trigger counts are 100, 101, and 102, and the timestamps when received are 1672823063788, 1672823064302, and 1672823065112, respectively. The timestamps when the corresponding magnetic tile image counts are 100, 101, and 102 are 1672823064309, 1672823065120, and 1672823065573, respectively. The differences are 521ms, 818ms, and 461ms, respectively. Three times in a row are greater than the set range of 5 to 15ms (this range is determined based on the actual camera performance). , set parameters and PC connection method), it is considered that the trigger signal is lost at this time, so an offset ±b offset is added, the initial value of b is 1 (if it is continuously greater than, it should be +b, if it is continuously less than, it should be -b), the received magnetic tile image counts are all added with b and then matched with the timestamp of the trigger signal on the PLC end, so the next received magnetic tile image count becomes 103+1=104, to correspond to the timestamp of the received trigger count 104, if it can correspond (that is, the timestamp difference meets the set range of 5-15ms), it is considered that the counting correction synchronization is successful, if it still cannot correspond and the timestamp difference is still greater than the set range, the offset b is increased to 2, the next magnetic tile image count is 104+2=106, to correspond to the timestamp of the received magnetic tile trigger count 106, until the timestamp difference can meet the set range of 5-15ms. If after a certain number of offset increases (usually 50 times), the magnetic tile image count cannot be matched to the magnetic tile trigger count on the PLC side, an alarm should be issued, indicating that an unforeseen problem has occurred and the count synchronization has failed.

[0025] Similarly, if the timestamp is found to be less than the set range for multiple times in a row, it is considered that there is a problem of too many trigger signals, and recovery is performed in the same way as above, except that the original addition of offset b is changed to subtraction of offset b. However, when there are too many trigger signals, the camera may have taken a picture, but the PLC has not yet sent the corresponding magnetic tile trigger count. For example, the count of the magnetic tile image received at this time is 105, but the corresponding magnetic tile trigger count 105 has not been sent to the PC. According to 105 modulo 32 equals 9, the last count 73 will be found. Therefore, when the count found is less than the image count continuously, it is also considered that there is a problem of too many trigger signals, and recovery is performed according to the above method of subtracting offset b.

[0026] PLC side:

[0027] When the magnetic tile triggers the sensor and transmits it to the input end of the PLC, the PLC controls the camera to take pictures and records the number of magnetic tile trigger signals. Then, the trigger position and magnetic tile trigger count of this trigger are sent to the PC. For example, if it is recorded that this is the 100th trigger signal, 100 will be sent to the PC. When the corresponding magnetic tile trigger count result is received from the PC, the rejection mechanism is controlled to reject or not reject the magnetic tile of the magnetic tile trigger count. The recorded trigger signal will be cleared when the device stops and restarts.

[0028] Through the above approach, the image count of the machine vision inspection software on the PC side and the trigger count on the PLC side can be effectively detected, and the problem of mismatch between the two can be effectively restored. This can solve the problem of missed detection and wrong detection caused by the mismatch between the counts on the PC side and the PLC side.

[0029] In this process, it can be seen that it is necessary to ensure that the trigger signal from the PLC end is sent before the camera takes a picture to obtain the image. There may be a problem of delay in sending the trigger signal due to communication fluctuations. At this time, the magnetic tile image and count obtained will not correspond to the correct magnetic tile trigger count sent by the PLC end, so the magnetic tile corresponding to this count will be considered to be an error and will be rejected. If this phenomenon occurs very frequently, a large number of magnetic tiles will be rejected due to this problem, which will greatly reduce the pass rate. Therefore, a delay of, for example, 10ms, can be added when obtaining the magnetic tile image to ensure that the trigger signal sent by the PLC end has been received before processing.

[0030] On the other hand, the present invention also provides a synchronous verification device for machine vision equipment, the device comprising an industrial camera 1, a product to be detected 2, an industrial computer PC 3 and a PLC 4;

[0031] The PLC 4 is used to record the trigger signal when the sensor detects the product 2 to be detected, control the industrial camera 1 to shoot the product 2 to be detected, and send the trigger camera position and trigger count of this trigger to the industrial computer PC 3 through PLC serial port communication;

[0032] The industrial camera 1 is used to photograph the product to be inspected 2, and send the corresponding photographed image of the product to be inspected 2 to the industrial computer PC 3;

[0033] The industrial computer PC3 is used to receive the trigger count of the current camera position sent by the PLC end and the picture count taken by the industrial camera 1, compare the timestamps of the two, and compare the timestamp when the picture is received with the timestamp of the trigger count sent by the PLC end with the same picture count according to the timestamp threshold range. If the difference between the two is within the timestamp threshold range, the count is considered to be accurate, and the qualified result of the corresponding trigger count is sent to the rejection mechanism; otherwise, it is considered that the trigger signal is abnormal, and a count correction is performed to add a ±b offset to the picture count, and the initial value of b is 1. Then, the offset picture count is used to correspond to the trigger count of the PLC end, and the absolute value of the offset is increased by 1 each time until the time difference can fall into the corresponding range again, and the count correction is successful.

[0034] The above embodiments are used to illustrate the present invention rather than to limit the present invention. Any modification and change made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.

Claims

1. A synchronous verification method for a machine vision device, characterized in that: The counting of the PC and PLC is synchronized based on the PLC serial port communication, including the following steps: (1) When the object to be detected triggers the sensor and transmits it to the input end of the PLC, the PLC controls the camera to take a photo and records the trigger signal. Then, the trigger camera position and trigger count of this trigger are sent to the PC. (2) The PC receives the trigger count of the current camera position sent by the PLC. The PC allocates a space of size M according to the memory, calculates the received trigger count according to the modulus M, and corresponds the value to the sequence number of the space, and records the received trigger count and the PC timestamp. When the image of the object to be detected taken by the camera is obtained, the count when the image is received and the PC timestamp are recorded, and the timestamp threshold range is set. The timestamp when the image is received is compared with the timestamp of the trigger count sent by the PLC with the same image count. If the difference between the two is within the timestamp threshold range, the count is considered accurate and step (4) is executed. If the comparison result is outside the timestamp threshold range for multiple consecutive times, it is considered that the trigger signal is abnormal and step (3) is executed. (3) When the trigger signal is abnormal, count correction is performed by adding a ±b offset to the image count, with the initial value of b being 1. Then, the offset image count is used to correspond to the trigger count on the PLC end. The absolute value of the offset is increased by 1 each time until the time difference falls within the corresponding range again. In this case, the count correction is successful. (4) The PLC receives the qualified result of the corresponding trigger count sent by the PC, and controls the rejection mechanism to reject or not reject the product of the trigger count; the recorded trigger signal will be cleared when the equipment stops and restarts.

2. A synchronous verification method for a machine vision device according to claim 1, characterized in that: In step (2), the timestamp threshold range is set according to the actual camera performance, setting parameters and PC connection method.

3. The synchronous verification method of a machine vision device according to claim 1, characterized in that: In step (3), if the offset increase times threshold is exceeded and the count of the image cannot be matched with the trigger count on the PLC side, an alarm should be issued.

4. A synchronization verification device for implementing the synchronization verification method of a machine vision device according to any one of claims 1 to 3, characterized in that: The device comprises an industrial camera (1), a product to be inspected (2), an industrial computer PC (3) and a PLC (4); The PLC (4) is used to record a trigger signal when the sensor detects the product to be detected (2), control the industrial camera (1) to shoot the product to be detected (2), and send the trigger camera position and trigger count of this trigger to the industrial computer PC (3) through PLC serial port communication; The industrial camera (1) is used to photograph the product to be inspected (2), and send the corresponding photographed image of the product to be inspected (2) to the industrial computer PC (3); The industrial computer PC (3) is used to receive the trigger count of the current camera position sent by the PLC end and the picture count taken by the industrial camera (1), compare the timestamps of the two, and compare the timestamp when the picture is received with the timestamp of the trigger count sent by the PLC end with the same picture count according to the timestamp threshold range. If the difference between the two is within the timestamp threshold range, the count is considered to be accurate, and the qualified result of the corresponding trigger count is sent to the rejection mechanism; otherwise, it is considered that the trigger signal is abnormal, and the count correction is performed, adding a ±b offset to the picture count, the initial value of b is 1, and then the offset picture count is used to correspond to the trigger count of the PLC end, and the absolute value of the offset is increased by 1 each time until the time difference can fall into the corresponding range again, and the count correction is successful.

Citation Information

Patent Citations

  • Signal processing apparatus

    CN101431602A

  • Machine vision equipment communication verification method based on PLC serial communication

    CN108196524A