Summary of the invention
Therefore, the object of the invention is to the defect overcoming above-mentioned prior art, a kind of CNC interpolation method processing small route segment is provided.
The object of the invention is to be achieved through the following technical solutions:
On the one hand, the invention provides a kind of method for processing small route segment in numerically-controlled machine, comprising:
Step 1, for the multiple small route segment of continuous print in machine command file, selects several intermediate points between the start position of these small track end and final position;
Step 2, adopting with distance is that the cubic polynomial of variable is to describe the SPL section between adjacent two intermediate points;
Step 3, converts program segment corresponding with described multiple small route segment in machine command file to the program segment corresponding with described SPL section, produces new machine command file, and controls the operation of cutter according to this new machine command file.
In said method, the step of intermediate point in described step 1, is selected to comprise:
For the curve that the multiple small route segment of continuous print in machine command file is corresponding, from the starting point of the first small route segment, calculate the curvature in the starting point of each small route segment and the bending of destination county, if sign of curvature changes, or very fast relative to previous some Curvature varying, then select this point to be an intermediate point; Wherein, the distance between selected intermediate point and a upper intermediate point at least should be greater than the threshold value of setting, this threshold value be the cutting speed expected square divided by the peak acceleration of this lathe.
In said method, described step 1 selects the step of intermediate point to comprise:
For the curve that the multiple small route segment of continuous print in machine command file is corresponding, from the starting point of the first small route segment, calculate the curvature in the starting point of each small route segment and the bending of destination county, if sign of curvature changes, or very fast relative to previous some Curvature varying, then select this point to be an intermediate point; Wherein, the distance between selected intermediate point and a upper intermediate point is not less than the threshold value of setting, and this threshold value is the program hop count of cutting speed divided by compiling per second of expectation.
In said method, in described step 2, for any two point P1 and P2 in X-Y-Z space, connect the described SPL of these two point P1 and P2 profile can below be that the cubic polynomial of variable describes with distance:
P
X(d)=C
X3.d
3+C
X2.d
2+C
X1.d+C
X0
P
Y(d)=C
Y3.d
3+C
Y2.d
2+C
Y1.d+C
Y0
P
Z(d)=C
Z3.d
3+C
Z2.d
2+C
Z1.d+C
Z0
Wherein, d variable represents the standardized distance of G01 straight line along connecting these two points, 0≤d≤1, and when starting point P1, d is 0, and during to the terminal P2 of line, d reaches 1; C
xi, C
yi, C
zi(0≤i≤3) represent the coefficient of cubic polynomial; Wherein, d=P
g01t ()/pg, pg is the distance of the G01 straight line along these two points of connection of origin-to-destination, P
g01t () represents when the time is t, between the current location of cutter and starting point, along the distance of the G01 straight line of connection source and terminal.
In said method, described step 2 also can comprise the coefficient determining the cubic polynomial describing the SPL connected between these two intermediate points based on the position of adjacent two intermediate points on the direction of X, Y, Z and velocity.
In said method, the direction of the velocity of described intermediate point can be that the plane that forms at two lines of two points be up and down adjacent by this intermediate point is determined, the medium line of the angle that the direction of the velocity of this intermediate point is formed perpendicular to the line being adjacent two points by this intermediate point.
In said method, the direction of the velocity of described starting point and terminal can be with the line of itself and adjacent intermediate point for datum line, mirror image is done to the velocity direction of the intermediate point be adjacent and obtains.
In said method, described step 2 can comprise:
21) coefficient of the cubic polynomial describing the SPL connected between these two intermediate points is determined based on the position of adjacent two intermediate points on the direction of X, Y, Z and velocity;
22) for other points between adjacent intermediate point, judge whether the distance between this point with the relevant position in the SPL being connected these two intermediate points is greater than the precision of expectation; If be less than, then continue the next point of assessment; If be greater than, then select at these two mid-point position places o'clock as an intermediate point, and get back to 21) continue to perform.
In said method, the coefficient of described cubic polynomial can be determined by mode below:
For X, Y, the arbitrary axle in Z axis, position P, the speed V of this axle and acceleration A can be expressed as:
P(d)=C
3.d
3+C
2.d
2+C
1.d+C
0
V(d)=3.C
3.d
2+2.C
2.d+C
1
A(d)=6.C
3.d+2.C
2
Wherein, V (d) obtains P (d) differentiate, and A (d) obtains V (d) differentiate; Supposing two intermediate points for arbitrary neighborhood, is p in this position axially
1, p
2be v with speed
1, v
2, then the coefficient of above-mentioned cubic polynomial is:
C
0=p
1
C
1=v
1
C
2=3p
2–2v
1–3p
1–v
2
C
3=v
2–2p
2+2p
1+v
1
Another aspect, the invention provides a kind of equipment for processing small route segment in numerically-controlled machine, comprising:
For for the multiple small route segment of continuous print in machine command file, select the device of several intermediate points between the start position of these small track end and final position;
Be that the cubic polynomial of variable is to describe the device of the SPL section between adjacent two intermediate points for adopting with distance;
For converting program segment corresponding with described multiple small route segment in machine command file to the program segment corresponding with described SPL section, produce new machine command file and according to this new machine command file to control the device of the operation of cutter.
Another aspect, the invention provides a kind of CNC controller, and it comprises the equipment of the small route segment of process as above.
Compared with prior art, the invention has the advantages that:
The small route segment of multiple continuous print that Interpolation Process is formed in machine command file, adopting with distance is that the cubic polynomial of variable is to carry out matching.The method does not require to carry out any change to CAD/CAM system, CAD/CAM system that can be compatible all at present.Do not need to carry out any change to machine command file, do not need to increase batten and calculate, remain the advantage of ripe traditional G/M code programming completely.All traditional numerical control functions, as feeding locking, (again) loop start and multiplying power, single block execution etc. stand good.The method is all transparent for CNC operating personnel and CAD designer, and adopts cubic polynomial to carry out the small route segment of matching, and algorithm is simple, does not need extra computing power, can ensure precision simultaneously.
Embodiment
In order to make object of the present invention, technical scheme and advantage are clearly understood, below in conjunction with accompanying drawing, by specific embodiment, the present invention is described in more detail.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
In the motion control of traditional numeric-control machine, worktable (cutter) X, Y, the minimum Moving Unit of Z axis is a pulse equivalency.Therefore, the movement locus of cutter has the broken line (data point densification) that minimum step forms.Such as, with the curve on numerically-controlled machine machining profile line between 2, cutter can move from starting point along X-axis and move a step or a few step (one or several pulse equivalency D
x), then move along Y direction and move a step or several step (one or several pulse equivalency D
y), then move along X-axis and move a step or several step etc., until arrive impact point, thus the movement locus (straight line or curve) needed for synthesis.Digital control system, according to given straight line, circular arc (curve) function, between by the known point between the starting point in the ideal trajectory described by program segment, terminal, is carried out data point densification, is determined the process of some intermediate points, be called as Interpolation Process.
Fig. 3 gives work of numerical control machine schematic flow sheet according to an embodiment of the invention.After CNC controller receives machine command file, adopting with distance is the small route segment that the cubic polynomial of function comes in this machine command file of matching, and carries out interpolation and distribution to described cubic polynomial, to produce displacement command to control the motion of cutter.All operations all concentrate on CNC controller and complete, and do not require to carry out any change to CAD/CAM system, CAD/CAM system that can be compatible all at present.Do not need to carry out any change to machine command file, do not need to increase batten and calculate, remain the advantage of ripe traditional G/M code programming completely yet.In addition, all traditional numerical control functions, as feeding locking, (again) loop start and multiplying power, single block execution etc. stand good.Hereinafter will discuss in detail, and how cubic polynomial be generated for small route segment, and interpolation is carried out to cubic polynomial.
More specifically, first when CNC controller receives machine command file, detect wherein whether there is the small route segment of multiple continuous print.As mentioned above, these small route segments are the much small G01 straight-line segment and small G02/G03 arc section (being referred to as small route segment) that adopt straight line and circular arc piecewise fitting to produce to arbitrary curve or complex curve.In machine file, have the program segment corresponding to each route segment, usually can get the starting point of each program segment and terminal to calculate respective path length.Such as, if this path is less than the threshold value of setting, then can judge that this path is small route segment.The cutting speed V that the threshold value of this setting can be expected square obtains divided by the peak acceleration A of this lathe.Or, in order to improve efficiency and the stability of Interpolation Process further, this threshold value can be doubled again, i.e. S=2*V
2/ A.The cutting speed wherein expected can be arranged by the optimum configurations order of CNC controller, and the peak acceleration of this lathe depends on the physical restriction of this lathe.
Fig. 4 shows the process schematic producing new machine command file according to the interpolating method of the embodiment of the present invention.In traditional CAD/CAM system, usually for one section of not long curve, just may there be up to ten thousand G01, G02/03 route segments, corresponding to up to ten thousand orders in machine command file.As shown in Figure 4, the small route segment be made up of the point much segmented in the machine command file 401 produced by CAD/CAM system.Due in actual digital control processing working angles, for any one route segment, cutter all can through the process of acceleration-at the uniform velocity-deceleration.But because these small route segments are too little, also do not reach and at the uniform velocity just slowed down.And be not that a complete motion stops next motion just to start for real cutting, but carry out, Here it is creates overlap. simultaneouslyAs shown in Figure 5, if according to these small route segments, perform cutting one by one, then do not reach default desired speed at all.Therefore, in this embodiment, as shown in Figure 4 for the point of these segmentations, therefrom select some intermediate points, adopt the path that the G06 SPL based on cubic polynomial definition is come between matching two intermediate points, and ignore remaining point except intermediate point simultaneously.In fact be exactly that several or tens adjacent small route segments are fitted to a segment of curve represented by cubic polynomial.Thus the path that the path integration that the point segmented by these can be formed becomes to be made up of several G06 SPL sections.In the new machine command file 402 produced, comprise the program segment corresponding with these G06 SPL sections, so also just ordered less than up to ten thousand that bring due to small route segment.Fig. 6 gives according to the interpolating method of the embodiment of the present invention small route segment result schematic diagram.As shown in Figure 6, in actual digital control processing working angles, perform one by one in units of G06 SPL section, both can reach the speed of expectation, can overlap be reduced again, thus improve the efficiency of processing.
Fig. 7 gives the G06 SPL schematic diagram according to the embodiment of the present invention.As shown in Figure 7, any two point P1 and P2 in X-Y-Z space, define the curve that is labeled as " G06 batten ".Common SPL is all take time as the function curve of variable.But in this embodiment, adopt below take distance as the profile that the cubic polynomial of variable describes the G06 SPL connecting these two point P1 and P2:
P
X(d)=C
X3.d
3+C
X2.d
2+C
X1.d+C
X0
P
Y(d)=C
Y3.d
3+C
Y2.d
2+C
Y1.d+C
Y0
P
Z(d)=C
Z3.d
3+C
Z2.d
2+C
Z1.d+C
Z0
Wherein, d variable represents the standardized distance along the G01 straight line connecting these two points, 0≤d≤1.When starting point P1, d is 0, and during to the terminal P2 of line, d reaches 1.Wherein, C
xi, C
yi, C
zi(0≤i≤3) represent the coefficient of cubic polynomial.Hereafter will introduce the coefficient how solving above-mentioned cubic polynomial when the position of given two points and speed in detail.
Fig. 8 shows the position of cutter in cutter cutting process, speed, acceleration, acceleration and the relation schematic diagram between the time.As shown in Figure 8, in cutter cutting process, cutter is from reference position, and the process in time through acceleration-at the uniform velocity-deceleration arrives target location.Wherein the distance between reference position and target location is carried out standardization, when namely arriving target location from reference position, distance is 1.As can be seen from Figure 8, in the process accelerated, acceleration is increased to gradually and keeps a period of time constant, then reduces gradually.When reaching the speed of expectation, time namely at the uniform velocity in process, acceleration reduces to 0.Corresponding moderating process in contrast.Here distance refers to the distance that cutter runs, to time be variable distance function differentiate after can obtain speed, speed is here exactly the movement velocity of cutter, then differentiate is acceleration, when differentiate is acceleration again.As can be seen from Figure 8, distance Curve is dull, namely there is monotonic relationshi between distance d and time t.Such as, on arbitrary direction of principal axis, the relation between time t and standardization distance d can be expressed as: d=P
g01t ()/pg, pg is the distance of starting point (such as, P1 point) to the G01 straight line along these two points of connection of terminal (such as P2 point), P
g01t () represents when the time is t, between the current location of cutter and starting point, along the distance of the G01 straight line of connection source and terminal (such as, P1 and P2).Thus, in an embodiment of the present invention, the SPL that is variable with time t being converted to mentioned above take distance as the cubic polynomial of variable, describes the profile connecting G06 SPL.
Below for single axle illustrate how the G06 SPL function taking d as variable is converted into t be variable batten and how to determine the coefficient of cubic polynomial.For X, Y, the arbitrary axle in Z axis, position P, the speed V of this axle and acceleration A can be expressed as:
P(d)=C
3.d
3+C
2.d
2+C
1.d+C
0
V(d)=3.C
3.d
2+2.C
2.d+C
1
A(d)=6.C
3.d+2.C
2
Wherein, V (d) obtains P (d) differentiate, and A (d) obtains V (d) differentiate.For as any two points, boundary condition can be obtained in the position continuity of these two points and speed continuity, such as, suppose the position p of these two points
1, p
2and speed v
1, v
2, then can obtain 4 boundary conditions:
P (0)=p
1, V (0)=v
1, namely at reference position point, d=0;
P (1)=p
2, V (1)=v
2, namely at end position point, d=1.
Above-mentioned boundary condition is substituted into above-mentioned polynomial expression can obtain:
C
0=p
1
C
1=v
1
p
2=C
3+C
2+v
1+p
1
v
2=3.C
3+2.C
2+v
1
Thus, the coefficient of above-mentioned cubic polynomial can be obtained:
C
0=p
1
C
1=v
1
C
2=3p
2–2v
1–3p
1–v
2
C
3=v
2–2p
2+2p
1+v
1
Visible, as long as determine two point P1 and P2 (such as, p of the position on the direction of X, Y, Z
1, p
2) and velocity (such as, v
1, v
2) just can determine the coefficient of the cubic polynomial representing the G06 SPL connecting these two points in the corresponding direction.Wherein, position and the speed of each point can obtain from the machine command file produced by CAD/CAM system, wherein the speed of each point can be the speed reached according to the expectation of the optimum configurations command set of CNC controller, and it depends on the physical restriction of this lathe.After the direction of velocity obtaining the position P of each intermediate point and speed V and determine each intermediate point from machine command file, just can obtain each intermediate point velocity magnitude, i.e. v on the direction of X, Y, Z
x, v
y, v
z.
Fig. 9 gives the schematic diagram in the direction of the velocity determining each centre.In fig .9,1. mark as above determined intermediate point, 2. identify Origin And Destination.First determine the direction of the velocity of the intermediate point between Origin And Destination, and then determine the direction of starting point and terminal.The direction of certain intermediate point velocity is that the plane that forms at the line of two points be up and down adjacent by this intermediate point is determined, the medium line of the angle that the direction of the velocity of this intermediate point is formed perpendicular to the line being adjacent two points by this intermediate point.From the off first intermediate point as shown in Figure 9, the direction of the velocity of this point perpendicular to the medium line of the angle be made up of the line of this point and starting point and the line of this point and next intermediate point, its direction of advancing towards cutter.For starting point and terminal, with the line of itself and adjacent intermediate point for datum line, mirror image is done to the velocity direction of the intermediate point be adjacent, the direction of the velocity of Origin And Destination can be obtained.3. identified in Fig. 9 is the intermediate point being in special circumstances, the angle of the line of two intermediate points up and down that this intermediate point is adjacent is very little, less parallel, more difficult by these two line determination planes, now, can by these two lines and upper one and/or next line of being connected with these two lines to determine plane, the then medium line of angle that still forms perpendicular to the line being adjacent two points by this intermediate point of the direction of this intermediate point velocity.
Now get back to Fig. 4, as described above for the point of these segmentations as shown in Figure 4, therefrom select some intermediate points, adopt the path that the G06 SPL based on cubic polynomial definition is come between matching two intermediate points, and ignore remaining point except intermediate point simultaneously.In fact be exactly that several or tens adjacent small route segments are fitted to a curve represented by cubic polynomial.Thus the path that the path integration that the point segmented by these can be formed becomes to be made up of several G06 SPL sections.How main discussion below selects these intermediate points.
In one embodiment, main basis standard below determines these intermediate points:
1) minimum length of each G06 SPL section is decided according to the cutting speed of the physical restriction of machine, set peak acceleration and expectation, the minor increment namely between any two points.This minimum length at least should be greater than the threshold value of setting, the threshold value of this setting be the cutting speed V expected square divided by the peak acceleration A of this lathe.Or, in order to improve efficiency and the stability of Interpolation Process further, this threshold value can be doubled again, i.e. S=2*V
2/ A.
2) performance of CNC compiler, the program hop count of compiling per second can represent (being designated as C), or represent with the minimum execution time of each program segment, concerning each industrial computer, C is fixing.P is made to be the path that each program segment cutter performs, then speed V=C*P.Therefore in order to reach the cutting speed of set expectation, then need the path between guarantee two intermediate points to reach certain length as far as possible, such as, be greater than V/C.
3) curvature according to curved determines whether the G06 SPL section that beginning one is new.Be constant situation for curvature, the route segment of 45 degree can be retained.Work as curvature changes sign, or change is too fast, starts a new G06 SPL section.
4) precision expected (such as, 1 micron), such as, for the point segmented in Fig. 4, except according to 1) and 2) each point except the intermediate point of Standard Selection, judge this point and according to the distance in the SPL of intermediate point institute matching between relevant position, if this distance is within expectation quality, then give up this point, otherwise, also elect this point as intermediate point, with this curve of method mentioned above again matching, the precision of each expectation of putting of reappraising except intermediate point, until all points all meet the precision of expectation.
Figure 10 gives the schematic flow sheet of the small route segment of cubic polynomial method matching according to the embodiment of the present invention.The method comprises: for the multiple small route segment of continuous print in machine command file, selects several intermediate points (step S1) between the start position of these small track end and final position; According to cubic polynomial mentioned above, SPL section (step S2) between adjacent two intermediate points is described; Convert program segment corresponding with described multiple small route segment in machine command file to the program block corresponding with described SPL section, thus produce new machine command file (step S3); The operation (step S4) of cutter is controlled according to new machine command file.
According to one embodiment of present invention, in step S1, for each small route segment in the multiple small route segment of continuous print in received machine command file, determine starting point and the terminal of this small route segment; Then, using the starting point of the first small route segment as reference position, using the terminal of last small route segment as final position, from the starting point of determined each small route segment and the set of terminal, select several points as intermediate point.In one embodiment, the step of intermediate point is selected to comprise: for the curve that the multiple small route segment of continuous print in received machine command file is corresponding, from the starting point of the first small route segment, calculate the curvature in the starting point of each small route segment and the bending of destination county, if sign of curvature changes, or very fast relative to previous some Curvature varying, then select this point to be an intermediate point; Wherein, the distance between selected intermediate point and a upper intermediate point at least should be greater than the threshold value of setting, the threshold value of this setting be the cutting speed V expected square divided by the peak acceleration A of this lathe.
In yet another embodiment, intermediate point can also be selected according to the compilation performance of CNC.The performance of CNC compiler as mentioned above can represent with the program hop count C of compiling per second, and in order to reach the cutting speed V of set expectation, the path between adjacent intermediate point should be greater than V/C as far as possible.Namely in selecting between when putting, the distance between adjacent two intermediate points should be not less than the ratio of the cutting speed V of expectation and the program hop count C of compiling per second as far as possible.
In one embodiment, in step S2, for any two the adjacent points in selected point, with mentioned above be that the cubic polynomial of variable represents the G06 SPL connecting these two points with distance, and with reference to method mentioned above, determine the coefficient of this cubic polynomial based on the position of these two points and velocity.Like this, by several or tens adjacent small route segments are fitted to a SPL section represented by cubic polynomial, the path that the path integration that the small route segment segmented by these can be formed becomes to be made up of several G06 SPL sections.
In yet another embodiment, in step S2, also comprise the step adjusting the quantity of selected intermediate point according to the precision expected.This step S2 can comprise:
S2a) coefficient of the cubic polynomial of the G06 SPL represented between adjacent two intermediate points is determined;
S2b) for each point between adjacent two intermediate points, judge whether the distance between this point with the relevant position be connected in these two intermediate point G06 SPL is greater than the precision of expectation; If be greater than, then select in the centre position of these two intermediate points o'clock as an intermediate point, and get back to step S2a) continue to perform, until each point between adjacent two intermediate points meets the desired precision.Namely get back to step s2a) continue to perform, again matching connects the G06 SPL of adjacent intermediate point, namely the coefficient of the cubic polynomial of the G06 SPL between adjacent two intermediate points is redefined, and in step S2b) again assess each point between adjacent two intermediate points according to the precision expected.
In step S3, based on these determined intermediate points, convert program segment corresponding with described multiple small route segment in machine command file to the program segment corresponding with described SPL section, thus produce new machine command file.
The operation of cutter is controlled in step S4, CNC controller is according to the new machine command file produced.That is the CNC controller G06 SPL that can represent according to the cubic polynomial taking distance as variable is to produce cutter displacement command in all directions, thus controls the operating path of cutter.
In yet another embodiment, a kind of equipment for processing small route segment in numerically-controlled machine is additionally provided.This equipment comprises for for the multiple small route segment of continuous print in machine command file, selects the device of several intermediate points between the start position of these small track end and final position; Be that the cubic polynomial of variable is to describe the device of the SPL section between adjacent two intermediate points for adopting with distance; And for converting program segment corresponding with described multiple small route segment in machine command file to the program segment corresponding with described SPL section, produce new machine command file and according to this new machine command file to control the device of the operation of cutter.
In yet another embodiment, provide a kind of CNC controller, it comprises the equipment of the small route segment of process as above, adopts the multiple small route segment of continuous print in method handling machine command file mentioned above.
Although the present invention is described by preferred embodiment, but the present invention is not limited to embodiment as described herein, also comprises done various change and change without departing from the present invention.