CNC Machine Tools, Control Systems and ProgrammingIntroductionComputer numerical control (CNC) is the automated control of machine tools by numerical instructions interpreted by a controller. CNC integrates mechanical systems, electric drives, sensors, software, tooling and process knowledge. It enables repeatable production of complex components while reducing manual intervention and improving productivity, dimensional consistency and traceability. A CNC system does not merely replace handwheels with motors. It converts a part design into coordinated motion, applies geometric and dimensional compensation, controls cutting conditions, and verifies that machine movement remains within programmed and physical limits. Successful CNC practice therefore requires knowledge of machine configuration, coordinate systems, servo control, cutting mechanics, programming standards, tooling and safe operation. Learning ObjectivesAfter studying this chapter, the reader should be able to: - Classify common CNC machine configurations and identify their axes.
- Explain machine, work, tool and program coordinate systems.
- Describe drives, feedback devices, interpolation and controller functions.
- Calculate spindle speed, feed rate, material-removal rate and machining time.
- Develop and interpret ISO-style G-code using interpolation, compensation, canned cycles and subprograms.
- Identify programming, setup and verification practices that reduce defects and hazards.
1. CNC Machine Configurations and Axes1.1 Principal machine typesA CNC machining centre combines a spindle, tool-holding system, workholding, powered axes and a controller. Vertical machining centres generally have a vertical spindle and are convenient for prismatic components. Horizontal machining centres improve chip evacuation and often use pallet systems for high productivity. Five-axis machines coordinate three linear axes and two rotary axes, allowing access to several faces and reducing setups. CNC lathes and turning centres rotate the workpiece while the tool moves along and toward the spindle axis. A typical two-axis lathe has X and Z axes; live tooling, a C axis or a Y axis may be added. CNC routers are commonly used for panels, wood, plastics and non-ferrous materials. Grinding machines, wire electrical-discharge machines and additive machines also use CNC principles, although their cutting processes differ. 1.2 Axis conventionsThe ISO convention normally assigns Z to the spindle axis. Positive Z is generally away from the workpiece in a machining-centre convention, although the exact direction depends on the machine-tool standard and manufacturer. X and Y complete the right-handed Cartesian system. Rotary axes are conventionally named A about X, B about Y and C about Z. Axis names alone are insufficient: the machine manual defines positive direction, home position, travel limits and rotary sign conventions. A programmer must distinguish machine coordinates from workpiece coordinates and must never assume that a similar-looking machine has identical conventions. 1.3 Machine structureA CNC machine includes a bed or base, guideways, ball screws or linear motors, spindle, tool changer, workholding, coolant and guarding. Structural stiffness affects vibration and dimensional accuracy. Guideway friction, backlash, thermal expansion and bearing condition influence contour accuracy. A machine with excellent software cannot compensate indefinitely for poor mechanical condition. 2. Coordinate Systems and PositioningThe machine coordinate system is established by the builder and referenced from a machine zero or home position. On power-up, the control may require a reference-return operation so that position feedback is related to a known datum. The work coordinate system places the program origin at a convenient feature of the workpiece, such as the top face and centreline. Common work offsets include G54 through G59, although available codes vary by controller. A work offset stores the relationship between machine zero and the selected program zero. Tool length and cutter-radius compensation provide additional geometric transformations. Absolute programming uses positions measured from the active program origin (G90). Incremental programming uses distances from the current tool position (G91). Absolute coordinates are often easier to audit; incremental coordinates can be useful for repeated patterns but are more vulnerable to cumulative interpretation errors. A point commanded as X50 Y20 is not meaningful without knowing the active plane, units, work offset, absolute/incremental mode and tool compensation state. Modal codes remain active until changed, so safe programs explicitly establish units, plane, coordinate mode, feed mode and work offset near the beginning. 3. CNC Control ArchitectureA CNC controller typically contains a human-machine interface, program memory, numerical interpolator, programmable logic controller (PLC), axis-control loops and machine-input/output interfaces. The interpreter reads blocks of code, the interpolator calculates intermediate points, and servo loops command the drives. The PLC handles non-geometric machine functions such as chuck clamping, coolant, lubrication, door interlocks, tool changing and spindle orientation. The numerical control portion handles position, velocity and sometimes acceleration commands. Modern controls may include probing, tool monitoring, networking, simulation and data collection. 3.1 Open-loop and closed-loop controlIn an open-loop system, the controller commands a motor without measuring the achieved position. Stepper systems are an example; missed steps may remain undetected. In a closed-loop system, an encoder or linear scale measures position and feedback is used to reduce error. Servo performance depends on feedback resolution, sampling, tuning, friction, mechanical stiffness and disturbance rejection. A simplified position error is: e(t) = r(t) − y(t) where e(t) is position error, r(t) is commanded position and y(t) is measured position. The expression assumes both positions use the same coordinate and unit basis. In practice, a controller may also use velocity and acceleration feedback. 3.2 Drives and motorsAxis drives convert controller commands into motor torque and motion. AC servomotors are common because they provide high dynamic response and feedback compatibility. Stepper motors are less costly and useful in low-load applications but may lose synchronism. Spindle drives must provide a wide speed range and sufficient torque for cutting. Ball screws provide accurate rotary-to-linear conversion but may suffer backlash, wear and thermal growth. Linear motors remove screw-related transmission error but require sophisticated control and can generate substantial heat. Absolute encoders retain position information after power loss; incremental encoders require a reference procedure. 3.3 InterpolationThe controller interpolates between programmed points. Linear interpolation follows a straight path; circular interpolation follows an arc defined by a centre, radius or endpoint geometry. Helical interpolation combines circular motion in one plane with linear movement in the perpendicular direction. Higher-axis controls perform coordinated interpolation for simultaneous five-axis machining. 4. Machining Parameters and CalculationsCutting parameters must be selected from toolmaker recommendations, workpiece material, rigidity, coolant, depth of cut and machine capability. The following relations are fundamental, but they do not replace validated cutting-data tables. For a rotating tool of diameter D and cutting speed V, spindle speed N is: N = (1000V)/(πD) where V is cutting speed in m/min, D is tool diameter in mm, and N is spindle speed in rev/min. The factor 1000 converts metres to millimetres. This relation assumes the stated cutting speed is measured at the tool circumference and neglects small effects such as tool runout. For a milling cutter with z teeth and feed per tooth fₓ, table feed F is: F = fₓ z N where F is mm/min, fₓ is mm/tooth, z is the number of effective teeth and N is rev/min. The formula assumes all specified teeth are cutting effectively; interrupted cuts or damaged teeth may require a reduced practical feed. For turning, if feed per revolution is f, the axial feed rate is: F = fN where f is mm/rev and F is mm/min. In constant-surface-speed turning, spindle speed changes with work diameter, so the controller must observe maximum spindle-speed limits. A simple milling material-removal-rate estimate is: Q = aₚ aₑ F where Q is mm³/min, aₚ is axial depth of cut in mm, aₑ is radial width of cut in mm and F is feed in mm/min. This rectangular-engagement approximation is useful for planning, but actual removal can differ during ramping, trochoidal paths and partial engagement. For a programmed cutting distance L and feed F, ideal cutting time is: t = L/F where t is minutes if L is in mm and F is in mm/min. Rapid moves, acceleration, tool changes, approach, retract and dwell must be added for a realistic cycle-time estimate. Worked exampleA four-flute, 10 mm carbide end mill is recommended at 120 m/min and 0.05 mm/tooth. The spindle speed is: N = (1000 × 120)/(π × 10) ≈ 3819 rev/min. A practical programmed value may be 3800 rev/min. The feed rate is: F = 0.05 × 4 × 3800 = 760 mm/min. If axial depth is 3 mm and radial width is 5 mm, the rectangular-engagement estimate is Q = 3 × 5 × 760 = 11,400 mm3/min. This is a planning estimate and should be reduced if machine power, rigidity or chip evacuation is inadequate. 5. ISO-Style ProgrammingISO-style programming uses address letters and numerical values. Exact syntax differs among Fanuc, Siemens, Heidenhain and other controls, so a program must be checked against the target controller manual. A block may contain a sequence number, preparatory function, coordinates, feed, spindle speed, tool command and miscellaneous function. Typical commands include: | Function | Common purpose |
|---|
| G00 | Rapid positioning | | G01 | Linear interpolation at feed | | G02/G03 | Clockwise/counterclockwise circular interpolation | | G17/G18/G19 | XY, ZX and YZ plane selection | | G20/G21 | Inch/metre units | | G40/G41/G42 | Cutter compensation cancel/left/right | | G43/G49 | Tool length compensation/cancel | | G54–G59 | Work coordinate systems | | G80 | Canned-cycle cancel | | G81/G83 | Drilling/peck drilling cycles | | G90/G91 | Absolute/incremental programming | | M03/M04/M05 | Spindle clockwise/counterclockwise/stop | | M06 | Tool change | | M08/M09 | Coolant on/off | | M30 | Program end and reset |
5.1 Program structure and safety lineA robust program establishes conditions before motion. A representative milling structure is: %
O0901 (PLATE PROFILE)
G21 G17 G90 G40 G49 G80
G54
T01 M06
S3800 M03
G00 G43 Z50. H01
G00 X-5. Y-5.
M08
G01 Z-3. F150.
G01 X55. F760.
G01 Y35.
G01 X-5.
G01 Y-5.
G00 Z50.
M09
M05
G91 G28 Z0.
G90
M30
% This example is illustrative, not universally executable. G28 behaviour, tool-length conventions, spindle commands and safety requirements vary by controller. A programmer should verify the approach path, work offset, tool number, offset number and clearance before running the program. 5.2 Linear and circular interpolationG01 commands straight-line motion at the programmed feed. G02 and G03 create arcs in the active plane. Many controls define arc centres with I, J and K offsets from the arc start point; some also accept an R radius. Centre-offset programming is generally less ambiguous for arcs exceeding 180°, whereas radius programming requires careful sign interpretation. For a circle in the XY plane, the geometric relation is: (x − xc)2 + (y − yc)2 = R2 where (x, y) is a point on the arc, (x_c, y_c) is the centre and R is radius. The controller additionally requires a direction and a valid endpoint within its tolerance. 5.3 Tool length and cutter-radius compensationTool length compensation shifts the programmed tool tip according to measured tool length, commonly using G43 H-number. Without it, tools of different lengths would not reach the programmed Z positions correctly. Cutter-radius compensation allows the programmer to describe the part boundary while the controller offsets the centreline by the cutter radius stored in an offset table. G41 and G42 select left and right compensation relative to travel direction; G40 cancels it. Compensation requires a lead-in and lead-out long enough for the controller to establish or cancel the offset. Sudden activation at a corner can cause an alarm or an unwanted gouge. Compensation values must be measured and maintained. Excessive wear offset may make a programmed path impossible, especially in narrow pockets. Tool nose-radius compensation is similarly important in turning, where the insert nose is not a mathematical point. 6. Canned Cycles and SubprogramsCanned cycles compress repeated operations into a modal command. A drilling cycle may specify a hole position, depth, retract plane and feed. G81 commonly represents simple drilling, while G83 may represent peck drilling for deep holes. Parameters and retract behaviour vary by controller; the machine manual is authoritative. An illustrative drilling sequence is: G90 G98 G81 X20. Y20. Z-12. R2. F120.
X60. Y20.
X60. Y50.
X20. Y50.
G80 Here G98 often returns to the initial plane and G99 often returns to the R plane, but this convention must be confirmed. G80 is essential because leaving a cycle active can cause unintended drilling at later coordinates. Subprograms store repeated geometry. A main program may call subprogram O0910 with M98 P0910, and the subprogram may return with M99. A repeat count may be encoded differently among controls. Subprograms improve consistency and reduce program length, but excessive nesting can make troubleshooting difficult. Parametric programming uses variables and conditional logic on controls that support macro functions. It is valuable for families of parts, but variables, operators and alarm syntax are controller-specific. Programs must be validated in simulation and on a controlled test run. 7. Programming Workflow and VerificationA professional workflow begins with drawing interpretation: establish datums, tolerances, material, stock, features and inspection requirements. The programmer then chooses machine, workholding, tools, cutting data, coordinate origin, operation sequence and toolpaths. CAM software may generate code, but post-processing remains essential because the output must match the machine controller. Verification should include: - tool and holder collision checking;
- travel-limit and over-travel checking;
- correct work offset and tool offset mapping;
- spindle direction, speed and coolant confirmation;
- cutter-compensation and arc validation;
- dry run, single-block and feed override tests;
- first-off inspection against the drawing.
Simulation is not proof of safe operation. A simulation may omit fixture geometry, incorrect offset tables, machine kinematics, clamping errors or a tool holder not represented in the model. The operator remains responsible for safe setup and controlled proving. 8. Applied Case: Illustrative Production of a Drilled Pocket PlateBackgroundA small aluminium plate requires a rectangular pocket and four corner holes. The component is produced on a three-axis vertical machining centre using a 10 mm four-flute end mill and a 6 mm drill. The drawing defines the top face as Z0 and the plate centre as the XY origin. ProblemAn initial program produced inconsistent pocket size because the programmer mixed centreline coordinates with boundary coordinates and activated cutter compensation without a lead-in. Hole locations were correct, but the drilling cycle remained active during a subsequent positioning move. AnalysisThe pocket boundary was specified as X−25 to X25 and Y−15 to Y15. With a 10 mm cutter, a centreline path must be offset 5 mm from the boundary unless cutter compensation is used. The program instead commanded the boundary as the tool-centre path, making the pocket 10 mm oversize in both dimensions. The absence of a lead-in caused compensation ambiguity. The active drilling cycle created a risk that a later XY command would initiate another hole. Approach and solutionThe revised process used a measured tool-length offset, G54 at the top-face datum, and either a mathematically offset centreline or a verified G41/G42 path with a linear lead-in. The drilling operation ended explicitly with G80. The programmer added a clearance plane, checked holder clearance, and proved the program in single block above the workpiece before cutting aluminium. For the milling tool, the earlier cutting data gave approximately 3800 rev/min and 760 mm/min. These values were reduced during the first-off trial to account for fixture rigidity and then adjusted after observing chip formation and spindle load. OutcomeThe pocket reached its dimensional target, all four holes were produced once, and the first-off inspection confirmed the datum strategy. The revised program was saved with documented tool numbers, offsets and setup instructions. Learning pointsProgramming errors frequently arise from state and datum misunderstandings rather than from G-code syntax alone. Explicit modal initialization, clear coordinate conventions, compensation lead-ins, cycle cancellation and simulation are essential controls. A drawing, setup sheet, offset table and program must be treated as one integrated manufacturing system. 9. Limitations, Safety and Contemporary PracticeCNC accuracy is limited by thermal drift, tool wear, machine geometry, vibration, backlash, workholding and measurement uncertainty. High feed rates may reduce cycle time but increase cutting force, deflection and tool failure. A theoretically correct toolpath can be unsuitable if the tool is too long, the holder collides, or coolant cannot evacuate chips. Safety is a professional and regulatory obligation. Guards, interlocks, emergency stops, lockout procedures, chip-control practices and personal protective equipment must follow institutional and national requirements. Operators should never reach into a moving machine, bypass an interlock or rely on a simulation instead of a guarded prove-out. Coolant, swarf and cutting tools also create chemical, sharp-edge and slip hazards. Modern CNC practice increasingly combines CAD/CAM, digital twins, probing, adaptive control, tool-condition monitoring, networked data and machine learning. AI can assist feature recognition, toolpath optimization, anomaly detection and predictive maintenance. However, AI-generated code must be treated as an unverified proposal: post-processing, simulation, engineering review and supervised prove-out remain necessary. Intellectual-property protection, cybersecurity, access control and traceability become important when machines are connected to enterprise networks. Best-Practice Checklist- Confirm the machine manual, controller dialect and axis directions.
- Use a documented work datum and verified work offset.
- Establish units, plane, coordinate mode, compensation and cycle state.
- Select cutting data from reliable tool and material recommendations.
- Check tool length, diameter, holder clearance and wear offsets.
- Use safe approach and retract positions.
- Provide lead-in and lead-out moves for cutter compensation.
- Cancel modal cycles and compensation when operations end.
- Simulate, dry-run and single-block the first execution.
- Inspect the first component and record corrective actions.
Chapter SummaryCNC machine tools combine mechanical structures, motors, drives, feedback devices, controllers and software to produce coordinated motion. Machine, work and tool coordinate systems must be distinguished carefully, while axis conventions and modal states must be confirmed from the machine documentation. Closed-loop servo systems use measured position to reduce error, and interpolation converts programmed geometry into coordinated axis motion. Machining calculations connect cutting speed, tool diameter, spindle speed, feed per tooth, number of teeth, feed rate, depth of cut and cycle time. ISO-style programming uses modal G-codes and M-codes for positioning, interpolation, compensation, work offsets, cycles and machine functions. Tool length compensation, cutter-radius compensation, canned cycles and subprograms improve capability but introduce state-management risks. Safe CNC practice depends on correct datums, verified offsets, simulation, controlled prove-out, inspection and respect for machine hazards. CAM and AI can increase productivity, but neither removes the need for engineering judgment and operator responsibility. Key TermsCNC: Computer numerical control of a machine tool using coded instructions. Axis: A controlled linear or rotary direction of machine motion. Machine coordinate system: The builder-defined coordinate frame referenced to machine zero. Work coordinate system: A coordinate frame established on the workpiece or fixture. Work offset: Stored transformation between machine zero and program zero. Interpolation: Calculation of coordinated intermediate positions between programmed points. Servo drive: Drive system that commands motor motion using feedback-based control. Encoder: Sensor that measures rotary or linear position. Open-loop control: Control without measurement of achieved output position. Closed-loop control: Control that compares commanded and measured position. Cutting speed: Relative speed between cutting edge and work surface, usually in m/min. Feed rate: Linear tool or workpiece advance, usually in mm/min. Feed per tooth: Material advance per effective cutter tooth. Tool length compensation: Offset correcting for actual tool length. Cutter-radius compensation: Offset that shifts a path by the cutter radius. Canned cycle: Modal command representing a repeated machining operation. Subprogram: Reusable program segment called by a main program. Modal code: Code whose state remains active until changed or cancelled. Post-processor: Software that converts CAM toolpaths into controller-specific code. Material-removal rate: Estimated volume removed per unit time. Review QuestionsShort Answer Questions- What is the purpose of a work coordinate offset?
- Distinguish open-loop from closed-loop CNC control.
- What functions do G41, G42 and G40 commonly perform?
- Why must G80 normally be used after a drilling cycle?
- State two factors that can reduce CNC dimensional accuracy.
Long Answer Questions- Explain the architecture of a CNC system, including the controller, PLC, drives, feedback and machine mechanisms.
- Compare vertical machining centres, horizontal machining centres and CNC turning centres.
- Explain absolute and incremental programming and discuss the risks associated with modal commands.
- Describe a complete workflow for developing, verifying and proving a CNC program.
- Explain tool length compensation, cutter-radius compensation and the importance of lead-in and lead-out moves.
Analytical / Application Questions- A four-flute, 12 mm cutter is used at 90 m/min with a feed per tooth of 0.04 mm/tooth. Calculate spindle speed and feed rate, then explain why the programmed values may be adjusted.
- A pocket is dimensioned X−30 to X30 and Y−20 to Y20, and a 10 mm cutter is used without cutter compensation. Determine the required tool-centre boundary and explain the datum assumption.
- A drilling program produces an unintended hole after the intended hole pattern. Diagnose the likely modal-state error and propose program-verification steps to prevent recurrence.
Multiple Choice Questions with AnswersQuestion 1Which axis is conventionally aligned with the spindle axis on a machining centre? A. X B. Y C. Z D. A Correct Answer: C. Z Question 2A 10 mm cutter operates at 120 m/min. What spindle speed is approximately required? A. 382 rev/min B. 1,200 rev/min C. 3,820 rev/min D. 12,000 rev/min Correct Answer: C. 3,820 rev/min Question 3What is the principal purpose of tool length compensation? A. To change spindle direction B. To account for measured tool length C. To cancel a drilling cycle D. To select the work offset Correct Answer: B. To account for measured tool length Question 4Which command commonly cancels a modal drilling cycle? A. G40 B. G49 C. G80 D. G90 Correct Answer: C. G80 Question 5In milling, feed rate is calculated from feed per tooth, number of teeth and what additional quantity? A. Spindle speed B. Tool length C. Work offset D. Coolant pressure Correct Answer: A. Spindle speed Question 6What does a closed-loop axis system use to reduce positioning error? A. A larger workpiece B. Position feedback C. A manual handwheel only D. A coolant pump Correct Answer: B. Position feedback Question 7Which code commonly represents clockwise circular interpolation? A. G00 B. G01 C. G02 D. G03 Correct Answer: C. G02 Question 8Why is a lead-in commonly used when activating cutter-radius compensation? A. To establish the offset smoothly B. To increase tool length C. To cancel the work offset D. To stop the spindle Correct Answer: A. To establish the offset smoothly Question 9What is the main function of a post-processor? A. To sharpen cutting tools B. To convert CAM data into controller-specific code C. To measure coolant concentration D. To replace machine guarding Correct Answer: B. To convert CAM data into controller-specific code Question 10If feed rate is 760 mm/min and programmed cutting distance is 1520 mm, what is the ideal cutting time? A. 0.5 min B. 1 min C. 2 min D. 5 min Correct Answer: C. 2 min
|