A STEP-NC Compatible Cutting Tool Detection System

Traditional cutting tool detection system cannot meet the needs of modern manufacture. To improve the automation and intelligence of processing, a STEP-NC compatible cutting tool detection system is needed. This paper designed a cutting tool detection system based on machine vision. Using pattern recognition, the type of cutting tool is recognized. Using coordinate system transform and stereo vision, the parameters which are defined in STEP-NC and position information of cutting tool are measured. Through experiment, this detection system is working well with industrial robot. It improves the efficiency and accuracy compared with traditional method.


Introduction
Since the birth of the world's first CNC machine tool in 1952, the numerical control technology has developed rapidly, and the numerical control system has gradually developed into today's computer numerical control (CNC).However, the demand of modern manufacture is higher and higher. The incompatible problem between CNC systems greatly limits the modernization of manufacture and the development of NC technology. Among them, the numerical control system using in G, M code (ISO 6983) has obvious disadvantages. The NC program for processing limits the openness of CNC system and intelligent development. It also creates obstruct between CNC and CAX technology, mainly reflected in: (1) The G and M code only defines the movement of machine tool, does not contain the information of products. It lacks complete product information, leading far from real intelligent manufacturing; (2) There are many difficulties in processing programming and modifying. The information from CAD/CAM system to the CNC system is one-way transmission process. The machine tool cannot provide feedback. It is difficult to support the advanced manufacturing model; (3)It can only do some simple line and arc interpolation; (4) Production preparation time is long, and the production efficiency is low. Obviously, G, M code cannot meet the needs of the development of modern production and technique, hindering the development of mechanical manufacturing [1] . Therefore, international researcher developed a new kind of NC system data interface specification ISO14649 (STEP -NC). It can describe the unified data model throughout the life cycle of the product, thus realizing the standardization of the whole manufacturing process and product information in various industrial condition [2] . Traditional way of processing is to use CAX technology to generate G, M code and pass it to the numerical control system for programming spindle motion. STEP-NC programming is based on manufacturing feature, using the same model in the CAD/CAM, CNC system and the whole design and processing [3] . It uses the same kind of model of machining process as the basic unit, connecting the characteristics and technical information together. Each working step only defines an operation [4] . STEP-NC is a revolutionary standards. Tool path planning based on STEP -NC and automatic processing based on the characteristics, will become a part of the intelligent manufacturing. Based on the current progress, the extensive application of STEP-NC may be implemented in 2021, and the G and M code may be the history.
In STEP-NC, cutting tool is an essential part. The accuracy of tool parameters affects machining efficiency and machining accuracy. A large number of researches have been carried out on the measurement of tool parameters at home and abroad.At present, the tool parameter detection has three main methods ,optical projection measuring method, laser measuring method and machine vision measuring method [5] , shown in Figure 1.The error of optical projection method is large.And it is inefficient. In theory, laser measuring method can achieve high precision, but the irregular surface of the cutting tool can generate scattering, which makes the measurement results greatly reduced.The machine vision method is an ideal measurement method due to its high precision, high degree of automation and high efficiency. Although there are some cutting tool measuring instruments with high precision, they are not STEP-NC compatible. They cannot meet the need of modern manufacture and have a low efficiency, shown in Figure 2.And they all need to measure the cutting tool separated from machine tool. Therefore they cannot measure the position of cutting tool to make compensation for positioning error [6] .

Figure 2 Difference Between Traditional Detection System and STEP-NC Compatible System
To meet the needs of modern manufacture and improve the degree of automation, a STEP-NC compatible cutting tool detecting is important. This paper designs a cutting tool system based on machine vision. Using Hu. Moment, the type of cutting tool can be recognized. Using standard tool and external tools to calibrate standard tools, the transform between stereo vision frame and machine tool frame can be obtained, then the parameter defined in STEP-NC can be measured. The process is shown in Figure 3.

The Principle of Binocular Vision
It is necessary to construct a binocular vision measurement system before calibration. Stereo-vision measurement is based on the principle of stereoscopic parallax. Multiple cameras with known spatial mutual coordinate relationships are used to acquire the images of the measured object at the same time, and then the three-dimensional coordinates of the measured object are solved by the image processing.The binocular stereo vision is the simplest stereo vision measurement model,as shown in Figure 4.

Figure 4 Stereo-vision System
Binocular stereo vision measurement model is to simulate the human eye to obtain three-dimensional information by two fixed cameras. The measured object and the two cameras in the space form a triangle, and it is in the public field of view in two cameras. The two cameras respectively take image of the measured object , and then process. By coordinate conversion, the three-dimensional coordinates of the measured point under the stereo-vision coordinate system can be obtained.
Camera imaging is a complex physical process that involves many factors. Pinhole imaging model is a linear imaging relationship, ignoring the impact of various error factors. It is the most commonly used ideal perspective transformation model [7] . It is the basis for the analysis of complex models, as shown in Figure 5. optical center of the lens module and optical module f. The external parameter is the spatial transform relation between camera frame and calibration frame,as shown in Figure 6.The acquirement of camera internal and external parameters is the key step in machine vision.Zhang ZY 's calibration method is the most popular method to get internal and external parameters [8] .Putting accurate chess board in the view of field,and then process the image of chess board. a) internal parameter b) external parameter Figure 6 Parameter of Camera (X CAM represents the coordinate in camera frame) So '' in out S P T T OP = Since and '' SP is known, the in T and out T can be solved.

