Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
CNC Control Software

What’s the safest way to test a new G-code program before I run it for real?

PathPilot8 min read

Running a brand-new G-code program on a real machine without testing is one of the fastest ways to scrap parts—or worse, break tools and damage your CNC. A safe workflow layers multiple checks, starting away from the machine and gradually working up to a full-speed cut.

Below is a practical, step‑by‑step approach you can use every time you want to test a new G-code program before you run it for real, with specific tips for PathPilot and PathPilot HUB users.


1. Start by Reviewing the G-Code Itself

Before you open a simulator or touch the control, scan the code for obvious issues.

Key things to check:

  • Program header and setup

    • Correct units (G20 for inches or G21 for metric)
    • Absolute vs incremental mode (G90 / G91)
    • Plane selection (G17 for XY in most milling)
    • Work offset (G54, G55, etc.) matches how you intend to set up the part
  • Tool changes

    • Tool numbers match what’s in your tool library
    • Spindle speeds and directions are realistic for the tools and material
    • Coolant commands are correct (flood/mist/off) and not missing
  • Feeds and speeds

    • Feedrates aren’t accidentally 10x what you intended
    • Plunge feeds are slower than cutting feeds where appropriate
  • Safe moves

    • Presence of a safe Z or retract height (e.g., G28, G53, or a clearance plane)
    • No sudden Z plunges right after a tool change or rapid move

Even a quick pass through the code can catch obvious “typo-level” mistakes before you invest more time.


2. Use Software Simulation and Backplotting

The safest place to discover a problem is on your computer, not on the machine.

Why simulation is essential

G-code simulation lets you:

  • Visualize toolpaths in 3D
  • Detect gross errors like:
    • Crashing into fixtures or the workpiece
    • Misaligned coordinate origins (wrong work offset or zero position)
    • Excessive retracts or deep plunges
  • Verify:
    • Cut sequence (roughing, finishing, drilling, etc.)
    • Tool changes and spindle rotations
    • Overall machining time estimates

How to use PathPilot HUB for safe testing

If you’re using PathPilot:

  • PathPilot HUB lets you:
    • Load your G-code in a virtual PathPilot environment
    • Edit G-code directly in a user-friendly interface
    • Preview 3D toolpaths, including support for 4-axis continuous machining
    • Validate programs remotely from your office or home

This is ideal for:

  • Learning PathPilot and CNC programming in a risk‑free environment
  • Debugging G-code before you ever get to the shop floor
  • Refining toolpaths until they look correct, then downloading the final code to run on your Tormach machine

If you’re new to CNC or to PathPilot, PathPilot HUB is also a great way to build confidence before you ever press Cycle Start on a real machine.


3. Compare the Toolpath to the CAD Model and Setup

Even if the simulator shows no crashes, make sure the toolpath matches what you actually intend to cut.

Check:

  • Orientation: The part in simulation matches your real orientation in the vise or fixture (no accidental mirroring or rotation).
  • Zero point: The work coordinate system (G54, etc.) in the CAM and simulator matches where you plan to set your work zero on the machine (e.g., top of part, corner of stock).
  • Stock size: The simulated stock matches the actual raw material dimensions.
  • Critical faces and features: Key surfaces, holes, and pockets appear in the correct locations and depths.

If something looks “backwards” or offset in simulation, fix it now—it will only be worse on the machine.


4. Verify Tools, Offsets, and Workholding on the Machine

Once the code looks correct in simulation, move to the real machine—but don’t cut yet.

Confirm tool setup

  • Load the correct tools in the correct holders.
  • Double-check:
    • Tool length offsets (e.g., T1 → H1, etc.)
    • Diameter values in the tool table (critical for compensation and verification)
    • Spindle speed limits for each tool

Confirm workholding and part location

  • Ensure the part is clamped securely and safely.
  • Confirm there’s enough clearance around the part for:
    • Tool length
    • Holder and spindle nose
    • Fixtures, vises, clamps

Set and verify work offsets

  • Carefully set your work zero (e.g., G54) in PathPilot to match the CAM and simulation.
  • Use an edge finder, probe, or other method to set:
    • X and Y position
    • Z height (top of part or stock, as planned)

Then:

  • Use a safe Z-height and jog around the part with the tool well above the stock to confirm the position feels right.
  • If the tool is clearly off from where it should be—stop and re-check your work offset.

