Inventables Community Forum

Learning About G28

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:

  1. Turn on the machine and connect with something like Universal G-Code Sender (UGS)
  2. Run a homing cycle (Ensure a consistent machine zero point)
  3. Now move your machine to your desired reference point.
  4. In UGS go to the commands tab
  5. Issue the command: G28.1
  6. 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:
https://github.com/grbl/grbl/wiki

G28 Descriptions:
http://www.cnccookbook.com/CCCNCGCodeG28ReturntoReference.htm
http://www.tormach.com/g28_g30.html

Part Zeroing
http://www.cnccookbook.com/CCCNCGCodeTouchOff.htm

34 Likes

What a great write-up, thanks for sharing!

1 Like

This is something I have always taken for granted. In my tool chain, for each project, I set a “Safe Z,” which is a predetermined amount above the work surface (like .5") I set my work zero for every job. When V-Carve Pro generates the tool path, it also generates code to go to work 0,0 at safe z to begin the job. At the end of the job it returns there. Once you set your safe z, it becomes the default and if you set it right, you rarely have to mess with it.

I literally never think about it unless my stock is so thick that .5" above it would top out my spindle. (It’s never happened).

I just assumed everyone would always have to establish work zero for every job anyway so why on earth would anyone every mess with machine zero?

Isn’t there a way in Fusion to do this? Like in preferences or something?

1 Like

Yes you can set the retract height and use work zero and never worry about machine zero.

For various reasons (especially on more traditional CNC machines, with tool changers etc) these things are sometimes important.

One nice thing is that if you know machine zero, then you write down where your work zero was relative to that, you can easily recover from a machine restart, or if you want to run a fixture and do the same job multiple times.

Definitely don’t have to use this technique but wanted to share for those that are interested.

2 Likes

Thank you for that explanation. I just learned more in 5 minutes than everything I thought I knew about machine and work position.

1 Like

Patrick

I just watched your video and all I can say is THANK YOU for breaking this down in such an easy to understand way. This really answers a lot of questions I have had in my head about what my workflow should look like for doing more complex projects that require tool change outs, etc. having your machine zero and G28 set up the way you described should make it a lot easier to run multiple “setups” on the same part without worrying about getting the machine misaligned between setups.

1 Like

WOW!

Big THANK YOU for this post!

1 Like

Thank you so much! This was the one thing that spooked me and quite frankly made me steer clear of 3D printing or using anything other than Easel. You did a wonderful job of explaining and clarifying a complicated concept.

If this topic isnt pinned, it should be. I dont know about anyone else but I would love to see you do some more writeups like this. I just downloaded fusion 360 free hobbist edition. I have been watching the videos on youtube from NYC CNC so that I can learn it… I have mostly donw graphics work (ai/ps) for tee shirts and banners etc.
But I liked the way your writeup wasnt so much a ad for 360 but explaining how the interaction goes directly to the x-carve.
Now I am new to gcode… when I was doing vinyl and doing print-cuts the software did the work so you never got to see the post process… so g28 would be used to have a safe return before and after a process… and for a tool change… but what is I wanted post operation return that is diffrent then the position then the place I wanted it to move for tool change. On the x-carve it returns to the front of the machine… but what if I wanted it to move to the back (y-) so that is out of the way of the bed.

Thanks for all the kind feedback everyone!
@JohnSheak you can set the G28 position anywhere you like. Alternatively you could add a line to the G-Code at the end to go to a specific position. This could even be customized in the post, but that is getting a little crazy. I think in the future we are going to have some better tools to setup your individual machine in Fusion, for now I just jog it in UGS when I’m done :smile:

2 Likes

Very nicely written, it helps with setup. I was looking for a way to set the Z zero on the work surface as that is nessesary.

After reading here and a couple of other related articles on the web, it is now clear why incremental mode (G91) combined with any of X0, Y0, Z0 is beneficial for G28.

Out of academic curiosity, I was wondering if raising Z safely then moving X&Y as mentioned above

G28 G91 Z0 : “move” Z by nothing (i.e. select Z only), then move up to the reference point Z
G28 X0 Y0 : “move” X&Y by nothing (i.e. select X&Y), then move to the reference point X&Y

could be also done in absolute mode.

Let’s assume that we are using the default WCS (G54), and its zero Z is the same as MCS zero Z as set by a top homing switch. Let’s also assume we are in absolute mode (G90) and work in mm (G21).

G28 Z-30 : move Z only 30mm below Z homing switch, then to reference point Z
G28 : then move X&Y&Z , but effectively only X&Y to reference X&Y

30mm is arbitrary. It basically sets a safe intermediate Z point that is high enough, but not too high to hit the switch at rapid pace.

Wouldn’t that work too?

1 Like

Yes if your workpiece zero and your machine zero are the same then it will not really matter. Typically when working on the X-Carve this is never the case though for me. I always set the workpiece at some arbitrary point and then set the zero in the software on a corner of the stock.

I have to add my .02 here. This was very well done and easy to understand. I was a CNC machinist for many years and did my own programing. I had a subprogram that did that that I called up whenever I needed to change tools or whatever. I had forgotten the codes and function for reasons I will not go into here.
Thank you very much because now I can avoid future crashes.
This does need to be at the top of the list one more time as we are always getting new people here.

I know this thread has been out here for a few months, but I finally got a chance to read it yesterday, and I used this last night to set a good location for tool changes. It really is pretty convenient. Thanks for this good info!

G28 is awesome! :smile:

First time learning about this machine !
In my past experience running in absolute G90 , it was always easier to maintain Z0 has the bottom of workpiece ; program the part to read like your drawing , less confusing when machining .
Retracts for tool changes always the same number
Always using the center of workpiece as X0,Y0

Thank you very much for this. It was really easy to digest the way you presented it. I added limit switches to my order (which arrives 6/6/16!!) because I had read somewhere that it facilitated tool changes. Thanks to your explanation, I understand that it is more than that.

So, that gadget the inventable boys are working on is a way to automate the setting of the reference point, correct?

not sure which gadget you are referring to?

1 Like

Sorry about that, I’m not sure what it’s called. I was referring to the device that is used to set the reference point by making an electrical contact with the spindle.