M07 is a modal command which turns on mist coolant.
Mist coolant is compressed air and coolant (usually oil).
It can be more efficient than flood coolant and in some situations be better at clearing chips than flood coolant, but it is used far less often than flood coolant with the M08 command.
Flood coolant is where the cutter and workpiece are literally flooded with the coolant fluid. This works to lubricate the part, remove chips, and reduce heat buildup.
Mist coolant with the M07 code combines the coolant fluid with compressed air and sprays it on the cutting area.
Mist coolant uses less coolant fluid and can be less messy depending on your CNC setup, but it isn’t as good at reducing heat buildup as flood coolant is.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
The three main advantages of using coolant with your CNC machine are:
Lubricate the cutter
Clear chips
Reduce heat buildup
What are the other options for using coolant?
We discussed mist and flood coolant above but there are other options available as well including:
Air: This type of coolant reduces heat and clears the chips, but it does not lubricate the workpiece. This type of coolant is used more often with sensitive materials.
High pressure: High pressure coolant is similar to flood coolant. The only difference is that it hits the workpiece at greater than 1000psi. The higher pressure and higher quantity of coolant helps cool the cutter better and remove more chips.
Through spindle: Through spindle coolant delivers the coolant directly where it is needed. It is better at clearing chips in many cases because the coolant from the spindle pushes the chips out of a hole or pocket.
The M06 code tells the CNC to perform a tool change.
The machine will swap the tool that is in the ready position of the automatic tool changer into the spindle.
Preparing the CNC for a tool change
You should be aware of some of the characteristics of your cutting tool. The size, as in diameter and length need to be taken into account.
A cutter with a very large diameter may need to be placed near empty spots in your tool changer so it doesn’t smash into other tools.
Length isn’t usually as big of an issue but still keep it in mind to make sure you have enough clearance with the machine and with your part.
Another big thing to consider is the weight of the cutter. Check your machine manual because the capabilities of various machines differ.
Remember that the total weight of everything you are putting in the spindle or automatic tool changer is what counts, not just the cutter.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Certain conditions need to be met for a safe tool change.
Machine movement needs to be stopped and the machine should be in the tool change position. Often this position is the same as the home position.
The spindle should be stopped and the tool to be swapped in should be in the ready position.
Performing a tool change without an automatic tool changer
If your machine doesn’t have an automatic tool changer, then the operator (probably you) will need to change the tools manually.
The best way to do this is to put a program stop in your program using the M00 code. You should include comments in your program at the program stop to tell the operator what they are expected to do.
What other CNC codes are used with the M06 command?
The main code used with the M06 command is the T code.
The T code selects the tool that will be swapped in.
The line of code performing the tool change will usually be something like:
T02 M06
In this example tool #2 is readied for the tool change and then the M06 tells the CNC to swap the tool into the spindle.
M6 vs M06
Some people get confused about whether the 0 is required to include with an M06 code.
To clear this up, there is no need to include the zero in the code.
The CNC machine will read the code the same. It really is just a matter of preference.
Often you will see the full M06 code used in textbooks or other reference materials. In practice though, many prefer the shortened M6 code in their programs.
If you are working on your own, then go with whichever format you prefer.
If you work in a bigger shop, make sure to stick to the format that the business has been using.
Frequently asked questions about the M06 code
Do you use the M06 code if you want to switch to an empty spindle?
Yes, just call up a tool holder location without a tool in it.
When the M06 command is used the machine will swap in the empty spot, leaving no tool in the spindle.
Do you need to use the M06 command if you don’t have an automatic tool changer?
No, if you don’t have an automatic tool changer, the M06 code isn’t needed.
Without an automatic tool changer all tool changes will need to be done manually.
If you need to change directions, then it is best to stop the spindle before changing directions.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Some people get confused about whether the 0 is required to include with an M05 code.
To clear this up, there is no need to include the zero in the code.
The CNC machine will read the code the same. It really is just a matter of preference.
Often you will see the full M05 code used in textbooks or other reference materials. In practice though, many prefer the shortened M5 code in their programs.
If you are working on your own, then go with whichever format you prefer.
If you work in a bigger shop, make sure to stick to the format that the business has been using.
What other codes will stop the spindle?
There are multiple codes that turn the spindle off.
Most of them perform multiple functions such as stopping various machine functions all at once. Some of those codes are:
They both will turn off the spindle, turn off the coolant, stop any machine movement and pause your program until the cycle start button is pushed again.
The difference between the two is that M00 will always cause the machine to act in this way and M01 will only cause the CNC to perform these action if the optional stop switch or button is set to on.
M02 and M30 are both program end codes.
They will cause the machine to shut everything down just like the M00 and M01 codes but instead of pausing the program, they stop it.
M02 is a legacy code from when many CNC programs were made on tape for the machine to read. The M02 code would cause the machine to end the program.
The M30 command would end the program and then rewind the tape back to the beginning of the program.
In many newer CNC machines, the M02 code is treated the same as the M30 code. In cases where the default is not to treat the codes the same, the machine often has a setting that can allow it to treat them both as M30 codes.
M02 codes are not needed on newer CNC machines. M30 is the standard code to end a CNC program.
The M04 code turns the CNC spindle on in a counterclockwise direction.
On a CNC mill, M04 is used with left hand tools. This is far less often used compared to the M03 (clockwise) command.
The M04 is often programmed together with a spindle speed using the S code such as S2500 M03.
Programming the speed on a previous line is also acceptable. Using the code below will functionally be no different than S2500 M04.
S2500
M04
If no speed is given on the same line as the M04 code, the CNC machine will use the last set speed in the machine’s memory.
To ensure the proper speed is set when turning the spindle on with M04, it is good practice to set the speed even if it has not changed since it was last set.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Some people get confused about whether the 0 is required to include with an M04 code.
To clear this up, there is no need to include the zero in the code.
The CNC machine will read the code the same. It really is just a matter of preference.
Often you will see the full M04 code used in textbooks or other reference materials. In practice though, many prefer the shortened M4 code in their programs.
If you are working on your own, then go with whichever format you prefer.
If you work in a bigger shop, make sure to stick to the format that the business has been using.
M03 vs M04
There are two codes for turning the CNC spindle on.
G96 – Constant surface speed mode – On lathes this mode tells the machine to maintain a constant surface speed so as the part being machined gets smaller, the spindle will turn faster to maintain the same speed at the cutting point
G97 – RPM speed mode – This code tells the CNC to run the spindle at a constant number of revolutions per minute
The M03 code turns the CNC spindle on in a clockwise direction.
On a CNC mill, M03 is used with right hand tools. This is by far the most common type of tooling used with machining centers.
The M03 is often programmed together with a spindle speed using the S code such as S1000 M03.
Programming the speed on a previous line is also acceptable. Using the code below will functionally be no different than S1000 M03.
S1000
M03
If no speed is given on the same line as the M03 code, the CNC machine will use the last set speed in the machine’s memory.
To ensure the proper speed is set when turning the spindle on with M03, it is good practice to set the speed even if it has not changed since it was last set.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Some people get confused about whether the 0 is required to include with an M03 code.
To clear this up, there is no need to include the zero in the code.
The CNC machine will read the code the same. It really is just a matter of preference.
Often you will see the full M03 code used in textbooks or other reference materials. In practice though, many prefer the shortened M3 code in their programs.
If you are working on your own, then go with whichever format you prefer.
If you work in a bigger shop, make sure to stick to the format that the business has been using.
M03 vs M04
There are two codes for turning the CNC spindle on.
The M03 code turns it on in a clockwise direction. M03 is used with right hand tooling.
The M04 code turns it on in a counterclockwise direction. M04 used with left hand tooling.
If you need to change directions, then it is best to stop the spindle before changing directions.
Which code turns off the spindle?
The code to turn off the CNC spindle is M05.
The same M05 code is used no matter which direction the spindle is currently rotating.
Other CNC codes to know when working with M03
Because the M03 code is used so often, there are a number of codes that are used together with the M03 command.
G96 – Constant surface speed mode – On lathes this mode tells the machine to maintain a constant surface speed so as the part being machined gets smaller, the spindle will turn faster to maintain the same speed at the cutting point
G97 – RPM speed mode – This code tells the CNC to run the spindle at a constant number of revolutions per minute
It does not return to the beginning of the program. This is sometimes called program end with rewind.
The rewind has to do with the way CNC program used to be read. They were on tapes or cards.
Using M02 would tell the machine to not rewind. This was done for multiple reasons. Sometimes when the tape was rewound, the CNC would “eat” the tape. The tape would also get taped together to form a continuous loop for programs that were run over and over sometimes.
The M02 code turns off the following machine functions:
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
It stops the current program in the middle of running but only if the optional stop switch or button is on.
If the optional stop switch is not on, then the machine will ignore any M01 codes it reads and continue running the program like normal.
When the machine reads an M01 code and the optional stop switch/button is on, it will turn off the following functions:
Movement of all axes
Spindle rotation
Coolant flow
The machine pauses reading the program
When the M01 code is used, nothing is reset. In other words, any active modes or parameters will stay as they are.
The program is merely paused when it reads the M01 code.
The machine will resume reading the program when the cycle start button is pressed after the program stop has occurred.
Note that the machine doesn’t turn on functions when cycle start is pushed.
If the M01 code turns something off such as the spindle or coolant, it will need to be turned back on in the program.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Ideally the CNC programmer will list why the M01 code was used in the program and/or on the setup sheet.
How to resume program operation after using an M01 code
The M01 command stops the machine in the middle of reading the program.
However, it does not restart or reset the program.
The CNC machine will keep all the conditions that were set before the stop occurred such as feed rate, spindle speed, unit mode, positioning mode, etc.
When the programmer wants to resume the program, he or she will have to make sure that they turn the spindle and coolant on again if needed in the program.
The CNC operator will resume the program by pressing the cycle start button.
What are the benefits of using the M01 code?
Using the M01 code to put an optional stop in your CNC program allows you to check on the status of your machine or part. It also allows the operator to safely perform any needed manual actions.
Making the stop optional allows the machine to keep running if the stop isn’t needed for every run.
For instance, if you need to check the size of every 5th part then you could simply turn the optional stop switch on for one out of every five runs.
The other four runs can have the optional stop switch set to off and the machine will ignore the optional stop
What to watch out for when using an M01 code
Check the program comments and setup sheet to understand why the program stop has been used.
Most CNC machines are intended to run as much as possible because many businesses will look at it as “making chips means making money”. Because of this, it is usually safe to say that if the machine has been stopped on purpose, it is usually for an important reason.
If you aren’t sure why the M01 code is being used, find someone who does.
M00 [program stop] vs M01 [optional stop]
The M00 code and M01 code are very similar CNC codes.
They both stop the machine in the same way:
Machine functions off
Program is paused
Both codes required the cycle start button to be pushed after the stop occurs to make the CNC machine resume reading the program.
The difference between them is that the CNC will ignore the M01 code unless the optional stop button or switch is on.
If the switch is off, the machine will ignore any M01 codes it reads and continue running the program like normal.
M01 [optional stop] vs M30 [program end]
The M01 and M30 codes both stop the machine, but the M01 stop is just a pause in the program.
The M30 code ends the program.
Pressing cycle start after an M30 code will start the entire program over again.
Pressing cycle start after an M01 code will continue reading the program from the next line after the M01 code was used.
The M30 code is also not affected by whether the optional stop switch is on or off. The M30 code will end the program no matter what.
It stops the current program in the middle of running.
Using the M00 code turns off the following functions:
Movement of all axes
Spindle rotation
Coolant flow
The machine pauses reading the program
When the M00 code is used, nothing is reset.
In other words, any active modes or parameters will stay as they are. The program is merely paused when it reads the M00 code.
The machine will resume reading the program when the cycle start button is pressed after the program stop has occurred.
Note that the machine doesn’t turn on functions when cycle start is pushed.
If the M00 code turns something off such as the spindle or coolant, it will need to be turned back on in the program.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
Ideally the CNC programmer will list why the M00 code was used in the program comments and/or on the setup sheet.
How to resume program operation after using an M00 code
The M00 command stops the machine in the middle of reading the program.
However, it does not restart or reset the program.
The CNC machine will keep all the conditions that were set before the stop occurred such as feed rate, spindle speed, unit mode, positioning mode, etc.
When the programmer wants to resume the program, he or she will have to make sure that they turn the spindle and coolant on again if needed in the program.
The CNC operator will resume the program by pressing the cycle start button.
What are the benefits of using the M00 code?
Using the M00 code to put a program stop in your CNC program allows you to check on the status of your machine or part.
It also allows the operator to safely perform any needed manual actions.
What to watch out for when using an M00 code
Check the program comments and setup sheet to understand why the program stop has been used.
Most CNC machines are intended to run as much as possible because many businesses will look at it as “making chips means making money”. Because of this, it is usually safe to say that if the machine has been stopped on purpose, it is usually for an important reason.
If you aren’t sure why the M00 code is being used, find someone who does.
When it comes to the machining, safety should always be the top concern. Assuring safety at all times involves taking good care of the CNC operator, the workpiece, the machine, and any tooling or fixtures.
That is why it is important to pay close attention and fully understand how the G28 command works.
What does a G28 code do?
The G28 command tells the CNC machine to rapid move to a chosen reference point and then rapid move to the machines zero position in one or more axes.
This command is useful when you want to do a tool change or similar function during a program and want to avoid things that might be in the way of a direct rapid move to the zero position.
Using the G28 code can allow you to move your cutter to a safe position and then directly from the safe position to the machine zero position. This lets you make sure you don’t run into the part or any tooling or fixtures in the machine when returning to the zero position.
Because the G28 command is used for safety purposes, you will find it in many CNC programs.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
G28 codes get used when you want to send the machine to a known position. This is often a “safe” position which means the machine is clear of any parts or tooling and is out of the way of any machine functions such as a tool or pallet change.
You will find G28 codes near the end of a section of code. This is because the code is used to prepare the machine for the next section of code.
What to think about when using a G28 code
The main things to think about when using the G28 are picking the right point to travel to that creates a safe straight line to the zero position and how many of the axes you are going to return to the zero position.
When you pick the point, you want to make sure that it doesn’t add too much extra travel because that will add extra time to machine each part.
With that in mind, the best way to avoid collisions is to move the Z-axis first. You will want to move the cutter up and away from the workpiece. This is why you will often see a G28 code that only sends the Z axis to the zero position.
All axes that are used with the G28 code will be sent to the machine zero position.
In most CNC programs, when using a G28 command you will also use a G91 code on the same line.
The G91 code sets the machine to incremental positioning. This means the machine will take each new location value as distances from the machine’s current location.
The other type of positioning is absolute positioning which bases locations off the workpiece zero. The workpiece zero is usually the center or a corner of the part.
Both positioning modes are modal which means they will stay in effect until switched.
If you use G28 without also using G91, it is possible that your CNC is in absolute positioning mode. This could cause a crash if you aren’t careful.
It is easier to move incrementally when you want to retract the cutter.
A simple code can be used to move the cutter two inches up in the Z axis and know that you are safe to travel to the zero position.
If you are in absolute positioning mode, you would need to calculate the XYZ location of the move. Moving incrementally makes the move as simple as a Z move only.
The main portion of a CNC program is often written in absolute positioning mode. This is why it is important to switch to incremental mode and also to switch back to absolute mode once you are done moving incrementally.
Is G28 a modal command?
No, G28 is not modal. Modal commands stay in effect until changed, such as a G20 (inches) or G21 (mm) code.
G28 only affects the line it is on. It is a very simple canned cycle with two steps.
Step one = move to the intermediate position.
Step two = move to the machine zero position.
Common modal commands
Code
Name
G00
Rapid Motion
G01
Linear Interpolation
G02
Circular Interpolation, Clockwise
G03
Circular Interpolation, Counter-Clockwise
G17
XY Plane
G18
XZ Plane
G19
YZ Plane
G20
Inch Mode
G21
Metric Mode
G41
Cutter Compensation, Left
G42
Cutter Compensation, Right
G43
Tool Length Compensation
G54-G59
Work Offsets
Various Canned Cycles
Hole Drilling, Reaming, Boring, etc.
G28 vs G53
The G53 code is a very similar command to G28.
Remember that we talked about the two positioning modes, absolute and incremental positioning. The G53 command sets a different type of positioning mode. G53 sets the positioning mode as relative to the machine’s coordinates.
This means the X0Y0Z0 location will be the machine’s zero return position. This also makes it easy to locate a secondary tool changer or a safe location for a pallet change.
One key difference when compared to the other positioning modes is that the G53 code is not modal. This means the machine will move relative to the machine coordinates but only for the line in which the G53 code appears.
G53 is a very handy code and often is safer than using a G28, but not all machines will accept a G53 code. G28 can be used on just about any CNC machine.
When figuring out whether you should use a G28 or G53 code, the best thing is to do is be consistent so that no one gets confused. It will be better for everyone involved, including operators, programmers, and setup personnel, if they only have to remember to use one code.
Keep it simple and if all your machines don’t accept G53 then stick with using G28 for consistency.
G28 vs G28.1
The G28.1 command sets the location that the machine will go to when the G28 command is used.
The location set by the G28.1 code will be used instead of the machine zero position when a G28 command is used.
G28 codes examples with descriptions of what they do
G28 X0 Y0 Z0
This line of code returns all 3 axes (X, Y and Z) of the CNC machine to the zero reference position. This point is often called the home position.
If the positioning mode is set to incremental (G91), the machine will go straight to the zero return position.
If the positioning mode is set to absolute (G90), the machine will go to the work offset (G54) zero location. This could often result in a machine crash.
G28 U0 W0
This line of code is often used for CNC lathes. U0 & W0 are incremental moves in the X and Z axis. Because these incremental moves are zero, the machine will move directly to the machine zero position.
G28 G91 Z0
This line of code sets the positioning mode as incremental with the G91 command. The Z0 means that the machine will move 0 units in the Z axis which means it won’t move and then the machine will return to the zero position.
G28 G91 X0 Y0 Z35.0
This line of code is very similar to the one above with the exception that the Z axis will move 35 units in the positive Z axis and then return to the zero position.
CNC codes that are similar to G28
There are different ways to return to the reference point and as explained before, G28 and G53 are very similar codes that allow users to achieve the same goal.
Both are safe retracts and home positioning commands that not only help protect the machine but also help protect the workpiece and/or any tooling that could be damaged.
The G28 code and other similar codes also have the benefit of making the program look clean and neat.
This is very important because a clear and easily read piece of code helps anyone who might be using the program.
Remember that it might be some time between before the program gets run again which gives you plenty of time to forget everything you knew about that specific program. This is also one of the reasons that it is recommended to include comments in your program so that it is easier to follow along and understand the code.
G98 also controls the movement of the machine after finishing a canned cycle.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!
The difference is that they lift the tool to different heights when finishing a canned cycle process.
The G98 code lifts the tool back to the initial Z position which the machine was at when starting the canned cycle. This is safer option if you are unsure.
G99 travels back to the R plane instead. The R plane is closer to the part which can potentially cause problems if there are obstacles close to the part such as fixtures or clamps.
Other codes and parameters used with a G99 code
When using the G99 code you should consider all of the following items that can be included as part of the code:
Initial plane – the Z height before starting the canned cycle
The feed rate will depend on the material that is being cut and the diameter of the drilling tool that you are using.
The retract (R) plane or clearance level refers to the plane height where the tool can move safely from one hole to another. The R value should be set so the machine will clear any and all obstacles including clamps, fixtures and the part itself.
X and Y are the location of the hole. Z controls the depth of the hole.
G99 code format
Using the parameters above, the format for using a G99 code is:
G81 X0 Y0 R0 Z1 F5 G99
G81 is the canned cycle. This can be replaced with any other canned cycle as needed.
The rest of the codes are as listed in the parameters section above. The X, Y and F codes are not required. Often, the X and Y codes will be placed on the previous line.
It is good practice to include the feedrate (F) code.
What to think about when using G99
When using the G99 command, think about the obstacles that could be in the way of the movement of your cutter.
Using G99 will move your cutter to the R plane specified with the R code.
The R plane will usually be set close to the top of the part to make the moves shorter which takes less time.
This is great for reducing cycle time but not great for avoiding obstacles.
Common obstacles in the machine are:
The workpiece
Clamps
Fixtures
Other tooling
Reducing the cycle time is great for industrial CNC machines, but for hobbyists this isn’t as much of a concern.
Unless you are trying to maximize the output of your machine, G98 is a safer option.
The Z-3.0 is the depth of the counterbore and P500 is the dwell time when the machine reaches the bottom of the hole in milliseconds.
F is feed rate in mm/min.
Line 3 (N3) tells the machine to move the X axis of the machine to the X=10.0 location. Because the canned cycle is a modal code, another counterbore will be drilled to the same parameters as in line 2.
The next line (N4) drills the third hole at X=20mm. G98 tells the control to return to the initial plane. This is Z=5.0, the last Z location before starting the canned cycle. The machine will rapid back to Z=5.0 above the part surface after drilling the previous hole.
The machine drills the final hole 10mm in X from the last one, the G99 code tells the machine to rapid back to the R position instead of the initial Z position.
Lastly, on line 6 (N6) G80 turns the counterboring canned cycle off.