//An involute spur gear, with reasonable defaults for all the parameters. //Normally, you should just choose the first 4 parameters, and let the rest be default values. //Meshing gears must match in mm_per_tooth, pressure_angle, and twist, //and be separated by the sum of their pitch radii, which can be found with pitch_radius(). module gear ( mm_per_tooth = 3, //this is the "circular pitch", the circumference of the pitch circle divided by the number of teeth number_of_teeth = 11, //total number of teeth around the entire perimeter thickness = 6, //thickness of gear in mm hole_diameter = 3, //diameter of the hole in the center, in mm twist = 0, //teeth rotate this many degrees from bottom of gear to top. 360 makes the gear a screw with each thread going around once teeth_to_hide = 0, //number of teeth to delete to make this only a fraction of a circle pressure_angle = 28, //Controls how straight or bulged the tooth sides are. In degrees. clearance = 0.0, //gap between top of a tooth on one gear and bottom of valley on a meshing gear (in millimeters) backlash = 0.0 //gap between two meshing teeth, in the direction along the circumference of the pitch circle ) { pi = 3.1415926; p = mm_per_tooth * number_of_teeth / pi / 2; // radius of pitch circle c = p + mm_per_tooth / pi - clearance; // radius of outer circle b = p*cos(pressure_angle); // radius of base circle r = p-(c-p)-clearance; // radius of root circle t = mm_per_tooth/2-backlash/2; // tooth thickness at pitch circle k = -iang(b, p) - t/2/p/pi*180; // angle to where involute meets base circle on each side of tooth { difference() { for (i = [0:number_of_teeth-teeth_to_hide-1] ) rotate([0,0,i*360/number_of_teeth]) linear_extrude(height = thickness, center = true, convexity = 10, twist = twist) polygon( points=[ [0, -hole_diameter/10], polar(r, -181/number_of_teeth), polar(r, r