Tramming a CNC Router

To get the best performance out of your CNC machine, you need to "tram" it - this is the process that ensures that all axes are square.
It includes
- The X and Y movements are perpendicular
- The Z movement is perpendicular to the XY plane
- The spindle shaft is parallel to the Z axis
Most online tutorials describe an overly simplified process that almost exclusively focuses on checking if the spindle shaft is perpendicular to the XY plane. And worse, the prescribed method for correcting the alignment almost certainly gets the spindle out of parallel.
In practice this is often sufficient for 2D work, like if you are laser engraving or cutting 2D shapes from flat thin materials.
But if you are making precise 3D parts, you need to address all aspects of the tramming.
Here I will outline my own process. It is in reverse order from the list above
- Ensure that the spindle is parallel to the Z axis of movement
- With both of them parallel, we make the spindle perpendicular to the XY plane, which because of #1 means the Z axis is also perpendicular to XY
- Finally square up X and Y
Aligning the Spindle With the Z Axis





I think this is the trickiest and the most important step. If the spindle is not aligned with the Z axis, then it will move sideways when plunging. This leads to inaccurate cuts, chatter, and excessive wear.
To measure the error, first mount a dial indicator securely to the bed. I am using a 1-2-3 block that is bolted down with T-nuts, and the magnetic base of the dial is attached to the block.
Insert a straight metal rod in the spindle. I recommend something that could stick out at least 20-30 mm. I am using a 2" long 1/4" diameter steel pin. Touch the spindle to the top of the pin and zero it out.
Then move the Z up by 20mm. Measure the error.
In this example the error is 0.13mm, indicating that the spindle is tilted away from us.
Since the spindle mounting bracket is 50mm tall, I multiplied 0.13 by 2.5 and that gives me an error of 0.33mm over the entire height of the bracket. This means I have to shim the top of the spindle bracket by that thickness.
Note: You can try flipping the spindle bracket upside down. The assembly has multiple parts, each contributing its own error. Flipping the bracket might cause the errors to cancel out. In my case this simply reversed the direction of the error, indicating that all of the error comes from the bracket itself - the opening for the spindle was just not parallel to the face of the bracket. There’s no other way but to shim.
I made a shim out of thin plastic material. After shimming, the new error became 0.02 over 20mm, which I find acceptable.
The second half of this step is to align the spindle side to side. The measurement step is the same, just put the indicator sideways.
Correcting the sideways error is easier. Basically, just loosen the bolts of the bracket and give it a little push. Measure, repeat, until you are happy with the result.
Once you are done, fully tighten the bracket to the Z plate and never touch it again.
Aligning the Spindle With the XY Plane




