CAD/CAM and CNC

CAD fundamentals, CAM toolpaths/post-processing, and CNC programming/control to turn digital designs into accurate machined parts.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

CAD/CAM and CNC bridge design and manufacturing: you model the part (CAD), generate optimal toolpaths (CAM), and execute them precisely on machine tools (CNC). Strong grasp here reduces setup time, avoids scrap, improves surface finish and dimensional accuracy, and is routinely tested in GATE ME, PSUs, and core interviews.

Key ideas

  • Computer-Aided Design (CAD): Using software to create precise geometric models of parts and assemblies. Core model types:

    • Wireframe model: Edges and vertices only; ambiguous topology; rarely used for manufacturing now.
    • Surface model: Skins without volume; good for Class-A aesthetics; may be non-manifold.
    • Solid model: Has volume, can compute mass properties, boolean ops; used most in CAM.
    • CSG (Constructive Solid Geometry) vs B-rep (Boundary representation): CSG builds shapes by boolean operations on primitives; B-rep stores faces/edges/vertices with topology; modern CAD uses hybrid B-rep + parametric features.
  • Parametric, feature-based modeling: Geometry driven by parameters and constraints. Edit a dimension, model updates. Useful for design changes and downstream CAM associativity.

  • Assembly modeling: Parts constrained by mates (coincident, concentric, parallel, etc.); detects interferences and defines kinematic relationships.

  • CAD data exchange: Neutral formats like STEP (ISO 10303) and IGES transfer geometry; the post-processor in CAM targets a specific CNC controller (Fanuc/Siemens/Heidenhain) and shop conventions.

  • Computer-Aided Manufacturing (CAM): Converts CAD geometry into a manufacturable plan.

    • Process planning (in CAM): Select machine, tools, operations, depths of cut, step-over, feeds and speeds. Draws from Machining Processes, but CAM captures them as parameters.
    • Toolpath generation: Algorithms compute the tool center path (TCP) relative to the part surface, with offset equal to tool radius (or tool shape envelope). Strategies include contouring, pocketing, adaptive/constant-load, spiral, and raster.
    • Lead-in/lead-out and link moves: Smooth entry/exit (arcs/lines) to avoid dwell marks; reduce retracts.
    • Cutter compensation: In control, G41/G42 apply lateral offsets to the programmed path to account for tool radius; typically G41 = cutter left, G42 = cutter right, when moving in the defined path direction (check controller conventions).
    • Post-processing: Converts controller-independent CL data (cutter location) to controller-specific code (e.g., Fanuc G-code), handling arcs (I, J, K vs R), cycles, macros, and machine kinematics.
    • Simulation and verification: Detect collisions, gouges, and check remaining stock; essential before running on CNC.
  • Computer Numerical Control (CNC): A microprocessor-based control that interprets part programs to drive machine axes and spindle.

    • NC vs CNC vs DNC: NC uses fixed hardware logic; CNC is programmable with memory and feedback; DNC networks multiple CNCs to a central computer for program distribution.
    • Control types: Point-to-point (e.g., drilling) vs contouring (continuous path, multi-axis interpolation).
    • Open-loop vs closed-loop: Steppers (open-loop) for low-cost, low-load; servos (closed-loop) with encoders for high accuracy and dynamic response.
    • Axis conventions: Right-hand rule; typically X (left-right), Y (front-back), Z (spindle). Positive rotation is CCW about the axis following right-hand rule. Planes: G17 (XY), G18 (ZX), G19 (YZ).
    • Coordinate systems: Machine coordinates (reference to machine home), work coordinates (G54–G59 offsets), and tool offsets (length H, radius D). Program in absolute (G90) or incremental (G91). Units: G21 (mm), G20 (inch).
    • Interpolation: The controller’s interpolator generates intermediate target points at a control cycle time.
      • Linear (G01): Straight line at feed F.
      • Circular (G02/G03): Clockwise/counterclockwise arc defined by center offsets I, J, K (usually incremental from arc start) or radius R; plane must be set (G17/G18/G19). The fundamental circle equations apply, with chordal error dependent on feed and cycle time.
    • Common G/M codes (typical Fanuc-style; controller-specific): G00 rapid, G01 linear feed, G02/G03 circular, G04 dwell, G40/41/42 cutter comp off/left/right, G43 tool length comp +, G54–G59 work offsets, G80 cancel cycle, G81 drilling, G83 peck drilling, G90 abs, G91 inc; M03/M04 spindle CW/CCW, M05 stop, M08/M09 coolant on/off, M30 end.
    • Canned cycles: Prepackaged drill/tap/boring motions reducing code; parameters include R-plane, Z end, feed F, peck Q (if applicable), dwell P.
    • Look-ahead and jerk control: The controller blends short segments to maintain feed and avoid stops; reduces cycle time and tool marks.
  • Geometric foundations used in CAM/CNC:

    • Homogeneous transformations: Combine rotation and translation in one matrix; associative and invertible for pose changes.
    • Offset curves/surfaces: For profile milling, the TCP follows an offset at a distance equal to tool radius (for a cylindrical tool). Inside concave corners, minimum achievable inside radius equals tool radius; hence internal corners cannot be sharper than the tool.
    • Arc geometry: An arc of radius R subtending angle θ (radians) has length L = Rθ; parametric form relative to center simplifies interpolation.
  • Feeds and speeds (CNC execution parameters):

    • Cutting speed Vc depends on tool/work material and tool coating; spindle speed N is derived from Vc and tool diameter D.
    • Feed rate F is derived from chip load per tooth fz, number of teeth z, and N in milling; for drilling/turning use feed per revolution f.
    • For surface quality with ball-nose tools, scallop height relates to step-over; CAM uses this to meet roughness targets.
  • Why real devices differ from ideal:

    • Backlash and compliance: Leadscrews, belts, and structure deflect; closed-loop control and preloaded ballscrews mitigate but not eliminate.
    • Servo lag and quantization: Finite control cycle time causes small tracking errors and chordal deviation on curves.
    • Thermal drift: Spindle and axis heat change geometry; compensation tables help.
    • Tool runout and wear: Alters effective diameter and chip load; cutter comp and tool life management adjust for this.
    • Fixturing errors: Misalignment between CAD datum and work coordinate; probing and careful zeroing reduce this.

