The contours of parts machined by CNC machine tools are generally composed of straight lines and arcs. There are also some non-circular curve contours such as ellipse, hyperbola, parabola, etc. For these quadratic curves, we can use the user macro program to program.
A user macro program is a flexible program that can be flexibly applied through various combinations of arithmetic and logic operations, transitions, and loops. By changing the value of a variable, different processing or operations can be performed. The difference between the user macro program and the normal program is as follows: (1) The user macro program can use variables to program, and assign and process variables, and perform some actions that have regular changes (such as non-circular quadratic curve contours); 2) Normal programs can only specify constants. They cannot be operated between constants. Programs can only be executed sequentially and cannot be jumped. Therefore, the functions are fixed, cannot be changed, and lack flexibility and usability.
1 The basic idea of ​​programming Generally, the non-circular curve can be processed in two ways: one is to use a straight line segment to approximate a non-circular curve; the other is to use a circular arc segment to approximate a non-circular curve.
The straight line segment is used to approximate the non-circular curve. At present, the commonly used node calculation methods include equal spacing method, equal block method and equal error method. The following is a description of the node calculation for the straight line segment approximation of the equidistant method. The basic principle: the equidistance method is to divide a coordinate axis into equal spacing. Taking ΔX along the X-axis direction is equally spaced, and according to the equation y=f(x) of the known curve, yi can be obtained from xi, x i+1=x i+ΔX, y i+1=f(x i+ΔX), So find a series of nodes.
Since the required distance between the required curve y=f(x) and the adjacent two-node connection is less than the allowable programming error δ, the ΔX value cannot be arbitrarily set. Generally, △X=0.1 is taken first for trial calculation. In the actual processing, the error between any two adjacent points should be checked. For the change of the curvature radius of the curve, only the error of the longest distance between the two nodes should be checked. When the curvature radius of the curve changes greatly, the calculation should be checked. The error at a small radius of curvature is usually directly observed by the contour pattern to determine the position of the calibration.
2 User macro program function 2.1 Variables In a regular main program and subprogram, always assign a specific value to an address. In order to use the program more versatile and flexible, variables are set in the macro program. For example: #100, #500, #5, etc.
2.1.1 Representation of Variables A variable consists of the symbol # and the variable number, such as #I(I=1,2,3,...).
2.1.2 References to Variables The process of replacing a value following an address character with a variable is called a reference variable.
Such as: G01X#100Y-#101F#102; When #100=100.0;#101=50.0;#102=80, the above formula is expressed as G01X100.0Y-50.0F80; 2.1.3 variable type variable is divided into local There are three types of variables, public variables and system variables: (1) local variables. Local variables (#1 to #3) are variables that are used locally in the macro program.
(2) Public variables. The public variables (#100~#149; #500~#549) run through the entire program.
(3) System variables. A system variable is a variable that has a fixed purpose and its value determines the state of the system. System variables include tool offset value variables, interface inputs and interface output signal variables, and position signal variables.
2.2 Control instructions in the program In the user macro program, there are two kinds of statements that control the execution of the control program: branch statements and repeated statements.
2.2.1 Branch statement (1) Unconditional transfer. Instruction format: GOTOn unconditionally jumps to a block of sequence n.
(2) Conditional transfer. Command format: When IF[<conditional expression>]GOTOn<conditional expression> is established, it is executed from the block with sequence number n; when <conditional> is not satisfied, the next block is executed.
2.2.2 Repeat statement instruction format: WHILE[<conditional expression>] DOm (m=1, 2, ...) ... ENDm <conditional expression> is established, the program from the DOm program to the ENDm is repeatedly executed; <condition If it is not true, it will be executed from the next block of ENDm.
3 Application Example Analysis 3.1 The example is described as a finishing procedure for writing a parabola of a curved surface of a lampshade mold () using a macro program.
3.2 Problem Analysis Macro program instructions are generally used for finishing. The machining allowance cannot be too large, and the roughing is usually performed before the finishing, and the rough machining can be performed by arc fitting (the machining program is omitted).
When finishing, use a straight line to fit. The cross section of the surface is a parabola, and the equation is Z=X 2/40-50. Here, the Z coordinate is used as an independent variable, and the X coordinate is used as a dependent variable. Then the equation becomes x = 40 × (z + 50) 姨, note that it is the amount of radius, so the x coordinate value is 2 × 40 × (z + 50). The operation is performed using the following variables: #100Z coordinate value variable; #101X function value variable; #102X coordinate value variable.
3.3 Finishing macro program Finishing macro program is as follows: O0508; G98G40G21; T0101; (inner hole turning tool) M03S600F100; G00X85.0Z2.0; #100=0.0; N100#110=#100+50.0; #101=SQTR[ #110*40.0];#102=#101*2; (diameter) G01X#102Z#100; #100=#100-0.10; (Z is decremented by 0.1mm each time) IF[#100GE-48.0]GOTO100; G00Z2.0; G00X100.0Z100.0; M05; M30; 4 Conclusion Using the user macro program to perform quadratic curve fitting processing in NC, the key lies in: first, the establishment of the quadratic curve equation, the curvature of the curve in a certain interval Size, and then decide to establish an equation by selecting an expression or a trigonometric function; second, the determination of the law of the evolution of the equation variable over the processing interval. With these two points, the difficulty in using the macro program to program the quadratic curve should be easier to solve.
(Finish)
Steel Wire
Shandong Rizhaoxin Metal Products Co., Ltd. , https://www.rizhaoxinsteel.com