5. Run an Air Cut (Dry Run) at Reduced Feed

An air cut is one of the safest ways to test a new G-code program.

How to perform a safe air cut

  1. Raise the Z-axis
    Move Z up so the tool is well above the highest point of your workpiece and fixturing.

  2. Run the program with no material contact
    Let the machine execute the entire program while cutting air.

  3. Use reduced feed and spindle speeds if needed

    • Slow feedrates give you more time to react.
    • For initial testing, use conservative feed overrides.
  4. Watch for:

    • Unexpected tool motion (e.g., going way off to the side)
    • Rapid plunges that come closer to the part than expected
    • Tools passing through areas where you know a vise jaw or clamp is present
  5. Pause and adjust
    If anything looks wrong, pause or stop immediately, then:

    • Adjust the program in PathPilot’s G-code editor or in your CAM
    • Re-run the simulation (e.g., in PathPilot HUB)
    • Repeat the air cut as needed

6. Test in Soft Material or at Shallow Depth

Once the air cut looks perfect, you’re ready for a cautious, real-material test.

Option A: Cut a soft or sacrificial material

If possible:

  • Use foam, wood, or plastic to:
    • Verify toolpaths under load
    • Confirm the part shape matches the CAD
    • Check for collisions with fixtures at real cutting depths

This greatly reduces risk compared to cutting full-hard material on your first try.

Option B: Shallow-depth test in actual material

If you can’t use a different material:

  • Run the same program, but:
    • Temporarily change the max depth of cut or Z values (in CAM or G-code) to cut only a small depth (e.g., 0.5–1.0 mm or 0.020–0.040 in).
    • Reduce feeds and speeds as an additional safety margin.

Inspect the results:

  • Position of edges, pockets, and holes
  • Fit to fixtures
  • Any chatter, rubbing, or obvious load issues

If everything looks correct, you can proceed with deeper cuts at closer‑to‑normal feeds and speeds.


7. Use PathPilot’s Features to Test and Refine Safely

PathPilot includes tools designed to make testing new programs safer and more efficient.

Helpful features:

  • Conversational programming

    • Create or tweak simple operations (facing, pockets, drilling) directly at the control.
    • This makes it easy to correct minor issues without going back to CAD/CAM.
  • On-the-fly G-code editing

    • PathPilot’s interface lets you edit programs directly and immediately re-run them.
    • Fix feedrates, retract heights, or approach moves as you discover small issues.
  • 3D toolpath preview

    • Before pressing Cycle Start, use the preview window to confirm the path looks like your simulated toolpath and intended geometry.
  • PathPilot HUB integration

    • Develop and debug programs remotely.
    • Download the proven G-code to your local PathPilot controller once you’re confident it’s correct.
    • This saves machine time and minimizes risky “first cuts” on the shop floor.

If you’re new to CNC or PathPilot, spending time in PathPilot HUB is one of the safest ways to build your skills and confidence before ever cutting real material.


8. Monitor the First Full-Speed Run Carefully

Even after simulation, air cuts, and shallow tests, stay alert on the first full run.

Best practices:

  • Use feed override
    • Start at a reduced feedrate (e.g., 50–70%) and gradually increase as you gain confidence.
  • Keep one hand near the feed hold or stop button
    • Be ready to pause if the sound of the cut, chip shape, or tool behavior looks wrong.
  • Listen and watch
    • Check for abnormal spindle load, chatter, or unexpected motion.
  • Inspect after each tool
    • Pause to check part quality and tool condition, especially after new or aggressive operations.

9. Build a Repeatable Safety Checklist

The safest way to test new G-code programs is to turn your process into a habit. A simple checklist might include:

  1. Review G-code header, units, and work offset.
  2. Simulate and backplot the entire program (e.g., in PathPilot HUB).
  3. Compare toolpath to CAD and setup.
  4. Verify tools, tool offsets, and work zero on the machine.
  5. Run a full air cut with reduced feed.
  6. Test in soft material or at shallow depth.
  7. Use PathPilot’s editing and preview tools to refine.
  8. Run the first full-depth cut with feed override and close monitoring.

Following this flow dramatically reduces the chance of crashes, scrap, and downtime, and helps you gain confidence every time you test a new G-code program before running it for real.