Extracting cycle and standard times from G-code can unlock measurable throughput gains, more accurate quoting, and better staffing plans without hiring additional operators. This guide explains a practical, seven-step process to move from optimistic G-code run-time estimates to validated, plan-ready standard times you can push into MES/ERP systems. Readers will learn what inputs are required, how to parse and simulate programs, how to add non-cutting activities, and how to close the loop with shop-floor data for continuous improvement.

TL;DR:

  • Extracting cycle time from G-code requires machine kinematics, tooling, and program context; missing specs can bias estimates by 10–40%.

  • Use kinematic simulation (accounts for acceleration, jerk, and axis blending) for accurate estimates; naÏve distance/feed summation underestimates short-move-heavy programs.

  • Validate with machine logs/OEE and automate extraction into MES via REST, OPC-UA, or CSV for reliable capacity planning and continuous refinement.

Step 1 — What pre-flight data and files do you need to extract cycle times from G-code?

Accurate cycle-time extraction depends on more than the G-code text. The primary inputs are the raw part program and the machine-specific parameters that determine how motion is executed. At minimum, collect the following items before parsing:

  • G-code file and header information: Raw NC program including modal state lines, start/end blocks, and any included subprograms or macro calls. Confirm post-processor flavour (Fanuc, Siemens/Heidenhain, Heidenhain conversational, or ISO RS-274) because coding conventions and M-code sets vary.

  • Machine kinematics and axis limits: Number of axes (3/4/5-axis), axis travel, maximum feedrate (mm/min or IPM), maximum acceleration (mm/s² or in/s²), and jerk/jerk-limited profiles where available. These define achievable feed on short moves and blending behaviour.

  • Spindle and tooling specs: Spindle speed range (S), tool list with offsets, number of tool changes per part, and documented tool-change times (turret index or ATC carousel time). Typical automatic tool changes range 8–45 seconds depending on turret or ATC style.

  • Fixturing and program context: Workholding constraints, pallet or pallet-changer timings, probing statements, and any manual load/unload steps. Probing cycles and operator interventions add non-cutting minutes per cycle.

  • Controller-specific codes: Identify common G/M codes in the program (G0/G1/G2/G3, F, S, M6, M30, M01) and any proprietary M-codes or macro calls that trigger machine functions not obvious in ISO G-code.

