This repository has been archived by the owner on Nov 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
clockworkLibrary.scad
executable file
·1189 lines (1039 loc) · 34.3 KB
/
clockworkLibrary.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
This is an OpenSCAD library to create various pinion wheels, escapements and other pieces of clockwork gearing
Uses the MCAD involute_gears library and will not work without it!
Created by syvwlch and licensed under the Attribution - Share Alike - Creative Commons license.
v1 - 2011 04 15
First library version of the code
v2 - 2011 04 21
Added spokes() module, and used it in escapement() module
Updated escapement(), ringtooth(), tooth() and ring() modules to render better in openCSG mode
v3 - 2011 04 22
Renamed to clockworkLibrary
Added hand(), handNotch(), pinionWheel(), pinionEscapementWheel(), pinionDrum()
v4 - 2011 04 29
Added negative space toggle to the parts, with a default value of false
v5 - 2011 05 01
Added herringbone gear option, with a default value of 0
Strengthened pinion teeth.
v6 - 2011 05 04
Changed how drum height in pinionDrum() is measured to work like sleeve extension does, to simplify placement math
Corrected error in how sleeve extension is measured in pinionWheel() (wheels are 2*thickness+1*spacer thick)
Changed how drum height in pinionEscapementWheel() is measured, to standardize
Create a drum() module, and implemeted flanges to keep the string from falling off
Retrofitted drum() into pinionDrum(), as well as for the spacer in pinionEscapementWheel() and pinionWheel()
v7 - 2011 05 04
Added an assymetric spacer so that the herringbone gears would mesh without running into the drum flanges
Switched to using mirror() to implement the two halves of the herringbone as a result
v8 - 2011 05 06
Fixed a bug in spokes() which referenced the wrong spoke width parameter (thanks kitlaan!)
v9 - 2011 05 07
Modified the escapement wheel profile to support club teeth (still defaults to ratchet teeth)
Club tooth parameters accessible in tooth(), ringtooth(), escapementWheel() and pinionEscapementWheel()
Modified escapement to control angle of impulse faces on the pallets, defaults to 45o as per ideal Graham escapement w/o club teeth
Escapement will work if impulse face angles are set to 45o minus tooth lean plus club angle, and drop can be controlled via face angle
v10 - 2011 05 08
Modified the drum() module to add holes to attach a string
Backwards compatible with no holes if the new arguments are not passed
Modified pinionDrum() to make use of this new feature, but backwards compatible with no holes if the new arguments are not passed
v11 - 2011 05 18
Modified to support the ratcheting drum designed by rustedrobot: http://www.thingiverse.com/thing:8555
Backwards compatible, one-piece drum still available as an option
v12 - 2012 02 06
Modified after Clockathon #1 and #2
PinionDrum deprecated, invoke pinionWheel instead, with number of teeth for the pinion gear set to zero.
It includes the following modules:
module ring(outerRadius,innerRadius,thickness,outerSegment=30,innerSegment=30)
creates a hollow cylinder centered at origin
outerRadius and innerRadius should be self-explanatory
thickess is along z
outerSegment is an optional override of the system variable $fn
innerSegment is an optional override of the system variable $fn
module spokes(number_spokes,spoke_length,spoke_thickness,spoke_width,bore_radius,spoke_rotate=0)
creates spokes for a ring
number_spokes controls the number of spokes
spoke_length controls the length of the spokes, measured radialy from the center
spoke_thickness controls the thickness of the spokes, measured along z
spoke_width controls the width of the spokes, at right angles to length and thickness
bore_radius controls the radius of the hole at the center
spoke_rotate allows to rotate the whole set of spokes by some value
module tooth(toothLength,thickness,toothLean,toothSharpness)
creates a triangular tooth, sharp end at origin
toothLength is measured along longest side
thickess is along z
toothLean measures how far the tooth leans over, in degrees
toothSharpness measures how sharp the tooth is, in degrees
module ringTooth(outerRadius,innerRadius,thickness,numberTeeth,toothLength)
creates a ring centered at origin with the child spaced regularly along the outside edge of the inner radius
outerRadius and innerRadius should be self-explanatory
thickess is along z
numberTeeth controls how many instances of the child are used
toothlength is used to offset the teeth outward, if needed
module escapementWheel(radius,rimWidth,drumHeight,toothThickness,numberTeeth,toothLength,toothLean,toothSharpness,numberSpokes,spokeWidth,hubWidth,bore)
creates an escapement wheel centered at origin that matches the escapement if the parameter values are the same
the teeth can be given a smaller thickness than the wheel, creating a drum, e.g. for powering the escapement via a weight on a string
radius is the outer radius measured from the tooth tips
rimWidth is the width of the rim of the wheel, measured radially
drumHeight is the height of the drum along z
toothThickess is the thickness of the teeth along z
numberTeeth controls how many teeth the wheel has
toothLength is the length of each tooth,
toothLean measures how far the tooth leans over clockwise, in degrees
toothSharpness measures how sharp the tooth is, in degrees
numberSpokes controls the number of spokes of the wheel
spokeWidth controls the width of the spokes of the wheel
hubWidth controls the width of the hub
bore controls the size of the bore in the hub
module escapement(radius,thickness,faceAngle,armAngle,armWidth,numberTeeth,toothSpan,hubWidth,hubHeight,bore)
creates a Graham escapement that matches the escapement wheel if the parameter values are the same
the escapement is centered at the origin and mirrored around the y axis
for proper meshing, it must be translated by 2*radius*cos(180/numberTeeth*toothSpan) along the y axis
radius is the radius of the wheel, not of the escapement
thickess is along z
faceAngle controls how many degrees the impulse face covers seen from the hub of the escapement wheel
armAngle controls the angle of the escapement's arms, 0= no bend
armWidth controls the width of the arms
numberTeeth is the number of teeth of the wheel
toothSpan is how many teeth the escapement spans
hubWidth controls the width of the hub
hubHeight controls the height of the hub along z
bore controls the size of the bore in the hub
module placeEscapement (angle,radius,numberTeeth,toothSpan)
places the child (e.g. an instance of the escapement module) in a position to mesh properly with a matching wheel at origin
also rotates the escapement around the wheel, if needed
angle is the angle the escapement is rotated around the wheel
radius is the radius of the escapement wheel (from the tooth tips)
numberTeeth is the number of teeth in the wheel
toothSpan is the number of teeth the escapement spans
module hand(hand_length,hand_width,hand_thickness,sleeve_level,pin_radius,sleeve_thickness,loose_fit,tight_fit,negative_space=false)
module handNotch(notch_height,notch_width,sleeve_level,pin_radius,sleeve_thickness,notch_angle=0,negative_space=false)
module pinionWheel (large_gear_teeth,large_gear_circular_pitch,small_gear_teeth,small_gear_circular_pitch,gear_clearance,gear_backlash,pressure_angle,rim_width,sleeve_level,pin_radius,sleeve_thickness,loose_fit,gear_thickness,sleeve_extension,spacer,spoke_width,notch_angle=0,negative_space=false)
module pinionEscapementWheel (radius,escapement_teeth,tooth_length,tooth_lean,tooth_sharpness,small_gear_teeth,small_gear_circular_pitch,gear_clearance,gear_backlash,pressure_angle,rim_width,sleeve_level,pin_radius,sleeve_thickness,loose_fit,gear_thickness,sleeve_extension,spacer,spoke_width,notch_angle=0,negative_space=false)
module pinionDrum (drum_height,number_spokes,large_gear_teeth,large_gear_circular_pitch,gear_clearance,gear_backlash,pressure_angle,rim_width,sleeve_level,pin_radius,sleeve_thickness,loose_fit,gear_thickness,sleeve_extension,spacer,spoke_width,notch_angle=0,negative_space=false)
*/
module ring(
outerRadius,
innerRadius,
thickness,
outerSegment=30,
innerSegment=30)
{
difference() // hollows out the center of one cylinder with another, smaller one
{
cylinder(thickness,outerRadius,outerRadius,$fn=outerSegment);
translate([0,0,-1])
cylinder(thickness+2,innerRadius,innerRadius,,$fn=innerSegment);
}
}
module spokes(
number_spokes,
spoke_length,
spoke_thickness,
spoke_width,
bore_radius,
spoke_rotate=0)
{
for ( j=[0:number_spokes-1]) // adds the spokes
{
rotate(spoke_rotate+360/number_spokes*j,[0,0,1])
translate([bore_radius,-spoke_width/2,0])
cube([spoke_length-bore_radius,spoke_width,spoke_thickness]);
}
}
module tooth(
toothLength,
thickness,
toothLean,
toothSharpness,
clubSize=0,
clubAngle=0)
{
rotate(-toothLean,[0,0,1])
rotate(180,[0,0,1])
linear_extrude(height=thickness,center=false,twist=0)
polygon(
points= [
[0,0],
[clubSize*toothLength*cos(45+toothLean+clubAngle),-clubSize*toothLength*sin(45+toothLean+clubAngle)],
[clubSize*toothLength*(0.2+cos(45+toothLean+clubAngle)),-clubSize*toothLength*sin(45+toothLean+clubAngle)],
[clubSize*toothLength*0.5,-clubSize*toothLength*0.5],
[toothLength,0],
[toothLength*cos(toothSharpness),toothLength*sin(toothSharpness)]
],
paths= [
[0,1,2,3,4,5]
] );
}
module ringTooth(
outerRadius,
innerRadius,
thickness,
numberTeeth,
toothLength)
{
difference() // makes the center hollow while shaving off any parts of the teeth which might otherwise extend into the center
{
union() // unites the teeth and the ring
{
cylinder(thickness,outerRadius,outerRadius,$fn=30);
for ( i=[0:numberTeeth])
{
rotate(i*360/numberTeeth,[0,0,1])
translate([innerRadius+toothLength,0,0])
child(0);
}
}
translate([0,0,-1])
cylinder(thickness+2,innerRadius,innerRadius,$fn=30);
}
}
module drum(
radius,
rimWidth,
drumHeight,
numberHoles=0,
holeRadius=0,
holeRotate=0)
{
flangeWidth=min(drumHeight/3,rimWidth/2);
difference() // makes the center hollow & includes holes to attach string
{
union() // builds the drum with flanges
{
cylinder(flangeWidth,radius,radius-flangeWidth,$fn=30);
translate([0,0,flangeWidth])
cylinder(drumHeight-2*flangeWidth,radius-flangeWidth,radius-flangeWidth);
translate([0,0,drumHeight-flangeWidth])
cylinder(flangeWidth,radius-flangeWidth,radius,$fn=30);
}
translate([0,0,-1])
cylinder(drumHeight+2,radius-rimWidth,radius-rimWidth,$fn=30);
for ( j=[0:numberHoles-1]) // adds the holes
{
translate([0,0,drumHeight/2])
rotate(holeRotate+360/numberHoles*j,[0,0,1])
rotate(90,[0,1,0])
cylinder(r=holeRadius,h=radius+1);
}
}
}
module escapementWheel(
radius,
rimWidth,
drumHeight,
toothThickness,
numberTeeth,
toothLength,
toothLean,
toothSharpness,
numberSpokes,
spokeWidth,
hubWidth,
bore,
clubSize=0,
clubAngle=0)
{
flangeWidth=min(drumHeight/3,rimWidth/2);
union() // unites the wheel, the spokes and the hub
{
ringTooth(radius-toothLength+rimWidth,radius-toothLength,toothThickness,numberTeeth,toothLength)
tooth(toothLength,toothThickness,toothLean,toothSharpness,clubSize,clubAngle);
spokes(numberSpokes,radius-toothLength,drumHeight+toothThickness,spokeWidth,bore,0);
ring(hubWidth,bore,toothThickness+drumHeight);
ring(radius-toothLength+rimWidth,radius-toothLength,toothThickness);
translate([0,0,toothThickness])
drum(radius-toothLength+rimWidth,rimWidth,drumHeight);
}
}
module escapement(
radius,
thickness,
faceAngle,
armAngle,
armWidth,
numberTeeth,
toothSpan,
hubWidth,
hubHeight,
bore,
negative_space=false,
space=0.1,
max_swing=6,
entryPalletAngle=45,
exitPalletAngle=45)
{
faceWidth=2*3.1415*radius*faceAngle/360; // calculate once
escapementAngle=180/numberTeeth*toothSpan; // calculate once
rotate(90,[0,0,1]) // rotates escapement so pendulum is along y axis
if (negative_space==false)
{
union()
{
// this is the hub
ring(hubWidth,bore,hubHeight);
// this is the exit pallet
// this is the arm of the pallet
rotate(-90-armAngle,[0,0,1])
translate([bore,-armWidth/2,0])
cube([radius+faceWidth/2-bore,armWidth,thickness]);
// this is the pallet itself
intersection()
{
// this is the ring from which the "dead" faces are made
// it is important that the arcs be smooth, i.e. $fn high
// otherwise, there would be some recoil
ring(radius+faceWidth/2,radius-faceWidth/2,thickness,180,180);
// this is the cube which cuts the pallet where it meets the arm
rotate(-90-armAngle,[0,0,1])
translate([radius,0,0])
rotate(180,[0,0,1])
translate([-0.5*radius,0,-radius])
cube(2.1*radius);
// this is the cube which cuts the pallet at the impulse face
translate([-2*radius*cos(escapementAngle),0,0])
rotate(-escapementAngle,[0,0,1])
rotate(0,[0,0,1])
translate([radius,0,0])
rotate(-90-exitPalletAngle,[0,0,1])
translate([-0.5*radius,0,-radius])
cube(2.2*radius);
}
// this is the entry pallet
// this is the arm of the pallet
rotate(90+armAngle,[0,0,1])
translate([bore,-armWidth/2,0])
cube([radius+faceWidth/2-bore,armWidth,thickness]);
// this is the pallet itself
intersection()
{
// this is the ring from which the "dead" faces are made
// it is important that the arcs be smooth, i.e. $fn high
// otherwise, there would be some recoil
ring(radius+faceWidth/2,radius-faceWidth/2,thickness,180,180);
// this is the cube which cuts the pallet where it meets the arm
rotate(90+armAngle,[0,0,1])
translate([radius,0,0])
rotate(0,[0,0,1])
translate([-0.5*radius,0,-radius])
cube(2.1*radius);
// this is the cube which cuts the pallet at the impulse face
translate([-2*radius*cos(escapementAngle),0,0])
rotate(-escapementAngle,[0,0,1])
rotate(2*escapementAngle,[0,0,1])
translate([radius,0,0])
rotate(-90-entryPalletAngle,[0,0,1])
translate([-0.5*radius,0,-radius])
cube(2.2*radius);
}
}
}
if (negative_space==true)
{
translate([0,0,-space])
union()
{
ring(hubWidth+space,0,hubHeight+2*space);
difference()
{
ring(radius+faceWidth/2+space,0,thickness+2*space);
rotate(max_swing-armAngle,[0,0,1])
translate([-radius,armWidth/2,-1])
cube(2*radius+faceWidth+2*space);
mirror([1,0,0])
rotate(max_swing-armAngle,[0,0,1])
translate([-radius,armWidth/2,-1])
cube(2*radius+faceWidth+2*space);
}
}
}
}
module placeEscapement (
angle,
radius,
numberTeeth,
toothSpan)
{
rotate(angle,[0,0,1])
translate([0,2*radius*cos(180/numberTeeth*toothSpan),0])
child(0);
}
module hand(
hand_length,
hand_width,
hand_thickness,
sleeve_level,
pin_radius,
sleeve_thickness,
loose_fit,
tight_fit,
negative_space=false,
space=0.1)
{
bore_radius=pin_radius+sleeve_level*sleeve_thickness;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
if (negative_space==false)
{
union()
{
intersection()
{
for ( i=[1:2])
{
rotate(i*360/3,[0,0,1])
translate([bore_radius+loose_fit,-hand_width/2,0])
cube([sleeve_radius-bore_radius-loose_fit+sleeve_thickness,hand_width,hand_thickness]);
}
translate(-1,[0,0,1])
cylinder(hand_thickness+2,sleeve_radius+sleeve_thickness,sleeve_radius+sleeve_thickness);
}
translate([bore_radius+loose_fit,-hand_width/2,0])
cube([hand_length-bore_radius-loose_fit,hand_width,hand_thickness]);
ring(sleeve_radius+sleeve_thickness,bore_radius+tight_fit+sleeve_thickness,hand_thickness);
}
}
if (negative_space==true)
{
translate([0,0,-space])
ring(sqrt(hand_length*hand_length+hand_width*hand_width)+space,0,hand_thickness+2*space);
}
}
module handNotch(
notch_height,
notch_width,
sleeve_level,
pin_radius,
sleeve_thickness,
notch_angle=0,
negative_space=false)
{
//bore_radius=pin_radius+sleeve_level*sleeve_thickness;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
if (negative_space==false)
{
if (notch_width!=0)
{
difference()
{
child(0);
for ( i=[0:2])
{
rotate(notch_angle+i*360/3,[0,0,1])
translate([0,-notch_width/2,notch_height])
cube([sleeve_radius+1,notch_width,notch_height+1]);
}
}
}
if (notch_width==0)
{
child(0);
}
}
if (negative_space==true)
{
child(0);
}
}
module pinionWheel(
large_gear_teeth,
large_gear_circular_pitch,
small_gear_teeth=0,
small_gear_circular_pitch=0,
gear_clearance=0.2,
gear_backlash=0.1,
gear_spacer=0.5,
pressure_angle=14.5,
twist_factor=0,
rim_width,
sleeve_level=0,
pin_radius,
sleeve_thickness,
loose_fit=0.5,
gear_thickness,
sleeve_extension,
spacer,
number_spokes=5,
spoke_width,
notch_angle=0,
negative_space=false,
space=0.1)
{
large_dedendum_radius=large_gear_circular_pitch*(large_gear_teeth-2)/360-gear_clearance;
small_dedendum_radius=small_gear_circular_pitch*(small_gear_teeth-2)/360-gear_clearance;
large_addendum_radius=large_gear_circular_pitch*(large_gear_teeth+2)/360-gear_clearance;
small_addendum_radius=small_gear_circular_pitch*(small_gear_teeth+2)/360-gear_clearance;
bore_radius=pin_radius+sleeve_level*sleeve_thickness+loose_fit;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
small_gear_color = [0.88, 0.78, 0.5];
structure_color = [0.45, 0.43, 0.5];
large_gear_color = [0.2, 0.2, 0.2];
if (negative_space==false)
{
union()
{
color(large_gear_color)
translate([0,0,gear_thickness/2])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2-gear_spacer,
rim_width = rim_width,
hub_thickness = gear_thickness/2-gear_spacer,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=large_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=twist_factor*180/large_gear_teeth);
color(large_gear_color)
translate([0,0,gear_thickness/2])
mirror([0,0,1])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2,
rim_width = rim_width,
hub_thickness = gear_thickness/2,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=large_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=twist_factor*180/large_gear_teeth);
color(structure_color)
translate([0,0,gear_thickness-gear_spacer])
drum(
radius=large_dedendum_radius,
rimWidth=rim_width,
drumHeight=spacer,
numberHoles=number_spokes,
holeRadius=min(1,(spacer+gear_spacer)/6),
holeRotate=180/number_spokes);
color(structure_color)
ring(sleeve_radius,bore_radius,2*gear_thickness+spacer+sleeve_extension);
color(structure_color)
spokes(number_spokes,large_dedendum_radius-rim_width,gear_thickness-gear_spacer+spacer,spoke_width,bore_radius,0);
if (small_gear_teeth!=0)
{
color(structure_color)
ring(small_addendum_radius,bore_radius,gear_thickness-gear_spacer+spacer);
color(small_gear_color)
translate([0,0,gear_thickness*1.5+spacer])
gear (circular_pitch=small_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2,
rim_width = rim_width,
hub_thickness = gear_thickness/2,
hub_diameter=small_dedendum_radius*2,
bore_diameter=bore_radius*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=small_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=-twist_factor*180/small_gear_teeth);
color(small_gear_color)
translate([0,0,gear_thickness*1.5+spacer])
mirror([0,0,1])
gear (circular_pitch=small_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2+gear_spacer,
rim_width = rim_width,
hub_thickness = gear_thickness/2+gear_spacer,
hub_diameter=small_dedendum_radius*2,
bore_diameter=bore_radius*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=small_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=-twist_factor*180/small_gear_teeth);
}
}
}
if (negative_space==true)
{
color(structure_color)
translate([0,0,-space])
union()
{
ring(large_addendum_radius+space,0,gear_thickness+2*space);
ring(small_addendum_radius+space,0,2*gear_thickness+spacer+2*space);
ring(sleeve_radius+space,0,2*gear_thickness+spacer+sleeve_extension+2*space);
}
}
}
module pinionEscapementWheel (
radius,
escapement_teeth,
tooth_length,
tooth_lean,
tooth_sharpness,
small_gear_teeth,
small_gear_circular_pitch,
gear_clearance=0.2,
gear_backlash=0.1,
gear_spacer=0.5,
pressure_angle=14.5,
twist_factor=0,
rim_width,
sleeve_level=0,
pin_radius,
sleeve_thickness,
loose_fit=0.5,
gear_thickness,
sleeve_extension,
spacer,
number_spokes=5,
spoke_width,
notch_angle=0,
negative_space=false,
space=0.1,
clubSize=0,
clubAngle=0)
{
//large_dedendum_radius=large_gear_circular_pitch*(large_gear_teeth-2)/360-gear_clearance;
small_dedendum_radius=small_gear_circular_pitch*(small_gear_teeth-2)/360-gear_clearance;
//large_adddendum_radius=large_gear_circular_pitch*(large_gear_teeth+2)/360-gear_clearance;
small_addendum_radius=small_gear_circular_pitch*(small_gear_teeth+2)/360-gear_clearance;
bore_radius=pin_radius+sleeve_level*sleeve_thickness+loose_fit;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
small_gear_color = [0.88, 0.78, 0.5];
structure_color = [0.45, 0.43, 0.5];
//large_gear_color = [0.2, 0.2, 0.2];
if (negative_space==false)
{
union()
{
color(structure_color)
escapementWheel(
radius,
rim_width,
0,
gear_thickness-gear_spacer,
escapement_teeth,
tooth_length,
tooth_lean,
tooth_sharpness,
number_spokes,
spoke_width,
small_addendum_radius,
bore_radius,
clubSize,
clubAngle);
color(structure_color)
translate([0,0,gear_thickness-gear_spacer])
drum(
radius=radius-tooth_length+rim_width,
rimWidth=rim_width,
drumHeight=spacer,
numberHoles=number_spokes,
holeRadius=min(1,(spacer+gear_spacer)/6),
holeRotate=180/number_spokes);
color(structure_color)
ring(sleeve_radius,bore_radius,2*gear_thickness+spacer+sleeve_extension);
color(structure_color)
spokes(number_spokes,radius-tooth_length,gear_thickness-gear_spacer+spacer,spoke_width,bore_radius,0);
color(structure_color)
ring(small_addendum_radius,bore_radius,gear_thickness-gear_spacer+spacer);
color(small_gear_color)
translate([0,0,gear_thickness*1.5+spacer])
gear (circular_pitch=small_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2,
rim_width = rim_width,
hub_thickness = gear_thickness/2,
hub_diameter=small_dedendum_radius*2,
bore_diameter=bore_radius*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=small_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=-twist_factor*180/small_gear_teeth);
color(small_gear_color)
translate([0,0,gear_thickness*1.5+spacer])
mirror([0,0,1])
gear (circular_pitch=small_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2+gear_spacer,
rim_width = rim_width,
hub_thickness = gear_thickness/2+gear_spacer,
hub_diameter=small_dedendum_radius*2,
bore_diameter=bore_radius*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=small_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=-twist_factor*180/small_gear_teeth);
}
}
if (negative_space==true)
{
color(structure_color)
translate([0,0,-space])
union()
{
ring(radius+space,0,gear_thickness+2*space);
ring(small_addendum_radius+space,0,2*gear_thickness+spacer+2*space);
ring(sleeve_radius+space,0,2*gear_thickness+spacer+sleeve_extension+2*space);
}
}
}
module pinionDrum ( //deprecated, use pinionWheel instead, with number of pinion teeth set to zero!
drum_height,
large_gear_teeth,
large_gear_circular_pitch,
gear_clearance=0.2,
gear_backlash=0.1,
gear_spacer=0.5,
pressure_angle=14.5,
twist_factor=0,
rim_width,
sleeve_level=0,
pin_radius,
sleeve_thickness,
loose_fit=0.5,
gear_thickness,
sleeve_extension,
spacer,
number_spokes,
spoke_width,
number_holes=0,
hole_radius=0,
notch_angle=0,
negative_space=false,
space=0.1)
{
echo("pinionDrum is depreacted, use pinionWheel instead, with number of pinion teeth set to zero!");
large_dedendum_radius=large_gear_circular_pitch*(large_gear_teeth-2)/360-gear_clearance;
//small_dedendum_radius=small_gear_circular_pitch*(small_gear_teeth-2)/360-gear_clearance;
large_addendum_radius=large_gear_circular_pitch*(large_gear_teeth+2)/360-gear_clearance;
//small_addendum_radius=small_gear_circular_pitch*(small_gear_teeth+2)/360-gear_clearance;
bore_radius=pin_radius+sleeve_level*sleeve_thickness+loose_fit;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
//small_gear_color = [0.88, 0.78, 0.5];
structure_color = [0.45, 0.43, 0.5];
large_gear_color = [0.2, 0.2, 0.2];
if (negative_space==false)
{
union()
{
color(large_gear_color)
translate([0,0,gear_thickness/2])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2-gear_spacer,
rim_width = rim_width,
hub_thickness = gear_thickness/2-gear_spacer,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=large_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=twist_factor*180/large_gear_teeth);
color(large_gear_color)
translate([0,0,gear_thickness/2])
mirror([0,0,1])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2,
rim_width = rim_width,
hub_thickness = gear_thickness/2,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=large_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=twist_factor*180/large_gear_teeth);
color(structure_color)
translate([0,0,gear_thickness-gear_spacer])
drum(
radius=large_dedendum_radius,
rimWidth=rim_width,
drumHeight=drum_height+gear_spacer,
numberHoles=number_holes,
holeRadius=min(hole_radius,(drum_height+gear_spacer)/6),
holeRotate=notch_angle+180/number_holes);
color(structure_color)
spokes(number_spokes,large_dedendum_radius-rim_width,drum_height+gear_thickness,spoke_width,bore_radius,notch_angle);
color(structure_color)
ring(sleeve_radius,bore_radius,gear_thickness+drum_height+sleeve_extension);
}
}
if (negative_space==true)
{
color(structure_color)
translate([0,0,-space])
union()
{
ring(large_addendum_radius+space,0,gear_thickness+2*space);
ring(large_dedendum_radius+space,0,thickness+drum_height+2*space);
ring(sleeve_radius+space,0,drum_height+sleeve_extension+2*space);
}
}
}
module ratchetArm(
height=4,
width=4,
length=23,
headLength=12,
angle=45,
distance=21,
clockwise=true)
{
circleRadius=10;
translate([distance+width,0,0])
rotate([0,0,angle])
difference()
{
union()
{
cube([headLength,width,height]);
cube([length,width/2,height]);
}
translate([headLength,circleRadius+width/2,height/2])
cylinder(r=circleRadius, h=height+1, center=true);
}
}
module chirality(clockwise=true)
{
if (clockwise==true) child(0);
if (clockwise!=true) mirror([0,0,1]) rotate(180,[1,0,0]) child(0);
}
module ratchetGear(
drum_height,
clockwise=true,
large_gear_teeth,
large_gear_circular_pitch,
gear_clearance=0.2,
gear_backlash=0.1,
gear_spacer=0.5,
pressure_angle=14.5,
twist_factor=0,
rim_width,
sleeve_level=0,
pin_radius,
sleeve_thickness,
loose_fit=0.5,
gear_thickness,
sleeve_extension,
spacer,
number_spokes,
spoke_width,
notch_angle=0,
negative_space=false,
space=0.1)
{
large_dedendum_radius=large_gear_circular_pitch*(large_gear_teeth-2)/360-gear_clearance;
//small_dedendum_radius=small_gear_circular_pitch*(small_gear_teeth-2)/360-gear_clearance;
large_addendum_radius=large_gear_circular_pitch*(large_gear_teeth+2)/360-gear_clearance;
//small_addendum_radius=small_gear_circular_pitch*(small_gear_teeth+2)/360-gear_clearance;
bore_radius=pin_radius+sleeve_level*sleeve_thickness+loose_fit;
sleeve_radius=pin_radius+(sleeve_level+1)*sleeve_thickness;
small_gear_color = [0.88, 0.78, 0.5];
structure_color = [0.45, 0.43, 0.5];
large_gear_color = [0.2, 0.2, 0.2];
if (negative_space==false)
{
union()
{
color(large_gear_color)
translate([0,0,gear_thickness/2])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2-gear_spacer,
rim_width = rim_width,
hub_thickness = gear_thickness/2-gear_spacer,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,
number_of_teeth=large_gear_teeth,
clearance=gear_clearance,
backlash=gear_backlash,
twist=twist_factor*180/large_gear_teeth);
color(large_gear_color)
translate([0,0,gear_thickness/2])
mirror([0,0,1])
gear (circular_pitch=large_gear_circular_pitch,
gear_thickness = 0,
rim_thickness = gear_thickness/2,
rim_width = rim_width,
hub_thickness = gear_thickness/2,
hub_diameter=large_dedendum_radius*2,
bore_diameter=(large_dedendum_radius-rim_width)*2,
circles=0,
pressure_angle=pressure_angle,