-
Notifications
You must be signed in to change notification settings - Fork 2
/
RodHelicalGear.scad
346 lines (282 loc) · 8.25 KB
/
RodHelicalGear.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
// Helical Gears
// Catarina Mota
// Creative Commons Attribution Share Alike
// 20091123
use <slotNutTrap.scad>;
use <Parameters.scad>;
//GEAR PARAMETERS
doubleHelical=1; //int: 0=no, 1=yes (will make the gear 2x taller)
gearHeight=2.5; //gear depth
pitchDiam=45; //pitch diameter
shaftDiam=8; //shaft diameter
//TEETH PARAMETERS
teethNum=30; //number of teeth (int)
addendum=1.5;
dedendum=1.5;
toothWidth=1.5;
angle=30; //positive=right, negative=left
//CENTER SHAPE PARAMETERS
centerShape=3; //int: solid=1, star=2, circle=3
starNum=6; //number of lines for star shape (int)
starWidth=2; //width of star lines
circleNum=8; //number of circles (int)
circleDiam=8; //diameter of circles
//CENTER CIRCLE PARAMETERS
extrudeOut=1; //int: 0=no, 1=yes
extrudeOutHeight=8;
extrudeOutWidth= 2 * shaftDiam; //in relationship to shaft
extrudeIn=1; //int: 0=no, 1=yes
//extrudeInDiam=pitchDiam/2-dedendum*2;
extrudeInRad=pitchDiam/2-dedendum*2;
extrudeInHeight=0;
//ROME (extrudeIn must be set to 0)
rome=0; //int: 0=no, 1=yes
romeDiam=pitchDiam/2; //pitch diameter for top gear
romeHeight=gearHeight; //top gear height
romeTeeth=teethNum*2/3;
romeAdd=2; //top gear addendum
romeDed=2; //top gear dedendum
romeToothWidth=2; //teeth width for top gear
romeAngle=5; //rotate top gear (angle)
//----------------------
difference(){
gear();
translate([0, extrudeOutWidth / 2, 5]){
rotate([90,0,0]){
slotNutTrap(2.7, 4, 12, 5.5, 10, 3);
}
}
rotate([0,0, 180]){
translate([0, extrudeOutWidth / 2, 5]){
rotate([90,0,0]){
slotNutTrap(2.7, 4, 12, 5.5, 10, 3);
}
}
}
}
//----------------------
//TOOTH
module tooth(heightGear,
diamPitch) {
toothHeight=addendum+dedendum*2;
union(){
translate([0,toothHeight/2,0]) rotateTooth(1);
if (doubleHelical==1){
translate([0,toothHeight/2,-heightGear+0.1]) rotateTooth(-1);
}
}
module rotateTooth(direction){
difference(){
rotate([0,direction*angle,0])
box(toothWidth,toothHeight,heightGear*1.5);
translate([0,0,heightGear*0.75+dedendum/2])
box(heightGear,toothHeight+0.5,dedendum+heightGear/2);
translate([0,0,-heightGear*0.75-dedendum/2])
box(heightGear,toothHeight+0.5,dedendum+heightGear/2);
}
}
}
//HELICAL
module helical(numTeeth, diamPitch, heightGear) {
rootRad=diamPitch/2-dedendum;
difference(){
for (i = [1:numTeeth]) {
translate([sin(360*i/numTeeth)*(rootRad-dedendum), cos(360*i/numTeeth)*(rootRad-dedendum), 0 ]){
rotate([0,0,-360*i/numTeeth]) tooth(heightGear, diamPitch);
}
}
translate([0,0,-gearHeight/2-1]) cylinder(heightGear+2, diamPitch/2-dedendum, diamPitch/2-dedendum);
}
}
//SOLID
module solid(heightGear, diamPitch) {
rootRad=diamPitch/2-dedendum;
translate([0,0,-(heightGear*doubleHelical)+0.1*doubleHelical])
cylinder(heightGear+(heightGear-0.1)*doubleHelical, rootRad, rootRad);
}
//STAR
module star() {
starAngle=360/starNum;
rootRad=diamPitch/2-dedendum;
union(){
for (s=[1:starNum]){
translate([0,0,gearHeight/2-(gearHeight/2*doubleHelical)]){
rotate([0, 0, s*starAngle]) dislocateBox(starWidth, (pitchDiam/2-dedendum*2)/2, gearHeight+(gearHeight*doubleHelical));
}
}
translate ([0,0,-gearHeight*doubleHelical])
tube(gearHeight+(gearHeight*doubleHelical), pitchDiam/2-dedendum, starWidth);
translate ([0,0,-gearHeight*doubleHelical]){
tube(gearHeight+(gearHeight*doubleHelical), pitchDiam/4+dedendum, starWidth);
//cylinder(gearHeight+(gearHeight*doubleHelical), pitchDiam/4+dedendum, pitchDiam/4+dedendum);
}
translate([0,0,-gearHeight*doubleHelical])
cylinder(gearHeight+(gearHeight*doubleHelical), shaftDiam/2+starWidth, shaftDiam/2+starWidth);
}
}
//CIRCLE
module circle() {
rootRad=pitchDiam/2-dedendum;
difference(){
solid(gearHeight-0.1*doubleHelical, pitchDiam);
for (c=[1:circleNum]){
translate([sin(360*c/circleNum)*(rootRad/2+shaftDiam/2), cos(360*c/circleNum)*(rootRad/2+shaftDiam/2), -gearHeight*doubleHelical]){
cylinder(gearHeight+gearHeight*doubleHelical, circleDiam/2, circleDiam/2);
}
}
}
}
//ROME
module romeGear(){
translate([0,0,romeHeight/2+gearHeight]){
rotate([0,0,romeAngle]){
union(){
helical(romeTeeth, romeDiam, romeHeight);
translate ([0,0,-romeHeight/2]) solid(romeHeight, romeDiam);
}
}
}
}
//GEAR
module gear(){
difference () {
union() {
translate([0,0,gearHeight/2]) helical(teethNum, pitchDiam, gearHeight);
if (centerShape==1) solid(gearHeight, pitchDiam);
if (centerShape==2) star();
if (centerShape==3) circle();
if (rome==1) romeGear();
//extrudeOut around shaft
if (extrudeOut==1) {
translate([0,0,-gearHeight*doubleHelical+0.1*doubleHelical]) cylinder(gearHeight-(extrudeInHeight*extrudeIn)+extrudeOutHeight+romeHeight*rome+gearHeight*doubleHelical-0.1*doubleHelical, extrudeOutWidth/2+shaftDiam/2, extrudeOutWidth/2+shaftDiam/2);
}
}
//extrudeIn around shaft
if (extrudeIn==1) {
difference(){
translate([0,0,gearHeight-extrudeInHeight+0.1*doubleHelical]) cylinder(extrudeInHeight, extrudeInRad, extrudeInRad);
cylinder(gearHeight+extrudeOutHeight, (extrudeOutWidth+shaftDiam)/2*extrudeOut, (extrudeOutWidth+shaftDiam)/2*extrudeOut);
}
}
//shaft
translate([0,0,-gearHeight*doubleHelical]) cylinder(gearHeight+extrudeOutHeight+romeHeight+(gearHeight*doubleHelical), shaftDiam/2, shaftDiam/2);
}
}
//----------------------
//SILLY WAY TO GET AROUND ROTATION AXIS
module dislocateBox(xBox, yBox, zBox){
translate([0,yBox,0]){
difference(){
box(xBox, yBox*2, zBox);
translate([-xBox,0,0]) box(xBox, yBox*2, zBox);
}
}
}
//----------------------
module box(w,h,d) {
scale ([w,h,d]) cube(1, true);
}
module hollowBox(w,h,d,wall){
difference(){
box(w,h,d);
box(w-wall*2,h-wall*2,d);
}
}
module roundedBox(w,h,d,f){
difference(){
box(w,h,d);
translate([-w/2,h/2,0]) cube(w/(f/2),true);
translate([w/2,h/2,0]) cube(w/(f/2),true);
translate([-w/2,-h/2,0]) cube(w/(f/2),true);
translate([w/2,-h/2,0]) cube(w/(f/2),true);
}
translate([-w/2+w/f,h/2-w/f,-d/2]) cylinder(d,w/f, w/f);
translate([w/2-w/f,h/2-w/f,-d/2]) cylinder(d,w/f, w/f);
translate([-w/2+w/f,-h/2+w/f,-d/2]) cylinder(d,w/f, w/f);
translate([w/2-w/f,-h/2+w/f,-d/2]) cylinder(d,w/f, w/f);
}
module cone(height, radius) {
cylinder(height, radius, 0);
}
module oval(w,h,d) {
scale ([w/100, h/100, 1]) cylinder(d, 50, 50);
}
module tube(height, radius, wall) {
difference(){
cylinder(height, radius, radius);
cylinder(height, radius-wall, radius-wall);
}
}
module ovalTube(w,h,d,wall) {
difference(){
scale ([w/100, h/100, 1]) cylinder(d, 50, 50);
scale ([w/100, h/100, 1]) cylinder(d, 50-wall, 50-wall);
}
}
module tearDrop(diam) {
f=0.52;
union(){
translate([0,diam*0.70,depth/2]) rotate([0,0,135]) rightTriangle(diam*f,diam*f, depth);
cylinder(depth,diam/2,diam/2);
}
}
module hexagon(height, depth) {
boxWidth=height/1.75;
union(){
box(boxWidth, height, depth);
rotate([0,0,60]) box(boxWidth, height, depth);
rotate([0,0,-60]) box(boxWidth, height, depth);
}
}
module octagon(height, depth) {
intersection(){
box(height, height, depth);
rotate([0,0,45]) box(height, height, depth);
}
}
module dodecagon(height, depth) {
intersection(){
hexagon(height, depth);
rotate([0,0,90]) hexagon(height, depth);
}
}
module hexagram(height, depth) {
boxWidth=height/1.75;
intersection(){
box(height, boxWidth, depth);
rotate([0,0,60]) box(height, boxWidth, depth);
}
intersection(){
box(height, boxWidth, depth);
rotate([0,0,-60]) box(height, boxWidth, depth);
}
intersection(){
rotate([0,0,60]) box(height, boxWidth, depth);
rotate([0,0,-60]) box(height, boxWidth, depth);
}
}
module rightTriangle(adjacent, opposite, depth) {
difference(){
translate([-adjacent/2,opposite/2,0]) box(adjacent, opposite, depth);
translate([-adjacent,0,0]){
rotate([0,0,atan(opposite/adjacent)]) dislocateBox(adjacent*2, opposite, depth);
}
}
}
module equiTriangle(side, depth) {
difference(){
translate([-side/2,side/2,0]) box(side, side, depth);
rotate([0,0,30]) dislocateBox(side*2, side, depth);
translate([-side,0,0]){
rotate([0,0,60]) dislocateBox(side*2, side, depth);
}
}
}
module 12ptStar(height, depth) {
starNum=3;
starAngle=360/starNum;
for (s=[1:starNum]){
rotate([0, 0, s*starAngle]) box(height, height, depth);
}
}