Transform of Coordinates
After getting the internal and external parameters of the camera, the binocular vision measurement method can be used to measure the point in visual field. But the coordinate information of measuring point is under the stereo-vision coordinate system. The needed coordinate information of the measuring points is the coordinate value in the machine tool coordinate system. To get the accurate position of cutting tool in machine tool frame, a transform between stereo-vision frame and machine tool frame is necessary. The key is to measure the reference object in both stereo-vision frame and machine frame. In this paper, a transform method using in industrial robot is illustrated. Other NC machine tool can use similar method. TCP (Tool Center Position) is an important information in industrial robot. It is similar to cutting tool positioning error in machine tool partly. While TCP is the value in the flange coordinate system, and the robot flange is not easy to measure directly under the camera, so the coordinate transformation is needed [9] . The industrial robot can be simplified as a connecting rod mechanism. In order to obtain the position of its flange coordinate system, the standard cutting tool is  Figure 7. The standard cutting tool is a regular shaped cylinder that can be mounted on the spindle. Since the tool axis is fixed on the spindle, the axis of standard tool and the tool to be measured should be the same. The TCP of standard tool is measured in stereo-vision frame and flange frame, then the coordinate transformation between stereo-vision frame and flange frame can be got.

Figure 7 Standard Tool
To reach high-accuracy measurement, a laser tracker is used to measure the TCP of standard tools in flange frame. The methods of measurement are as follows: (1) The standard cutting tool is mounted on the spindle. The rotation angle of the A6 axis is set to 0, which is recorded as the robot posture P, and the laser target seat is fixed on the A6 axis of the robot; (2) The laser target ball is placed on the target seat of the robot, and the robot rotates around the A6 axis to measure a number of points and fit the circle A6; (3) Back to the posture P, the robot rotates around the A5 axis. Then measure it and fit the circle A5; (4) Restore to the posture P. The standard cutting tool cylindrical surface is scanned and get the center point in laser tracker frame.
(5) The coordinate system of the flange is obtained by A6 and A5, and the offset value of the target seat from the center of the flange. The scene of calibrating standard tool is shown in figure 8. Since the standard cutting tool frame and flange frame are measured in laser tracker.The transform matrix between standard tool frame and the flange frame T S-F (4x4 matrix) can be got. Measure TCP of the standard tool (Xstd, Ystd, Zstd) using stereo-vision measuring method. And then measure TCP of the tool to be measured under the same robot posture.
Euclidean distance of two center points: Then TCP coordinates of the tool to be measured can be got:

Principle of Recongnition
Since industrial robots are not able to judge the type of cutting tool, the cutting tool detection system is required to acquire the type of cutting tool automatically.The common pattern recognition methods usually need a lot of samples and feature points. According to the characteristics of the cutting tool, appearance is simple,having less feature points. This paper uses the Hu moment method to recognize the tool types, which is description of contour rather than feature point.
Relative to the center of the spindle is calculated by area normalization moment, zoom in object, translation and rotation remain the same. When the center of the pure moment although it is possible to represent the geometry of a flat object, but have not deformation, but it can be made from these moment invariant construction. This method was originally put forward by Ming Kuei Hu in 1962, he used the normalized 2 and 3 order central moments, around seven local transform, rotation and scaling of independence of the moment (Hu moment invariants) [10] : The specific steps are as follows: (1)Process the sample cutting tool: Load the initial target image and preprocess, the power law method [11] is used to improve the contrast and divide the target from the background.
(2)Extract the edge of the target using Canny method [12] ,get the contour of cutting tool and calculate the vector made of Hu moment.
(3) Repeat (1) and (2) step to calculate the vector of the cutting tool to be measured. Then calculate euclidean distance between two vectors, D is the target image and the test image is normalized Euclidean distance of feature vector. Set a threshold L in advance, to determine the similarity of the two, if D < L, the goal is to seek the goal of the test image, the opposite is not.

Experimental Verification
An experiment is carried out to verify the theory. An industrial robot, two industrial cameras and a computer are used. The industrial cameras uses a 5-megapixel 12-bit industrial monochrome CCD module and a low-distortion machine vision lens. The scene is shown in Figure 9.   This paper presents a TCP error detection method. Control the industrial robot to rotate around the TCP so that the TCP remain unchanged but the tool axis direction changed. In this way, the real TCP rotate around the measuring TCP. The TCP error can be measured according to the radius of rotation, as shown in Figure 11.

Conclusion
A STEP-NC compatible cutting tool detecting system based on machine vision is designed in this paper. Using stereo-vision, transform of coordinate system, pattern recognition, the parameters defined in STEP-NC can be measured. This detecting system sends information in STEP-NC compatible form. Through the experimental verification, the accuracy and efficiency have been improved compared with traditional method.