-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgears.scad
126 lines (112 loc) · 3.5 KB
/
gears.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
gear(
number_of_teeth=15,
modulus=1,
pressure_angle=45,
depth_ratio=.5,
clearance=.25,
h=5,
center=true);
function gear_outer_radius(number_of_teeth,
modulus,
depth_ratio,
clearance) = (number_of_teeth*modulus/2)+depth_ratio*(modulus*PI)/2-clearance/2;
function gear_pitch_radius(number_of_teeth, modulus) = number_of_teeth*modulus/2;
module gear (
number_of_teeth,
modulus,
pressure_angle,
depth_ratio,
clearance,
h,
center=false)
{
linear_extrude(height=h, center=center, convexity=4)
{
gear2D(number_of_teeth, modulus, pressure_angle, depth_ratio, clearance);
}
}
module gear2D (
number_of_teeth,
modulus,
pressure_angle,
depth_ratio,
clearance)
{
circular_pitch = modulus*PI;
pitch_radius = gear_pitch_radius(number_of_teeth, modulus);
base_radius = pitch_radius*cos(pressure_angle);
depth=circular_pitch/(2*tan(pressure_angle));
outer_radius = clearance<0 ? pitch_radius+depth/2-clearance : pitch_radius+depth/2;
root_radius1 = pitch_radius-depth/2-clearance/2;
root_radius = (clearance<0 && root_radius1<base_radius) ? base_radius : root_radius1;
backlash_angle = clearance/(pitch_radius*cos(pressure_angle)) * 180 / PI;
half_thick_angle = 90/number_of_teeth - backlash_angle/2;
pitch_point = involute (base_radius, involute_intersect_angle (base_radius, pitch_radius));
pitch_angle = atan2 (pitch_point[1], pitch_point[0]);
min_radius = max (base_radius,root_radius);
*echo("circular_pitch = ", circular_pitch,
"pitch_radius = ", pitch_radius,
"base_radius = ", base_radius,
"depth = ", depth,
"outer_radius = ", outer_radius);
intersection()
{
rotate(90/number_of_teeth)
circle($fn=number_of_teeth*3,r=pitch_radius+depth_ratio*circular_pitch/2-clearance/2);
union()
{
rotate(90/number_of_teeth)
circle($fn=number_of_teeth*2,r=max(root_radius,pitch_radius-depth_ratio*circular_pitch/2-clearance/2));
for (i = [1:number_of_teeth])rotate(i*360/number_of_teeth)
{
halftooth (
pitch_angle,
base_radius,
min_radius,
outer_radius,
half_thick_angle);
mirror([0,1]) halftooth (
pitch_angle,
base_radius,
min_radius,
outer_radius,
half_thick_angle);
}
}
}
}
module halftooth (
pitch_angle,
base_radius,
min_radius,
outer_radius,
half_thick_angle)
{
index=[0,1,2,3,4,5];
start_angle = max(involute_intersect_angle (base_radius, min_radius)-5,0);
stop_angle = involute_intersect_angle (base_radius, outer_radius);
angle=index*(stop_angle-start_angle)/index[len(index)-1];
p=[[0,0],
involute(base_radius,angle[0]+start_angle),
involute(base_radius,angle[1]+start_angle),
involute(base_radius,angle[2]+start_angle),
involute(base_radius,angle[3]+start_angle),
involute(base_radius,angle[4]+start_angle),
involute(base_radius,angle[5]+start_angle)];
difference()
{
rotate(-pitch_angle-half_thick_angle)polygon(points=p);
square(2*outer_radius);
}
}
// Mathematical Functions
//===============
// Finds the angle of the involute about the base radius at the given distance (radius) from it's center.
//source: http://www.mathhelpforum.com/math-help/geometry/136011-circle-involute-solving-y-any-given-x.html
function involute_intersect_angle (base_radius, radius) = sqrt (pow (radius/base_radius, 2) - 1) * 180 / PI;
// Calculate the involute position for a given base radius and involute angle.
function involute (base_radius, involute_angle) =
[
base_radius*(cos (involute_angle) + involute_angle*PI/180*sin (involute_angle)),
base_radius*(sin (involute_angle) - involute_angle*PI/180*cos (involute_angle))
];