-
Notifications
You must be signed in to change notification settings - Fork 0
/
gear_test.scad
99 lines (82 loc) · 2.36 KB
/
gear_test.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
// build a gear with a 0.1" shaft hole
//
// Copyright 2018,2019 by Bob Frazier and S.F.T. Inc.
//
// There is no restriction as to how this file can be used
//
// GEAR example - 16 teeth, 1 inch diameter
//
function scaler(n) = n * 0.254 * 1.02;
// convert 1/100 inch to millimeters
// with 1.02 shrink factor
function anti_scaler(n) = (n / 0.254) / 1.02;
$shd=scaler(9.7)/2; // 0.1" hole diam
// hole is slightly smaller to fit shaft
// gear will have to be tapped or pressed on
$whd=scaler(25)/2; // 0.25" 'wheel' diam
$gd=scaler(100)/2; // 1.00" 'gear' diam
$whh=scaler(22); // 0.22" 'wheel' height
$gh=scaler(8); // 0.08" 'gear' height
$tc=16; // number of gear teeth
// accuracy parameters
$fn=256; // number of faces in shape
module tooth(r,h,n,tot) // r=radius,
{ // h=heght, n=egment,
// tot=total # of segments
// center of equilateral triangle with
// a base of 'A' has a delta Y of A/3
// the chord length 'A' is equal
// to 2 * r * sin(th / 2)
th=360 / tot; // theta angle of chord
aa=2 * r * sin(th / 2); // length of chord
ah=sin(60)*aa; // height of triangle
cx1=cos((n * th) - th / 2) * r;
cx2=cos((n * th) + th / 2) * r;
cy1=sin((n * th) - th / 2) * r;
cy2=sin((n * th) + th / 2) * r;
// get x,y for the 'tip'
cx3=(cx1+cx2)/2 + cos(n * th) * ah;
cy3=(cy1+cy2)/2 + sin(n * th) * ah;
if(n == 0)
{
// echo out the various tooth sizes as
// calculated. it's a bit easier to
// tweek things to match using the
// gear diameter so that gear teeth
// will mesh.
echo("gear wheel radius: ", anti_scaler(r));
echo("Tooth side length: ", anti_scaler(ah));
echo("gear radius: ", anti_scaler(sqrt(cx3*cx3+cy3*cy3)));
}
color("blue")
linear_extrude(height=h)
polygon(points=[[cx1,cy1],[cx2,cy2],[cx3,cy3]]);
}
union()
{
color("red")
difference()
{
translate([0,0,0])
linear_extrude(height=$whh)
circle($whd, center=true);
translate([0,0,-1])
linear_extrude(height=$whh+2)
circle($shd, center=true);
}
color("green")
difference()
{
translate([0,0,0])
linear_extrude(height=$gh)
circle($gd, center=true);
translate([0,0,-1])
linear_extrude(height=$whh+2)
circle($whd, center=true);
}
for(i=[0:$tc-1])
{
translate([0,0,0])
tooth($gd,$gh,i,$tc);
}
}