Now that we ensured that the spindle and the Z axis are parallel, we can indeed use the spindle to align the Z, as long as we don’t disturb the spindle bracket.
The traditional method relies on creating a reference surface that is parallel to the XY plane. Most often this is achieved by pre-surfacing the spoilboard. It can create a rough surface because the spindle is not trammed yet, but it will generally be parallel to XY on the macro level. Some tutorials suggest placing a flat material on the table (like a glass or granite plate), then shimming it in the corners until it is parallel.
After you get the reference surface, you mount a tramming tool on the spindle and check if it rubs equally over the surface as it spins. More advanced examples use a tramming tool with a mounted dial indicator for greater precision.
I have a better method that doesn’t rely on creating a plane. You only need a single fixed point in space. Then you move the spindle around it. This is geometrically equivalent to the old method. Also, we don’t need a dial indicator. CNCs already have a way of measuring heights using the Z probe.
First, create a simple tramming tool. I made one from a 3D printed part, an old 1/8" endmill and a small V-bit. They are secured with M3 screws and nuts. There is 100mm between the two holes. An all-metal version will be even better as it will eliminate errors due to flexing.
The real goal of the tool is to exaggerate the error. Having a nice round distance of 100mm between the holes makes it easy to do the math.
Next, jog the machine somewhere in the middle and zero out both X and Y. Place the Z-probe in that location. If you have a way to attach it firmly to the surface, like with double-sided tape, even better.
Move the machine 100mm to the left. Insert the tramming tool in the spindle. Rotate it so the V bit is above the Z probe and connect the cable. Run the following G code.
The first line will probe down for 5mm, and the second will retract 2mm up.
Zero out your work Z. Jog 200mm to the right, rotating the tramming tool 180 degrees.
Warning: When moving between the left and right locations, be careful not to push on the tool. It is plastic and can flex, which will skew the results. Also be careful not to tangle the probe wires while the machine is in motion.
Then run the G code again to measure the new height. The new Z will be the difference between the two heights, which will give you the error over 200mm.
To correct the error, you need to push the top of the Z assembly in the direction of the higher Z value.
This is where most tutorials go wrong, as they recommend twisting the spindle bracket directly. Do not loosen the spindle bracket! We worked so hard to align it in step 1.
The actual correct method depends on your exact CNC model. For my Fox Alien Vasto you have to loosen the bolts that hold the Z assembly to the X gantry. One of the bolts is behind the limit switch, which needs to be temporarily moved aside. Wiggle the Z assembly a bit, and retighten.
Repeat the measurements and readjust as necessary. The process is fiddly and will take a few iterations. Fully tighten the bolts when done.
Afterwards, repeat the process but in the Y direction. Take two measurements - front and back.
Specific to Fox Alien Vasto: To adjust in that direction, loosen the bolts on both sides that hold the X rails to the orange Y plates. Twist a little bit in the direction of the error.
If you’ve exhausted all the slop in the bolts, and there is still error to be corrected, you will have to create a shim between the Z assembly and the X gantry.
Finally, run the measurements in all 4 directions. If you get Z values that are close enough, you are done.
The advantage of this method is that all measurements are taken from the same point on the surface. It doesn't rely on the bed being level, or even flat.
You can now surface the spoilboard. Take a few height measurements along the surface to find the highest and lowest point. Run one or more flattening passes from the highest level to slightly below the lowest (let's say 0.2mm lower). You will get a fresh, flat, and trammed surface.
Downloads
Aligning X and Y



Finally, let's check if the X and Y are perpendicular. The instructions described here apply mostly for CNC machines that have dual Y axis, with one carriage on each side. For other CNC designs the measurement process will still apply, but the correction steps will be different.
For dual Y machines: Move the gantry close to the front, then use a caliper to measure the distance between the front and the two carriages. If they are more than 1mm apart, adjust Y1 or Y2 to get them closer. When the machine is powered on, the motors are energized to hold position. It will be easier to rotate by hand if you turn off the power.
Now let's measure the exact error between X and Y. There are two ways to do it.
First approach is to cut a piece of wood along X and Y, let’s say a box that is 100x100mm. Then check it with a known good carpenter square and a feeler gauge. Once you’ve determined the error over 100mm, scale it up to the actual distance between Y1 and Y2. In my case they are 600mm apart, so I have to multiply by 6.
Second approach is to use a large metal object that is known to be square. I used my cast iron combination square. Put a flat endmill in the spindle, or even better, a smooth metal pin. Connect one end of the probe to the object and the other to the endmill.
Use the following G code to locate the X along the side of the object.
The first line moves 5mm in negative X direction until it encounters a contact. The second line retracts 2mm in positive X direction.
My procedure is the following. Position the pin close to the near end of the object. Run the G code until it makes contact on the left side. If there is no contact within 5mm, the machine will error out. Don’t worry, clear the error and go again until the probe makes contact. Zero out X. Then move Y forward to the far end of the object. Measure again. The new X coordinate will be the difference between the two measurements. If it is not close to zero, adjust the position of the object and repeat the procedure until you get it right.
This will ensure you have one edge that is parallel to the Y axis front to back. Therefore the other edge is perpendicular and can be used for checking the X axis.
Next, take two measurements along the X axis, ideally at least 100mm apart. Use this G code.
Compute the difference between the two X positions. Scale it up by the ratio between the sample distance (e.g. 100mm) and the width of the machine (e.g. 600mm). That's your error from side to side. If the error is more than the precision you need, you have to fix the machine.
For dual Y machines: Pick one of the sides (Y1 or Y2) and decide how much you need to move it and in which direction. Temporarily disconnect the other motor (either at the back of the machine or at the back of the control box). Use your control software to move the Y by the computed amount. Only the motor that is still connected will move. Use slow jog rate and be prepared to abort in case something moves too far or in the wrong direction. When done, reconnect the cable to the other motor right away. If you forget to connect the motor, next time you jog the Y axis only one side will move. The X axis will twist, jam, and possibly damage something.
Warning: Ideally you should turn off the power to the control box while disconnecting and reconnecting motors because there’s high current going through them and you will get a spark.
Now your X axis should be perpendicular to Y. Run the measurement again to verify. Repeat the fix if necessary.
Final Thoughts
Most consumer grade CNC routers are not super rigid. So even if you achieve the perfect tram, it will not survive the first cut you do. Things are bound to move a bit. So don't stress about getting all errors down to zero.
Still, having a well aligned machine is important. You will get better results with less effort and wear.