top of page

It's hip to be auto-square...

A little known feature of grblHAL is the ability to automatically square a moving gantry machine. This allows you to have very precise control over the squareness of your gantry. All you need is an extra limit switch/sensor for your moving gantry and a way to precisely control the trigger points of your gantry limit switches/sensors.

First, let's take a look at the example hardware. This is a typical moving gantry design where the gantry moves along the Y Axis. There are two sets of screws and stepper motors, one on each side of the gantry. The two Y Axis motors are ganged together and will move in tandem. Generally they stay in sync but an end-stop crash or missed steps can cause them to get out of sync. Then the machine would no longer cut squares or circles but rather parallelograms and ellipses. Without auto-squaring, you would have to manually adjust one side of the gantry to fix the problem. While auto-squaring may sound complicated, once it is set up, all you have to do is Home the machine.

Auto-squaring relies on having a minimum travel limit switch on each side of the gantry. Typically, they will be at the front of the CNC machine. In addition, you will need a way to adjust the point where each limit switch triggers. A common way is to have the limit target be mounted on a screw that you can turn to adjust the position of the target. You can see an example of this in the photo of the Avid Pro4848 limit target. The limit switches are wired so that the side with min and max travel limit switches goes to Axis Y limit input. The other side just has a single min travel limit switch that goes to the Axis A limit input. With auto-squaring enabled, grblHAL knows to make sure both minimum travel limit switches are triggered when homing the Y Axis. If the limit targets are properly adjusted, the gantry will be perfectly square.

Turning on auto-squaring is easy. You just enable it in the my_machine.h file and rebuild grblHAL. [2023 Edit: no need to set up a build environment and recompile any more, use the grblHAL Web Builder] You also have to enable a ganged axis and the auto-squaring option for that axis as well. There may be pre-built firmware available for your configuration. In grblHAL settings, be sure to enable homing ($22=1).

The next step is to test your machine and adjust the ganged axis limit switch targets if needed. With the auto-squaring firmware loaded, run a homing cycle - either from your GCode sender or by sending a $H command directly to grblHAL. You will need to create a GCode file to cut 4 holes in a rectangular pattern. The larger you can make the rectangle, the more accurately you can square the gantry. As a starting point before running the test, try adjusting the limit targets so they are both the same distance from the front of the machine and are in the middle of their adjustment range. Once you have run the test GCode, measure the distance between the diagonal holes. If the distances are equal then you are done and every time you home your machine, your gantry will be square. If the distances are not equal, adjust one of the limit targets a small amount and rerun the test. See the diagram below to know which side to adjust.. Be sure to mark the previous holes so you don't get confused. Repeat this process until your diagonals are equal.

And, now, when you start up your machine and run a homing cycle, you will have a perfectly square gantry every time.

While you are doing this, you may also want to tune your machine's homing performance. Grbl settings $24, $25 and $27 are worth looking at because the default values are fairly conservative. The way homing works is a rapid move is made to find approximately where the limit sensor is, Then it backs away from the sensor. Finally, it does a slow move to accurately find the sensor again. $25 (Homing search seek rate) controls how fast grblHAL goes when it is first looking for the limit. I am using 500 mm/min on my Avid machine - that allows homing to happen fairly quickly. The higher the speed, the more it will "run past" the trigger point. $27 controls how far grblHAL backs away from the limit switch after it first finds it. I have mine set for 1 mm. This was determined by seeing when the limit sensor switched off as I manually moved away from it. But, if you have a fairly fast seek rate, you may need to set $27 higher. Finally $24 controls the slow seek. I am using 25 mm/min. This seems to be a reasonably good value. After making those changes, homing is fairly fast on my machine.

About Me

I'm a CNC enthusiast. I run a small company, Brookwood Design, that makes 32-bit Grbl breakout boards for grblHAL and love to help people get the most out of their CNC machines.

Featured Posts
Check back soon
Once posts are published, you’ll see them here.
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page