GreatLight CNC Machining Factory logo
CNC Machining
Rapid Prototyping
Materials
Industries
News
About GL

Get Instant Quote

CNC programming guide

How to Program CNC Machines PDF: A Working Guide

This page shows how to turn a PDF programming guide into a program that runs on a real machine. It is written for engineers and machinists who already read drawings and now need to write, check, and prove out G-code. You will see the order of operations, the numbers that matter, and the mistakes that scrap parts.

G-code structureWork offsetsFeeds and speedsDry-run checks
how to program cnc machines pdf
Quick answer

Key takeaways

A PDF is a reference, not a workflowUse it to look up G-code words and cycles, then write the program in CAM or at the control.
Set the order firstStock, work offset, tool list, then cutting. Skipping a step shows up as a crash, not a warning.
Numbers decide the cutSurface speed, chip load, and depth of cut matter more than the code syntax.
Prove it without metalGraphics simulation, single block, and a 25 mm air gap catch most errors before the first cut.
Match the guide to your controlA Fanuc PDF will not explain a Siemens cycle. Check the control model before you copy code.
Foundations

What a CNC programming PDF should cover

Most guides that explain how to program CNC machines PDF style start with the same block of theory: the machine reads a text file of commands, one block per line, and each block tells the control where to move, how fast, and with which tool. That part is easy to read and easy to forget. The useful half of any guide is the part that tells you which numbers belong in those blocks.

A good reference covers five areas in order. Coordinate systems and work offsets. G-code groups and modal behavior. Tool length and diameter compensation. Cutting parameters for common materials. Canned cycles for drilling, tapping, and boring. If a PDF skips work offsets or treats them as an afterthought, put it down. Almost every first-part crash traces back to a wrong offset or a wrong tool length.

You also want the guide to name the control it was written for. Fanuc, Haas, Siemens, and Heidenhain share the core G-codes but differ on cycles, subprograms, and how they handle cutter compensation. Copying a cycle from a Fanuc PDF into a Siemens control will either alarm out or, worse, run a different motion than you intended.

Keep the PDF open next to your CAM software while you work. It is a lookup table for syntax and a sanity check for parameters. It is not a substitute for the setup sheet, the drawing, or the inspection plan.

  • 1
    Coordinate systemsG54 to G59 offsets, machine zero, and how part zero is set.
  • 2
    Modal groupsWhich codes stay active until changed, and which cancel each other.
  • 3
    CompensationG41/G42 for cutter radius, G43 for tool length.
  • 4
    CyclesG81 to G89 for drilling, tapping, boring, and pecking.
Program anatomy

The block structure of a working program

Every program follows the same skeleton, whatever the part. A safety block cancels compensation and fixed cycles, sets absolute positioning, and selects the plane. Then a tool change, a spindle start, and a rapid to the first position. Then the cutting moves. Then a retract, a coolant off, and an end block that returns the machine home.

The safety block is the one people skip. It should cancel cutter compensation (G40), cancel tool length compensation (G49), cancel any active cycle (G80), set absolute mode (G90), and select the XY plane (G17). Five words that prevent a class of crashes. Put them at the top of every program and at the start of every tool section.

Sequence numbers are optional on modern controls but useful on older ones and in long programs where you need to restart mid-file. Line numbers also make it easier to point at a specific block when you are debugging with a machinist standing at the control.

Comments cost nothing. A short note before each tool section, naming the tool, the operation, and the feature, turns a 900-line file into something a second person can read at 2 a.m. If your post processor strips comments, turn that off.

  • 1
    HeaderProgram number, safety block, work offset, tool call.
  • 2
    BodyPositioning moves, cutting moves, compensation on and off.
  • 3
    FooterSpindle stop, coolant off, retract, program end.
Parameters

Feeds, speeds, and depth of cut

The PDF gives you formulas. The machine gives you the result. Surface speed (Vc) in meters per minute and feed per tooth (fz) in millimeters drive everything else. Spindle speed comes from Vc and tool diameter. Feed rate comes from spindle speed, tooth count, and chip load. Learn those two formulas and you can set up any material in the list.