Formulas

  • N = (1000 · Vc) / (π · D)
    • N: spindle speed, rev/min (rpm); Vc: cutting speed, m/min; D: tool diameter, mm. Applies to milling/drilling when using constant surface speed at tool periphery.
  • Vf = fz · z · N
    • Vf: table/feed rate, mm/min; fz: chip load per tooth, mm/tooth; z: number of teeth; N: rpm. Milling feed conversion.
  • Vf = f · N
    • Vf: feed rate, mm/min; f: feed per revolution, mm/rev; N: rpm. Drilling/turning feed conversion.
  • T = L / Vf
    • T: machining time for a feed move, min; L: path length, mm; Vf: feed rate, mm/min. Assumes constant feed with no acceleration limits.
  • Larc = R · θ
    • Larc: arc length, mm; R: arc radius, mm; θ: included angle, radians. For circular paths.
  • x = xc + R · cos θ; y = yc + R · sin θ
    • x, y: arc point coordinates, mm; xc, yc: circle center, mm; R: radius, mm; θ: angle parameter, radians. Used in circular interpolation theory; CW/CCW depends on θ progression and plane.
  • [x'; y'; 1] = [cos φ -sin φ tx; sin φ cos φ ty; 0 0 1] · [x; y; 1]
    • x', y': transformed point in work/machine frame, mm; x, y: original part coordinates, mm; φ: rotation angle about +Z, radians; tx, ty: translations, mm. 2D homogeneous transform; applies to planar fixture rotations/translations.
  • h ≈ s² / (8 · R)
    • h: scallop height, mm; s: step-over between adjacent passes, mm; R: tool radius (for ball-end tool), mm. Approximation for machining a flat surface with a ball-nose cutter.
  • Resolution = Lead / PulsesPerRev
    • Resolution: basic positioning increment, mm/pulse; Lead: ballscrew lead, mm/rev; PulsesPerRev: encoder counts per motor rev (after quadrature and gearing). Applies to axis positioning capability (neglecting interpolation microsteps and control algorithms).

Worked examples

Example 1 — Direct: Milling spindle speed, feed, and move time Given: End mill diameter D = 10 mm; cutting speed Vc = 180 m/min; teeth z = 4; chip load fz = 0.05 mm/tooth; linear cutting move length L = 120 mm.

Steps:

  1. Spindle speed from cutting speed Formula: N = (1000 · Vc) / (π · D) Numbers: N = (1000 · 180 m/min) / (π · 10 mm) = 180000 / 31.4159 = 5729.58 rpm.
  2. Feed rate from chip load Formula: Vf = fz · z · N Numbers: Vf = 0.05 mm/tooth · 4 · 5729.58 rpm = 1145.92 mm/min.
  3. Time for the programmed linear move Formula: T = L / Vf Numbers: T = 120 mm / 1145.92 mm/min = 0.10474 min = 6.28 s.

Answer: Spindle speed ≈ 5729.6 rpm; feed ≈ 1145.9 mm/min; time ≈ 6.28 s.

Example 2 — Combined (CAD transform to CNC coordinates + drilling time) A hole is defined in CAD at part coordinates (x, y) = (60 mm, 30 mm). On the machine, G54 work origin is at machine coordinates (X0, Y0) = (200 mm, 150 mm). The part is rotated CCW by φ = 20° about the G54 origin. Drill diameter D = 10 mm in steel; cutting speed Vc = 25 m/min; feed per revolution f = 0.20 mm/rev. Drill through 15 mm thickness with 2 mm breakthrough. Use a simple drilling cycle without peck (G81), R-plane 2 mm above surface. Clearance plane is 50 mm above surface. Rapid speed Vrapid = 3000 mm/min.

