The Basics Of Computer Numerical Control
Key concept number one: Fundamentals Of CNC
While the specific intention and application for CNC machines vary from onemachine type to another, all forms of CNC have common benefits. Though thethrust of this presentation is to teach you CNC usage, it helps to understandwhy these sophisticated machines have become so popular. Here are but a few ofthe more important benefits offered by CNC equipment.
The first benefit offered by all forms of CNC machine tools is improvedautomation. The operator intervention related to producing workpieces can bereduced or eliminated. Many CNC machines can run unattended during their entiremachining cycle, freeing the operator to do other tasks. This gives the CNCuser several side benefits including reduced operator fatigue, fewer mistakescaused by human error, and consistent and predictable machining time for eachworkpiece. Since the machine will be running under program control, the skilllevel required of the CNC operator (related to basic machining practice) isalso reduced as compared to a machinist producing workpieces with conventionalmachine tools.
The second major benefit of CNC technology is consistent and accurateworkpieces. Today's CNC machines boast almost unbelievable accuracy andrepeatability specifications. This means that once a program is verified, two,ten, or one thousand identical workpieces can be easily produced with precisionand consistency.
A third benefit offered by most forms of CNC machine tools is flexibility.Since these machines are run from programs, running a different workpiece isalmost as easy as loading a different program. Once a program has been verifiedand executed for one production run, it can be easily recalled the next timethe workpiece is to be run. This leads to yet another benefit, fastchange-overs. Since these machines are very easy to setup and run, and sinceprograms can be easily loaded, they allow very short setup time. This isimperative with today's Just-In-Time product requirements.
Motion control - the heart of CNC
The most basic function of any CNC machine is automatic, precise, andconsistent motion control. Rather than applying completely mechanical devicesto cause motion as is required on most conventional machine tools, CNC machinesallow motion control in a revolutionary manner. All forms of CNC equipment havetwo or more directions of motion, called axes. These axes can be precisely andautomatically positioned along their lengths of travel. The two most commonaxis types are linear (driven along a straight path) and rotary (driven along acircular path).
Instead of causing motion by turning cranks and handwheels as is required onconventional machine tools, CNC machines allow motions to be commanded throughprogrammed commands. Generally speaking, the motion type (rapid, linear, andcircular), the axes to move, the amount of motion and the motion rate(feedrate) are programmable with almost all CNC machine tools.
Accurate positioning is accomplished by the operator counting the number ofrevolutions made on the handwheel plus the graduations on the dial. The drivemotor is rotated a corresponding amount, which in turn drives the ball screw,causing linear motion of the axis. A feedback device confirms that the properamount of ball screw revolutions have occurred.
A CNC command executed within the control (commonly through a program) tellsthe drive motor to rotate a precise number of times. The rotation of the drivemotor in turn rotates the ball screw. And the ball screw causes drives thelinear axis. A feedback device at the opposite end of the ball screw allows thecontrol to confirm that the commanded number of rotations has taken place.
Though a rather crude analogy, the same basic linear motion can be found ona common table vise. As you rotate the vise crank, you rotate a lead screwthat, in turn, drives the movable jaw on the vise. By comparison, a linear axison a CNC machine tool is extremely precise. The number of revolutions of theaxis drive motor precisely controls the amount of linear motion along the axis.
How axis motion is commanded - understanding coordinate systems It would beinfeasible for the CNC user to cause axis motion by trying to tell each axisdrive motor how many times to rotate in order to command a given linear motionamount. (This would be like having to figure out how many turns of the handleon a table vise will cause the movable jaw to move exactly one inch!) Instead,all CNC controls allow axis motion to be commanded in a much simpler and morelogical way by utilizing some form of coordinate system. The two most popularcoordinate systems used with CNC machines are the rectangular coordinate systemand the polar coordinate system. By far, the most popular of these two is therectangular coordinate system, and we'll use it for all discussions made duringthis presentation.
One very common application for the rectangular coordinate system isgraphing. Almost everyone has had to make or interpret a graph. Since the needto utilize graphs is so commonplace, and since it closely resembles what isrequired to cause axis motion on a CNC machine, let's review the basics ofgraphing.
As with any two dimensional graph, this graph has two base lines. Each baseline is used to represent something. What the base line represents is brokeninto increments. Also, each base line has limits. In our productivity example,the horizontal base line is being used to represent time. For this base line,the time increment is in months. Remember this base line has limits - it startsat January and end with December. The vertical base line is representingproductivity. Productivity is broken into ten percent increments and starts atzero percent productivity and ends with one hundred percent productivity.
The person making the graph would look up the company's productivity forJanuary of last year and at the productivity position on the graph for January,a point is plotted. This would then be repeated for February, March, and eachmonth of the year. Once all points are plotted, a line or curve can be drawnthrough each of the points to make it more clear as to how the company did lastyear.
Let's take what we now know about graphs and relate it to CNC axis motion.Instead of plotting theoretical points to represent conceptual ideas, the CNCprogrammer is going to be plotting physical end points for axis motions. Eachlinear axis of the machine tool can be thought of as like a base line of thegraph. Like graph base lines, axes are broken into increments. But instead ofbeing broken into increments of conceptual ideas like time and productivity,each linear axis of a CNC machine's rectangular coordinate system is brokeninto increments of measurement. In the inch mode, the smallest increment isusually 0.0001 inch. In the metric mode, the smallest increment is 0.001millimeter. (By the way, for rotary axes the increment is 0.001 degrees.)
Just like the graph, each axis within the CNC machine's coordinate systemmust start somewhere. With the graph, the horizontal baseline started atJanuary and the vertical base line started at zero percent productivity. Thisplace where the vertical and horizontal base lines come together is called theorigin point of the graph. For CNC purposes, this origin point is commonlycalled the program zero point (also called work zero, part zero, and programorigin).
For this example, the two axes we happen to be showing are labeled as X andY but keep in mine that program zero can be applied to any axis. Though thenames of each axes will change from one CNC machine type to another (othercommon names include Z, A, B, C, U, V, and W), this example should work nicelyto show you how axis motion can be commanded.
The program zero point establishes the point of reference for motioncommands in a CNC program. This allows the programmer to specify movements froma common location. If program zero is chosen wisely, usually coordinates neededfor the program can be taken directly from the print.
With this technique, if the programmer wishes the tool to be sent to aposition one inch to the right of the program zero point, X1.0 is commanded. Ifthe programmer wishes the tool to move to a position one inch above the programzero point, Y1.0 is commanded. The control will automatically determine howmany times to rotate each axis drive motor and ball screw to make the axisreach the commanded destination point. This lets the programmer command axismotion in a very logical manner.
With the examples given so far, all points happened to be up and to theright of the program zero point. This area up and to the right of the programzero point is called a quadrant (in this case, quadrant number one). It is notuncommon on CNC machines that end points needed within the program fall inother quadrants. When this happens, at least one of the coordinates must bespecified as minus.
Understanding absolute versus incremental motion
All discussions to this point assume that the absolute mode of programmingis used. The most common CNC word used to designate the absolute mode is G90.In the absolute mode, the end points for all motions will be specified from theprogram zero point. For beginners, this is usually the best and easiest methodof specifying end points for motion commands. However, there is another way ofspecifying end points for axis motion.
In the incremental mode (commonly specified by G91), end points for motionsare specified from the tool's current position, not from program zero. Withthis method of commanding motion, the programmer must always be asking"How far should I move the tool?" While there are times when theincremental mode can be very helpful, generally speaking, this is the morecumbersome and difficult method of specifying motion and beginners shouldconcentrate on using the absolute mode.
Be careful when making motion commands. Beginners have the tendency to thinkincrementally. If working in the absolute mode (as beginners should), theprogrammer should always be asking "To what position should the tool bemoved?" This position is relative to program zero, NOT from the toolscurrent position.
Aside from making it very easy to determine the current position for anycommand, another benefit of working in the absolute mode has to do withmistakes made during motion commands. In the absolute mode, if a motion mistakeis made in one command of the program, only one movement will be incorrect. Onthe other hand, if a mistake is made during incremental movements, all motionsfrom the point of the mistake will also be incorrect.
Assigning program zero
Keep in mind that the CNC control must be told the location of the programzero point by one means or another. How this is done varies dramatically fromone CNC machine and control to another. One (older) method is to assign programzero in the program. With this method, the programmer tells the control how farit is from the program zero point to the starting position of the machine. Thisis commonly done with a G92 (or G50) command at least at the beginning of theprogram and possibly at the beginning of each tool.
Another, newer and better way to assign program zero is through some form ofoffset. Commonly machining center control manufacturers call offsets used toassign program zero fixture offsets. Turning center manufacturers commonly calloffsets used to assign program zero for each tool geometry offsets. More on howprogram zero can be assigned will be presented during key concept number four.
Other points about axis motion
To this point, our primary concern has been to show you how to determinethe end point of each motion command. As you have seen, doing this requires anunderstanding of the rectangular coordinate system. However, there are otherconcerns about how a motion will take place. Fore example, the type of motion(rapid, straight line, circular, etc.), and motion rate (feedrate), will alsobe of concern to the programmer. We'll discuss these other considerationsduring key concept number three.
Telling the machine what to do - the CNC program
Almost all current CNC controls use a word address format for programming.(The only exceptions to this are certain conversational controls.) By wordaddress format, we mean that the CNC program is made up of sentence-likecommands. Each command is made up of CNC words. Each CNC word has a letteraddress and a numerical value. The letter address (X, Y, Z, etc.) tells thecontrol the kind of word and the numerical value tells the control the value ofthe word. Used like words and sentences in the English language, words in a CNCcommand tell the CNC machine what it is we wish to do at the present time.
One very good analogy to what happens in a CNC program is found in any setof step by step instructions. Say for example, you have some visitors coming infrom out of town to visit your company. You need to write down instructions toget from the local airport to your company. To do so, you must first be able tovisualize the path from the airport to your company. You will then, insequential order, write down one instruction at a time. The person followingyour instructions will perform the first step and then go on to the next untilhe or she reaches your facility.
In similar manner, a manual CNC programmer must be able to visualize themachining operations that are to be performed during the execution of theprogram. Then, in step by step order, the programmer will give a set ofcommands that makes the machine behave accordingly.
Though slightly off the subject at hand, we wish to make a strong pointabout visualization. Just as the person developing travel directions MUST beable to visualize the path taken, so MUST the CNC programmer be able tovisualize the movements the CNC machine will be making BEFORE a program can besuccessfully developed. Without this visualization ability, the programmer willnot be able to develop the movements in the program correctly. This is onereason why machinists make the best CNC users. An experienced machinist shouldbe able to easily visualize any machining operation taking place.
Just as each concise travel instruction will be made up of one sentence, sowill each instruction given within a CNC program be made up of one command.Just as the travel instruction sentence is made up of words (in English), so isthe CNC command made up of CNC words (in CNC language).
The person following your set of travel instructions will execute themexplicitly. If you make a mistake with your set of instructions, the personwill get lost on the way to your company. In similar fashion, the CNC machinewill execute a CNC program explicitly. If there is a mistake in the program,the CNC machine will not behave correctly.
- O0001 (Program number)
- N005 G54 G90 S400 M03 (Select coordinate system, absolute mode, and turnspindle on CW at 400 RPM)
- N010 G00 X1. Y1. (Rapid to XY location of first hole)
- N015 G43 H01 Z.1 M08 (Instate tool length compensation, rapid in Z toclearance position above surface to drill, turn on coolant)
- N020 G01 Z-1.25 F3.5 (Feed into first hole at 3.5 inches per minute)
- N025 G00 Z.1 (Rapid back out of hole) N030 X2. (Rapid to second hole)
- N035 G01 Z-1.25 (Feed into second hole)
- N040 G00 Z.1 M09 (Rapid out of second hole, turn off coolant)
- N045 G91 G28 Z0 (Return to reference position in Z)
- N050 M30 (End of program command)
While the words and commands in this program probably do not make much senseto you (yet), remember that we are stressing the sequential order by which theCNC program will be executed. The control will first read, interpret andexecute the very first command in the program. Only then will it go on to thenext command. Read, interpret, execute. Then on to the next command. Thecontrol will continue to execute the program in sequential order for thebalance of the program. Again, notice the similarity to giving any set of stepby step instructions.
Other notes about program makeup
As stated programs are made up of commands and commands are made up of word.Each word has a letter address and a numerical value. The letter address tellsthe control the word type. CNC control manufacturers do vary with regard to howthey determine word names (letter addresses) and their meanings. The beginningCNC programmer must reference the control manufacturer's programming manual todetermine the word names and meanings. Here is a brief list of some of the wordtypes and their common letter address specifications.
- O - Program number (Used for program identification)
- N - Sequence number (Used for line identification)
- G - Preparatory function
- X - X axis designation
- Y - Y axis designation
- Z - Z axis designation
- R - Radius designation
- F - Feedrate designation
- S - Spindle speed designation
- H - Tool length offset designation
- D - Tool radius offset designation
- T - Tool Designation
- M - Miscellaneous function (See below)
As you can see, many of the letter addresses are chosen in a rather logicalmanner (T for tool, S for spindle, F for feedrate, etc.). A few requirememorizing.
There are two letter addresses (G and M) which allow special functions to bedesignated. The preparatory function (G) specifies is commonly used to setmodes. We already introduced absolute mode, specified by G90 and incrementalmode, specified by G91. These are but two of the preparatory functions used.You must reference your control manufacturer's manual to find the list ofpreparatory functions for your particular machine.
Like preparatory functions, miscellaneous functions (M words) allow avariety of special functions. Miscellaneous functions are typically used asprogrammable switches (like spindle on/off, coolant on/off, and so on). Theyare also used to allow programming of many other programmable functions of theCNC machine tool.
To a beginner, all of this may seem like CNC programming requires a greatdeal of memorization. But rest assured that there are only about 30-40different words used with CNC programming. If you can think of learning CNCmanual programming as like learning a foreign language that has only 40 words,it shouldn't seem too difficult.
Decimal point programming
Certain letter addresses (CNC words) allow the specification of real numbers(numbers that require portions of a whole number). Examples include X axisdesignator (X), Y axis designator (Y), and radius designator (R). Almost allcurrent model CNC controls allow a decimal point to be used within thespecification of each letter address requiring real numbers. For example,X3.0625 can be used to specify a position along the X axis.
On the other hand, some letter addresses are used to specify integernumbers. Examples include the spindle speed designator (S), the tool stationdesignator (T), sequence numbers (N), preparatory functions (G), andmiscellaneous functions (M). For these word types, most controls do NOT allow adecimal point to be used. The beginning programmer must reference the CNCcontrol manufacturer's programming manual to find out which words allow the useof a decimal point.
Other programmable functions
All but the very simplest CNC machines have programmable functions otherthan just axis motion. With today's full blown CNC equipment, almost everythingabout the machine is programmable. CNC machining centers, for example, allowthe spindle speed and direction, coolant, tool changing, and many otherfunctions of the machine to be programmed. In similar fashion, CNC turningcenters allow spindle speed and direction, coolant, turret index, and tailstockto be programmed. And all forms of CNC equipment will have their own set ofprogrammable functions. Additionally, certain accessories like probing systems,tool length measuring systems, pallet changers, and adaptive control systemsmay also be available that require programming considerations.
The list of programmable functions will vary dramatically from one machineto the next, and the user must learn these programmable functions for each CNCmachine to be used. In key concept number two, we will take a closer look atwhat is typically programmable on different forms of CNC machine tools.