For aluminum on a 3-axis mill, a starting range of 300 to 500 m/min surface speed with a 0.05 to 0.15 mm chip load per tooth works for carbide tooling with coolant. For 304 stainless, drop to 120 to 180 m/min and keep the chip load at 0.03 to 0.08 mm so the tool cuts instead of rubbing. Titanium Ti-6Al-4V runs slower still, 40 to 60 m/min, with heavier coolant and no dwell in the cut.

Depth of cut depends on rigidity more than on the material. A light finishing pass at 0.2 to 0.5 mm radial engagement holds Ra 0.8–1.6 μm on most aluminum parts. Roughing with a 12 mm end mill on a 5-axis center can take 3 to 6 mm axial depth if the setup is solid and the tool has the flute length. If the machine chatters, reduce radial engagement before you reduce feed.

These are starting points, not settings. Every spindle, holder, and fixture changes the answer. Write your proven values on the setup sheet and keep them. The next job with the same material and tool should not start from scratch.

  • 1
    Check the holderA long holder loses rigidity before the tool does.
  • 2
    Watch the chipThin, blue chips mean heat in the cut. Fine dust means rubbing.
  • 3
    Log the resultRecord what worked so the next run starts ahead.
Offsets and setup

Work offsets, tool length, and the first cut

The program assumes the control knows where the part is and how long each tool is. Both come from setup, not from code. Set the work offset by touching the datum face and edge, then store it in G54. Set tool length with a presetter or by touching off on a known surface, and store it in the tool offset page. A 0.1 mm error in tool length is a 0.1 mm error in every Z move that follows.

Diameter compensation deserves its own note. G41 and G42 shift the tool path by the radius stored in the offset table, so you can program the part profile instead of the tool centerline. Turn compensation on with a lead-in move longer than the tool radius, and turn it off with a lead-out move of the same length. Turning it on in a tight corner is a common cause of gouges.

Before the first cut, dry-run the program with the tool 25 mm above the stock. Watch the position display, not the tool. If a rapid move goes somewhere you did not expect, stop and read the block. Then run the first part with the feed override at 25% and the rapid override at 25%, and listen.

For a first article, measure the features the drawing calls out before you run the second part. If the offset is off by 0.05 mm, correct it now. Running ten parts to find out that the first ten are out of tolerance is expensive.

  • 1
    Touch off, do not guessUse a probe or an edge finder with a known diameter.
  • 2
    One offset per setupKeep G54 for the main datum. Use G55 and G56 for second operations.
  • 3
    Check the first Z moveIt is the move most likely to crash.
Real limits

When a PDF guide is not enough

A PDF teaches syntax and standard practice. It cannot see your part. Thin walls, deep pockets, and unsupported features need judgment that comes from cutting similar geometry before. If the wall is under 1 mm thick and 20 mm tall, no formula in the guide tells you how to hold it without chatter. You slow down, support it, or change the process.

Five-axis work is another limit. Hand-writing simultaneous 5-axis code is possible and rarely wise. Tool axis control, singularity handling, and post-processor accuracy are CAM problems. Use the PDF for the G-code that comes out of the post, not for the path itself.

Hard materials change the rules too. Inconel and hardened tool steel wear tools fast, and the guide's default parameters will burn an edge in minutes. Start conservatively, watch the load meter, and change the insert before the finish suffers.

The honest version: the PDF gets you to a program. The machine, the fixture, and the first article get you to a good part.

  • 1
    Thin featuresSupport them or expect deflection and chatter.
  • 2
    Simultaneous 5-axisUse CAM. Keep the post accurate and verified.
  • 3
    Hard alloysReduce speed, increase coolant, change tools early.
Workflow

Step by step: from PDF to first part

