Why a 5 mm peg doesn't fit a 5 mm hole
Files: linear-actuator-with-mg90 on GitHub (STEP and Fusion archive) · Watch: 3D-printed linear actuator · Belt-driven linear rail with servo Z axis
Files: linear-actuator-with-mg90 on GitHub (STEP and Fusion archive) · Watch: 3D-printed linear actuator · Belt-driven linear rail with servo Z axis
In CAD, a 5 mm peg fits a 5 mm hole perfectly. On a 3D printer, it doesn’t fit at all. Any printed mechanism, like the MG90S rack-and-pinion actuator in this post, comes down to the same lesson: you don’t design the size you want, you design the size the printer will give you.
Why holes come out small
Three things shrink a printed hole, and they all push the same way.
The export. STL files have no circles, only flat triangles. When you export, a round hole becomes a polygon with its corners on the circle and its flat sides inside it. Across the flats, a 5 mm hole is smaller than 5 mm:
| Sides | Across the flats |
|---|---|
| 12 | 4.83 mm |
| 16 | 4.90 mm |
| 32 | 4.98 mm |
Fusion’s STL export has a refinement setting. Use high for anything that has to fit.
The plastic. A printed line isn’t a sharp edge. It’s a squashed, rounded bead of plastic, and around a small curve the inside of that bead bulges inwards. Holes come out a little small, and outside edges a little big. How much depends on your printer, nozzle and material, which is exactly why you measure instead of guessing.
The first layers. The bottom layers get pressed into the bed and spread outwards, the “elephant’s foot”. A peg printed standing up gets a lip at its base that won’t go into anything.
Holes printed sideways, with their axis flat on the bed, have one more problem: the top of the hole is an overhang, and it sags. The hole comes out slightly oval and short from top to bottom. A teardrop-shaped hole, with a point at the top, prints much cleaner.
Clearance is a parameter, not a fix
The answer is to design in a gap, called clearance, and to make it a named parameter like in the Fusion post:
shaft_d = 5 mm
fit_sliding = 0.3 mm
hole_d = shaft_d + fit_sliding
When the first print is too tight, you change fit_sliding once, and every hole that uses it updates.
These are common places to start for PLA with a 0.4 mm nozzle on a decently tuned printer. Your printer will disagree a little, which is the point of the next section.
| Fit | Used for | Start with (on the diameter) |
|---|---|---|
| Press fit | magnets, bearings in a housing | 0 to 0.1 mm |
| Snug | a pinion on a shaft, a pin you push in by hand | 0.15 to 0.2 mm |
| Sliding | a rack in its guide, parts that telescope | 0.3 to 0.4 mm |
| Loose | print-in-place hinges | 0.5 mm or more |
Test strips before real parts
A full actuator body can take hours to print. A test strip takes minutes. Before printing a part that has to fit, I’d print a small bar with the same hole at several clearances, say +0.1, +0.2, +0.3 and +0.4 mm, plus a matching peg. Each hole’s sketch dimension references the parameter (shaft_d + 0.1 mm and so on), so it stays in sync with the real design.
Print it the same way round as the real part, in the same material. A hole printed flat and a hole printed sideways are not the same hole.
Check the printer itself first, though. If a 20 mm calibration cube doesn’t measure 20 mm in both X and Y, or its two diagonals differ, the printer is out of square or out of calibration. Then every fit depends on which way the part faces, and no clearance value will be right for all of them.
Racks and gears that actually mesh
A rack and pinion turns the servo’s rotation into a straight push, and it has its own rules.
Same module on both. The module is the tooth size in millimetres. A pinion’s pitch diameter is module × teeth, and the rack’s teeth repeat every π × module. If the module doesn’t match, the teeth don’t fit, however carefully everything else is sized.
Travel from angle. The rack moves by the pinion’s pitch circumference times the fraction of a turn. For example, a module 1 pinion with 20 teeth has a 20 mm pitch diameter, so a 180° sweep of the servo moves the rack:
const travel = (module, teeth, degrees) =>
Math.PI * module * teeth * (degrees / 360);
travel(1, 20, 180); // 31.4 mm
That’s the trade-off in one line: a bigger pinion gives more travel but less push, because the servo’s torque acts over a longer lever.
Generate the gear, draw the rack. Fusion comes with a SpurGear sample script (under Utilities, Add-Ins, Scripts and Add-Ins) that builds a pinion from module, tooth count and pressure angle. There’s no built-in rack, but one tooth sketched to the same module and patterned every π × module along a line works fine for small loads.
Leave room between the teeth. Printed teeth are a little fat, for the same reason holes are a little small. Moving the rack a tenth or two of a millimetre away from the theoretical pitch line stops them binding.
Print teeth flat. Lay a gear flat, and turn a rack on its side, so the tooth outline is drawn by the nozzle within a layer. If the teeth are built up from stacked layers instead, they come out stepped and rough.
The MG90S pocket
The actuator’s README lists the MG90S body as 22.5 × 12 × 35.5 mm. That’s the size of the servo, not the size of the hole it goes in. A pocket drawn at exactly 22.5 × 12 mm won’t take it. A pocket at the servo’s size plus a snug or sliding fit will, and it’s the same parameter trick again.
All of this comes down to one habit: treat the printer like a dependency with known quirks, and design for the version of it you actually have.