CNC calibration with Nomad883

Jake Dean
|
February 1, 2021

I recently bought a threaded table from Carbide3d but it has introduced offset and calibration issues into the product I’ve been making. This is primarily because the product I’m making requires CNC’d on both sides of the design, so even an offset issue of say 0.2mm from the X axis gantry will present itself as 0.4mm, which has led to excessive material on some axis when parts start coming together. So I’ve been experimenting with ways I can calibrate the to the threaded table. I've been able to calibrate to within about +-0.05mm

The main thing I love about the nomad is it’s repeatability and mechanical resolution

Mechanical Resolution: 0.0005 in or 0.0127 millimetres

Mechanical Repeatability: 0.0015 in or 0.0381 millimetres


Mechanical resolution is how fine the motor on the x or y axis can move, mechanical repeatability describes how well the x and y homing sequence can calibrate themselves. So theoretically, if I had perfectly calibrated the threaded table to the x and y axis, I can still expect to experience 38 microns, or 0.0281 mm of error on my cuts, which is perfectly fine for our purposes.


I’ve set out to find a way to make a calibration procedure that is easy to use and can account for as little human error as possible. Previously I would eyeball measurements, and while I can get close doing this, I can’t help anyone else with a cnc machine do the same thing or repeat the same results if my bed changes.


The method uses a samsung galaxy camera, and holes made at specific locations.

Picture of Original Setup

Image of the calibration block mounted onto the cnc machine

I placed some mounting holes into some stock material that could mount the material into the bed. I placed two holes along the x axis, and two holes along the y axis. After mounting the material to the threaded table, the next step is to mill holes at an offset of 0.5 inch around the mounted screws in both the x and y directions. This is so you end up with 4 separate points around a particular mounting hole. The mounting hole is positioned relative to the threaded table, where the 4 alignment holes drilled around it are relative to the cnc axis frame. 


I used 0.5 inch here but you can use anything. The reason I used 0.5 inch is I wanted a nice round number, so when I go to take photos of the holes using my galaxy, I’m able to get accurate results.

I used the Galaxy s20 in 3:4HD mode with 6x zoom to take the shots. The only reason I used zoom is because I couldn’t get the HD mode to focus on the material with the camera so close. 

I should mention that I was able to get about 6000 pixels in between the inch difference between the center of two alignment holes. So as it sits, my theoretical limit to what I’m able to detect is 

1inch / 6000, which is around a 10th on what the mechanical step over for this machine is, so even when we move onto the object detection, if we are 10 pixels off the exact center, it won’t matter too much.


Because we’re dealing with an application where 10s of pixels matter, you’ll also have to calibrate the camera that you’re using. I’ll be posting all my code to github and cleaning this up a little bit once I've finished the test block to confirm this works.


I’ll refer to the mounting holes as North, South, East and West where North is 3 inches up, East is 3 inches right, South is 3 inches down and West is 3 inches left. For each hole, I took multiple photos to ensure that the variation due to camera error could be seen 


I used an initial pixel grayscale threshold to help detect the initial center of the alignment holes, then I’ve made an algorithm that recomputes the center.

The algorithm recomputes the center by detecting how far away from the edge of the alignment holes the current center is at a particular angle, say 0 degrees, then checks how far away the angle is at 180 degrees, if the 180 degrees is more than the 0 degrees, the algorithm moves the center towards the 180 degrees. 

Mounting hole Image

An image of a mounting hole set with 4 alignment holes and a mounting hole

Threshold Image

Threshold Image where white are the sections where the holes are
Threshold Image where white are the sections where the holes are

Calculating centre of alignment holes

Calculated image holes of the previous image, there are red rings around the alignment holes






Results

Example of the South mounting hole showing the difference between ideal and measured

The image shows an example of one of the holes, specifically the south mounting hole. I’m going to switch to mm here because it feels more friendly for me to read from the plots but will include the inches in the text. The above plot shows the difference with what the ideal was, to what was measured using the camera technique above, with the calculated centers taken as red dots. In this particular case, we would have to move our Y axis about 0.3mm or 11 thousands of an inch and our X axis about 0.12mm or about 4 thousands of an inch.


But as we have 4 separate measurements for 4 separate points, it would be better to use all of the data and calculate a Transformation matrix between what the theoretical is to what our measured results are.


After having multiple images of each mounting hole, and finding the position of the alignment holes. We can calculate the offset that would be required for each mounting hole to reach the center that the alignment holes create. I’ll show the transformation matrix but only take out a few values to continue further.


Transformation matrix required

 [[9.9904174e-01, 3.4027777e-04, 1.3890886e-01]

 [4.4444454e-04, 9.9980557e-01, 2.8627944e-01]

 [0.0000000e+00, 0.0000000e+00, 1.0000000e+00]]


Ideally we should only have a translational element and a rotational element in our transformation matrix, but it seems we’ve also got a shear element and a scale element. The shear element can be noted from the difference between the 3.4 value and the 4.4 value. The scale element can be noted from the difference between the 9.99 and 9.998 value in that matrix. The other two numbers, 0.1389 and 0.286 represent the calculated x axis and y axis translation required. It may not be the case as it could be written to measurement error where the calculated center of 4 camera measurements is a little bit off to what the true value is, but the best way to have a look at what might be happening is to apply the translation elements we got out of this matrix into Ideal measurement and see how close each Ideal measurements gets to the camera calculate measurement.



North Mounting Hole Calibrated showing ideal position after translation effects vs measured


South Mounting Hole Calibrated showing ideal position after translation effects vs measured


East Mounting Hole Calibrated showing ideal position after translation effects vs measured


West Mounting Hole Calibrated showing ideal position after translation effects vs measured




Looking at the above 4 plots. We seem to see some scale error along the x axis where the East mounting hole error is positive and the West mounting hole error is negative. However the calibration looks okay with just the translation element included. I’ll look in the future to be able to add the scale error and the shear error that we saw in the matrix, but for now, I’m not sure how to. The next step is to test however my machine has recently broken down and Carbide3d are shipping me some parts to fix the machine. In any case, I’m pretty happy with the calibration with the new values.

Looking at the above 4 plots. We seem to see some scale error along the x axis where the East mounting hole error is positive and the West mounting hole error is negative. However the calibration looks okay with just the translation element included. I’ll look in the future to be able to add the scale error and the shear error that we saw in the matrix, but for now, I’m not sure how to. The next step is to test however my machine has recently broken down and Carbide3d are shipping me some parts to fix the machine. In any case, I’m pretty happy with the calibration with the new values.