In order to solve the problem that paper surface defects (paper defects) are not easy to identify in the production process of medical test paper, a medical test paper disease detection system based on NJ controller is designed by analyzing the main characteristics of manual detection methods and paper defects. The system is composed of visual inspection module and action marking module. The basic method of visual inspection is introduced and the effect diagram of visual inspection is given. The corresponding relationship between visual coordinate system and motion marking coordinate system is explained. The motion control program designed in this paper realizes the effective recognition and time marking of paper diseases on the surface of medical test paper. After debugging many times, the system can effectively detect and mark bright spots and dark spots of 1 m m or more on the surface of medical test paper when the paper speed is not more than 3 m/s and the width is 200 mm. Medical test paper is to fix biochemical reagents on test paper to test human biochemical substances, and then screen some diseases. Because of its simple operation, convenience and accuracy, it is favored by many consumers. The quality requirement of medical test paper is much higher than that of ordinary paper. Medical test paper using patch processing technology will have the production process as shown in Figure 1. In production, paper will be strictly inspected manually, mainly checking the light transmittance and dark spots on the surface of paper larger than 1 mm. The traditional method of manual detection of paper diseases, whether speed or accuracy, can not meet the current production needs. Medical test paper disease detection requires that the detection and marking be carried out simultaneously to meet the needs of the next elimination, and the controller is required to be high. Therefore, this system chooses NJ series controller, which is a new generation of motion control, PLC, visual control integrated controller developed by Omron Company [2]. NJ series controllers have built-in EtherCAT and EtherNet/IP ports, which can be networked with devices with EtherCAT interface as well as the platform. They have better expansibility, no signal loss and high control accuracy [3]. NJ’s programming software is Sysmac Studio. The software model follows IEC61131?3 standard, adopts variable programming system different from previous PLC, and is closer to C programming system. The programming language includes ladder diagram, ST and function block. Servo control through function block greatly improves programming efficiency [4]. Medical paper disease detection system consists of three parts: visual detection part, action marker and human-computer interaction interface. Visual inspection is the input part of the whole system, and the specific coordinate position of the paper disease is obtained by image acquisition and algorithm processing; NJ controller acquires coordinate position of the visual part, then carries on data analysis and coordinate conversion, and controls the servo motor to mark the corresponding position; the action part of marking module is XY screw slider device. The paper speed is controlled by the frequency converter. The main parameters of the system are modified and debugged through the touch screen interface. The specific system structure is shown in Figure 2. The final calculation needs 1,000 pixels, 2 million pixels (1 600 *1 200) FZ? SC2M camera can be selected, and the visual module uses FH? 1050? 10 visual processor. The visual control fully meets the requirements of the system from the speed of image input, processing and transmission. The action marking part needs three servo motors, two servo drivers and one frequency converter. The NJ301? 1200 core controller, which can control up to 8-axis synchronization, 3 ns single-step instruction speed and 42 ns digital instruction speed, can fully meet the control requirements of the system. The hardware structure and network topology of the system are shown in Figure 3. NJ controller is connected with PC and touch screen through EtherNet/IP bus to form upper computer system; NJ is connected with visual processor, servo driver and frequency converter to form lower computer system through EtherCAT bus; visual processor is connected with industrial camera through camera bus; servo driver and frequency converter are connected with power cable and encoder line. Connect with each servo motor.
The calibration of visual coordinate system is mainly to determine the one-to-one correspondence between the real world coordinates and the pixel coordinates. The pinhole model of the camera shows that the correspondence is determined by six parameters in the camera. In the formula, [X, Y] is the pixel coordinate, [X’, Y’] is the real world coordinate. From the formula, the values of A, B, C, D, E and F can be obtained by three pairs of corresponding pixel coordinates and real world coordinates. The plane target of 10 *10 is selected for calibration. This kind of plane target is easy to make and has high accuracy [6]. After determining the relationship between the pixel coordinates and the world coordinates, the absolute position of the camera in the world coordinates is determined because the installation position of the camera is fixed.
Image smoothing can effectively reduce image noise.
The basic principle of median filtering is to replace the value of a point in a digital image with the median value of each point in a neighborhood of the point, so that the surrounding pixel values are close to the real value, thus eliminating the isolated noise points [7]. The method uses a two-dimensional sliding template with a certain structure to sort the pixels in the board according to the size of the pixel value, and generates a monotonous rising (or falling) sequence of two-dimensional data. In the formula, [f (x, y)], [g (x, y)] are the original image and the processed image respectively, [W] is a 2-D neighborhood template of 3 *3. Edge emphasis is to eliminate the blurring of image edges and contours caused by image smoothing. In this paper, the gradient method of spatial method is used to emphasize the edge. The gradient modulus of the image contains the boundary and details. The gradient modulus operator is used to calculate the gradient modulus. It is generally considered as a boundary extraction operator with extremum, displacement and rotation invariance.
In the formula, [G ([f (j, k)]] represents the gradient module. Prewitt edge detection operator is a first-order differential operator edge detection, which uses the gray difference between the upper and lower pixels and the left and right adjacent pixels to reach the extreme detection edge at the edge, and has a smooth effect on noise [8]. The two templates detect horizontal edges and vertical edges. Each point in the image is convoluted with these two templates, and then the larger one of the two convolutions is obtained as the output. In the formula, [Gx] and [Gy] are convolutions of two templates of the Prewitt operator respectively, [M is the gradient value obtained by applying the Prewitt operator. After calculating the gradient, a constant T can be set. When [M]> T, the point is marked as the boundary, and its pixel value is set to 255, while the others are set to 0. Shape search algorithm first needs to select the appropriate reference image as the model; then roughly search the whole region to determine the location of similar model; then further search around the model to determine the similarity of the image, shape search is to process the contour information as the image pattern [9]. The results of the above algorithm are shown in Figure 4. It can be seen that both black and bright spots are marked effectively by shape search.
After programming the visual processor and calling the visual processing module described above, you can see the processing result of Figure 4. The first two pictures are the result images after the treatment of paper diseases; the third one is the result image of Prewitt edge detection operator detection, and the edges of the two kinds of paper diseases are clearly detected; the figure shows that all paper diseases will be effectively identified after the invocation of shape search algorithm, and its results can be obtained. Corresponding coordinate position and coordinate data will be arranged in ascending order with Y axis. Finally, the data transmission module will be called to transfer the coordinates obtained each time to the NJ controller. The action marking part determines a one-to-one correspondence with the world coordinates by setting the actual feed of the sliding platform of servo rotation for one week. Limit switches are arranged at four corners of the two-dimensional slide table, and non-contact constant open proximity switches are installed in the middle of the screw as near-origin signals. By using Sysmac programming software, the servo motor is set as the approach to the origin of “near origin input OFF action”.
After the system is powered on, the origin can be searched automatically in various states.
The specific action situation is shown in Fig. 5, which can determine the absolute position of the action marker in the real world. When the visual coordinate system and the action mark coordinate system are determined relative to the world coordinate system, the coordinate of the whole system can be determined. First, the system initialization program is carried out. In the main periodic tasks, servo locking program segment, origin search program segment, frequency converter control program segment, point control program segment, stop function program segment and fault recovery program segment are added to realize the basic manual function of the system. In Sysmac, two servo motors of two-dimensional sliding platform control Abstract XY two axes. The two axes are combined and added to XY_GROUP axle group. The control model of axle group is simplified, and the synchronization of action improves the stability of sliding platform. In the automatic control program, the X_POS [100], Y_POS [100] and MOVE_TIME [100] arrays of LREAL type of queue data structure are created, and the action sequence and time interval of XY axis are stored respectively. After the servo enablement is completed, the camera is triggered to take photos, and then the data is taken out from the NJ data buffer.
The coordinate position is checked to determine whether it is in a reasonable interval. After coordinate conversion, the XY coordinate and time interval data are obtained. The StackPush function block is called and the visually transformed data is processed into the queue. By calling the StackFIFO function block to perform the queue operation through whether the first action and the last action are completed or not, the coordinates are obtained and then run to the designated position, thermostatic element waiting for the paper disease to reach the coordinate point, triggering the marking action, and positioning the last action completion mark. Pop up the next data and compare the position difference between the two coordinates. If the XY direction interval is too small, the data will be discarded. There will be fault tolerance when paper diseases are eliminated. If the queue counter is found to be zero when pop up, the first action sign will be positioned to ensure that the data can be successfully queued next time there is data. The specific procedure flow is shown in Figure 6. Experiments show that the marker module can accurately mark paper diseases. The upper computer uses OMRON NS8? TV01B? V2 touch screen; the human-computer interaction interface mainly includes the operation interface, manual operation, parameter setting and historical records and many other pictures [10]. The main interface shows some main parameters of the current system, and the main parameters of the system are set. The historical record interface can query the specific location of paper diseases, and combine with the number of defects, it can determine the quality of paper and make timely adjustment of production plan. The touch screen interface is shown in Figure 7. The medical paper disease detection system takes NJ301? 1200 as the core controller, FH? 1050? 10 visual control module and action module as the auxiliary control unit, through the design of visual algorithm, the paper disease location can be accurately obtained, and through the cooperation of queue data structure and timer, the action control algorithm can effectively deal with the delay action sequence. Man-machine interface can set parameters and monitor the state of the system. After debugging for many times, the system can effectively detect and mark bright spots and dark spots on the surface of medical test paper when the paper speed is not more than 3 m/s and the width is 200 mm. The whole system can detect and mark paper diseases accurately and quickly. Its speed and precision can meet the needs of production and greatly improve the production efficiency of medical test paper.