The Design of The Algorithm For Measuring The Straightness of Deep Hole Based on Matlab

Straightness of deep hole is an important quality index of deep hole parts. Due to the different methods of detecting the straightness of deep hole, the accuracy of the mathematical model for straightness evaluation is also different. In order to get a more accurate measurement method, this paper through the bus measurement, using the principle of least square method to evaluate straightness, establishes a mathematical model suitable for the measurement method, and uses MATLAB software to compile the data processing program. The automatic calculation of straightness error is realized, and the feasibility of the algorithm is verified by simulation experiment.

The equation is obtained Amongthem: From the properties of the circle, we can see that: d1= d2=d3=R (5) The distance from the three points to the center of the circle can be expressed as follows: The following formula can be obtained: They are as follows: Together we can get: The above formula is obtained, and the coordinates of the center of the circle are obtained The coordinates of the center of the circle can be obtained by formula (10). Let the coordinates of the center of the circle measured by the I th section be O i ( , , ). The least square method is used to fit the center points linearly, which is used as the evaluation reference line L for straightness error detection. Taking l as the axis of the cylindrical surface and the maximum distance between the measuring point and the datum line as the radius, the model is constructed as shown in Fig.2. The straightness error can be expressed as = 2 . Unites the l-direction vector of the line so that [3] : According to the error theory, the arithmetic mean center of hole center coordinate value is the most accurate. O 0 ( , , ) coordinate is a datum space point of datum line L, and its coordinate is ( , , )has the following properties: Point to space line formula: According to the principle of least square method, the sum of squares of distances from each point to the datum line L should be minimized, which is expressed as follows: = ∑ The formula (15) and (11) are obtained Reference matrix [B ij ] [4] : Make: Thus, the optimal solution of straightness can be transformed into: Formula (23) can be arranged as follows: If B is a symmetric matrix, then: When equation (21) is the minimum, the direction vectors (A, B, C) can be obtained. Then the space linear direction vector is the unit eigenvector corresponding to the maximum eigenvalue of matrix B [4] .

3.VISUAL INTERACTIVE PROGRAMMING
The data processing of straightness data processing system is based on MATLAB 2019b platform, which is divided into three modules: data input, data calculation and result output.
Data input is mainly used to record the coordinates of bus sample points. Through the sensor, the A / D converter inputs the digital signal into the module.
The data calculation module is divided into two parts. The first is the solution of the center coordinates, that is, through the design of MATLAB sddy01 function to solve the center of the circle; the second is the calculation of straightness algorithm. The coordinates of the center of the circle calculated in the first step are used for the calculation of straightness, and the two are the relationship before and after.
The specific procedures are as follows:

4.TEST ANALYSIS
In order to study the feasibility of the algorithm, a straightness model is established to simulate the straightness detection. Reference (5), taking z-axis as measurement direction, bottom diameter d = 75mm and length 1750mm, the straightness model was established [5] . As shown in Figure 3 and 4, the number of sections measured is m = 17, the number of sampling points of each bus is n = 3, and the sampling interval is L = 100 mm.
The design of simulation test model: Based on UG modeling software, multiple datum planes are established, and 17 sample points are taken to make circles according to the center coordinate data in reference (5). A circular cross-section is established by taking the sample points as the center of the circle in multiple reference sections, and three points are randomly selected on the section as the measurement sampling points. According to the calculation result of reference (5), f = 0.366, the straightness error of the simulation model is required to be f = 0.3 [5] . Run the core program of straightness calculation, and the interface of straightness calculation system is shown in Figure 5. The program results show: center coordinate, reference line direction vector, straightness error, data processing image Figure 5 operation results of straightness calculation system The coordinates of the center of the circle are shown in Table 1.  (5), which proves that the algorithm can meet the detection requirements and has higher accuracy.

5.CONCLUSION
In this paper, Matlab is used to design the least square straightness error algorithm, and the feasibility of the algorithm is verified by the designed simulation experiment. The evaluation results of the algorithm accord with the definition of national standard of straightness. The program is simple and the calculation process is fast. It is suitable for the use of multiple measurement points, and provides a simple and accurate operation platform for the market.