Mach3 G Code Examples
Mach3 CNC
G-Code Examples for Milling Machines. Boomerangv4.ncc: 3D profiling job on a boomerang. Griffin Relief.ncc: 3D profiling job for a gryphon logo. HomeSwitchRearPanelEngrave: A control panel for my CNC electronics. SupportLogo.ncc: CNCCookbook logo for my tooling rack.
Mach3 is a software package which runs on a PC and turns it into a very powerful and economical Machine Controller.
- M98 P52000; The number that precedes the program number is the amount of times it is to be repeated (in this case 5 times) At the end of the subprogram, the M-Code M99 is used to return to the previous program. Note: the previous program may be a subprogram. Up to 4 subprograms can be nested, this means we can call upon a subprogram inside.
- P a g e 9 MachMotion Version 1.01 1.13 Tool Table Zero or one tool is assigned to each slot in the tool table. 1.14 Tool Change Mach3 allows you to implement a procedure for implementing automatic tool changes using macros or to change the tools by hand when required.
Mach3 is a full featured CNC controller suitable for controlling the Lathe ,Mill, Plasma Cutter, Router, Engravers etc.
Below is a list of Mach3 Mill G code with description.
If you like to read Mach3 Turn G code read Mach3 Turn G-Code List
Mach3 Mill
Mach3 G Code List Mill
G Code | Description |
---|---|
G0 | Rapid positioning |
G1 | Linear interpolation |
G2 | Clockwise circular/helical interpolation |
G3 | Counterclockwise circular/Helical interpolation |
G4 | Dwell |
G10 | Coordinate system origin setting |
G12 | Clockwise circular pocket |
G13 | Counterclockwise circular pocket |
G15/G16 | Polar Coordinate moves in G0 and G1 |
G17 | XY Plane select |
G18 | XZ plane select |
G19 | YZ plane select |
G20/G21 | Inch/Millimetre unit |
G28 | Return home |
G28.1 | Reference axes |
G30 | Return home |
G31 | Straight probe |
G40 | Cancel cutter radius compensation |
G41/G42 | Start cutter radius compensation left/right |
G43 | Apply tool length offset (plus) |
G49 | Cancel tool length offset |
G50 | Reset all scale factors to 1.0 |
G51 | Set axis data input scale factors |
G52 | Temporary coordinate system offsets |
G53 | Move in absolute machine coordinate system |
G54 | Use fixture offset 1 |
G55 | Use fixture offset 2 |
G56 | Use fixture offset 3 |
G57 | Use fixture offset 4 |
G58 | Use fixture offset 5 |
G59 | Use fixture offset 6 / use general fixture number |
G61/G64 | Exact stop/Constant Velocity mode |
G68/G69 | Rotate program coordinate system |
G70/G71 | Inch/Millimetre unit |
G73 | Canned cycle – peck drilling |
G80 | Cancel motion mode (including canned cycles) |
G81 | Canned cycle – drilling |
G82 | Canned cycle – drilling with dwell |
G83 | Canned cycle – peck drilling |
G84 | Canned cycle – right hand rigid tapping |
G85 | Reaming Canned Cycle |
G86 | Intended Boring Canned Cycle |
G87 | Intended Back Boring Canned Cycle |
G88 | Intended Boring Canned Cycle |
G89 | Boring Canned Cycle |
G90 | Absolute distance mode |
G90.1 G91.1 | Set I J Mode |
G91 | Incremental distance mode |
G92 | Offset coordinates and set parameters |
G92.x | Cancel G92 etc. |
G93 | Inverse time feed mode |
G94 | Feed per minute mode |
G95 | Feed per rev mode |
G98 | Initial level return after canned cycles |
G99 | R-point level return after canned cycles |
To speed up the programming of a part using G-Code, we can reuse sections of the code and recall it within the program. These sections are known as subroutines.
The best way to explain subroutines is with an example. Let’s take a look at how we can write a roughing and finishing cycle on a CNC lathe writing the profile once.
The Roughing Cycle
This block of code will turn a 12mm spherical radius and turn a 24mm diameter at 20mm length.
G71 U0.1R0.1;
G71 P100 Q200 U0.0 W0.0 F0.2;
N100 G0 X0.0;
G01 G42 Z0.0;
X0.0;
G03 X24.0 Z-12.0 R12.0;
G01 Z-20.0 F0.1;
N200 G01 G40 X30.0;
Note:The example above is not the full block of code needed to program the cycle, it is written to demonstrate calling a subroutine within a G71 roughing cycle. For a full explanation of how to program a roughing cycle and any operation on a CNC lathe check out
The G71 lines are our roughing cycle. The thing to note here is the P100 Q200 commands. These commands define the start (P100) and end (Q200) of our subroutine. These values can be any number but they must be identical to the ‘N’ numbers found at the start and end of our profile subroutine.
P100 tells the control to read the subroutine that starts at N100, while Q200 defines the last line of the subroutine that ends with N200.
In the old days (now I’m showing my age), we used to add ‘N’ numbers on every line. Now, we just tend to use them as a way to jump around the program.
You will notice that I start my blocks of programs with N1, N2 etc. This is so I can search quickly to that section of code. I usually keep these ‘N’ numbers the same as the tool number, so if I am cutting with T05, then I will start the section of G-Code with N5.
For more on roughing cycles, check out my article called “
Mach3 Turn G-Code List - Helman CNC
Finishing Cycle
Now that we have our profile already written, we don’t need to write it out again when we use a finishing tool, we just need to recall the G-Code subroutine.
To do this, we just need this simple line of G-Code.
G70 P100 Q200;
G70 is the G-Code used to indicate that we are using a finishing cycle and the ‘P’ and ‘Q’ values point the program to the start and end lines of our subroutine.
Below is the full program of the roughing cycle and finishing cycle that makes use of a subroutine. This program produces a 12mm spherical radius and a 20mm long by 24mm diameter feature. As shown in this drawing.
N1 (ROUGH TURN);
G50 S2000;
G99 G54 G18;
G00 G96 S180 T0101 M03;
X30.0 Z0.1 M08;
G71 U0.1R0.1;
G71 P100 Q200 U0.0 W0.0 F0.2;
N100 G0 X0.0;
G01 G42 Z0.0 F0.08;
X0.0;
G03 X24.0 Z-12.0 R12.0;
G01 Z-20.0 F0.1;
See All Results For This Question
X30.0;
N200 G01 G40 X30.0;
G53 X0.0 Z-200.0 M09;
M05;
M01;
;
N2 (FINISH TURN) ;
G50 G54 S2500;
G00 G96 S200 T0202 M03;
X26.0 Z0.0 M08;
G70 P100 Q200;
Mach3 G Code Examples - Lasopatrader
G53 X0.0 Z-200.0 M09;
M05;
M01;
M30;
In conclusion, subroutines are a simple and efficient way to call upon sections of code and reuse them in order to help you speed up the programming process.
G Code Example: How To Run Your First CNC Program
Author: Marc Cronin, Senior CNC Machine Tools Engineer, and founder of
Mach3 CNC CONTROLLER SOFTWARE - THE MAKERS GUIDE
Categories: CNC Machining