How to Run a gShield CNC Machine Without Limit Switches

Mini Mill CNC Conversion - Test Cuts without Limit Switches

Limit switches, we don’t need limit switches!

I am new to CNC machines. If you are anything like me, you want to make chips as soon as possible. Once I had the bare minimum setup on my CNC mini mill conversion, I wanted to see chips! I installed the CNC Fusion kit and dialed in the motion on the x, y & z axis. I even trammed the mill. I did not install limit switches. I figured for the first few runs, I will keep my hand on the E-stop. As in many things in life, it wasn’t that simple.

I setup a scrap piece of wood on the mill and ran my first lines of gcode from Fusion360 and the default grbl post processor. It worked really well. I knew enough to set the x, y & z zero position just as I had done in the CAM steps. I was feeling pretty good.

Now, I wanted to perform the second operation on the test parts. A pair of helically interpolated holes with a counter bore. After a few minutes in Fusion360, I had tool paths that looked good to me. Using the grbl post processor in Fusion 360, I generated the gcode.  After transferring it to the machine and resetting my zeros, I hit start. Now, I was careful, I set my Z zero way above the part so the first run would cut nothing but air. Or so I thought. For some reason, the machine moved to what appeared to be the correct x, y position for the holes and then plunged into the work piece! Hmm, that wasn’t supposed to happen. I setup my job and tired again, this time moving the z axis zero even further away from the part. Again, the tool just barely touched the work piece and then moved back up in z and started to cut the holes as expected. What was going on…

I opened up the Gcode in my text editor and started going through the code line by line. I knew whatever was causing the unwanted movement happened before the helical interpolations. In this case the gcode has decent comments straight out of fusion 360. I was able to review the code prior to my first boring operation. Next I though well, I should look for some type of z command.

Example Gcode

The following is the first part of the gcode from the file I used.

(Second OP Test)
(T10 D=0.125 CR=0 – ZMIN=-0.38 – flat end mill)
G90 G94
G28 G91 Z0

T10 M6
S2500 M3
G0 X0 Y0.2969
G1 Z0 F5
X-0.024 Y0.2924
G3 X-0.0252 Y0.2747 I0.0083 J-0.0094
X0.0252 Y0.319 Z-0.0197 I0.0252 J0.0221
X-0.0252 Y0.2747 Z-0.0394 I-0.0252 J-0.0221
X0.0252 Y0.319 Z-0.0591 I0.0252 J0.0221
X-0.0252 Y0.2747 Z-0.0787 I-0.0252 J-0.0221
X0.0251 Z-0.0894 I0.0252 J0.0221
X0.0189 Y0.3246 Z-0.1 I-0.0251 J0.0222
X-0.0189 Y0.2692 I-0.0189 J-0.0277
X0.0189 Y0.3246 I0.0189 J0.0277
X0.0015 Y0.3213 I-0.007 J-0.0103
G1 X0 Y0.2969
G0 Z0.6

The file continues with 3 additional “(Bore)” operations.

The Culprit

That’s when I found the following line.

G28 G91 Z0

What does all of that mean?

G28 is a command that tells the machine to go to its zero position. This is the same position the machine goes to if you home or reference the machine. That is, using the limit switches, the machine learns where it is in 3d space.

For a detailed description of the G28 command click here to head over to the CNC Cookbook.

But wait, Tim, you don’t have limit switches! Winner winner chicken dinner. So without limit switches where is the home or zero position of the machine?

Well it turns out, if you are using a gShield with GRBL software, the machine zero position (x = 0, y = 0 and z = 0) is by default the position of the machine when the gShield powers on!

Note, we are talking about machine position not work position. You can see the difference below in the screen shot from the Universal Gcode Sender.


Image from universal gcode sender detailng the machine position 0,0,0 without limit switches

Without limit switches on your machine, the 0,0,0 machine position defaults to the machine power on position.

When the G28 G91 Z0 line is sent to the gShield, the machine goes to the Machine (position (x = 0, y = 0 and z = 0) in this case it was in my work piece.

So what do you do? For now, I am going to remove the G28 G91 Z0 command(s) from my gcode files. I do not care about the machine position yet. I suspect this is important if you have things like an automatic tool changer and the machine always needs to know where to find the tool change position in space.

The G28 G91 Z0 command appeared twice in my program. Once in the beginning and once at the end. Once I have my limit switches in place, I can see where this command might also be handy for manual tool changes. I can set the tool change position at my maximum z position to give me lots of room to remove a drill chuck.

Final Thoughts

I knew when I started this adventure, there would be a lot to learn. Let’s say, I have not been disappointed. Hopefully this will help you avoid my mistake. Don’t have your DIY CNC controller setup yet? Click here for a step by step guide to setup your arduino & gShield.

What has been your greatest challenge learning your CNC machine? Leave a quick note in the comments below.

Thanks for reading. Until next time…







    thank you

    1. Tim (Post author)

      Angelo – You are welcome. Glad it was helpful.


Leave a Comment

Your email address will not be published. Required fields are marked *