Introduction

In this post I will explain how to design a gear for 3D printing. "There are 4 main kinds of gears" (Tata, Basic Gear Fundamentals) but I'll be exploring the simplest one - a spur gear. You can run all the code in this article with the fantastic (and open source) modelling software: OpenSCAD. After reading this article you will hopefully have a better understanding of how a gear works conceptually and how you can design one yourself!

What parameters are required to make a gear?

Pressure Angle

Fact: every tooth in a working gear has the exact same "pressure angle". It is this property that allows the gear to have a repeatble and smooth point of contact. All gears with the same pressure angle can mesh together. So that's our first parameter.

Tooth Count

The second parameter is how many teeth you want the gear to have. This is pretty straightforward, however, "it is recommended that the minimum number of teeth be 16 for 14.5° pa and 13 for 20° pa" (Boston Gears).

Diametrical Pitch

The last parameter is diametrical pitch. This will essentially define how big the gear is. A higher diametrical pitch will result in a smaller, tighter gear. Remember that you can tweak this variable if you need to adjust the overall size of your gear sets.

It's important to keep in mind that pressure angle and diametrical pitch must be the same for all gears that will be meshing together.

The shape of the teeth is pretty non-negotiable, but easily derived using the parameters above. If you look at page 5 of Gear Theory (Boston Gears) you can see all the different formulas and how to calculate each one of them using a combination of known values.

To summarize, the common parameters you can tweak for a gear:

  • Tooth count
  • Pressure Angle
  • Diametrical Pitch

Other derived variables

On top of these common parameters, there are a number of derived values as well:

  • Dedendum - the base of the tooth up until it starts to angle according to the pressure-angle variable
  • Addendum - the total length of the angled part of the tooth
  • Base circle - the minimum diameter needed to accommodate a particular pressure-angle and diametrical pitch
  • Root circle - the exact diameter at which the gear teeth start forming
  • Pitch circle - the exact diameter at which the gear teeth start becomming angled
  • Whole Depth - the total depth of a fully generated gear tooth

Easy mistakes

NASA has published a great paper on Common Problems and Pitfalls in Gear Design (Townsend) which is definitely worth a read. In addition to their advice, I've discovered a few others that I'd like to share.

  • Units
    • Most 3D printers are all about SI units. Unfortunately, a lot of gear-related data that I read specifies Imperial US units. So be aware of that fact. The formulas in the documents I've linked are all computing inches and this is why I multiply a lot of factors by the "in_to_mm" constant.
  • Tolerances
    • This is not gear-specific but I recommend adding an additional 0.2mm to account for error tolerances with your 3D printer. Specifically, I make sure any circular holes include this offset (like the hole in the center of the gear).
  • Tooth count
    • When meshing two gears together, you can help them last longer by ensuring one of the gears has a slightly odd ratio. For example, if you have two gears: 16T and 32T. Each tooth will always mesh with the exact same tooth whenever they complete two full revolutions. You might consider instead 16T and 33T to ensure the point of contact is distributed evenly over time.

Verifying your gear

The very first gear set I printed turned out rather poorly. In the early iteration of my script, the teeth were positioned directly off of the Base Circle which seemed reasonable at the time. Upon closer inspection though, there's actually some additional padding baked into the gear formulas that I had missed.

How did I know my gears failed? Let's talk first about testing them.

Testing your gears physically

The simplest and least scientific strategy I discovered for testing your gears: put the two gears flat on your table top and have them roughly meshing. Select one gear (this will be your "driven" gear) and, using your fingers, anchor the gear to the table by gently applying pressure inside the bore of the gear at two separate points. Then with your other hand, rotate the "driver" gear and pay attention to how smooth the process is.

What does a bad connection look like? Well for one, if the gears aren't designed well you will notice a "hiccup" or "jumping" motion as they begin rotating. There's also an audible clicking sound which you'll detect if they're grinding too much.

A well designed gear should rotate smoothly. Each tiny motion of the driver gear should cause an equal displacement along the driven gear.

Testing your gears in code

