Blog

Zeroing a CNC

Thursday, February 20th, 2014

We enjoy machining custom aluminum robot parts on our CNC Mill. One of the best things about a CNC is that it can cut precise parts by following the geometry of a CAD drawing. We measure the precision and repeatability of our CNC in thousandths of an inch (0.001). But one of the challenges of using a CNC is to to get the raw material setup properly and make sure the spindle starts at exactly the right position. The CNC can only hold a precise position from its starting point. For example, let’s say you want to cut a pocket that is .050″ deep. That’s easy to do, but you need to start the CNC at the exact surface of the raw material so that it knows how far down along the Z-axis to move the spindle. Or let’s say you need to drill a precise hole pattern in a square sheet of aluminum. That’s easy to do, but you need to start the CNC at the exact corner of the square or your pattern will be way off. Finding the exact starting point is called “zeroing” the CNC. There are whole books written on the subject and a whole sub-industry of gizmos for handling this challenging problem. It took us a while to figure out, but this is what we’ve found to be the best solution for us:

1. When it comes to zeroing out the X and Y position of the CNC at the beginning of a job, we have tried a number of approaches, including eye-balling (not very accurate), mechanical edge finders (don’t like these), and even a laser edge finder (not as accurate and cool as you’d think). For our solution, we installed a super-cool USB camera microscope from our friends at Adafruit onto the frame of our spindle. We mounted the camera using a small aluminum bracket that we designed in SolidWorks and machined on our CNC. We secure the camera bracket to the spindle frame using a 4-40 threaded hole that we tapped for that purpose. The microscope camera points downward toward the raw material. It displays a large, magnified image on the computer screen, including crosshairs. When we want to set the X and Y zero point, we turn on the camera and then move the spindle until the crosshairs line up exactly with the corner of the raw material (or whatever position we want to identify as the zero point). Because it’s a microscope, it’s very precise. We then press the Mach3 “REF ALL HOME” button, which we’ve re-purposed and re-programmed to set the X=0 and Y=0 based on the offset distance between the camera crosshairs and the spindle position. This allows us to quickly and easily zero out the X and Y axis to the exact point we need to.

The microscope camera is the tall, tube-shape thing clamped to the edge of the spindle mount. It has a built-in ring of LED lights to illuminate the subject area.

Close-up of the custom bracket we made to hold the tube-shpaed camera to the spindle frame

Close-up of the custom bracket we made to hold the tube-shpaed camera to the spindle frame

In this situation, we are using the crosshairs of the microscope to zero the CNC to the center of a small hole. The macro will set this as X=0, Y=0.

In this situation, we are using the crosshairs of the microscope to zero the CNC to the center of a tiny hole. The macro will set this as X=0, Y=0.

2. The Z-axis, which is the vertical position of the spindle, is by far the most important axis to zero out properly. For this, we rigged up a very cool solution that works great. We cut a piece of copper-clad circuit board (about 1″ x 1″) and soldered it to a long wire that we ran back to one of the 5 volt inputs on our controller. We ran another wire from the base of the CNC. These two wires, combined with the CNC and the end mill (which are both conductive), become like the leads of a voltmeter that is setup to test conductivity. We then wrote a macro in the BASIC language that runs when we press the “Auto Zero Tool” button on the Mach3 interface. When we want to zero-out the z-axis, we place the copper plate on the top of the raw material and press the button. The CNC moves the spindle slowly down toward the plate. The instant the tip of the end mill touches the copper plate the electrical circuit is closed. The macro instantly stops the spindle, sets the Z-axis zero point (by subtracting the .063″ thickness of the plate), and then moves up .125″ so that the copper plate can be removed. The whole process only takes a few seconds to complete. And the result is that the CNC determines exactly where the top surface of the material is and sets it as Z = 0.

 

CNC Z-axis Zero Plate

The zero plate is placed on top of the raw material. The macro automatically moves the spindle down until the end mill touches the plate and closes the electrical circuit, which signals the CNC to zero the z-axis. Note the wire soldered to the copper plate.

These two techniques have really helped improve our setup time and accuracy.

Comments (11)

  1. BobbyB.
    February 21st, 2014

    I am so jealous of all your toys.

  2. 10 Essential Accessories for Your CNC | MAKE
    March 17th, 2014

    […] for handling this difficult challenge, such as edge finders, lasers, and z-axis dial gauges, but here’s how we do it. Photo: Beatty […]

  3. Chris V
    March 20th, 2014

    Simple and easy; Always the best way to do it. Very cool.

  4. Lukas d
    April 22nd, 2014

    Hi,

    I really like what you’ve done with your USB microscope and Z axis zeroing device. I’ve been struggling with zeroing my CNC machine for a while now. Can you share the macro code with us please?!?!

  5. Robert
    April 25th, 2014

    Lukas: I don’t have it right in front of me, but next time I’m in the workshop I’ll snag the macro code and post it here.

  6. hutch
    May 9th, 2014

    I purchased this USB microscope from AdaFruit. CD had only a chinese user manual. I did not see any crosshairs option in the software. Did you use the amcap.exe software on the CD, or a different program?

  7. Robert
    May 16th, 2014

    Hutch: On the version of amcap.exe that I have, the crosshair option is turned on/off under the “Window” menu option. As I recall, I did not use the CD. I downloaded it from the developer’s site.

  8. Robert
    May 16th, 2014

    Lukas: Here is my macro code:
    Be sure to test and check this code thoroughly before you trust it. Also, go through each line and make sure you understand it so that it applies to your machine and situation:

    Message(“Auto Zeroing program….”)
    If IsSuchSignal(22)Then
    code “G31 Z-3 F10″
    While IsMoving()
    Wend
    Call SetDRO(2,.062)
    Message(“Z-zero set. Moving to 0.125″)
    code “G1 Z0.125 F20″
    Message(“Auto Tool Zero Program Complete”)
    End If

  9. Guido
    May 21st, 2014

    How did you ensure that the microscope axis is aligned with the spindle axis? If the axes are skew won’t you have a different offset depending on how high off the material the scope is when you zero the x and y?

  10. Robert
    May 22nd, 2014

    Guido: You can use a digital level and/or a machinist’s level to make sure that the camera is mounted vertical with respect to the spindle axis.

  11. Ardash
    August 12th, 2014

    Actually the proper way to do it is by using a mirror at the bed. Lower the spindle to get the camera as close as possible to the mirror and centre the cross hair to the reflection of the lens. Initially I thought that aligning the barrel of the camera to the spindle, will do the trick. But the camera it self is not always aligned. Mine for instance had a pretty big angle after doing the alignment with the mirror. But the cross hair is dead centre all the way from top to bottom of the Z axis.

Leave a Comment



4 + = 10