Mazak EIA/ISO (G-Code) Programming — MAZATROL SmoothAi
Every Mazak machining center that ships with the EIA/ISO option runs two programming languages side by side: the conversational MAZATROL program the control is famous for, and standard EIA/ISO G-code — the same ISO dialect posted by any CAM system. This page covers the G-code side on the SmoothAi and SmoothG controls: how EIA programs are stored and selected, the G-code and M-code vocabulary, the drilling/boring canned cycles, and Mazak’s user-macro language (#-variables, arithmetic, IF/WHILE). Where Mazak’s dialect diverges from a Fanuc, those points are called out — do not assume a Fanuc habit carries over. See also the Mazak Control Guide for control operation.
How EIA/ISO Mode Works on a Mazak
On a MAZATROL control, a stored program is either a MAZATROL program (a conversational unit sequence) or an EIA/ISO program (line-oriented G-code). The control decides which interpreter to use from the program’s own content — there is no global “G-code mode” switch equivalent to Fanuc’s. You select the program to run from the program directory; a MAZATROL program opens in the conversational editor, an EIA program opens as a text-style G-code listing.
An EIA/ISO program is identified by a program number of the form O followed by an unsigned integer (the format spec permits up to eight digits, O8), or by a program name of up to 32 characters. The first significant line is typically a comment header in parentheses naming the part, followed by the setup block. A real Mazak header from a maker-supplied probing routine:
(O207409921 REN X DIAM)
(COPYRIGHT*2015-2017*RENISHAW*PLC.*ALL*RIGHTS*RESERVED)
M98P207409923 ; call a subprogram by O-number
#1=#5041 ; read present workpiece X into a local variable
...
M99 ; return to caller (subprogram) / rewind (main)
EIA and MAZATROL programs coexist and can call each other. An EIA program calls a MAZATROL program the same way it calls any subprogram; the reverse is also supported. One rule the manual is emphatic about: when a MAZATROL program is called from an EIA/ISO program, the MAZATROL END unit must have CONTI. = 1 so control returns cleanly to the EIA main program — never put an M99 in the MAZATROL program to force the return.
Block and word rules that bite when hand-editing: a “word” with an address but no number (e.g. G28XY) is, by default (parameter F36 bit 3 = 0), treated as G28X0.Y0.; set that bit to 1 and the same block throws alarm 807 ILLEGAL FORMAT. Coordinate values without a decimal point are interpreted in the least input increment (0.0001 mm / 0.00001 in) — so X10 is 0.001 mm, not 10 mm. Always program a decimal point on dimensional data. G20/G21 (inch/metric) affect program data only; tool and offset data are not converted, so set those in the correct unit beforehand.
G-Code Reference
The following is the everyday subset of the SmoothAi EIA/ISO G-code list, grouped by function. The Group column is the modal group (codes in the same non-zero group are mutually exclusive and modal; group 00 codes are one-shot). Codes marked (option) are only present if the machine builder configured them. This is a working subset — the full list runs to well over a hundred codes including five-axis, turning, inclined-plane, and gear-cutting functions.
| G-code | Group | Function |
|---|---|---|
| Interpolation / Motion | ||
G00 | 01 | Positioning (rapid traverse) |
G01 | 01 | Linear interpolation |
G02 / G03 | 01 | Circular interpolation CW / CCW (also helical with a 3rd axis) |
G02.1 / G03.1 | 01 | Spiral interpolation CW / CCW |
G02.2 / G03.2 | 01 | Involute interpolation CW / CCW (option) |
G06.1 | 01 | Cylindrical interpolation |
G07 | 00 | Circle cutting |
G33 / G34 | 01 | Thread cutting (constant / variable lead) |
G60 | 00 | One-way (unidirectional) positioning |
| Plane, Units, Feed & Dwell | ||
G17 / G18 / G19 | 02 | Plane selection X-Y / Z-X / Y-Z |
G20 / G21 | 06 | Inch / metric data input |
G15 / G16 | — | Polar coordinate command OFF / ON |
G12.1 / G13.1 | — | Polar coordinate interpolation ON / OFF (option) |
G90 / G91 | 03 | Absolute / incremental data input |
G94 / G95 | 05 | Asynchronous feed (per minute) / synchronous feed (per rev) |
G93 | 05 | Inverse-time feed |
G04 | 00 | Dwell (G04 X_ or P_ = time under G94; X_ = revolutions under G95) |
G09 | 00 | Exact-stop check (one-shot) |
G61 / G64 | 13 | Exact-stop mode / cutting (continuous-path) mode |
G61.1 / G62 / G63 | 13 | High-accuracy mode / automatic corner override / tapping mode |
| Reference Return & Coordinate Systems | ||
G27 | 00 | Reference-point return check |
G28 | 00 | Return to 1st reference (home) position via intermediate point |
G29 | 00 | Return from reference point |
G30 | 00 | Return to 2nd / 3rd / 4th reference position |
G53 | 00 | Machine (fundamental) coordinate system selection |
G54–G59 | 12 | Workpiece coordinate systems 1–6 |
G54.1 P_ | 12 | Additional workpiece coordinate systems (P1–up to P300 with option) |
G54.2 P_ | 23 | Fixture offset selection (option) |
G54.4 P_ | 27 | Workpiece setup error correction (option) |
G52 | 00 | Local coordinate system setting |
G92 | 00 | Coordinate system setting / spindle speed clamp |
G68 / G69 | 16 | 3-D coordinate conversion ON / OFF (G68.2 inclined-plane, option) |
G50 / G51 | 11 | Scaling / mirror image (see notes) |
G50.1 / G51.1 | 19 | Programmable mirror image OFF / ON |
G54.2, coordinate rotation G68 | — | Programmed coordinate rotation and 3-D conversion share group 16 |
| Tool Compensation & Offset | ||
G40 | 07 | Tool radius (cutter) compensation OFF |
G41 / G42 | 07 | Tool radius compensation left / right (offset by D-number) |
G43 / G44 | 08 | Tool length offset + / − (offset by H-number) |
G43.1 | 08 | Tool length offset in tool-axis direction (option) |
G43.4 / G43.5 | 08 | Tool tip point control Type 1 / Type 2 (5-axis, option) |
G49 | 08 | Tool length / tool tip control cancel |
G45–G48 | 00 | Tool position offset (extension / reduction / double) |
G37 | 00 | Automatic tool length measurement |
| Data Setting & Skip | ||
G10 / G11 | 00 | Programmable data setting ON / OFF (offsets, work coordinates) |
G10.9 | — | Diameter / radius data input selection (turning) |
G22 / G23 | 04 | Pre-move stroke check ON / OFF |
G31 | 00 | Skip function (stop on skip-signal input; used by probing) |
G31.1 / G31.2 / G31.3 | 00 | Multi-step skip 1 / 2 / 3 |
| Macro & Program-Flow G-codes | ||
G65 P_ | 00 | User macro single (non-modal) call |
G66 P_ | 14 | User macro modal call A (call per motion block) |
G66.1 P_ | 14 | User macro modal call B (call every block) |
G67 | 14 | User macro modal call cancel |
| Hole-Pattern Cycles | ||
G34.1 | 00 | Hole machining pattern — holes on a circle |
G35 | 00 | Hole machining pattern — holes on a line |
G36 | 00 | Hole machining pattern — holes on an arc |
G37.1 | 00 | Hole machining pattern — holes on a grid |
Drilling & Boring Canned Cycles
All hole-machining fixed cycles are modal group 09 and are canceled by G80 (or by any group-01 motion code such as G00). Return level is set by G98 (initial point) / G99 (R point). The typical format is G8x Xx Yy Zz Rr Ff [Qq] [Pp] [Ll] where Z is hole bottom, R is the rapid-approach (R) plane, Q is peck depth or shift, and P is a bottom dwell.
| Code | Cycle | Notes |
|---|---|---|
G73 | High-speed deep-hole drilling | Peck by Q, small chip-break retract |
G74 | Reverse (left-hand) tapping | Spindle reverses at bottom |
G75 | Boring 1 | |
G76 | Boring 2 (fine boring, oriented-spindle shift) | Shift amount by Q; not the Fanuc G76 threading cycle |
G77 | Back spot facing | |
G78 / G79 | Boring 3 / Boring 4 | |
G80 | Fixed cycle cancel | |
G81 | Spot drilling | G81 [Xx Yy] Rr Zz |
G82 | Drilling (with bottom dwell) | P = dwell |
G83 | Deep-hole (full-retract peck) drilling | Q = peck depth |
G84 | Tapping | Right-hand; feed-per-rev under G95 |
G84.2 / G84.3 | Synchronous tapping / synchronous reverse tapping | Rigid tapping (option) |
G85 | Reaming (bore in and out at feed) | |
G86 | Boring 5 (spindle stop at bottom, rapid out) | G86 [Xx Yy] Rr Zz [Ptc] |
G87 | Back boring | |
G88 / G89 | Boring 6 / Boring 7 | |
G71.1 / G72.1 | Chamfering-cutter cycles (CW / CCW) |
Watch the boring-cycle numbering. Mazak calls G75/G76/G78/G79/G86/G88/G89 “Boring 1–7,” and G74 is reverse tapping. On a Fanuc, G76 is fine boring, G74 is left-hand (counter) tapping, and G75/G78/G79 are not standard mill cycles. Do not assume a Fanuc canned-cycle number means the same thing here — check the cycle behavior in the manual before running a converted program.
M-Codes
The EIA/ISO manual defines a small set of NC-internal M-codes whose behavior is fixed by the control. Everything else (spindle, coolant, tool change, orientation) is a machine-configured miscellaneous function — the manual is explicit that whether such an M-code executes before, during, or after axis motion “depends on the machine specifications.” For those, consult the machine’s operation manual, not the EIA manual.
| M-code | Function |
|---|---|
| NC-Internal (defined by the EIA/ISO manual) | |
M00 | Programmed (unconditional) stop — disables pre-read; press start to resume |
M01 | Optional stop (only when OPTIONAL STOP is on) |
M02 | Program end (resets control; reads back to program head) |
M30 | Program end and rewind (tape) / return to head |
M98 | Subprogram call — M98 P_ H_ L_ or M98 <name> H_ L_ |
M99 | Subprogram return (in a main program, loops to the head) |
M998 | Continuous execution after parts-count and work-number search |
M999 | Program chaining (jump to another program) |
| Machine-Configured (typical — verify per machine) | |
M03 / M04 / M05 | Spindle CW / CCW / stop |
M06 | Tool change (usually T_ M06; on many Mazak programs the ATC pot is pre-selected, e.g. T[#20]T00M06) |
M08 / M09 | Coolant ON / OFF |
M19 | Spindle orientation |
M00, M01, M02, M30, M998, and M999 all disable buffer pre-read, so a following block is not looked ahead. Real Mazak maker programs also use many machine-specific codes such as M111, M200, M203/M205, M648, and M787 — these are model-specific (probe arm, spindle selection on multi-tasking machines, sensor control) and their meaning must not be guessed; look them up for the specific machine.
User Macros — Variables
Mazak’s EIA/ISO user-macro language uses #-variables that will look familiar to anyone who knows Fanuc Custom Macro B, but the ranges and some system-variable numbers are Mazak-specific — verify them here rather than porting Fanuc numbers blind. A variable holds a value with an effective precision of 8 decimal digits; the null (undefined) variable is #0. A word whose value is an undefined variable (e.g. G#10 where #10 is null) is simply ignored.
| Range | Class / Usage |
|---|---|
| Local & Common Variables | |
#1–#33 | Local variables — macro-call arguments and scratch; a fresh set per call level (up to 8 nesting levels). Level 0 (main program) has its own set that cannot be passed as arguments |
#100–#199 | Common variables — shared across programs; cleared on power-off |
#500–#999 | Common variables — shared across programs; retained through power-off |
#0 | Null / empty variable (test with EQ #0) |
| Macro Interface Signals (PLC I/O) | |
#1000–#1035 | Interface input signals, read-only (1 = closed, 0 = open). #1032 reads inputs #1000–#1031 as one 16/32-bit word |
#1100–#1135 | Interface output signals (read/write). #1132 writes #1100–#1131 as one word |
| Control / System Status | |
#3000 | Force NC alarm: #3000 = n (MESSAGE), n = 1–6999, message up to 31 chars |
#3001 / #3002 | Integrated time: POWER-ON timer / AUTO-CUT timer (read or write) |
#3003 | Single-block-stop / auxiliary-function-wait suppression |
#3004 | Feed-hold / feedrate-override / G09 enable-disable (cleared to 0 on reset) |
#3006 | Programmed stop with message: #3006 = 1 (MESSAGE) |
#3007 | Mirror-image status per axis (bit-coded, read) |
#3009 / #3010 | Message box — prompt operator for a value (needs parameter F331 bit 7) |
#3011 / #3012 | Date (YYMMDD) / time (HHMMSS) |
#3020 | Tool-data index number of the spindle tool |
#3901 / #3902 | Total machined-parts count / required-parts count |
| Modal Information | |
#4000 | Work (program) number of the main program |
#4001–#4027 | Modal G-codes of the pre-read block (e.g. #4006 = G20/G21, #4003 = G90/G91) |
#4201–#4227 | Modal G-codes of the block being executed |
#4101–#4132 | Other modal data of previous block (#4109 F, #4111 H, #4113 M, #4115 program No., #4120 T) |
#4301–#4330 | Other modal data of the executing block (#4313 M, etc.) |
#4501–#4530 | Modal data captured at the moment of a macro interruption |
| Position Information (axis 1–16 = last digit) | |
#5001–#5016 | End-point coordinates of the previous block (workpiece system; tool-tip, no offset) |
#5021–#5036 | Present machine coordinates (read after motion stops) |
#5041–#5056 | Present workpiece coordinates (read after motion stops) |
#5061–#5076 | Skip-signal position (captured at G31; readable any time after) |
#5081–#5096 | Present tool position-offset amount |
#5101–#5116 | Servo position deviation |
| Tool Offset Data | |
#40001–#40000+n | Tool length / length-A offset (n = tool-data index; up to 960 tools) |
#400001–#400000+n | Tool length offset, extended range (up to 4000 tools) |
#41001–#41000+n / #410001+ | Tool radius compensation amount |
#43001–#43000+n / #430001+ | Tool-life flag (1 = ON, 0 = OFF) |
| Workpiece-Setup Data Set | |
#5800 | Number (1–7) of the currently selected workpiece-setup data set (read-only) |
#5801–#5878 | Workpiece-setup-error correction data per data set (see G54.4) |
Because Mazak stores tool data by tool-data index (not a fixed offset-register number as on Fanuc), read #3020 or #3022/#3023 to resolve the index for a given tool before indexing into the #40001+ arrays. This is a genuine Mazak/Fanuc difference: there is no direct equivalent of Fanuc’s #2001–#2400 fixed tool-offset block.
User Macros — Arithmetic & Flow Control
Assignment takes the form #i = <expression>, where the expression may mix constants, variables, functions, and operators. Up to five nested sets of brackets [ ] per expression (functions count toward that limit). Angles are in degrees.
| Operator / Function | Meaning |
|---|---|
| Arithmetic & Logical | |
+ - * / | Add, subtract, multiply, divide |
OR AND XOR | Bitwise logical sum / product / exclusive-OR (each of 32 bits) |
| Functions | |
SIN[ ] COS[ ] TAN[ ] | Sine, cosine, tangent (degrees; TAN computed as SIN/COS) |
ATAN[ ] (or ATN) / ACOS[ ] | Arc-tangent / arc-cosine |
SQRT[ ] (or SQR) | Square root |
ABS[ ] | Absolute value |
ROUND[ ] (or RND) | Round to nearest whole number |
FIX[ ] / FUP[ ] | Truncate decimals / round decimals up |
BIN[ ] / BCD[ ] | Convert BCD→binary / binary→BCD |
| Comparison (in conditional expressions) | |
EQ NE GT LT GE LE | = ≠ > < ≥ ≤ |
Flow control:
| Construct | Behavior |
|---|---|
IF[cond] GOTO n | Branch to sequence number Nn in the same program if the condition holds (else fall through). GOTO n alone = unconditional. Missing target → alarm 843 |
IF[cond] THEN … ELSE … ENDIF | Structured branch; may enclose both macro and NC statements. Nesting up to 10 deep (11th → alarm 1918); unmatched ENDIF → alarm 1919 |
WHILE[cond] DOm … ENDm | Loop while condition holds. m = 1…127; up to 27 nested levels. Unbalanced DO/END → alarm 868 |
Macros are called with G65 P_ L_ <arguments> (single call), G66/G66.1 (modal, canceled by G67), or as plain subprograms with M98. Under G65/G66, argument addresses map to local variables like Fanuc: A→#1 B→#2 C→#3 D→#7 E→#8 F→#9 H→#11 I→#4 J→#5 K→#6 M→#13 Q→#17 R→#18 S→#19 T→#20 U→#21 V→#22 W→#23 X→#24 Y→#25 Z→#26. Key difference from M98: G65 passes arguments and changes the local-variable level with call depth, and does not single-block-stop; M98 passes no arguments and keeps the same local-variable level.
A worked macro — a bolt-circle drilling routine using the argument mapping, trig, and a WHILE loop:
(O8001 BOLT CIRCLE)
G65 P8002 X0. Y0. R40. H8 Z-10. F150. ; center X0 Y0, radius 40, 8 holes
(O8002 SUBMACRO) ; X#24 Y#25 R#18 H#11 Z#26 F#9
#30 = 360. / #11 ; angle step = 360 / hole count
#31 = 0. ; running angle
#32 = 1 ; hole counter
G90 G81 R2. Z#26 F#9 ; arm the spot/drill cycle (R plane 2 mm)
WHILE [#32 LE #11] DO1
#33 = #24 + #18 * COS[#31] ; hole X = Xc + R*cos(angle)
#34 = #25 + #18 * SIN[#31] ; hole Y = Yc + R*sin(angle)
X#33 Y#34 ; drill at this position
#31 = #31 + #30
#32 = #32 + 1
END1
G80 ; cancel canned cycle
M99
Work Offsets & Tool Data in EIA Mode
EIA/ISO programs use the standard work coordinate systems G54–G59, the additional systems G54.1 P1–P300 (option), a local shift with G52, and the machine system directly with G53. Offset values are set on the WORK OFFSET / coordinate display, or written from a program with G10 (programmable data setting). Reference return is G28 via an intermediate point — almost every Mazak EIA program opens with an incremental reference return, e.g. G91 G28 Z0. then G28 X0. Y0., before the first tool change.
Tool geometry and wear live in the control’s TOOL DATA, indexed by tool number, and are applied through G43 H_ (length) and G41/G42 D_ (radius). Because the EIA offset addresses (H, D) point into the same shared tool table the MAZATROL side uses, a tool edited for a MAZATROL program changes what an EIA program sees under the same H/D number — the two languages are not sandboxed from each other on tool data. Note also that G20/G21 in a program do not re-scale already-stored tool or offset values.
Real-World Examples
A compact self-contained program — a Mazak spindle condition-check routine that steps through speeds with dwells (adapted from a maker-supplied program). It shows the reference-return preamble, tool call, and G04 dwell in seconds:
(CONDITION CHECK PROGRAM FOR 12000rpm)
T[#20]T00M06 ; tool change, pot number from variable #20
G91G28Z0. ; incremental reference return, Z
G28X0.Y0. ; reference return, X and Y
M200 ; (machine-specific: select/ready spindle)
M111 ; (machine-specific)
M03S1000 ; spindle CW, 1000 rpm
G04X60. ; dwell 60 s
S5000
G04X60.
S9000
G04X60.
S12000
G04X120. ; dwell 120 s at top speed
M05 ; spindle stop
M30 ; end + rewind
A macro/probing excerpt (adapted from a Renishaw X-diameter routine) showing G31 skip moves, reading captured positions from #5041/#5043, tolerance checks with IF[…]GOTO, and a sub-macro call with arguments:
#1=#5041 ; store present workpiece X
#2=#5043-#116 ; store present workpiece Z (minus clearance)
IF[#26EQ#0]GOTO2 ; if Z-arg is null, skip the Z touch
#32=#7/2+#18 ; half tool dia + overtravel
G31X[[#1*#108]-#32]F#119 ; probe toward -X at feed #119
IF[ABS[#5041-[#1-[#32/#108]]]GE#123]GOTO14 ; over tolerance -> error branch
N2
G65P207409926X[#1-[#7/2]]Q#17S#19 ; call reporting macro with args
G0Z#2 ; rapid clear in Z
M99
Note the real-program idiom IF[#4006 EQ 21] that these routines use to branch on metric (G21) vs. inch (G20) mode by reading the modal-G system variable — a clean example of using #4001–#4027 in practice.
Gotchas & Fanuc Differences
| Area | What to watch |
|---|---|
| EIA vs MAZATROL storage | Both program types share one directory and one tool table. The interpreter is chosen from the program, not a mode switch. When EIA calls a MAZATROL program, the MAZATROL END unit must set CONTI. = 1 — do not use M99 to return. |
| Boring-cycle numbers | G75–G79 and G86–G89 are “Boring 1–7”; G76 is fine boring (not threading); G74 is reverse tapping. Fanuc canned-cycle numbers do not map one-to-one. |
| Decimal points | No-decimal values are in least input increment (0.0001 mm). X10 = 0.001 mm, not 10 mm. A parameter can additionally scale non-decimal data ×10. |
| Tool-offset variables | No fixed #2001-style block. Tool data is indexed by tool-data index; resolve it via #3020/#3022/#3023, then read #40001+n (length), #41001+n (radius). |
| Empty words & F36 bit 3 | An address with no number is silently treated as 0 by default, or raises alarm 807 if F36 bit 3 = 1. A word whose value is a null (#0) variable is ignored entirely. |
| G20/G21 | Affect program data only; stored tool and offset data are not converted on a unit change. Set them in the intended unit first. |
| Loop / IF limits | WHILE nesting to 27 levels (DO numbers 1–127); IF/ENDIF nesting to 10. Overruns raise alarms 1918/1919/868 — not the Fanuc alarm numbers. |
| Option-gated codes | Involute interpolation, polar interpolation (G12.1/G13.1), synchronous tapping (G84.2/G84.3), inclined-plane machining (G68.2), fixture offset (G54.2), tool tip control (G43.4/G43.5), turning cycles, and hob milling all require options — a code’s presence in this list does not guarantee it on a given machine. |
| Machine M-codes | Only M00/M01/M02/M30/M98/M99/M998/M999 are defined by the EIA manual. Spindle/coolant/tool-change and codes like M111/M200/M648 are machine-specific — look them up, don’t assume. |
For conversational programming on the same control, see Mazak MAZATROL Programming; for control operation, screens, and setup, see the Mazak Control Guide.
References
- Yamazaki Mazak, Programming Manual (for Machining Centers) — EIA/ISO, MAZATROL SmoothAi, Manual No. H747PB1000E, 02.2020.
- Yamazaki Mazak, Programming Manual (for Machining Centers) — EIA/ISO, MAZATROL SmoothG, Manual No. H749PB1003E, 07.2022 (companion control).
Have a question or want to contribute?
Contact us with corrections, additions, or topics you'd like covered.
Get in Touch