top of page

A faster and more precise way to square a gantry

Gantry auto-squaring as a part of machine homing is a great feature of modern motion control software. Typically, one creates a large square or rectangle with the machine, measures the diagonals and then adjust one of the homing targets to change a homing sensor target point. This requires a trial and error process to bring the gantry into square and relies on the accuracy of a tape measure. The process is described here.


The basic idea


That process works but, in measuring the diagonals, you have all the information you need to know how much to change the homing sensor targets by. And, modern motion controllers allow you to enter that value directly. In grblHAL, this is called a dual axis offset. Even if your motion controller software doesn't support that you can still use this method, see below. The reason for this comes from the Pythagorean Theorem. When your gantry is not square and you try to cut a square what you get is a parallelogram. The diagonals will be of different lengths.

The dotted line shows what you told the machine to cut, the blue shaded area is the actual cut and d is the distance you have to move the homing sensor target to get a true square. By using the Pythagorean Theorem, we can determine d. The amount of squaring error is exaggerated in the above figure. The amount will typically be fairly small.


The actual dual axis offset value needs to be scaled by the size of your machine - specifically scaled by the ratio of the width between your homing sensors and the size of your test block (h).

Note: the diagrams are set up for a moving gantry on the Y rails. You will need to adjust if your gantry moves on the X or other rails.


The gory details


The process starts with cutting a square block on your machine and measuring the diagonals - we will call them r1 and r2. See the formulas below for how to get a value of d from each of them. But fear not about the math, a worksheet is available - you just plug in h, r1, r2 and width between sensors and it gives you the dual axis offset



value to enter into your machine settings. See below.


The process


If you have grblHAL on your CNC machine, make sure you have a recent firmware build with auto-squaring enabled. (Look for $17x in the axis settings.) Also make sure you have calibrated your machine. If not, see here. Digital calipers will give you a more accurate measurement but a tape measure or even simple ruler can work. Do this in metric to keep it simple.

  1. Using you favorite CAD/CAM application, create a GCode program for a square measurement block. Remember the size of the square, you will use it in the spreadsheet as h.

    1. If you have digital calipers, cut a square block. Pick a size that will work for them. 80 to 100 mm is good size for 6" calipers. MDF is a good choice of material.

    2. If you don't have digital calipers, instead of cutting a block, drill four peg holes in a square. You can mount 4 pieces of scrap wood on your machine if you want to avoid drilling into your spoilboard. The larger you can make it, the more accurate it will be.

  2. Cut the measurement block on your machine.

  3. Measure the two diagonals. Get the most accurate measurement you can. R1 runs from the left primary motor side to the right secondary motor side. R2 is the other one.

  4. Enter h, r1 and r2 into the spreadsheet cells highlighted in green.

  5. Determine the width between your two homing sensors and enter into the spreadsheet. Take the dual offset value (highlighted in yellow) and enter into the $17x setting for your axis. If you have a moving gantry on the Y rails, it would be $171.

We calculate 2 values of the dual offset, one each from r1 and r2 and use the average. This is to try to minimize measurement error. If the two dual offset values are not close, try to get better measurements.


Error, accuracy and simplicity


Because we are physically measuring the diagonals, there will be some measurement error. It is important to get the best possible measurements you can. One trick is to rotate the cut block to force the calipers to the widest measurement. That should be the true diagonal distance. If using pegs, try to keep the rule/tape measure exactly parallel to the true diagonal.


One should repeat the process to verify the process worked.


The mathematically inclined will recognize that the above method makes a simplification. The height of the block (along the gantry) will actually not be h, but rather h' in the diagram. The length of the side is h and h' <h. However, if d, the true dual offset value, is small then the computed dual offset value will be very close the true value. For a 100 mm square, 6 mm (about 1/4 inch) of offset error results in a 0.2 mm offset error after adjusting. An offset error of 1.6mm (1/16") results in a 0.017mm offset error after adjusting. Repeating the process with either adjustment results in an offset error below 0.001 mm. Well better than the granularity of most machines.


My motion control software doesn't support dual axis offset


If your MCS supports auto-squaring but not dual axis offset, you can still use the computed dual axis offset to adjust your homing sensor target.


About Me.

I'm Phil Barrett, a long time CNC enthusiast. I run a small company, Brookwood Design, that makes several breakout boards for grblHAL and love to help people get the most out of their CNC machines.



Comments


Featured Posts
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page