Understanding G28
I hope this is appropriate to post here. Didn’t know where else to put it. Maybe would make more sense as a project?
Background
I am new to CNC. I have recently been using a Shapeoko then upgraded to an X-Carve. In my job I have had the fortune recently to have at my disposal a wealth of resources on the Autodesk CAM team that I have been pestering for information on my quest to learn more about using CNC machines. One of the topics that I found most confusing and caused me the most grief in the beginning was the concept of Machine Zero, Work Zero and most importantly Zero Return (reference point). Disclaimer I work for Autodesk with the Fusion 360 product so my references here will be specific to the output from Fusion 360 (or HSMWorks) but really it is pretty universal to most CAM programs I would imagine.
Also by no means am I an expert, this is my attempt to distill what i have learned recently. I am more than open to feedback. I just wanted to share this for anybody that is going through the same thing.
This topic is important if you are going to be using other CAM tools like Fusion 360 that have generic Grbl posts.
I also made a video here:
Machine Zero, Machine Coordinates
Machine Zero is typically the lower left hand corner of your machine. On an X-Carve with limit switches the machine “finds” this position when you run the homing cycle. If you do not have limit switches (or do not run a homing cycle) then machine zero will be where ever the spindle is when you turn on the machine or reset the G-Shield.
This would be Machine Zero after running homing cycle:
Work Zero, Work Coordinates
Now typically when you run any job you essentially ignore machine coordinates. The first step you typically do is to jog the machine to a predefined position on your piece of stock and “set zero” on the axis. Now when you run your program it is all relative to this newly defined work position. So it would seem that really machine coordinates don’t really matter for most jobs. This is why you don’t have to have limit switches and you don’t have to set a consistent machine zero… but you should and here’s why.
Here is a picture of setting the work zero:
Reference Point, Return Point
The reference point is a point you define on the machine. It is a repeatable “safe” position for you to return to before an operation, after an operation, or for a tool change, etc. It is a position that must be set by the user on the controller (GRBL in this case). The position is “remembered” when you turn the machine on and off.
Now here’s the caveat: The Reference point is RELATIVE to Machine Zero. SO if you don’t have a consistent machine zero then you won’t have a consistent return point. Imagine this, when the machine “wakes up,” it assumes it is at zero. You must run a homing cycle to say otherwise. The return point will then be specified relative to this arbitrary position not always against the actual machine zero.
G28
G28… This little command caused me quite a few problems in the beginning. G28 will move the machine to the return point. By default in the Fusion 360 post G28 is enabled at the beginning and end of each operation. So the first thing that happened when I went to run every program was the machine shot off to some random position or crashed. It was not repeatable because I was resetting the machine and moving it so the return point (G28) was always somewhere different.
To properly use G28 you HAVE to have a repeatable machine zero. If you don’t have limit switches (or some other way to zero the machine coordinates) then G28 will cause you lots of problems.
Setting Return Position: G28.1
The first thing you need to do (and only need to do once) is to set your reference point. Here are the steps:
- Turn on the machine and connect with something like Universal G-Code Sender (UGS)
- Run a homing cycle (Ensure a consistent machine zero point)
- Now move your machine to your desired reference point.
- In UGS go to the commands tab
- Issue the command: G28.1
- This sets your return position for ever after. This is stored in GRBL settings in the Arduino permanent memory.
For this position I have been using a position with Z all the way up and X and Y about 2 in from the lower left corner. On more advanced machines there would be a very specific location for this point but for me I think it is just important to be somewhere that will not interfere with your work pieces typically. I am not sure the best location yet, but this is what I have been using.
Of course you can always change the position by issuing another G28.1 command.
Using G28
The really nice thing about G28 is the way you can use it. By default if you enter G28 in the command line it will make a straight line to the position you set with G28.1
Alternatively you will see something more like this:
G28 G91 Z0
With out going into a big explanation of G90 vs G91 (see here: http://www.tormach.com/g90_g91.html)
What this command will do is first move the Z nowhere then move to the Zero position defined by G28.1. So you see this at the beginning of all programs in Fusion so that you know that regardless off where the machine is in space the first thing it will do is move the spindle up to the maximum height (assuming you set it this way) then go run your program.
This is important. Imagine your have the spindle at some random point down near the work surface. Your CNC code might have the first position be to move over above the other side of the part and then plunge in. Well? How do you ensure you don’t crash into the part on the way over? Make sure you stop by return point Zero on the way, that’s how.
Another one you will see at the end of the programs coming from Fusion 360 is:
G28 G91 Z0
G28 X0 Y0
Again this first moves the Z up to the return point. Then it moves to the X and Y return point. The idea is that when you are done, bring the head all the way up, then move it out of the way.
Why not G53?
G53 allows you to move to a prescribed position in machine coordinates. SO if you were developing a custom post processor for a specific machine with known sizes you could very easily replace the G28 G91 Z0 line with G53 Z0 and you would get the same result. The problem with X and Y though is that many machines will have different sizes. You can’t exactly know where a person may want their return position to be. So for making a generic post G28 is more universal in that it would work with any machine as long as the person has set a point. If the post processor for example hard coded in G53 X2 Y2 Z0 that might work for some people but not others. Good article here showing benefit of G53, although it really is dependent on setting up a specific post for that machine.
G28 in Fusion 360
So after all this you decide you don’t want to worry about it, or just don’t like it? Here’s how to turn it off (or turn it back on when you realize it is actually awesome and want it back). When post processing tool paths from Fusion 360 select the Generic Grbl post (1). In the Properties dropdown (2) you can select whether or not to use G28 (3). You only have to set this once as the software will remember this setting.
Other References:
GRBL Documentation:
Home · grbl/grbl Wiki · GitHub
G28 Descriptions:
G28 G-Code: CNC Return to Reference [ Easy Tutorial & Guide ]
http://www.tormach.com/g28_g30.html
Part Zeroing
Edge Finders, Center Finders, 3D Tasters and Work Coordinate Systems