Follow the order. Each step assumes the one before it is finished and checked.

  • 1
    Read the drawing and pick the datumChoose the face and edges the part will be measured from. Note tolerances tighter than ±0.05 mm and any Ra callout. Mark the datum on the setup sheet before you open CAM.
  • 2
    Choose the stock and the workholdingLeave 1 to 3 mm on faces that will be machined. For a 100 × 100 × 50 mm block, a vise with parallels works. For thin plates, use a vacuum plate or tabs. Never assume the vise jaw is square to the spindle.
  • 3
    Build the tool listGroup operations by tool. A typical aluminum bracket uses a 12 mm roughing end mill, a 6 mm finishing end mill, a 5 mm drill, and an M6 tap. Fewer tools means fewer chances for an offset error.
  • 4
    Set parameters from the formulasCalculate spindle speed from surface speed and diameter, then feed from speed, teeth, and chip load. Aluminum: 300 to 500 m/min. 304 stainless: 120 to 180 m/min. Record the values on the setup sheet.
  • 5
    Write or generate the programUse CAM for contoured parts. Hand-write only simple profiles and drilling patterns. Put a safety block at the top: G40 G49 G80 G90 G17. Add a comment before every tool section.
  • 6
    Simulate and dry-runRun the graphics simulation at the control. Then dry-run with the tool 25 mm above the stock at 25% rapid override. Check every rapid move. If a position looks wrong, stop and read the block.
  • 7
    Cut the first part at reduced overrideStart at 25% feed and 25% rapid. Raise feed once the cut is stable and the chip looks right. Listen for chatter and watch the load meter. Stop if either changes suddenly.
  • 8
    Measure and correctMeasure the features the drawing controls. Adjust the work offset or tool offset, then rerun. Do not adjust the program geometry for an offset error.
Decision table

Hand-written code vs CAM vs PDF-only study

Pick the method that matches the geometry and the risk.

MethodBest forMain riskTypical use
Hand-written G-codeSimple profiles, drilling, facingTypo in a coordinate or offsetOne-off fixtures, repairs
CAM-generated codeContours, pockets, 3D surfacesBad post or wrong stock modelProduction parts, 5-axis work
PDF study onlyLearning syntax and cyclesNo prove-out, first cut crashesTraining, reference
Conversational controlSimple parts at the machineLimited to control's cyclesShort runs, prototypes
CAM plus dry-runTight tolerance, first articleSetup error survives simulationAerospace, medical, automotive

Program it, prove it, then cut metal

A PDF gives you the syntax. Simulation, a dry run, and a measured first article give you a part that meets the drawing. If the geometry is complex or the tolerance is tight, send the model and we will review the process before cutting.

FAQs

Questions engineers ask

Can I learn CNC programming from a PDF alone?

You can learn the syntax, the modal groups, and the standard cycles. That is real knowledge and it saves time at the control.

What a PDF cannot give you is prove-out. You still need simulation, a dry run, and a first article measured against the drawing. Treat the PDF as the reference and the machine as the teacher.

Which G-codes do I need for a basic milling program?

G00 rapid, G01 linear feed, G02 and G03 arcs, G17 plane selection, G40 to G42 compensation, G43 tool length, G54 work offset, G80 to G83 drilling cycles, M03 spindle on, M08 coolant on, M30 program end.

That set covers most 3-axis milling. Add G73 and G83 for deep holes and G84 for rigid tapping.

How do I set feeds and speeds if the PDF table does not list my material?

Find the closest material in the table and start at 70% of its surface speed. Then adjust from the chip and the sound.

For an unlisted stainless or a hardened alloy, start lower than you think and raise speed only after the cut is stable and the finish holds.

Why does my first part come out undersize even though the program is correct?

Usually a tool length or cutter compensation error, not a geometry error. Check that the tool offset matches the tool actually in the spindle.

Also check thermal growth on a warm spindle and backlash on an older machine. Measure the offset error with a test cut before you change the program.

Do I need a post processor, or can I run CAM output directly?

You need a post processor matched to your control. CAM output is machine-independent until the post converts it.

An unverified post can produce arcs the control rejects or compensation moves that gouge. Prove the post on a simple part before you trust it on a complex one.

What should be in a setup sheet next to the program?

The work offset, tool list with lengths and diameters, spindle speeds and feed rates, depth of cut, and the inspection points.

Add the datum and any notes about workholding. The next person to run the job should not need to ask you anything.

From program to finished part

Send your drawing or 3D model and we will return a quote with DFM notes. Uploads stay confidential, and an NDA is available on request.

12-hour quote100% inspectionNo minimum order

Follow

More from GreatLight

We publish setup notes, tooling trials and inspection data from the factory floor.

FacebookTikTokYouTubeLinkedInInstagramThreadsPinterest

Trusted by engineers and manufacturers worldwide

Tesla Ford Motor Company BYD Auto Denso Magna International Boeing Airbus Medtronic KUKA FANUC