Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 66
Lesson 8– CNC
Programming Basics
Prepared by: Ricardo S. Balog, RME, MEng’g
Engineering and Architecture
CNC Programming Basics 8.1 Introduction • The term numerical control is a widely accepted and commonly used term in the machine tool industry. Numerical control (NC) enables an operator to communicate with machine tools through a series of numbers and symbols. • CNC which quickly became Computer Numerical Control has brought tremendous changes to the metalworking industry. New machine tools in CNC have enabled industry to consistently produce parts to accuracies undreamed of only a few years ago. The same part can be reproduced to the same degree of accuracy any number of times if the CNC program has been properly prepared and the computer properly programmed. The operating commands which control the machine tool are executed automatically with amazing speed, accuracy, efficiency, and repeatability. • The ever-increasing use of CNC in industry has created a need for personnel who are knowledgeable about and capable of preparing the programs which guide the machine tools to produce parts to the required shape and accuracy.
Engineering and Architecture
CNC Programming Basics 8.2 Cartesian Coordinate System • Almost everything that can be produced on a conventional machine tool can be produced on a computer numerical control machine tool, with its many advantages. The machine tool movements used in producing a product are of two basic types: point to- point (straight-line movements) and continuous path (contouring movements). • With this system, any specific point can be described in mathematical terms from any other point along three perpendicular axes. This concept fits machine tools perfectly since their construction is generally based on three axes of motion (X, Y, Z) plus an axis of rotation. CNC systems rely heavily on the use of rectangular coordinates because the programmer can locate every point on a job precisely • When points are located on a workpiece, two straight intersecting lines, one vertical and one horizontal, are used. These lines must be at right angles to each other, and the point where they cross is called the origin, or zero point
Engineering and Architecture
CNC Programming Basics 8.2 Cartesian Coordinate System • Shown in the figure are three-dimensional coordinate (primary) planes. The X and Y planes (axes) are horizontal and represent horizontal machine table motions. The Z plane or axis represents the vertical tool motion. The plus (+) and minus (-) signs indicate the direction from the zero point (origin) along the axis of movement. The four quadrants formed when the XY axes cross are numbered in a counterclockwise direction (Fig. 3). All positions located in quadrant 1 would be positive (X+) and positive (Y+). In the second quadrant, all positions would be negative X (X-) and positive (Y+). In the third quadrant, all locations would be negative X (X-) and negative (Y-). In the fourth quadrant, all locations would be positive X (X+) and negative Y (Y-).
Engineering and Architecture
CNC Programming Basics 8.3 World Axis Standards • There are nine standard axes universally used in CNC machining. • Three are the familiar primary linear (straight-line) movements X, Y, and Z. • Three primary rotary axes (A, B, and C) are used to identify arc or circular movements such as a programmable turntable, lathe spindle, or an articulating, wrist action milling head (rotary motion). • Finally, we have three secondary, straight-line motions called the auxiliary linear axes (U, V, and W). Note: EIA-RS267-B Axial motion and position are standardized by the Electronic Industries Association (EIA) here in North America in its Recommended Standard EIA267-B. There is also a parallel standard through the ISO (International Standards Organization). These standards actually include 14 defined axes for motion and Position.
Engineering and Architecture
CNC Programming Basics 8.3 World Axis Standards • The basic axes used to define a three-space (three- dimensional) envelope lie at 90 degrees to each other, and as such are called an orthogonal axis set. Using the same root word as orthographic projection, the set is comprised of axis lines at mutual 900 angles, intersecting at a common reference point. The limit of machine’s axis travel is defined as the Work Envelope. • Combining any two primary axis lines defines a flat plane. There are three planes: X-Y, X-Z, and Y-Z. For example, when viewing a part placed on a vertical milling machine, the table represents the X-Y plane, while a lathe object is viewed in the X-Z plane—usually from overhead.
Engineering and Architecture
CNC Programming Basics 8.3 World Axis Standards • When the machine control is capable of cutting curves in more than one of these three discrete (unique) planes, the programmer must add a code word to define in which plane the motion is to occur, such codes are: G17 (X-Y plane), G18 (X-Z plane) and G19 (Y-Z plane)
Engineering and Architecture
CNC Programming Basics 8.3 World Axis Standards • Some CNC machines feature programmable axes that rotate or articulate. According to the EIA267-B standard, there are three primary rotary axes: A, B, and C • Each is identified by the central primary linear axis around which it pivots: A axis rotates around a line parallel to X B axis rotates around a line parallel to Y C axis rotates around a line parallel to Z • To identify a rotary axis, first find its central axis. For example, a lathe equipped with a positioning spindle that can stop at any given rotation angle facilitates drilling holes spaced around the perimeter of a turned part
Engineering and Architecture
CNC Programming Basics 8.3 World Axis Standards • The lathe drilling attachment illustrates another axis set, secondary linear axes: U, V, and W . • CNC machines occasionally receive secondary, straight- line axes to add auxiliary tool slides or boring quills and other machining functions to their capability. Secondary Linear Rule: • To identify the secondary linear axes, determine the primary linear parallels (X, Y, or Z). If the secondary axis is parallel to: X, it is the U axis Y, it is the V axis Z, it is the W axis
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.1 Positioning Reference Point Systems • Two types of programming modes, the incremental system and the absolute system, are used for CNC. Both systems have applications in CNC programming, and no system is either right or wrong all the time. Most controls on machine tools today are capable of handling either incremental or absolute programming.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.1 Positioning Reference Point Systems
• Incremental program locations
are always given as the distance and direction from the immediately preceding point. • In incremental programming, the G91 command indicates to the computer and MCU (Machine Control Unit) that programming is in the incremental mode.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.1 Positioning Reference Point Systems
• Absolute program locations are always given from a
single fixed zero or origin point. The zero or origin point may be a position on the machine table, such as the corner of the worktable or at any specific point on the workpiece. In absolute dimensioning and programming, each point or location on the workpiece is given as a certain distance from the zero or reference point and the G90 command indicates to the computer and MCU that the programming is in the absolute mode.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.2 CNC Positioning Systems • CNC programming falls into two distinct categories. The difference between the two categories was once very distinct. Now, however, most control units are able to handle both point-to point and continuous path machining. A knowledge of both programming methods is necessary to understand what applications each has in CNC. Engineering and Architecture CNC Programming Basics 8.4 Programming Systems 8.4.2 CNC Positioning Systems • Point-to-point positioning is used when it is necessary to accurately locate the spindle, or the workpiece mounted on the machine table, at one or more specific Iocations to perform such operations as drilling, reaming, boring, tapping, and punching. • Point-to-point positioning is the process of positioning from one coordinate (XY) position or location to another, performing the machining operation, and continuing this pattern until all the operations have been completed at all programmed locations.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.2 CNC Positioning Systems Example: • As shown in the figure, point 1 to point 2 is a straight line, and the machine moves only along the X axis; but points 2 and 3 require that motion along both the X and Y axes takes place. As the distance in the X direction is greater than in the Y direction, Y will reach its position first, leaving X to travel in a straight line for the remaining distance. A similar motion takes place between points 3 and 4.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.2 CNC Positioning Systems • Contouring, or continuous path machining, involves work such as that produced on a lathe or milling machine, where the cutting tool is in contact with the workpiece as it travels from one programmed point to the next. Continuous path positioning is the ability to control motions on two or more machine axes simultaneously to keep a constant cutter-workpiece relationship. The programmed information in the CNC program must accurately position the cutting tool from one point to the next and follow a predefined accurate path at a programmed feed rate in order to produce the form or contour required.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.3 Interpolation • The method by which contouring machine tools move from one programmed point to the next is called interpolation. This ability to merge individual axis points into a predefined tool path is built into most of today’s MCUs. There are five methods of interpolation: linear, circular, helical, parabolic, and cubic. • All contouring controls provide linear interpolation, and most controls are capable of both linear and circular interpolation. Helical, parabolic, and cubic interpolation are used by industries that manufacture parts which have complex shapes, such as aerospace parts and dies for car bodies.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.3.1 Linear Interpolation • Linear Interpolation consists of any programmed points linked together by straight lines, whether the points are close together or far apart (Fig. 11). Curves can be produced with linear interpolation by breaking them into short, straight-line segments. This method has limitations, because a very large number of points would have to be programmed to describe the curve in order to produce a contour shape. • A contour programmed in linear interpolation requires the coordinate positions (XY positions in two-axis work) for the start and finish of each line segment. Therefore, the end point of one line or segment becomes the start point for the next segment, and so on, throughout the entire program.
Engineering and Architecture
CNC Programming Basics 8.4 Programming Systems 8.4.3.2 Circular Interpolation • The development of MCUs capable of circular interpolation has greatly simplified the process of programming arcs and circles. • To program an arc the MCU requires only the coordinate positions (the XY axes) of the circle center, the radius of the circle, the start point and end point of the arc being cut, and the direction in which the arc is to be cut (clockwise or counterclockwise). The information required may vary with different MCUs. Engineering and Architecture CNC Programming Basics 8.5 Programming Format 8.5.1 Word Address Format • Word address is the most common programming format used for CNC programming systems. This format contains a large number of different codes (preparatory and miscellaneous) that transfers program information from the part print to machine servos, relays, micro-switches, etc., to manufacture a part. These codes, which conform to EIA (Electronic Industries Association) standards, are in a logical sequence called a block of information. Each block should contain enough information to perform one machining operation. • Every program for any part to be machined, must be put in a format that the machine control unit can understand. The format used on any CNC machine is built in by the machine tool builder and is based on the type of control unit on the machine
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5.1 Word Address Format • A variable-block format which uses words (letters) is most commonly used. Each instruction word consists of an address character, such as X, Y, Z, G, M, or S. Numerical data follows this address character to identify a specific function such as the distance, feed rate, or speed value. • The address code G90 in a program, tells the control that all measurements are in the absolute mode. The code G91, tells the control that measurements are in the incremental mode. Engineering and Architecture CNC Programming Basics 8.5 Programming Format 8.5. 2 Codes • The most common codes used when programming CNC machines tools are: G-codes (preparatory functions), and M codes (miscellaneous functions). • Other codes such as F, S, D, and T are used for machine • functions such as feed, speed, cutter diameter offset, tool number, etc.
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 2.1 G-Codes • G-codes are sometimes called cycle codes because they refer to some action occurring on the X, Y, and/or Z axis of a machine tool. The G-codes are grouped into categories such as Group 01, containing codes G00, G01, G02, G03. which cause some movement of the machine table or head. Group 03 includes either absolute or incremental programming, while Group 09 deals with canned cycles. • A G00 code rapidly positions the cutting tool while it is above the workpiece from one point to another point on a job. During the rapid traverse movement, either the X or Y axis can be moved individually or both axes can be moved at the same time. Although the rate of rapid travel varies from machine to machine, it ranges between 200 and 800 in./min (5 and 20 m/min).
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 2.1 G-Codes • The G01, G02, and G03 codes move the axes at a controlled feed rate. • G01 is used for straight-line movement (linear interpolation). • G02 (clockwise) and G03m(counterclockwise) are used for arcs and circles (circular interpolation).
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 2.1 G-Codes • Some of the moat commonly used G- code in CNC Programming
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 2.2 M-Codes • M or miscellaneous codes are used to either turn ON or OFF different functions which control certain machine tool operations, • M-codes are not grouped into categories, although several codes may control the same type of operations such as M03, M04, and M05 which control the machine tool spindle. • M03 turns the spindle on clockwise • M04 turns the spindle on counterclockwise • M05 turns the spindle off Engineering and Architecture CNC Programming Basics 8.5 Programming Format 8.5. 2.2 .M-Codes • Some of the most commonly used M- code in CNC Programming
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 3. Block Information • CNC information is generally programmed in blocks of five words. Each word conforms to the EIA standards and they are written on a horizontal line. If five complete words are not included in each block, the machine control unit (MCU) will not recognize the information, therefore the control unit will not be activated. • Example:
Engineering and Architecture
CNC Programming Basics 8.5 Programming Format 8.5. 3. Block Information • Example:
• Using the example shown, the five words are as follows:
N001 represents the sequence number of the operation. G01 represents linear interpolation X12345 will move the table 1.2345 in. in a positive direction along the X axis. Y06789 will move the table 0.6789 in. along the Y axis. M03 Spindle on CW.
Engineering and Architecture
CNC Programming Basics 8.6. Programming for Positioning • Before starting to program a job, it is important to become familiar with the part to be produced. From the engineering drawings, the programmer should be capable of planning the machining sequences required to produce the part. Visual concepts must be put into a written manuscript as the first step in developing a part program. It is the part program that will be sent to the machine control unit by the computer, tape, diskette, or other input media. • The programmer must first establish a reference point for aligning the workpiece and the machine tool for programming purposes. The manuscript must include this along with the types of cutting tools and work-holding devices required, and where they are to be located.
Engineering and Architecture
CNC Programming Basics 8.6. Programming for Positioning 8.6.1. Dimensioning Guidelines • The system of rectangular coordinates is very important to the successful operation of CNC machines. Certain guidelines should be observed when dimensioning parts for CNC machining. The following guidelines will insure that the dimensioning language means exactly the same thing to the design engineer, the technician, the programmer, and the machine operator. 1. Define part surfaces from three perpendicular reference planes. 2. Establish reference planes along part surfaces which are parallel to the machine axes. 3. Dimension from a specific point on the part surface. 4. Dimension the part clearly so that its shape can be understood without making mathematical calculations or guesses. 5. Define the part so that a computer numerical control cutter path can be easily programmed.
Engineering and Architecture
CNC Programming Basics 8.6. Programming for Positioning 8.6.2. Machine Zero Point • The machine zero point can be set by three methods—by the operator, manually by a programmed absolute zero shift, or by work coordinates, to suit the holding fixture or the part to be machined. • MANUAL SETTING - The operator can use the MCU controls to locate the spindle over the desired part zero and then set the X and Y coordinate registers on the console to zero.
Engineering and Architecture
CNC Programming Basics 8.6. Programming for Positioning 8.6.2. Machine Zero Point • ABSOLUTE ZERO SHIFT - The absolute zero shift can change the position of the coordinate system by a command in the CNC program. The programmer first sends the machine spindle to home zero position by a G28 command in the program. Then another command (G92 for absolute zero shift) tells the MCU how far from the home zero location, the coordinate system origin is to be positioned. • The sample commands may be as follows: N1 G28 X0 Y0 Z0 (sends spindle to home zero position) N2 G92 X4.000 Y5.000 Z6.000 (the position the machine will reference as part zero)
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.1. Work Coordinates • All CNC machine tools require some form of work setting, tool setting, and offsets (compensation) to place the cutter and work in the proper relationship. Compensation allows the programmer to make adjustments for unexpected tooling and setup conditions. • In absolute positioning, work coordinates are generally set on one edge or corner of a part and all programming is generally taken from this position. In the figure, the part zero is used for all positioning for hole locations 1, 2, and 3.
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.1. Work Coordinates • In incremental positioning, the work coordinates change because each location is the zero point for the move to the next location, as in the figure. • On some parts, it may be desirable to change from absolute to incremental, or vice versa, at certain points in the job. Inserting the G90 (absolute) or the G91 (incremental) command into the program at the point where the change is to be made can do this.
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.2. R-plane or Gage Height • The word-address letter R refers to a partial retraction point in the Z axis to which the end of the cutter retracts above the work surface to allow safe table movement in the X Y axes. It is often called the rapid-traverse distance, gage height, retract or work plane. The R distance is a specific height or distance above the work surface and is generally 0.100 in. above the highest surface of the workpiece, (see figure) which is also known as gage height. Some manufacturers build a gage height distance of 0.100 in. into the MCU (machine control unit) and whenever the feed motion in the Z axis is called for, 0.100 in. will automatically be added to the depth programmed.
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.3. Cutter Diameter Compensation • Cutter diameter compensation (CDC) changes a milling cutter’s programmed centerline path to compensate for small differences in cutter diameter. On most MCUs, it is effective for most cuts made using either linear or circular interpolation in the X-Y axis, but does not affect the programmed Z-axis moves. Usually compensation is in increments of .0001 in. up to +1.0000 in., and usually most controls have as many CDCs available as there are tool pockets in the tool storage matrix. • The advantage of the CDC feature is that it: 1. allows the use of cutters that have been sharpened to a smaller diameter. 2. permits the use of a larger or smaller tool already in the machine’s storage matrix. 3. allows backing the tool away when roughing cuts are required due to excessive material present. 4. permits compensation for unexpected tool or part deflection, if the deflection is constant throughout the programmed path.
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.3. Cutter Diameter Compensation • The basic reference point of the machine tool is never at the cutting edge of a milling cutter, but at some point on its periphery. If a 1.000 in. diameter end mill is used to machine the edges of a workpiece, the programmer would have to keep a 0.500 in. offset from the work surface in order to cut the edges accurately, (see Fig.). The 0.500 offset represents the distance from the centerline of the cutter or machine spindle to the edge of the part. Whenever a part is being machined, the programmer must calculate an offset path, which is usually half the cutter diameter
Engineering and Architecture
CNC Programming Basics 8.7. Work Settings and Offset 8.7.3. Cutter Diameter Compensation • Modern MCUs, which have part surface programming, automatically calculate centerline offsets once the diameter of the cutter for each operation is programmed. Many MCUs have operator-entry capabilities which can compensate for differences in cutter diameters; therefore an oversize cutter, or one that has been sharpened, can be used as long as the compensation value for oversize or undersize cutters is entered.
CNC Programming Basics 8.9. CNC Milling Programming (Illustrative Example) Program Notes: • Program in the absolute mode starting at the tool change position at the top left corner of the print. • The material is aluminum (300 CS), feed rate 10 in/min. • The cutting tool is a .250 in. diameter high speed steel 2-flute end mill. • Mill the 1 in. square slot. • Drill the two .250 in. diameter holes, .250 in. deep. • Mill the .250 in. wide angular slot, .125 in. deep. • Mill the .250 in. wide circular groove, .125 in. deep. • After the job is completed, return to the tool change position.
• The programming for the Fanuc compatible control is the one most commonly used in industry. Although many controls are similar to the Fanuc control, there are some differences. A few of the main differences are: 1.) The G28 code is used to set the programmed offset of the reference point. 2.) Codes are modal and do not have to be repeated in every sequence line. 3.) All dimensions are entered as decimals.
Engineering and Architecture
CNC Programming Basics 8.10. CNC Turning Programming (Illustrative Example) • Generate the CNC program for the piece-part shown: