Hi,

I have been searching of a solution to automatically correct the linear errors of my Shapeoko XXL and I couldn’t find anyone that created a simple software that corrects a Gcode file based on a machine’s behavior.

Typically I have seen that my machine had slightly different X and Y steps and that the machine was impossible to square easily. These characteristics are easy to correct mathematically using an inverse bilinear transformation. Since I couldn’t find anything I decided to write a Python script that does the job. It took me a little less than a week to debug everything and it works now.

Starting in a situation where 600mm was in reality 599.5 in X and 601 in Y (which is not bad) and the diagonals of a 600 x 600 mm square were 851 mm and 846.5 mm (which is not very good but really not uncommon I bet among Shapeoko users - the “ideal diagonal” should be very close to 848.5 mm), a single use of the script perfectly corrects:

- X and Y deviations
- unsquareness of the machine

The observed differences between the CAD model and the output virtually disappear in my case, which is awesome.

It would be really nice if the people at Carbide 3D could implement this within a future version of Carbide Motion - how should I pull such a request?

How does it works?

Basically you will take a small bit (for ex 2mm diameter) and you will drill 4 points on your wasteboard - note that your wasteboard should have been surfaced first, in order to correct for Z errors due to uneven wasteboard.

We call these points a, b, c, d:

d__________________c

| |

| |

| |

| |

| |

a__________________b

a & d sould be aligned with the machine’s Y axis

coordinates are:

A = 0, 0

B = 600, 0

C = 600, 600

D = 0, 600

Drilling these will allow us to measure the machine’s real output. My script requires the Gcode file to be set at the origin of X and Y, beware if you set your origin in the middle you will have negative values and it will crash (but this could be handled if someone helps rewriting this code)

Now we can measure the following distances:

ab (side)

bc (side)

ad (side)

ac (diagonal)

bd (diagonal)

The script will reconstitute the real output and calculate a correction to be applied to the Gcode.

Because it is impossible to apply linear corrections to arc and circles (G2 & G3 commands), the script will first “linearize” the Gcode (transform all G2/G3 into G1), then it will apply the correction to every X and Y elements.

You can find the script here: studioadrienlucca/Gcode3stepsCorrector.py at gcode_corrector · studioadrienlucca/studioadrienlucca · GitHub

Unfortunately I couldn’t write this in Python 3 because I am still behind and using Python 2.7 on my system… but it should work on Python 3 with some minor corrections (like adding parenthesis after print function and stuff like that)

Please let me know if it works for you!

Also, let’s convince the team of Carbide motion to include this into the software, that would be awesome