There are three valuable diameters to know.

  • Base circle
  • Root circle
  • Pitch circle

At one point while coding the gear generator, I started adding circles with those diameter values to my output. This was the first trick which really helped me visualize why my gears were grinding.

You can tell if your distances are correct because:

The root circle should not be covering up the teeth at all. In fact, it should start at the base of the gear teeth.

The pitch circle should cover up about half of the length of each tooth. Right until the point when the 14.5° pa angle is beginning to jut out from the tooth.

Another reality check you can make is the final size of the gear. This is why I've got that echo statement in the script. For example: my 32T / 14.5° pa / 12 Diametrical pitch gear ends up being around 70mm.

OpenSCAD code

I wrote this helper method a while ago which is referenced in my gear generation script. It's fairly straightforward and the gist is that it will mirror some OpenSCAD object circularly (and equidistance) around an origin point.

Helper Method

module circular_mirror(x=0, y=0, d, steps) {
    aps = 360 / steps;
    for (step=[0:steps]) {
        current_angle = step * aps;
        unit_x = cos(current_angle);
        unit_y = sin(current_angle);
        translate([x, y, 0]) {
            translate([unit_x * d, unit_y * d, 0]) {
                rotate(current_angle) children();
            }
        }
    }
}

Once you've got that circular mirror method defined, you can see the actual gear generation script below.

Notice the top section defines all the variables. As mentioned earlier, Number of teeth, Diametrical pitch, and Pressure angle are the most useful factors to tweak.

Gear Generation

// Constants
in_to_mm = 25.4;
tol = .2;

/* Bore              */ bore = 45 + tol; // mm
/* Height            */ h = 5; // mm
/* Number of teeth   */ N = 32;
/* Diametrical pitch */ P = 12;
/* Pressure angle    */ pa = 14.5;

/* *********************
   Calculated Values (distances)
   *********************/
/* Whole depth                */ ht = (in_to_mm) * (2.157 / P); // in_to_mm * ((2.2 / P) + 0.002);
/* Addendum                   */ a = (1 / P) * in_to_mm;
/* Dedendum                   */ b = ht - a;
/* Pitch Circle (diameter)    */ D = (N / P) * in_to_mm;
/* Base Circle (diameter)     */ Db = D * cos(pa);
/* Root Circle (diameter)     */ Dr = D - (2 * b);

echo("Final size ~");
echo(D + a);

/* *********************
   Calculated Values (other)
   *********************/
/* Circular pitch    */ p = (3.1416 / P) * in_to_mm;
/* Tooth thickness   */ t = (1.5708 / P) * in_to_mm;
/* Clearance         */ c = ht - 2 * a;

module base_circle() {
    // NOTE:
    // The additional .2 is for tolerances
    // and might need to be changed
    circle(d=Dr + tol, $fn=100);
}

module tooth_mesh() {
    x = cos(90-pa) * a;
    xop = cos(90+pa) * a;
    polygon(
         points=[
            [-t,0],
            [-t + x, a],
            [xop, a],
            [0,0]
        ]
    );
}

module tooth() {
    rotate(90)
    translate([-t/2,Dr/2,0])
    union() {
        square([t,b]);
        translate([t,b]) tooth_mesh();
    }
}

module teeth() {
    circular_mirror(d=0, steps=N)
    tooth();
}

module gear() {
    teeth();
    base_circle();
}


module final() {
    difference() {
        gear();
        circle(d=bore, $fn=100);
    }
}

linear_extrude(height=h)
final();

Resources

Boston Gears. Gear Theory. Retrieved from https://www.bostongear.com/-/media/Files/Literature/Brand/boston-gear/catalogs/p-1930-bg-sections/p-1930-bg_engineering-info-spur-gears.ashx

Tata, R. P. Basic Gear Fundamentals . Retrieved January 7, 2020, from https://www.cedengineering.com/userfiles/Basic Gear Fundamentals.pdf.

Townsend, D. P. Common Problems and Pitfalls in Gear Design . Retrieved from https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19870007600.pdf.