200821784 九、發明說明: 【發明所屬之技術領域】 本發明是一種電腦數值控制直線轉換NURBS曲線加 工路徑方法。 【先前技術】 CNC控制器傳統上是用直線或圓弧的刀具路徑進行加 工,而這些加工命令通常是以G碼的方式來紀錄(如:直 線:G01;圓弧:G02、G03)。但近年來由於工件形狀的 複雜化,耑使用更先進的曲線模型模擬,其中 NURBS(N〇n-uniform rational B_spHne)為最廣泛使用的參 數式模型,絕大多數CAD/CAM系統均以NURBS曲線模型作 為曲線資料結構與資料輸出的主要數學模型。 CAD/CAM軟體是以參數式的數學模型來描述擬加工 的工件路徑,過去的CNC控制器只能接受直線和圓弧的指 令,所以當這些參數化的工件加卫標在轉換成cnc控制器 能夠接受的短直線指令時,必須在CAM軟體中設定其加 工精度,將原來的參數式曲線、曲面外形打散成許多的短 直線段路[而其中大量的短直線段加卫命令,使得後續 加工機台在速度規劃必須儘量降低速度,以免加工過程中 機台發生較大振動,因此加工效率普遍均較差。 CNC加工機台應用參數式插補器已經愈來愈普及,但 目則仍有許多產業倚賴原來舊有的CAM系統,因此在輸 出其工件加工路徑指令時’仍舊以許多短直線段(G〇 1 ) 來近似工件外形的方式’不但加工時間較長,由於大量的 200821784 短直線段指令,使得動態資料傳輸負荷過大,容易在加工 過程產生間歇停頓的現象,影響工件表面平順度。 因為過去的CNC工具機只能接受直線和圓弧的加工路 徑指令,舊有的使用者依賴直線與圓弧線段模擬工件外形 的近似路徑。其中,大量的短直線段路徑使得在後續速度 規劃日守必須降低速度,以免加工過程中機台發生較大振 動,因此加工效率普遍均較差。然而,現今的CNC工具機 已有能力應用參數式數學模型,如:NURBS曲線(B-spline 曲線為其中的一種特例),規劃速度進行加工。CNC工具 機因為使用NURBS曲線進行路徑規劃,搭配適當的nurbs 曲線插補器,在運動控制、速度規劃上,均比原本使用直 線與圓弧線段規劃加工路徑為佳。 【發明内容】 本發明主要是因應現有使用者在使用上仍不脫離cam 的操作模式下,利用數值控制直線轉換nurbs曲線加工 路控的方法來使得使用者仍得以在不變換工作模式下,得 到最新的NURBS曲線。為達成上述的目的,本發明所使 用的技術手段在於利用電腦強大的運算能力,並經過自動 化程序,提升舊有的CAM輸出直線線段的指令格式(GQ1) 為NURBS曲線段的指令格式(G〇6·2),以符合現今cnc工 具機高速度、高精確度的需求。 【實施方式】 1·讀取加工程式轉換為座標點資料格式 在業界的加工程式(NC檔)裡,與工件的幾何外形(如 5 200821784 第ίο圖所示)和加工路徑較有直接關係的指令為〇碼,复 中G01用來指定刀具以直線插補的模式移動,程式的格 式如第2圖所示。本發明使用自訂的座標點資料格二 換NC檔案中屬於G〇1插補的路徑指令,讀標轉換過 的判斷方法如第3圖所示。在逐列讀取Nc檀案内容 主要先判斷路徑點座標系統的型態為增量座標系或絕對座 軚系,其影響路徑點座標值的計算方式。接著判 現的路徑點為GO 1的型<,# # _ 幻1式右判斷屬於G01的路徑點, 。取X Y、Z相關的數值存人自訂的點座標資料格式。、 2·根據容許弦長誤差過濾雜訊點資料 較大^二⑽趟所產生的短直線段,常與原始路徑有 點的動作二ΓΛ得:點資料,必須先進行過渡雜訊 J線:距離e.,為初始的弦長誤差。首先必須剔除點資二 中’各點的初肖弦長誤差大於 容許弦長誤h的點,接著將小於4' 義的 群,如第5圖所示,同圖;誤差的連續點 ,有哪些點是可以被省略 足上述條件的連續點群,若例’ ^為—滿 表示。。训能被省略再 y- h A馬起點’同上诚之方彳、社 仃2〜P5之間的判斷,·若兩者皆 》 步邦斷…容呼弦… 争弦長誤差,則進- 能伴值的大小關係。以這樣方式便 …五在滿足谷终弦長誤差值的條件下, 中的雜訊,並且進—步突 D k濾-占貝料 颂出整體點貧料中平坦或彎曲的 6 200821784 幾何特性。 3·根據幾何特性決定點資料的分段點 將連、·’貝的點貝料區分成直線路徑線段與曲線路徑線 段’以還原件的原始加卫路徑。直線路徑線段則可直接 轉換為G〇1指令形式做為輪出。曲線路徑線段的點資料則 需進-步以曲線嵌合的方式,產生滿足誤差限制的曲線。 首先,在曲線的頭、尾兩點之外,計算各點與下一點的轉 折角度乂,如第6圖所示, θ{ = cos'1 UVPilHulJ· 如果仏大於一個預先決定的門檻角度、,則^視為分段 點,反之,則需再觀察相鄰線段長是否為長直線段,如第 7圖所不,假定(·為線段長度,Ave』是相鄰線段長的平均值, 以N = 5為例,判斷法則如下:200821784 IX. Description of the Invention: [Technical Field of the Invention] The present invention is a computer numerical control linear conversion NURBS curve processing path method. [Prior Art] CNC controllers are traditionally processed with straight or circular tool paths, and these machining commands are usually recorded in G code (for example: straight line: G01; arc: G02, G03). However, in recent years, due to the complexity of the shape of the workpiece, 更 uses a more advanced curve model simulation, in which NURBS (N〇n-uniform rational B_spHne) is the most widely used parametric model, and most CAD/CAM systems use NURBS curves. The model is used as the main mathematical model for curve data structure and data output. The CAD/CAM software is a parametric mathematical model to describe the path of the workpiece to be machined. The past CNC controller can only accept the instructions of the line and the arc, so when these parameterized workpieces are added to the controller, they are converted into cnc controllers. When the short linear command can be accepted, the machining accuracy must be set in the CAM software, and the original parametric curve and surface shape are broken into many short straight segments [and a large number of short straight segments are added to the command, so that The processing machine must minimize the speed in the speed planning, so as to avoid large vibrations in the machine during the machining process, so the processing efficiency is generally poor. The use of parametric interpolators in CNC processing machines has become more and more popular, but there are still many industries that rely on the original CAM system, so there are still many short straight segments (G〇) when outputting their workpiece machining path commands. 1) The way to approximate the shape of the workpiece is not only long processing time, but also due to the large number of short-segment instructions of 200821784, the dynamic data transmission load is too large, and it is easy to cause intermittent pause in the machining process, which affects the smoothness of the workpiece surface. Because the past CNC machine tools only accepted the machining path commands of straight lines and arcs, the old users relied on straight lines and arc segments to simulate the approximate path of the workpiece shape. Among them, a large number of short straight-line segments make it necessary to reduce the speed in the subsequent speed planning, so as to avoid large vibrations in the machine during the machining process, so the processing efficiency is generally poor. However, today's CNC machine tools have the ability to apply parametric mathematical models such as the NURBS curve (B-spline curve is one of the special cases) and plan the speed for machining. Because the CNC tool machine uses NURBS curve for path planning and the appropriate nurbs curve interpolator, it is better to plan the machining path than the original straight line and arc segment in motion control and speed planning. SUMMARY OF THE INVENTION The present invention mainly utilizes a numerical control linear conversion nurbs curve processing road control method in response to an existing user's operation mode without using the cam, so that the user can still obtain the operation mode without changing the operation mode. The latest NURBS curve. In order to achieve the above object, the technical means used in the present invention is to utilize the powerful computing power of the computer, and to upgrade the command format (GQ1) of the old CAM output straight line segment to the command format of the NURBS curve segment through an automated program (G〇). 6·2), in order to meet the high speed and high precision requirements of today's cnc machine tools. [Embodiment] 1. The conversion of the reading program into the coordinate point data format is directly related to the geometry of the workpiece (as shown in 5 200821784) and the machining path in the machining program (NC file) of the industry. The command is a weight. The G01 is used to specify that the tool moves in linear interpolation mode. The format of the program is shown in Figure 2. The present invention uses a custom coordinate point data grid 2 to replace the path instruction belonging to G〇1 interpolation in the NC file, and the judgment method of the read label conversion is as shown in Fig. 3. Reading the contents of the Nc Tan by column by column The main method of judging the path point coordinate system is the incremental coordinate system or the absolute coordinate system, which affects the calculation method of the coordinate value of the path point. Then, the path point judged is the type of GO 1 <, # # _ 幻一式 right determines the path point belonging to G01. Take the X Y, Z related values to customize the point coordinate data format. 2, according to the allowable chord length error filtering data of the noise point is larger ^ 2 (10) 趟 generated short straight line segment, often with the original path a little action two points: point data, must first carry out the transition noise J line: distance e., is the initial chord length error. First of all, it is necessary to eliminate the point where the initial chord length error of each point is larger than the allowable chord length error h, and then the group smaller than 4', as shown in Fig. 5, the same figure; Which points are consecutive point groups that can be omitted from the above conditions, if the example '^ is - full. . The training can be omitted and then y-h A horse starting point 'the same as the judgment between the square of the Cheng, the social 2 2 ~ P5, if both are" step state broken ... Rong Hu string ... chord length error, then into - Can be associated with the value of the size relationship. In this way, the five noises in the condition of satisfying the valley final length error value, and the in-step-step D k filter--the flat material is flat or curved in the overall point-poor 6 200821784 . 3. Determine the segmentation point of the point data according to the geometrical characteristics. The point and material of the joint and the 'bee are divided into a straight path line segment and a curved path line segment' to restore the original reinforcement path of the piece. The straight path segment can be directly converted to the G〇1 command form for rounding. The point data of the curve path segment needs to be step-by-step to form a curve that satisfies the error limit. First, calculate the turning angle 各 between each point and the next point outside the two points of the curve. As shown in Fig. 6, θ{ = cos'1 UVPilHulJ· If 仏 is greater than a predetermined threshold angle, Then ^ is regarded as a segmentation point. Otherwise, it is necessary to observe whether the length of the adjacent line segment is a long straight line segment. As shown in Fig. 7, it is assumed that (· is the length of the line segment, Ave is the average value of the length of the adjacent line segment, For example, N = 5, the rule of thumb is as follows:
1. Ave^^+^+^+^+g/N1. Ave^^+^+^+^+g/N
Ave2=(/7+/8+/9+/I0+/u)/NAve2=(/7+/8+/9+/I0+/u)/N
Ave3=(/2+/3+/4+/5+/6)/NAve3=(/2+/3+/4+/5+/6)/N
Ave4=(/8+/9+/10+/n+/12)/N 2. 如果(/6>rt〇|XAve|)或(/6>Iw|XAve2)或(/7>yA^或 ^sr^xAve4),則1點為長線段端點,即視為分段點。 其中,L為一比例門捏值。 4·決定分段點連續性 當相鄰段落之端點的角度轉折,如第6圖,大於0時, 則給定該分段點之連續性為位置連續;反之則給定為斜率 連續。由於後續嵌合曲線時,除了考慮誤差,為了確保各 200821784 加工指令之間位置的連接盥平普 .,^ ^ 妖,、十α性,在曲線段落的端點連 續性條件必須事先給定。1中仞罢 ^ ,、τ位置連績條件可由曲線段落Ave4=(/8+/9+/10+/n+/12)/N 2. If (/6>rt〇|XAve|) or (/6>Iw|XAve2) or (/7>yA^ or ^ Sr^xAve4), then 1 point is the end point of the long line segment, which is regarded as the segmentation point. Where L is a proportional gate pinch value. 4. Determine the continuity of the segmentation point. When the angle of the endpoint of the adjacent paragraph is turned, as shown in Fig. 6, when it is greater than 0, the continuity of the segmentation point is given as the position continuity; otherwise, the slope is continuous. Due to the error in the subsequent fitting curve, in order to ensure the connection between the positions of the machining instructions in 200821784, the end point continuity condition in the curve paragraph must be given in advance. 1 中仞止 ^ , , τ position success conditions can be curved section
點Μ料的^^點獲得,而斜率造病y,ir /4. a I 計手運續條件則必須由分段點附近 取局部資料預先嵌合一條曲線來決定。但若曲線段落與直 線段落相鄰且為斜率連續之條件,則斜率連續條件則可由 連接直線點資料獲得,無需預先嵌合曲線。 5·滿足設定誤差之曲線邊界連績拘束性嵌合 NURBS曲線的數學模式表示如下: η ENu(u)wiAi i=0 ⑴ ZNi,k(u)wi i=0 其中 ' 為曲線控制,點,%為權重參數,&⑻為基底函 數,U為曲線參數’ Rik⑼為有理的基底函數,η+ι為控制點 數目,k為曲線階數,阅、[A]分別為Ri>)、Ai的矩陣形式。 點資料在同時考量曲線精度、平滑性與邊界條件之下 嵌合出NURBS曲線。曲線嵌合乃結合平方誤差函數(2)與 能量函數(3),在最小化平方誤差與能量函數的狀況下, 獲得最佳化之NURBS曲線。 h|[C(Uj)-Qj][C(Uj)_Qjr (3) E=|(〇CC’(Uj)][C(Uj)rw〃(Uj)][c"(Uj)]> 200821784 πήη(ε+Ε)^—— + ---— = 〇,= 0 j π dAe dAe => {[R]T[R] + 〇iRf [R1 + /5[RT[R1)[A] = [Rf [Q] (4) =>[rn】[a] = [qn] 其中6:為誤差函數,E為曲線能量函數,以和p為曲線 嵌合平滑化係數,Qj為點資料,[Q]為Qj的矩陣形式,[R]、 [RNJ與[RN〃】則分別為曲線有理的基底函數矩陣及其一次與 兩次微分矩陣。 依據前一步驟判斷出的點群資料Qi,i==〇山·.阳,嵌合成 RBS曲線日守乾要滿足點資料到嵌合曲線的均方根誤差 值enns最小化, , er\\Qrc(^)l 其中ej為點貝料Qj到嵌合曲線對應點之距離。 因此本步驟採用適當節點向量,並以聶 點向量與曲線控制 二式更新節 同時在點群資料產生_s=到滿足敗合曲線的精度。 座生NURBS曲線的運算過程中 界條件做為曲線嵌人……欠从 、枉T將曲線邊 .。的拘束條件,使得嵌合的NURBS曲绫 滿足所设定的邊界條件。 ύ曲線 滿足誤差設定 々日月&下 曲線邊界連續拘束性嵌合之演曾+w 況明如下,而曲線嵌 肩斤步驟 口机%圖如第8圖所示·· 步驟'•設定點資料嵌合曲線參數 】·依據點群資料在她 參數U。 〜長度的百分比,設定點資料曲線 (5) ^==0 200821784 u.=The ^^ point of the point material is obtained, and the slope is y, ir /4. a I The condition of the hand-operating condition must be determined by pre-mating a curve by taking the local data near the segment point. However, if the curve segment is adjacent to the straight paragraph and the condition is continuous, the slope continuous condition can be obtained by connecting the straight point data without the need to pre-fit the curve. 5. The curve boundary that satisfies the set error. The mathematical mode of the fitting NURBS curve is as follows: η ENu(u)wiAi i=0 (1) ZNi,k(u)wi i=0 where ' is the curve control, point, % is the weight parameter, &(8) is the basis function, U is the curve parameter ' Rik(9) is the rational basis function, η+ι is the number of control points, k is the curve order, and [A] is Ri>), Ai Matrix form. The point data is fitted with a NURBS curve under the consideration of curve accuracy, smoothness and boundary conditions. The curve fitting is combined with the squared error function (2) and the energy function (3) to obtain an optimized NURBS curve under the condition of minimizing the squared error and the energy function. h|[C(Uj)-Qj][C(Uj)_Qjr (3) E=|(〇CC'(Uj)][C(Uj)rw〃(Uj)][c"(Uj)]> 200821784 πήη(ε+Ε)^—— + ---— = 〇,= 0 j π dAe dAe => {[R]T[R] + 〇iRf [R1 + /5[RT[R1)[A ] = [Rf [Q] (4) => [rn][a] = [qn] where 6 is the error function and E is the curve energy function, and p is the curve fitting smoothing coefficient, Qj is the point The data, [Q] is the matrix form of Qj, [R], [RNJ and [RN〃] are respectively the rational basis function matrix of the curve and its one and two differential matrices. According to the previous step, the point group data Qi, i==〇山·.阳, chiseled into the RBS curve, the daily root mean square error value enns is satisfied to meet the point data to the chimeric curve, er\\ Qrc(^)l where ej is the distance from the point Qj to the corresponding point of the chimeric curve. Therefore, this step uses the appropriate node vector, and uses the neon point vector and the curve to control the two-form update section. At the same time, the point group data is generated to obtain the accuracy of the singularity curve. The boundary condition of the NURBS curve is set as the curve embedded... owe from 枉T to the edge of the curve. The constraint conditions allow the fitted NURBS curve to satisfy the set boundary conditions. The curve satisfies the error setting, and the continuous constraint fit of the curve boundary is as follows: the curve is embedded as shown in Figure 8. Steps • Setpoint Data fitting curve parameters] According to the point group data in her parameter U. ~ percentage of length, set point data curve (5) ^==0 200821784 u.=
由2:點附近的點資料設定嵌合曲線的邊界條件。 3·由成$函數最小化條件,設定嵌合曲線的平滑性係 數α與/?。 、 4. 設定嵌合曲線階數與設定後合誤差。 5. 由點群資料之反曲狀態,設定初始節點向量。 .點群資料可得到一組的方程組,利用數值分 斤方法解得曲線控制點,而得到嵌合曲線。 步驟二·计异點群資料人 嵌合誤差。 、4至队5曲線的距離,視為曲線 步驟四··在超出誤差之兩節點向量間插 值,並以疊代方式更新節點向量與曲線控制點數目。 步驟五··如果曲線嵌合誤差大於所設定的誤差,則重 複步驟一至步驟四,勃并§々机人窃 ^ ^ , 執仃即點向量與曲線控制點數目的疊 綠山入本 。决差小於所設定的誤差’則完成曲 ,、在敗。步驟,獲得最佳化NURBS曲線。 上述由i.讀取加工程式轉換為座標點資料格式 =弦長誤差過遽雜訊點資料、3.根據幾何特性決定點 貝;的分段點、4.決定分段點連續性、5.滿足設定誤差 曲線邊界連續拘束性嵌合等步驟所形成的實際情形則可分 200821784 別地由第11、第12、第13圖所顯示的情形得出。 6· NURBS曲線轉碼成參數式曲線碼之指令格式: 直線與曲線的幾何資訊重新產生後,接著需將這些資 訊轉換為NC檔案的指令格式。直線段落維持原來的G〇工 指令形式做為輸出,如第2圖所示;而nurbs曲線則轉換 成目如大部分NURBS曲線插補器所能接收的指令格式 G06.2,如第9圖所示。The boundary condition of the fitting curve is set by the point data near the 2: point. 3. Set the smoothness coefficients α and /? of the chimeric curve by the minimum condition of the $ function. 4. Set the fitting curve order and set the post-closing error. 5. Set the initial node vector from the recurve state of the point group data. The point group data can obtain a set of equations, and the curve control points are obtained by the numerical method to obtain the chimeric curve. Step 2: Calculate the error of the heterosexual group. The distance from the 4 to the 5 curve is regarded as the curve. Step 4· Interpolate between the two node vectors that exceed the error, and update the node vector and the number of curve control points in an iterative manner. Step 5· If the curve fitting error is greater than the set error, repeat step 1 to step 4, and 勃 々 々 人 ^ ^ ^ ^ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , If the difference is less than the set error, then the song is completed and defeated. Steps to obtain an optimized NURBS curve. The above is converted into a coordinate point data format by the i. reading processing program = chord length error over the noise point data, 3. the point is determined according to the geometric characteristics; the segmentation point is determined, 4. the segment point continuity is determined, 5. The actual situation formed by the steps of satisfying the boundary of the setting error curve and the continuous restraint fitting can be obtained by the case shown in the 11th, 12th, and 13th in 200821784. 6. The NURBS curve is transcoded into the parameter format of the parametric curve code: After the geometric information of the line and curve is regenerated, the information needs to be converted into the command format of the NC file. The straight paragraph maintains the original G completion command form as the output, as shown in Figure 2; and the nurbs curve is converted to the command format G06.2 that most NURBS curve interpolators can receive, as shown in Figure 9. Shown.
0.0018 0.00141 0.0011 0.0007 I 0.0004 I •0.0000 線段誤差分析結果 (Max為最大的單點誤差值,RMS*均方根誤差值,誤差值以右邊色差表來 呈現’可由右上圖看出各點的誤差值分佈,誤差在00018 mm以下) 轉換前 轉換後 414,309 24,690 表一轉後前後檔案所包含的加工指令數目 (轉換前只有GO 1(短直線段所以很多),轉換後GO 1和 GO6· 2混合(因為合併不少短直線段變成NURBS曲線,所以 指令變少很多)) 11 200821784 【圖式簡單說明】 第1圖:為本發明的主要運作流程圖。 第2圖:NC檔案G01指令格式。 第3圖:G01指令格式轉換為點資料格式之判斷流程 第 4圖 :點資料初始弦長誤差示意圖。 第 5圖 •點貢料更新弦長誤差不意圖。 第 6圖 :點資料轉折角度示意圖。 第 7圖 :點資料局部長度示意圖。 第 8圖 :曲線依誤差嵌合流程圖。 第 9圖 :NC檔案G06.2指令格式。 第10圖:加工工件外形示意圖。 第11圖:從加工工件外形擷取之單一道次資料。 第12圖:點資料分段結果。 第13圖:連續性給定結果。 120.0018 0.00141 0.0011 0.0007 I 0.0004 I •0.0000 Segment error analysis result (Max is the largest single point error value, RMS* rms error value, error value is presented in the right color difference table'. The error value of each point can be seen from the upper right figure. Distribution, error below 00018 mm) 414, 309 24, 690 after conversion. The number of machining instructions included in the file before and after the conversion (only GO 1 before conversion (short straight line segment, so many), GO 1 and GO6 · 2 mixed after conversion ( Since many short straight segments are merged into NURBS curves, the instructions are much less.) 11 200821784 [Simplified Schematic] Fig. 1: The main operational flow chart of the present invention. Figure 2: NC file G01 command format. Figure 3: The judgment flow of G01 command format conversion to point data format Fig. 4: Schematic diagram of the initial chord length error of point data. Figure 5 • Point tribute update chord length error is not intended. Figure 6: Schematic diagram of point data turning angle. Figure 7: Schematic diagram of the local length of the point data. Figure 8: Curve fits the error fit flow chart. Figure 9: NC file G06.2 command format. Figure 10: Schematic diagram of the shape of the machined workpiece. Figure 11: Single pass data taken from the shape of the machined workpiece. Figure 12: Point data segmentation results. Figure 13: Continuity given results. 12