Hendrik Langer
7 years ago
commit
6fe51f4944
8 changed files with 119172 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||
|
#define COUNT_LOW 2400 |
||||
|
#define COUNT_HIGH 8500 |
||||
|
|
||||
|
#define SERVO_CHANNEL 5 |
||||
|
|
||||
|
#define TIMER_WIDTH 16 |
||||
|
|
||||
|
#include "esp32-hal-ledc.h" |
||||
|
|
||||
|
void setup() { |
||||
|
ledcSetup(1, 50, TIMER_WIDTH); |
||||
|
ledcAttachPin(SERVO_CHANNEL,1); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void loop() { |
||||
|
for (int i = COUNT_LOW; i < COUNT_HIGH; i+=20) { |
||||
|
ledcWrite(1, i); |
||||
|
delay(10); |
||||
|
} |
||||
|
for (int i = COUNT_HIGH; i > COUNT_LOW+100; i-=20) { |
||||
|
ledcWrite(1, i); |
||||
|
delay(10); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,213 @@ |
|||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
// Public Domain Parametric Involute Spur Gear (and involute helical gear and involute rack) |
||||
|
// version 1.1 |
||||
|
// by Leemon Baird, 2011, Leemon@Leemon.com |
||||
|
//http://www.thingiverse.com/thing:5505 |
||||
|
// |
||||
|
// This file is public domain. Use it for any purpose, including commercial |
||||
|
// applications. Attribution would be nice, but is not required. There is |
||||
|
// no warranty of any kind, including its correctness, usefulness, or safety. |
||||
|
// |
||||
|
// This is parameterized involute spur (or helical) gear. It is much simpler and less powerful than |
||||
|
// others on Thingiverse. But it is public domain. I implemented it from scratch from the |
||||
|
// descriptions and equations on Wikipedia and the web, using Mathematica for calculations and testing, |
||||
|
// and I now release it into the public domain. |
||||
|
// |
||||
|
// http://en.wikipedia.org/wiki/Involute_gear |
||||
|
// http://en.wikipedia.org/wiki/Gear |
||||
|
// http://en.wikipedia.org/wiki/List_of_gear_nomenclature |
||||
|
// http://gtrebaol.free.fr/doc/catia/spur_gear.html |
||||
|
// http://www.cs.cmu.edu/~rapidproto/mechanisms/chpt7.html |
||||
|
// |
||||
|
// The module gear() gives 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. |
||||
|
// The module gear() gives a gear in the XY plane, centered on the origin, with one tooth centered on |
||||
|
// the positive Y axis. The various functions below it take the same parameters, and return various |
||||
|
// measurements for the gear. The most important is pitch_radius, which tells how far apart to space |
||||
|
// gears that are meshing, and adendum_radius, which gives the size of the region filled by the gear. |
||||
|
// A gear has a "pitch circle", which is an invisible circle that cuts through the middle of each |
||||
|
// tooth (though not the exact center). In order for two gears to mesh, their pitch circles should |
||||
|
// just touch. So the distance between their centers should be pitch_radius() for one, plus pitch_radius() |
||||
|
// for the other, which gives the radii of their pitch circles. |
||||
|
// |
||||
|
// In order for two gears to mesh, they must have the same mm_per_tooth and pressure_angle parameters. |
||||
|
// mm_per_tooth gives the number of millimeters of arc around the pitch circle covered by one tooth and one |
||||
|
// space between teeth. The pitch angle controls how flat or bulged the sides of the teeth are. Common |
||||
|
// values include 14.5 degrees and 20 degrees, and occasionally 25. Though I've seen 28 recommended for |
||||
|
// plastic gears. Larger numbers bulge out more, giving stronger teeth, so 28 degrees is the default here. |
||||
|
// |
||||
|
// The ratio of number_of_teeth for two meshing gears gives how many times one will make a full |
||||
|
// revolution when the the other makes one full revolution. If the two numbers are coprime (i.e. |
||||
|
// are not both divisible by the same number greater than 1), then every tooth on one gear |
||||
|
// will meet every tooth on the other, for more even wear. So coprime numbers of teeth are good. |
||||
|
// |
||||
|
// The module rack() gives a rack, which is a bar with teeth. A rack can mesh with any |
||||
|
// gear that has the same mm_per_tooth and pressure_angle. |
||||
|
// |
||||
|
// Some terminology: |
||||
|
// The outline of a gear is a smooth circle (the "pitch circle") which has mountains and valleys |
||||
|
// added so it is toothed. So there is an inner circle (the "root circle") that touches the |
||||
|
// base of all the teeth, an outer circle that touches the tips of all the teeth, |
||||
|
// and the invisible pitch circle in between them. There is also a "base circle", which can be smaller than |
||||
|
// all three of the others, which controls the shape of the teeth. The side of each tooth lies on the path |
||||
|
// that the end of a string would follow if it were wrapped tightly around the base circle, then slowly unwound. |
||||
|
// That shape is an "involute", which gives this type of gear its name. |
||||
|
// |
||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
|
||||
|
//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 |
||||
|
cut_circles = 0 |
||||
|
) { |
||||
|
assign(pi = 3.1415926) |
||||
|
assign(p = mm_per_tooth * number_of_teeth / pi / 2) //radius of pitch circle |
||||
|
assign(c = p + mm_per_tooth / pi - clearance) //radius of outer circle |
||||
|
assign(b = p*cos(pressure_angle)) //radius of base circle |
||||
|
assign(r = p-(c-p)-clearance) //radius of root circle |
||||
|
assign(t = mm_per_tooth/2-backlash/2) //tooth thickness at pitch circle |
||||
|
assign(k = -iang(b, p) - t/2/p/pi*180) { //angle to where involute meets base circle on each side of tooth |
||||
|
difference() { |
||||
|
union() { |
||||
|
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<b ? k : -180/number_of_teeth), |
||||
|
q7(0/5,r,b,c,k, 1),q7(1/5,r,b,c,k, 1),q7(2/5,r,b,c,k, 1),q7(3/5,r,b,c,k, 1),q7(4/5,r,b,c,k, 1),q7(5/5,r,b,c,k, 1), |
||||
|
q7(5/5,r,b,c,k,-1),q7(4/5,r,b,c,k,-1),q7(3/5,r,b,c,k,-1),q7(2/5,r,b,c,k,-1),q7(1/5,r,b,c,k,-1),q7(0/5,r,b,c,k,-1), |
||||
|
polar(r, r<b ? -k : 180/number_of_teeth), |
||||
|
polar(r, 181/number_of_teeth) |
||||
|
], |
||||
|
paths=[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]] |
||||
|
); |
||||
|
cylinder(r=b,h=thickness, center=true); |
||||
|
} |
||||
|
cylinder(h=2*thickness+1, r=hole_diameter/2, center=true, $fn=20); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
//these 4 functions are used by gear |
||||
|
function polar(r,theta) = r*[sin(theta), cos(theta)]; //convert polar to cartesian coordinates |
||||
|
function iang(r1,r2) = sqrt((r2/r1)*(r2/r1) - 1)/3.1415926*180 - acos(r1/r2); //unwind a string this many degrees to go from radius r1 to radius r2 |
||||
|
function q7(f,r,b,r2,t,s) = q6(b,s,t,(1-f)*max(b,r)+f*r2); //radius a fraction f up the curved side of the tooth |
||||
|
function q6(b,s,t,d) = polar(d,s*(iang(b,d)+t)); //point at radius d on the involute curve |
||||
|
|
||||
|
//a rack, which is a straight line with teeth (the same as a segment from a giant gear with a huge number of teeth). |
||||
|
//The "pitch circle" is a line along the X axis. |
||||
|
module rack ( |
||||
|
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 along the rack |
||||
|
thickness = 6, //thickness of rack in mm (affects each tooth) |
||||
|
height = 120, //height of rack in mm, from tooth top to far side of rack. |
||||
|
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 |
||||
|
pressure_angle = 28, //Controls how straight or bulged the tooth sides are. In degrees. |
||||
|
backlash = 0.0 //gap between two meshing teeth, in the direction along the circumference of the pitch circle |
||||
|
) { |
||||
|
assign(pi = 3.1415926) |
||||
|
assign(a = mm_per_tooth / pi) //addendum |
||||
|
assign(t = a*tan(pressure_angle)) //tooth side is tilted so top/bottom corners move this amount |
||||
|
assign(shift = -thickness*2*tan(twist)) |
||||
|
union() { |
||||
|
for (i = [0:number_of_teeth-1] ) |
||||
|
translate([i*mm_per_tooth,0,-thickness/2]) |
||||
|
//linear_extrude(height = thickness, center = true, convexity = 10) |
||||
|
polyhedron( |
||||
|
points=[ |
||||
|
[-mm_per_tooth * 3/4, a-height, 0], // 0 |
||||
|
[-mm_per_tooth * 3/4 - backlash, -a, 0], |
||||
|
[-mm_per_tooth * 1/4 + backlash - t, -a, 0], |
||||
|
[-mm_per_tooth * 1/4 + backlash + t, a, 0], |
||||
|
[ mm_per_tooth * 1/4 - backlash - t, a, 0], |
||||
|
[ mm_per_tooth * 1/4 - backlash + t, -a, 0], |
||||
|
[ mm_per_tooth * 3/4 + backlash, -a, 0], |
||||
|
[ mm_per_tooth * 3/4, a-height, 0], // 7 |
||||
|
[-mm_per_tooth * 3/4 + shift, a-height, thickness], |
||||
|
[-mm_per_tooth * 3/4 - backlash + shift, -a, thickness], |
||||
|
[-mm_per_tooth * 1/4 + backlash - t + shift, -a, thickness], |
||||
|
[-mm_per_tooth * 1/4 + backlash + t + shift, a, thickness], |
||||
|
[ mm_per_tooth * 1/4 - backlash - t + shift, a, thickness], |
||||
|
[ mm_per_tooth * 1/4 - backlash + t + shift, -a, thickness], |
||||
|
[ mm_per_tooth * 3/4 + backlash + shift, -a, thickness], |
||||
|
[ mm_per_tooth * 3/4 + shift, a-height, thickness], |
||||
|
], |
||||
|
faces=[ |
||||
|
[7,6,5,4,3,2,1,0], // bottom |
||||
|
[0,1,9,8], // side |
||||
|
[1,2,10,9], |
||||
|
[2,3,11,10], |
||||
|
[3,4,12,11], |
||||
|
[4,5,13,12], |
||||
|
[5,6,14,13], |
||||
|
[6,7,15,14], // side |
||||
|
[7,0,8,15], // back |
||||
|
[8,9,10,11,12,13,14,15], // top |
||||
|
]); |
||||
|
translate([(number_of_teeth-2)*mm_per_tooth/2,-(height)/2,0]) cube([(number_of_teeth+2)*mm_per_tooth,height-2*a,thickness], center=true); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
//These 5 functions let the user find the derived dimensions of the gear. |
||||
|
//A gear fits within a circle of radius outer_radius, and two gears should have |
||||
|
//their centers separated by the sum of their pictch_radius. |
||||
|
function circular_pitch (mm_per_tooth=3) = mm_per_tooth; //tooth density expressed as "circular pitch" in millimeters |
||||
|
function diametral_pitch (mm_per_tooth=3) = 3.1415926 / mm_per_tooth; //tooth density expressed as "diametral pitch" in teeth per millimeter |
||||
|
function module_value (mm_per_tooth=3) = mm_per_tooth / pi; //tooth density expressed as "module" or "modulus" in millimeters |
||||
|
function pitch_radius (mm_per_tooth=3,number_of_teeth=11) = mm_per_tooth * number_of_teeth / 3.1415926 / 2; |
||||
|
function outer_radius (mm_per_tooth=3,number_of_teeth=11,clearance=0.1) //The gear fits entirely within a cylinder of this radius. |
||||
|
= mm_per_tooth*(1+number_of_teeth/2)/3.1415926 - clearance; |
||||
|
|
||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
//example gear train. |
||||
|
//Try it with OpenSCAD View/Animate command with 20 steps and 24 FPS. |
||||
|
//The gears will continue to be rotated to mesh correctly if you change the number of teeth. |
||||
|
|
||||
|
n1 = 33; //red gear number of teeth |
||||
|
n1_2 = 13; |
||||
|
n2 = 33; //green gear |
||||
|
n3 = 5; //blue gear |
||||
|
n4 = 20; //orange gear |
||||
|
n5 = 50; //gray rack |
||||
|
n_servo = 20; |
||||
|
mm_per_tooth = 3.33; //all meshing gears need the same mm_per_tooth (and the same pressure_angle) |
||||
|
thickness = 5; |
||||
|
thickness_servo = 3; |
||||
|
hole = 5+0.2; |
||||
|
hole_screw = 2; |
||||
|
kopf_screw = 1.5; |
||||
|
height = 12; |
||||
|
twist = 8; |
||||
|
|
||||
|
d1 =pitch_radius(mm_per_tooth,n1); |
||||
|
d12=pitch_radius(mm_per_tooth,n1_2) + pitch_radius(mm_per_tooth,n2); |
||||
|
d13=pitch_radius(mm_per_tooth,n1) + pitch_radius(mm_per_tooth,n3); |
||||
|
d14=pitch_radius(mm_per_tooth,n1) + pitch_radius(mm_per_tooth,n4); |
||||
|
/* |
||||
|
translate([ 0, 0, 0]) rotate([0,0, $t*360/n1]) color([1.00,0.75,0.75]) gear(mm_per_tooth,n1,thickness,hole, twist); |
||||
|
echo("pitch_radius of n1 is: ", d1); |
||||
|
translate([ 0, 0, thickness]) rotate([0,0, $t*360/n1]) color([1.00,0.75,0.75]) gear(mm_per_tooth,n1_2,thickness,hole, twist); |
||||
|
|
||||
|
difference() { |
||||
|
translate([ 0, d12, thickness]) rotate([0,0,-($t+n2/2-0*n1+1/2)*360/n2]) color([0.75,1.00,0.75]) gear(mm_per_tooth,n2,thickness,hole_screw,twist,108); // servo gear |
||||
|
translate([ 0, d12, (thickness)/2]) color([0.75,1.00,0.75]) cylinder(r=4.5/2, h=kopf_screw*2, center=true, $fn=100); |
||||
|
translate([ 0, d12, thickness*1.5]) rotate([0,0,-($t+n2/2-0*n1+1/2)*360/n2]) color([0.75,1.00,0.75]) gear(0.79,n_servo,thickness_servo*2,0,0,108); // servo gear |
||||
|
}; |
||||
|
echo("pitch radius of servo bearing is: ", pitch_radius(0.79, n_servo)); |
||||
|
*/ |
||||
|
translate([mm_per_tooth*(-floor(n5/2)-floor(n1/2)+$t+n1/(3/2)-1/2)+100, +d1+0.0, 0]) rotate([0,0,180]) color([0.75,0.75,0.75]) rack(mm_per_tooth,n5,thickness,height, twist); |
||||
|
|
@ -0,0 +1,104 @@ |
|||||
|
box_x = 70; |
||||
|
box_y = 55; |
||||
|
box_z = 16+10; |
||||
|
wall_thickness=0.8; |
||||
|
inner_screw=1; // TODO! |
||||
|
gear_distance = 24.6; |
||||
|
gear_thickness = 5; |
||||
|
|
||||
|
module outer_old() { |
||||
|
$fn=50; |
||||
|
minkowski() { |
||||
|
cube([box_x,box_y,box_z]); |
||||
|
cylinder(r=wall_thickness,h=1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module inner_old() { |
||||
|
$fn=50; |
||||
|
translate([wall_thickness,wall_thickness,wall_thickness]) |
||||
|
minkowski() { |
||||
|
cube([box_x-2*wall_thickness,box_y-2*wall_thickness,box_z]); |
||||
|
cylinder(r=wall_thickness,h=1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module outer() { |
||||
|
$fn=50; |
||||
|
cylinder(r=40/2+wall_thickness,h=box_z); |
||||
|
translate([gear_distance,0,0]) cylinder(r=40/2+wall_thickness,h=box_z); |
||||
|
translate([0,-(40/2+wall_thickness),0]) cube([gear_distance,40+wall_thickness*2,box_z]); |
||||
|
} |
||||
|
|
||||
|
module inner() { |
||||
|
$fn=50; |
||||
|
translate([0,0,wall_thickness]) cylinder(r=40/2,h=box_z); |
||||
|
translate([gear_distance,0,wall_thickness]) cylinder(r=40/2,h=box_z); |
||||
|
translate([0,-(40/2),box_z-wall_thickness]) cube([gear_distance,40,5]); |
||||
|
} |
||||
|
|
||||
|
module servo() { |
||||
|
$fn=50; |
||||
|
translate([6,0,0]) |
||||
|
{ |
||||
|
cube([22.5+0.5,12+0.5,33.5-5.5],center=true); // body |
||||
|
translate([0,0,28/2-3]) cube([32.5,12.5,2.5],center=true); // bracket |
||||
|
translate([-6,0,-14]) cylinder(r=2.8,h=35.5); // bearing |
||||
|
translate([27.5/2,0,5]) cylinder(r=inner_screw,h=10); // screw |
||||
|
translate([-27.5/2,0,5]) cylinder(r=inner_screw,h=10); // screw |
||||
|
translate([-22.5/2-0.6,0,0]) cube([1.2,4,28],center=true); // cable |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module space() { |
||||
|
$fn=50; |
||||
|
translate([6,0,0]) |
||||
|
//translate([27.5/2,0,28/2-3]) cylinder(r=inner_screw*2.2,h=9); // place to screw |
||||
|
translate([0,0,28/2-3+4.5+2.5]) cube([32.5-0.3,12.5,2.5+9],center=true); // place to screw |
||||
|
} |
||||
|
|
||||
|
module servo_bracket() { |
||||
|
$fn=50; |
||||
|
minkowski() { |
||||
|
translate([6,0,3]) cube([22.5+0.5+9-wall_thickness*2,12+0.5-wall_thickness*2,6],center=true); // body |
||||
|
cylinder(r=wall_thickness,h=1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module gear_bearing() { |
||||
|
$fn = 50; |
||||
|
cylinder(r=10/2,h=6+2.5+1.5+gear_thickness); |
||||
|
cylinder(r=5/2,h=box_z-wall_thickness); |
||||
|
} |
||||
|
|
||||
|
module lid_screws() { |
||||
|
$fn = 50; |
||||
|
translate([gear_distance/2,40/2-2,box_z-8]) cylinder(r=inner_screw,h=8); |
||||
|
translate([gear_distance/2,-(40/2-2),box_z-8]) cylinder(r=inner_screw,h=8); |
||||
|
} |
||||
|
|
||||
|
module box() { |
||||
|
difference() { |
||||
|
outer(); |
||||
|
inner(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module rod() { |
||||
|
translate([20-7.5-16,-100,6+2.5+1.5+gear_thickness*2]) cube([12+0.4,173.2+0.4,5+0.4+1]); |
||||
|
} |
||||
|
|
||||
|
difference() { |
||||
|
union() { |
||||
|
box(); |
||||
|
translate([0,0,0]) servo_bracket(); |
||||
|
translate([gear_distance,0,0]) gear_bearing(); |
||||
|
} |
||||
|
translate([0,0,-4]) servo(); |
||||
|
translate([0,0,-4]) space(); |
||||
|
lid_screws(); |
||||
|
rod(); |
||||
|
} |
||||
|
%translate([0,0,-4]) servo(); |
||||
|
%rod(); |
||||
|
//translate([20,0,box_z-10-wall_thickness]) cube([10,10,10]); |
@ -0,0 +1,213 @@ |
|||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
// Public Domain Parametric Involute Spur Gear (and involute helical gear and involute rack) |
||||
|
// version 1.1 |
||||
|
// by Leemon Baird, 2011, Leemon@Leemon.com |
||||
|
//http://www.thingiverse.com/thing:5505 |
||||
|
// |
||||
|
// This file is public domain. Use it for any purpose, including commercial |
||||
|
// applications. Attribution would be nice, but is not required. There is |
||||
|
// no warranty of any kind, including its correctness, usefulness, or safety. |
||||
|
// |
||||
|
// This is parameterized involute spur (or helical) gear. It is much simpler and less powerful than |
||||
|
// others on Thingiverse. But it is public domain. I implemented it from scratch from the |
||||
|
// descriptions and equations on Wikipedia and the web, using Mathematica for calculations and testing, |
||||
|
// and I now release it into the public domain. |
||||
|
// |
||||
|
// http://en.wikipedia.org/wiki/Involute_gear |
||||
|
// http://en.wikipedia.org/wiki/Gear |
||||
|
// http://en.wikipedia.org/wiki/List_of_gear_nomenclature |
||||
|
// http://gtrebaol.free.fr/doc/catia/spur_gear.html |
||||
|
// http://www.cs.cmu.edu/~rapidproto/mechanisms/chpt7.html |
||||
|
// |
||||
|
// The module gear() gives 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. |
||||
|
// The module gear() gives a gear in the XY plane, centered on the origin, with one tooth centered on |
||||
|
// the positive Y axis. The various functions below it take the same parameters, and return various |
||||
|
// measurements for the gear. The most important is pitch_radius, which tells how far apart to space |
||||
|
// gears that are meshing, and adendum_radius, which gives the size of the region filled by the gear. |
||||
|
// A gear has a "pitch circle", which is an invisible circle that cuts through the middle of each |
||||
|
// tooth (though not the exact center). In order for two gears to mesh, their pitch circles should |
||||
|
// just touch. So the distance between their centers should be pitch_radius() for one, plus pitch_radius() |
||||
|
// for the other, which gives the radii of their pitch circles. |
||||
|
// |
||||
|
// In order for two gears to mesh, they must have the same mm_per_tooth and pressure_angle parameters. |
||||
|
// mm_per_tooth gives the number of millimeters of arc around the pitch circle covered by one tooth and one |
||||
|
// space between teeth. The pitch angle controls how flat or bulged the sides of the teeth are. Common |
||||
|
// values include 14.5 degrees and 20 degrees, and occasionally 25. Though I've seen 28 recommended for |
||||
|
// plastic gears. Larger numbers bulge out more, giving stronger teeth, so 28 degrees is the default here. |
||||
|
// |
||||
|
// The ratio of number_of_teeth for two meshing gears gives how many times one will make a full |
||||
|
// revolution when the the other makes one full revolution. If the two numbers are coprime (i.e. |
||||
|
// are not both divisible by the same number greater than 1), then every tooth on one gear |
||||
|
// will meet every tooth on the other, for more even wear. So coprime numbers of teeth are good. |
||||
|
// |
||||
|
// The module rack() gives a rack, which is a bar with teeth. A rack can mesh with any |
||||
|
// gear that has the same mm_per_tooth and pressure_angle. |
||||
|
// |
||||
|
// Some terminology: |
||||
|
// The outline of a gear is a smooth circle (the "pitch circle") which has mountains and valleys |
||||
|
// added so it is toothed. So there is an inner circle (the "root circle") that touches the |
||||
|
// base of all the teeth, an outer circle that touches the tips of all the teeth, |
||||
|
// and the invisible pitch circle in between them. There is also a "base circle", which can be smaller than |
||||
|
// all three of the others, which controls the shape of the teeth. The side of each tooth lies on the path |
||||
|
// that the end of a string would follow if it were wrapped tightly around the base circle, then slowly unwound. |
||||
|
// That shape is an "involute", which gives this type of gear its name. |
||||
|
// |
||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
|
||||
|
//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 |
||||
|
cut_circles = 0 |
||||
|
) { |
||||
|
assign(pi = 3.1415926) |
||||
|
assign(p = mm_per_tooth * number_of_teeth / pi / 2) //radius of pitch circle |
||||
|
assign(c = p + mm_per_tooth / pi - clearance) //radius of outer circle |
||||
|
assign(b = p*cos(pressure_angle)) //radius of base circle |
||||
|
assign(r = p-(c-p)-clearance) //radius of root circle |
||||
|
assign(t = mm_per_tooth/2-backlash/2) //tooth thickness at pitch circle |
||||
|
assign(k = -iang(b, p) - t/2/p/pi*180) { //angle to where involute meets base circle on each side of tooth |
||||
|
difference() { |
||||
|
union() { |
||||
|
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<b ? k : -180/number_of_teeth), |
||||
|
q7(0/5,r,b,c,k, 1),q7(1/5,r,b,c,k, 1),q7(2/5,r,b,c,k, 1),q7(3/5,r,b,c,k, 1),q7(4/5,r,b,c,k, 1),q7(5/5,r,b,c,k, 1), |
||||
|
q7(5/5,r,b,c,k,-1),q7(4/5,r,b,c,k,-1),q7(3/5,r,b,c,k,-1),q7(2/5,r,b,c,k,-1),q7(1/5,r,b,c,k,-1),q7(0/5,r,b,c,k,-1), |
||||
|
polar(r, r<b ? -k : 180/number_of_teeth), |
||||
|
polar(r, 181/number_of_teeth) |
||||
|
], |
||||
|
paths=[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]] |
||||
|
); |
||||
|
cylinder(r=b,h=thickness, center=true); |
||||
|
} |
||||
|
cylinder(h=2*thickness+1, r=hole_diameter/2, center=true, $fn=20); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
//these 4 functions are used by gear |
||||
|
function polar(r,theta) = r*[sin(theta), cos(theta)]; //convert polar to cartesian coordinates |
||||
|
function iang(r1,r2) = sqrt((r2/r1)*(r2/r1) - 1)/3.1415926*180 - acos(r1/r2); //unwind a string this many degrees to go from radius r1 to radius r2 |
||||
|
function q7(f,r,b,r2,t,s) = q6(b,s,t,(1-f)*max(b,r)+f*r2); //radius a fraction f up the curved side of the tooth |
||||
|
function q6(b,s,t,d) = polar(d,s*(iang(b,d)+t)); //point at radius d on the involute curve |
||||
|
|
||||
|
//a rack, which is a straight line with teeth (the same as a segment from a giant gear with a huge number of teeth). |
||||
|
//The "pitch circle" is a line along the X axis. |
||||
|
module rack ( |
||||
|
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 along the rack |
||||
|
thickness = 6, //thickness of rack in mm (affects each tooth) |
||||
|
height = 120, //height of rack in mm, from tooth top to far side of rack. |
||||
|
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 |
||||
|
pressure_angle = 28, //Controls how straight or bulged the tooth sides are. In degrees. |
||||
|
backlash = 0.0 //gap between two meshing teeth, in the direction along the circumference of the pitch circle |
||||
|
) { |
||||
|
pi = 3.1415926; |
||||
|
a = mm_per_tooth / pi; //addendum |
||||
|
t = a*tan(pressure_angle); //tooth side is tilted so top/bottom corners move this amount |
||||
|
shift = -thickness*2*tan(twist); |
||||
|
union() { |
||||
|
for (i = [0:number_of_teeth-1] ) |
||||
|
translate([i*mm_per_tooth,0,-thickness/2]) |
||||
|
//linear_extrude(height = thickness, center = true, convexity = 10) |
||||
|
polyhedron( |
||||
|
points=[ |
||||
|
[-mm_per_tooth * 3/4, a-height, 0], // 0 |
||||
|
[-mm_per_tooth * 3/4 - backlash, -a, 0], |
||||
|
[-mm_per_tooth * 1/4 + backlash - t, -a, 0], |
||||
|
[-mm_per_tooth * 1/4 + backlash + t, a, 0], |
||||
|
[ mm_per_tooth * 1/4 - backlash - t, a, 0], |
||||
|
[ mm_per_tooth * 1/4 - backlash + t, -a, 0], |
||||
|
[ mm_per_tooth * 3/4 + backlash, -a, 0], |
||||
|
[ mm_per_tooth * 3/4, a-height, 0], // 7 |
||||
|
[-mm_per_tooth * 3/4 + shift, a-height, thickness], |
||||
|
[-mm_per_tooth * 3/4 - backlash + shift, -a, thickness], |
||||
|
[-mm_per_tooth * 1/4 + backlash - t + shift, -a, thickness], |
||||
|
[-mm_per_tooth * 1/4 + backlash + t + shift, a, thickness], |
||||
|
[ mm_per_tooth * 1/4 - backlash - t + shift, a, thickness], |
||||
|
[ mm_per_tooth * 1/4 - backlash + t + shift, -a, thickness], |
||||
|
[ mm_per_tooth * 3/4 + backlash + shift, -a, thickness], |
||||
|
[ mm_per_tooth * 3/4 + shift, a-height, thickness], |
||||
|
], |
||||
|
faces=[ |
||||
|
[7,6,5,4,3,2,1,0], // bottom |
||||
|
[0,1,9,8], // side |
||||
|
[1,2,10,9], |
||||
|
[2,3,11,10], |
||||
|
[3,4,12,11], |
||||
|
[4,5,13,12], |
||||
|
[5,6,14,13], |
||||
|
[6,7,15,14], // side |
||||
|
[7,0,8,15], // back |
||||
|
[8,9,10,11,12,13,14,15], // top |
||||
|
]); |
||||
|
translate([(number_of_teeth-2)*mm_per_tooth/2,-(height)/2,0]) cube([(number_of_teeth+2)*mm_per_tooth,height-2*a,thickness], center=true); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
//These 5 functions let the user find the derived dimensions of the gear. |
||||
|
//A gear fits within a circle of radius outer_radius, and two gears should have |
||||
|
//their centers separated by the sum of their pictch_radius. |
||||
|
function circular_pitch (mm_per_tooth=3) = mm_per_tooth; //tooth density expressed as "circular pitch" in millimeters |
||||
|
function diametral_pitch (mm_per_tooth=3) = 3.1415926 / mm_per_tooth; //tooth density expressed as "diametral pitch" in teeth per millimeter |
||||
|
function module_value (mm_per_tooth=3) = mm_per_tooth / pi; //tooth density expressed as "module" or "modulus" in millimeters |
||||
|
function pitch_radius (mm_per_tooth=3,number_of_teeth=11) = mm_per_tooth * number_of_teeth / 3.1415926 / 2; |
||||
|
function outer_radius (mm_per_tooth=3,number_of_teeth=11,clearance=0.1) //The gear fits entirely within a cylinder of this radius. |
||||
|
= mm_per_tooth*(1+number_of_teeth/2)/3.1415926 - clearance; |
||||
|
|
||||
|
////////////////////////////////////////////////////////////////////////////////////////////// |
||||
|
//example gear train. |
||||
|
//Try it with OpenSCAD View/Animate command with 20 steps and 24 FPS. |
||||
|
//The gears will continue to be rotated to mesh correctly if you change the number of teeth. |
||||
|
|
||||
|
n1 = 33; //red gear number of teeth |
||||
|
n1_2 = 13; |
||||
|
n2 = 33; //green gear |
||||
|
n3 = 5; //blue gear |
||||
|
n4 = 20; //orange gear |
||||
|
n5 = 50; //gray rack |
||||
|
n_servo = 20; |
||||
|
mm_per_tooth = 3.33; //all meshing gears need the same mm_per_tooth (and the same pressure_angle) |
||||
|
thickness = 5; |
||||
|
thickness_servo = 2.8; |
||||
|
hole = 5+0.2; |
||||
|
hole_screw = 2.1; |
||||
|
kopf_screw = 1.5; |
||||
|
height = 12; |
||||
|
twist = 8; |
||||
|
|
||||
|
d1 =pitch_radius(mm_per_tooth,n1); |
||||
|
d12=pitch_radius(mm_per_tooth,n1_2) + pitch_radius(mm_per_tooth,n2); |
||||
|
d13=pitch_radius(mm_per_tooth,n1) + pitch_radius(mm_per_tooth,n3); |
||||
|
d14=pitch_radius(mm_per_tooth,n1) + pitch_radius(mm_per_tooth,n4); |
||||
|
|
||||
|
translate([ 0, 0, 0]) rotate([0,0, $t*360/n1]) color([1.00,0.75,0.75]) gear(mm_per_tooth,n1,thickness,hole, twist); |
||||
|
echo("pitch_radius of n1 is: ", d1); |
||||
|
translate([ 0, 0, thickness]) rotate([0,0, $t*360/n1]) color([1.00,0.75,0.75]) gear(mm_per_tooth,n1_2,thickness,hole, -twist*(n2/n1_2)); |
||||
|
|
||||
|
difference() { |
||||
|
translate([ 0, d12, thickness]) rotate([0,0,-($t+n2/2-0*n1+1/2)*360/n2]) color([0.75,1.00,0.75]) gear(mm_per_tooth,n2,thickness,hole_screw,twist,108); // servo gear |
||||
|
translate([ 0, d12, (thickness)/2]) color([0.75,1.00,0.75]) cylinder(r=4.5/2, h=kopf_screw*2, center=true, $fn=100); |
||||
|
translate([ 0, d12, thickness*1.5]) rotate([0,0,-($t+n2/2-0*n1+1/2)*360/n2]) color([0.75,1.00,0.75]) gear(0.79,n_servo,thickness_servo*2,0,0,108); // servo gear |
||||
|
}; |
||||
|
echo("pitch radius of servo bearing is: ", pitch_radius(0.79, n_servo)); |
||||
|
|
||||
|
assign(pi = 3.1415926) |
||||
|
translate([mm_per_tooth*(-floor(n5/2)-floor(n1/2)+$t+n1/(3/2)-1/2)+100, +d1+0.0, 0]) rotate([0,0,180]) color([0.75,0.75,0.75]) rack(mm_per_tooth,n5,thickness,height, -twist*atan((2*pi*pitch_radius(mm_per_tooth,n1))/mm_per_tooth)); |
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
Loading…
Reference in new issue