Research and community discussions show that attempting to estimate cycle time from program text alone can be misleading. For example, a developer planning an algorithm for a specific controller discussed trade-offs in a thread about calculating cycle time just from G-code: the source illustrates why controller states and machine profiles matter when estimating runtime from code alone (see the Dallas Makerspace discussion on calculating part cycle time from G-code for more context: https://talk.dallasmakerspace.org/t/calculate-part-cycle-time-from-g-code/9149). Missing machine specs often lead to optimistic estimates because short moves are limited by acceleration and look-ahead, not nominal feedrate. Collecting complete inputs reduces variance and enables higher-fidelity simulation later.

Step 2 — How do you parse G-code: reading moves, feedrates, and modal commands?

Parsing G-code robustly requires tokenizing blocks and maintaining a persistent modal state. Each line (block) contains tokens (e.g., G1 X10 Y5 F2000), and the parser must keep track of active modes such as feed mode (G94/G95), distance mode (G90/G91), plane selection, spindle state, and active tool offsets.

Key parsing steps:

  • Tokenization and modal state: Read each block and update the modal state. If a block sets F (feedrate), that feed applies to subsequent cutting moves until changed. G0 is rapid (non-cutting), G1 is linear feed, and G2/G3 are clockwise/counterclockwise arcs.

  • Distinguish rapid vs cutting moves: Treat G0 as a rapid move executed at the machine's maximum rapid rate, often subject to axis-specific limits. Cutting moves (G1, G2, G3) use the current feedrate. Convert feed units (mm/min vs IPM) based on G20/G21 declarations.

  • Arc handling and linearization: Arc moves (G2/G3) should be converted into linear segments if the simulation engine cannot natively simulate true circular interpolation. Choice of arc segmentation tolerance affects time: tighter tolerances yield more segments and slightly different blended velocities. For most estimates, 0.01–0.1 mm chordal tolerance balances accuracy and performance.

  • Canned cycles, macros, and subprograms: Recognize canned cycles (G81/G83) as higher-level operations with implicit retracts and dwell times. Expand subprogram calls (M98) or macros to inline motion sequences before simulation. Vendor-specific macros may trigger custom actions (e.g., hydraulic clamp actuations) that must be mapped to times.

  • Edge cases: Handle feedrate changes mid-block (some controllers allow S or F changes without an explicit move), dwell commands (G4) adding seconds, and multipart programs that call external files.

Industry references such as the Lean Enterprise Institute define cycle time from a measurement perspective; parsing must align to the operational definition of cycle time used in downstream planning and OEE calculations (see Lean Enterprise Institute on cycle time: https://www.lean.org/lexicon-terms/cycle-time). Open-source parsers like pygcode (Python) and community tools provide starting points, but vendors often use proprietary M-codes—so controllers like Fanuc or Siemens may require custom handling. Parsing that respects modal state and expands macros ensures the simulation layer receives a complete, linearized motion sequence.

Step 3 — How to simulate the program to estimate raw cycle time?

There are two common approaches to time estimation: a simple arithmetic summation and kinematic simulation. Each has trade-offs in accuracy and processing cost.

  • Naïve summation: Compute the Euclidean distance of each cutting move and divide by the programmed feedrate (distance / feed). Treat rapids separately using rapid-feed limits. This method is fast and suitable for early quotes but assumes the machine instantly reaches commanded feed—an optimistic assumption. Studies and shop-floor audits show naïve methods can underreport cycle by 10–40% on short-move or high-acceleration paths because acceleration and look-ahead reduce effective feed on short segments.

  • Kinematic simulation: Model axis accelerations, decelerations, jerk, and axis blending/look-ahead. This approach uses a machine profile (max feed, accel per axis, maximum jerk/jerk-limited motion, and look-ahead buffering) to simulate how the controller smooths transitions and limits cornering speeds. Kinematic simulators predict where programmed feed cannot be reached and compute time accordingly. For example, a 50 mm linear move at 6,000 mm/min with a 0.5 g acceleration limit will rarely reach the full feed before deceleration, increasing time compared with naïve estimates.

Kinematic differences are especially pronounced on:

  • Short, high-speed finishing passes

  • 5-axis simultaneous moves with coordinated axis limits

  • Programs with complex cornering and small arc radii

Visual tools such as CAM backplots and NC simulators (Mastercam, Siemens NX, Autodesk Fusion 360 backplot, or NCViewer) illustrate motion and can calculate cycle-time estimates. For practitioners who want to see the difference visually, industry tutorials demonstrate kinematic backplotting and show where naïve sums fail. Watch a step-by-step demo to observe how look-ahead and blending affect estimated cycle time: .

Machine monitoring is a complementary validation source—linking simulated motion to recorded axis and spindle telemetry helps tune kinematic profiles. See how machine monitoring provides run-time motion and spindle data for validation in our discussion of machine monitoring.

Step 4 — How do you include non-cutting time: tool changes, probing, setups and manual interventions?

Non-cutting time often dominates cycle variance and must be modeled explicitly. Typical non-cutting elements include:

  • Tool changes: Automatic tool change (ATC) times vary from ~8 seconds (turret-style) to 30–45 seconds (carousel ATC with long tool change arms). Manual tool changes take longer—measure with stopwatch or extract timestamps. Include both the physical change and the turret index/spindle reposition time.

  • Probing cycles: Probe cycles (touch probes) can add 10–60 seconds per part depending on complexity and repositioning. Programmed probes (ISO probe macros) usually call M-codes or controller-specific macros—parse and map these to empirically measured durations.

  • Part loading/unloading and pallet swaps: Single-load manual handling can be 30–120 seconds; automated pallet changers have documented swap times (e.g., 20–90 seconds). For cells with robots, include robot cycle time and index.

  • Setups and fixturing: First-article setups and fixture adjustments should be amortized over the batch size. Example: a 30-minute setup amortized over a 1,000-piece run adds 1.8 seconds per part.

  • Operator interventions and inspections: Manual quality checks, coolant replenishment, or part ejection can add random delays; measure via time studies or machine I/O event logs.

Empirical time studies and OEE/machine logs are recommended to populate non-cutting durations. The RepRap and Klipper communities document how firmware and macros correspond to timed actions, which can help when translating probe/cycle macros into seconds (see RepRap G-code descriptions for context: https://reprap.org/wiki/G-code). For probing-specific parameter behavior and perceived timings, Klipper documentation offers examples of explicit cycle-time parameters for certain commands: https://www.klipper3d.org/G-Codes.html.

Shop-floor data sources include PLC signals, operator input timestamps, and MES event logs. Capturing events like magazine change, probe start/finish, and pallet index via machine monitoring enables direct measurement and calibration of the model. Real machine telemetry often reveals that non-cutting elements contribute 20–50% of total part cycle time in low-run or high-mix environments; modeling these accurately is essential for reliable staffing and takt calculations.

Step 5 — How do you convert cycle time into a standard time usable for planning and staffing?

Cycle time (observed or simulated) becomes useful only when converted into a standard time that planners use for quotes, capacity planning, and staffing. Standard time accounts for performance ratings, allowances, scrap, and setup amortization.

Steps to calculate standard time:

  1. Assemble base time per unit: Sum simulated raw cutting time and empirically measured non-cutting elements (tool change, load/unload, probe). Example: raw cutting = 2.00 min, tool change amortized per part = 0.50 min, load/unload = 0.75 min → base observed time = 3.25 min.

  2. Apply performance rating: If the machine or operator is rated at a performance factor (e.g., 95% machine efficiency or operator performance rating), divide observed time by the performance rating. Industries often use a machine performance rating (e.g., 1.0 = standard operator pace). Example: 3.25 min / 0.95 = 3.42 min.

  3. Add allowances: Include rest and contingency allowances. Common allowance totals range from 5–15% depending on shop policy (short breaks, machine checks, delays). Example: 3.42 min × 1.10 = 3.76 min standard time per unit.

  4. Adjust for batch size and setup amortization: For small batches, setup time per part increases. For the earlier 30-minute setup amortized over 100 parts, add 0.30 min per part. For planning, always present standard time with the assumed batch size.

  5. Include scrap/rework factor: If the process historically yields 2% scrap, plan capacity accordingly: effective production per scheduled run = scheduled parts × (1 − scrap rate).

Converting to per-shift or per-day capacity: multiply standard time by parts per shift and compare to available machine hours. Use takt-time alignment when scheduling to ensure production matches demand.

A real-world case study demonstrates how programming optimization can reduce standard time and save significant costs; improvements in program structure and feed/lead-in strategies have produced measurable savings for small shops—see the example of smarter CNC programming that reduced cycle times and produced savings in our case study on smarter CNC programming. For capacity challenges, improved standard times are a lever to boost production capacity without additional headcount.

Step 6 — Which methods and tools should you use? Comparison and specs table

Choosing the right tool depends on accuracy needs, budget, and integration goals. Below is a practical comparison of common methods:

Method Typical accuracy Required inputs Automation potential Typical cost
Manual spreadsheet (distance/feed) ±10–40% (optimistic) G-code text, basic tool/time notes Low Low (free)
Open-source parsers + backplot (pygcode, NCViewer) ±5–20% G-code, some machine limits Medium (scripting) Low–medium
CAM/NC simulator (Mastercam, Fusion 360) ±5–15% G-code/CAM post, machine profile Medium Medium
Kinematic simulator with machine profiles ±1–8% Full kinematic params, axis accel/jerk High Medium–high
Commercial extraction + MES integration (enterprise) ±1–5% Machine profiles, tool tables, shop data Very high High

Key decision points:

  • For quoting single parts, spreadsheets or CAM backplots may suffice if combined with conservative allowances.

  • For shop-wide planning and automated scheduling, a kinematic simulator or commercial extraction tool that supports machine profiles and ERP/MES connectors will pay back through reduced variance.

  • Open-source libraries like pygcode allow customization; commercial tools provide connectors (REST, OPC-UA, native MES APIs) and support.

Quick wins vs long-term automation checklist:

  • Quick wins: Start with a pilot on 3–5 repeat parts; do stopwatch studies for tool changes and load/unload; use spreadsheet models with conservative allowances.

  • Medium-term: Adopt open-source parsers with batch scripts to parse and expand subprograms; add CAM backplot verification.

  • Long-term: Implement a kinematic simulator or commercial extraction platform with machine profiles and push validated standard times into MES/ERP.

Controller vendors (Fanuc, Siemens) and CAM systems (Mastercam, Fusion 360, Siemens NX) are common integration points. Evaluate platforms on accuracy, machine profile support, API availability, and whether they can import tool offset tables and post-processor variants.

Step 7 — How do you validate, automate, and integrate extracted times with MES/ERP?

Validation, automation, and integration turn estimations into operationalized planning inputs. A closed-loop approach reduces drift and improves confidence in standard times.

Validation steps:

  • Compare to machine telemetry: Use spindle-on, axis-movement timestamps, and M-code event logging to compute actual cycle durations. Metrics such as mean absolute error (MAE) and percentage accuracy should be tracked. Aim for MAE less than 5–10% for production scheduling.

  • Establish KPIs: Track accuracy (% within tolerance), variance (standard deviation), and failed-predictions rate. Regularly review KPIs by part family and machine type.

  • Pilot and tune: Run a pilot on repeat parts to calibrate machine accelerations and tool-change times; adjust kinematic profiles and non-cutting defaults.

Automation patterns:

  • CI for CAM to parser: Automate the pipeline: CAM post-processor → G-code repository → parser/simulator → database. This allows immediate recalculation whenever a program changes.

  • Event-driven updates: Trigger re-simulation when the post-processor or tool list changes. Use versioning to track program revisions and their time-impact.

Integration best practices:

  • Payload design: Standard time payloads typically include operation ID, standard time per unit (seconds/minutes), tool list, expected non-cutting time, and revision ID. Example JSON: { "operation": "OP10", "std_time_min": 3.76, "tools": ["T1","T4"], "revision":"v1.2" }.

  • Integration methods: Common patterns include REST APIs (most modern MES/ERP), OPC-UA for real-time telemetry, and CSV bulk imports for legacy systems. Use the MES capabilities described in the MES guide to map where standard times belong in operation/routing records.

  • Automated production tracking: Combine automated G-code-derived times with shop-floor tracking to capture real timestamps for validation. See our article on automated production tracking for implementation examples.

A practical integration scenario: A shop automates G-code parsing, simulates using machine profiles, and pushes standard times to the ERP routing. Real-time OEE data then compares planned vs actual, and a nightly job recalibrates machine profiles where variance exceeds thresholds. For real-time scheduling benefits, couple validated times with real-time data for scheduling to improve on-time performance and reduce bottlenecks.

The Bottom Line

Follow these seven steps to transform G-code into validated standard times: collect complete machine and tooling data, parse and simulate with kinematic fidelity, include non-cutting activities, convert to standard times with allowances, and automate validation and MES/ERP integration. Start with a focused pilot on repeat parts, tune using machine telemetry, then scale across the shop.

Frequently Asked Questions

How accurate are cycle times derived from G-code?

Accuracy depends on the method: naive distance/feed summation is optimistic and can under-estimate by 10–40% on short-move or high-accel programs. Kinematic simulation using axis accel/jerk and look-ahead typically yields 1–8% accuracy when calibrated to machine telemetry.

Validation against spindle-run timestamps and OEE logs is essential to quantify accuracy for your fleet and part families.

Can I extract times for multi-axis or simultaneous 5-axis programs?

Yes, but simultaneous 5-axis requires full kinematic modelling of rotary axes, axis coupling, and axis velocity limits. Controllers like Fanuc and Siemens apply different blending rules, so include the machine’s kinematic parameters and test with representative programs.

Expect more tuning and higher fidelity simulation to achieve sub-5% accuracy on 5-axis work.

How do I handle proprietary M-codes and macros?

Document controller-specific M-codes and map macros to timed actions (e.g., clamps, coolant ON/OFF, magazine swaps). Expand or inline subprograms during parsing and measure actual durations in a time study or from PLC logs to convert these events to seconds in the model.

Maintain a controller library per machine model (Fanuc, Siemens) for repeatability.

What’s the best way to validate G-code estimates on the shop floor?

Compare simulated times to machine telemetry such as spindle-on/spindle-off and axis motion timestamps, and compute KPIs like mean absolute error and percent within tolerance. Use automated production tracking or PLC event logs to collect ground-truth timestamps rather than relying on operator recall.

Iterate profile tuning until accuracy targets are met for each machine family.

Can extracted standard times be trusted for capacity planning?

Yes, once validated. Aim for consistent accuracy (e.g., ±5–10%), document assumptions (batch size, allowances), and integrate times with MES/ERP so planners use the latest validated standards. Maintain a feedback loop using OEE and shop-floor tracking to recalibrate when variance grows.