Basic Flat Tooth Gear

This short tutorial will help you create a basic gear in OpenSCAD. The gear will need two cylinders to create the gear and a 3 sided polygon to create the teeth.

The concepts you can learn about in this Tutorial

  • cylinder()
  • circle()
  • linear_extrude()
  • difference()
  • for loop
  • translate()

We will actually start with the 2d items. It will be easier to create a triangular tooth using a 2d circle with 3 sides. The radius of the circle will be half of the “Whole Depth” of the gear. If we draw a line perpendicular to the “Root Diameter” to the “Pitch Diameter”, this will be equal to the radius we use.

circle(3,$fn=3);
Press f6 to see the 2d rendered version

Next we nee to give our gear tooth some meat. We will use linear_extrude() to add 3 Dimensions

linear_extrude(2) circle(3,$fn=3);

Then we will offset the circle using the translate, this will set the single gear to to it’s final diameter. When we rotate in OpenSCAD it is around the main Z-Axis. In order to rotate around our diameter we set tooth the diameter distance from the Z-Axis.

translate([18,0]) linear_extrude(2) circle(3,$fn=3);

Next we will repeat this cylinder around the Z axis.We will use the for loop to add the desired number of gear teeth and rotate() to position the tooth around the axis.

for(i=[1:1:20]){
     rotate([0,0,(360/20)*i])
     translate([18,0]) linear_extrude(2)
          circle(3,$fn=3);
}

Each time through the for loop, a triangle is added at Z angle. The Z angle is calculated by dividing 360 by the number of teeth, then multiply the resulting angle by the tooth we are on.

Next we can add a cylinder that will define the Root Diameter. This is a cylinder that extends all the way to the edges of the Gear Teeth.

cylinder(h=2,r=17);

Finally we will add a second cylinder that will remove the center with difference()

Press F6 to get the finished render.

difference() {
     cylinder(h=2,r=17);
     cylinder(h=2,r=3,$fn=25);
}

Here is the final code for our super basic gear.

difference() {
    cylinder(h=2,r=17);
    cylinder(h=2,r=3,$fn=25);
}

for(i=[1:1:20]){
    rotate([0,0,(360/20)*i])
    translate([18,0]) linear_extrude(2) 
        circle(3,$fn=3);
}

One Reply to “Basic Flat Tooth Gear”

  1. Nik

    This works fine enough for basic gears that are large enough.. But for smaller gears, I find using the triangles to cut-out/difference the teeth from the cylinder, works better than adding them on.
    Example:

    module Gear(){
    difference(){
    cylinder(h=5,r=10);
    for(i=[1:1:20]){
    rotate([0,0,(360/20)*i]) translate([-9,0,-.01]) cylinder(h=5.02,r=2,$fn=3);
    }
    }
    }

    0
    0

Leave a Reply