Steps:

  1. Transform CAD hole coordinates to work coordinates with rotation φ about origin and then translate by G54 offset.
    • Formula (2D homogeneous rotation then translation): x' = x · cos φ − y · sin φ; y' = x · sin φ + y · cos φ; Xmachine = X0 + x'; Ymachine = Y0 + y'
    • Numbers: cos 20° = 0.9396926; sin 20° = 0.3420201 x' = 60 · 0.9396926 − 30 · 0.3420201 = 46.121 mm y' = 60 · 0.3420201 + 30 · 0.9396926 = 48.712 mm Xmachine = 200 + 46.121 = 246.121 mm; Ymachine = 150 + 48.712 = 198.712 mm.
  2. Compute spindle speed from Vc and D.
    • Formula: N = (1000 · Vc) / (π · D)
    • Numbers: N = (1000 · 25) / (π · 10) = 25000 / 31.4159 = 795.77 rpm.
  3. Compute drilling feed rate from feed per rev.
    • Formula: Vf = f · N
    • Numbers: Vf = 0.20 mm/rev · 795.77 rev/min = 159.15 mm/min.
  4. Compute feed travel and time during drilling (from R-plane to Z end).
    • Feed distance = R-gap + thickness + breakthrough = 2 + 15 + 2 = 19 mm
    • Formula: Tfeed = L / Vf
    • Numbers: Tfeed = 19 / 159.15 = 0.11939 min = 7.16 s.
  5. Compute rapid approach and retract times (clearance 50 mm to R-plane 2 mm).
    • Each rapid travel distance = 50 − 2 = 48 mm
    • Formula: Trapid = L / Vrapid
    • Numbers: Trapid = 48 / 3000 = 0.0160 min = 0.96 s (approach); same for retract.
  6. Total cycle time for this hole
    • Ttotal = Tfeed + 2 · Trapid = 7.16 s + 2 · 0.96 s = 9.08 s.

Answer: Programmed machine position ≈ (X, Y) = (246.121 mm, 198.712 mm); spindle ≈ 796 rpm; feed ≈ 159.15 mm/min; drilling time ≈ 9.08 s per hole.

Assumptions: Controller uses mm (G21), absolute mode (G90), Fanuc-style I/J arcs if used (not used here), constant feed without acceleration limits, and no dwell at bottom.

Common mistakes

  • Mixing units: using Vc in m/min with D in mm but forgetting the 1000 factor for N.
  • Confusing feed definitions: using fz (mm/tooth) directly as mm/min, or forgetting to multiply by number of teeth and rpm.
  • Wrong sign/direction for cutter compensation (G41/G42) because of unclear path direction; always decide “tool left/right” by standing at the start and looking along the path direction in the active plane.
  • Programming arcs with wrong I/J sign or in the wrong plane (forgot to set G17/G18/G19), causing overcuts.
  • Ignoring tool radius in internal corners: expecting a sharp 90° internal corner with a finite tool; minimum internal radius equals tool radius.
  • Skipping work offset verification: assuming CAD origin = machine origin; not accounting for part rotation/translation on the fixture.
  • Estimating time with L/V but forgetting approach/retract and R-plane motion in cycles.
  • Overlooking controller specifics: using R for large arcs where the control expects the smaller arc; mixing absolute vs incremental I/J settings (controller-dependent).

For GATE ME

  • Conceptual comparisons: NC vs CNC vs DNC; open vs closed loop; point-to-point vs contouring; wireframe/surface/solid; CSG vs B-rep; STEP vs IGES.
  • Coding basics: identify common G/M codes, plane selection, absolute vs incremental, canned cycle parameters (G81/G83), and typical post-processor roles.
  • Geometry/kinematics: 2D rotation/translation of coordinates; arc center calculations; tool radius compensation direction (inside vs outside offset).
  • Feeds and speeds: compute spindle speed from cutting speed; feed rate from chip load or feed per rev; machining time for linear/arc moves; combine with rapid moves and R-plane.
  • Interpolation and errors: linear vs circular interpolation; arc length Rθ; estimate chordal (discretization) error qualitatively; effect of control cycle time on finish.
  • Practical constraints: minimum internal radius equals tool radius; scallop height vs step-over for ball-nose finishing; relation between look-ahead and corner rounding.

Practise by:

  • Converting between CAD coordinates and machine coordinates via rotation + translation.
  • Writing minimal, correct G-code blocks for a line and an arc (set plane, feed, spindle, coolant, comp off, move, end).
  • Quick calculations: N from Vc and D; Vf from fz·z·N; time for line and arc; Rθ for arcs.
  • Deciding G41 vs G42 for given contour direction with a sketch.

Quick check

  1. A 12 mm end mill runs at Vc = 150 m/min with fz = 0.06 mm/tooth and z = 4. What are N and Vf?
  2. For an internal pocket corner specified as R = 5 mm, what is the minimum tool diameter that can produce this without overcut?
  3. A point at (x, y) = (40, 10) mm is rotated by 90° CCW about the origin. What are the new coordinates?

Answers: 1) N = (1000·150)/(π·12) ≈ 3979 rpm; Vf = 0.06·4·3979 ≈ 955 mm/min. 2) Tool diameter ≤ 2·R ⇒ ≤ 10 mm. 3) (−10, 40).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?