-
Notifications
You must be signed in to change notification settings - Fork 0
/
Microscope_objective_funnel_stop_universal_2.scad
1464 lines (1055 loc) · 48.3 KB
/
Microscope_objective_funnel_stop_universal_2.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
// design of darkfield objective funnel stops
// Giorgio Pattarini Oktober-November 2021
//user-defined parameters
/*[ Choice of model]*/
// Choose the design that fits best into your objective, Flat is for Plan and low power like 4x, Funnel tab flange can substitute an existing stop
mount="Funnel neck fit"; //[Funnel neck fit, Funnel tab flange, Funnel flush flange, Tub sleeve fit, Tub tip fit, Flat disk, Flat tab flange]
// For funnel models only, tip can be integrated (one piece, more solid) or separated (interchangeable, more options, neater aperture)
tip_style="Fixed tip"; //[Fixed tip, Interchangeable tip]
//Choice of fitting
fitting="Press fit"; //[Screw thread, Press fit, Straight, Fake thread]
/*[ Body and fitting dimensions]*/
// Nominal diameter of the fitting AS MEASURED (for screw, diameter of male thread) (for press fit, inner diameter of the bore to fit)
fit_diam_nom=15.1;
// Pitch of the screw thread (most common are 0.5 or 0.75 mm)
passo_vite=0.51; //italian because the english is already in use
// Tweak the fitting diameter to get optimal fit ( use zero for the first print trial) (change it for looser or tighter fit, +0.2 mm makes it larger, therefore tighter) (by default: Thread and Straight are designed with nominal diameter. Press-fit has built-in 0.4mm extra diameter)
fit_diam_tweak= 0.001;
//Funnel total height (it is 0 for flat ) (does not include base thickness)
funneldepth=33.3;
// Outer diameter of the funnel tip (zero for automatic, same as funnel base diameter (will get overridden by fit diameter for flat and tip-fit models)
topdiam=0;
// Heigth of the tip, (will override total height if larger) (is overridden only for tip-fit tub, by minimum fit height)
taph= 6.6; // heigth tip
// Outer diameter of the funnel main tube (0 for automatic)(may get overridden if there is no space)
fundiam= 0;
// Diameter of the base flange (only for funnel models) (0 for auto, +3mm step)
flangediam=0;
// Thickness of the base flange for funnel models (also tot thickness for flat models)
base_thick=2.1;
/*[Type and dimensions of the stop]*/
// Type of stop (some designs are available only for flat-printed aperture)
tip="Standard"; //[Standard, Half Moon, Center stop,Stop that removes all aberrations, Ohers ]
// Main stop diameter (will be overridden if smaller than available diameter, and also baffling may chime in ) (0 for automatic, will set the maximum)
odstop=0;
// Main stop off-center, for oblique illumination and 3D imaging (leave 0 for centered)
ostopoff=0;
// inner stop disk diameter , for inverted darkfield aka luminance contrast
idstop= 2.1;
// Inner stop disk off-center, for oblique illumination
istopoff=0;
// Half moon stop coverage, in percentage, 50% covers half circle, 60% a bit more
halfmoon=50;
// Angle between the off-center of outer main stop and the other stops, either inner or half moon
angleinoutstop=0;
/*[Baffling]*/
// Size of small baffles (they may restrict the desired aperture, put 0 to get rid of them)
minhbaffle=0.4;
// Number of big baffles (put 0 for no main baffles)
baffleantall=5;
// Open optical diameter of the main baffle at the flange, (if left to 0, diameter gets generated automatically )(may get overridden if there is not enough space)
dbaffle = 0; //
/*[ Geometry and print tweaks]*/
// Cuts half of the body so the inside is visible
cross_section="Full body";//[Full body, Cross section]
// Normal wall thickness of the parts (funnel walls, tabs etc have this thickness by default)()
wallth_normal=1.1;
//Use wallth for most modules
wallth=wallth_normal;
// max overhang angle, for FDM 3D printing (it affects shape, baffles, etc) (30, safe) (45, ok) (60, risk of printing defects) (90, printer or software crash) ( >90 , tachions)
maxoverhang=30;
overhang=maxoverhang;
rake_overhang=tan(90-maxoverhang);
// fitting ring
// Total height of the fitting tab block (0 for automatic, the minimum to have some fit) (to remove the fitting tab altogether, choose "straight fit" above) (if shorter than the Auto, will remove relief and rake)
ring_height_override=0;
// Rake angle of the fitting tab (0 for automatic, the rake_overhang angle)
tab_rake_override=0;
// relief of the fitting tab, in both direction (here zero means zero)
tab_relief=0.5;
//moves up and down the fit tab wrt its auto position
tab_height=0;
// makes the fitting tab of different thickness, (extra radius wrt supporting ring)(0 auto)
tab_thickness_override=0.0;
// Tweak the size of the relief cuts for press fit models (Large, 1 makes for better print and fit, but takes space, 1/2 takes half space, 0 no cuts)
pressfit_cut_size=1; //[1, 0.5, 0]
// Tweak the standard interference (extra diameter) for press fit models (0.4 mm recommended)
pressfit_interference_diameter=0.4;
// number of braces supporting the stop(spiders)
spidernumber=3;
// width spiders, to make them as thin as possible
wspider = 0.8;
// For Interchangeable tip funnels, choose what to print
inter_print="One base and one tip"; //[ "One base and one tip", "Base only", "Tip only"]
//build geometries slightly larger to avoid issues in intersections and differences
overmaterial=0.05;
// render quality, number of divisions in rotations, global $fn (higher, smoother 3D, but longer processing time)
divs= 30; //
// screw design, circumferential step (heavily affect processing time) (1mm is ok )
screw_resolution = 1.1; // in mm
// unknown tweak with unknown results
cylrad=7.5;
/*[Make an array of stops with different diameters etc]*/
// number of stop diameters (it generates several caps together with the funnel) put 0 for no caps, With 1, it makes the minimum
rcapsteps=4;
// minimum radius of the central stop
rcapmin=1;
// maximum radius of the central stop
rcapmax=3;
// The central stop can be off centered, Here how many offset caps will print
offcapsteps=1;
// minimum off center of the central stop, Leave zero for centered stop
offcapmin=0;
// max stop offset, distance from center
offcapmax=1;
{// Geometry drawings and calculations----------------------------
{ // Drawings
/*
_
|_| minimum wall thickness
|
|
+ center axe - Half-section profile views
|
|
|
- STANDARD FUNNELS -
_ ____ _
| aperture_or-\ |-tip_rad_build |tip_height_build
| \ | |
| | | _|
| \ \-(taper cone)
|tot_height_build \ \
| | |-tube_rad_build
| | |
| | |__|fit_ring_rad_in _
| | | | | |fit_ring_height_build
| | | | \ |
| fit_bore_rad_build-| | | |-fit_rad_out |
| | | | / |
| | | |-fit_ring_rad_out |
|_ | | | |__________ _| _
baffle_rad_build|_| | | | |flange_height_build
\__|__|____________|-flange_rad_build _|
- TIP FIT FUNNEL -
_ ___
| baffle_rad_build\ |
| | |-tube_rad_build
| | |
| / /
| / / __ tip_height_build
|tot_height_build | | _|
| | | |fit_ring_height_build
|fit_bore_rad_build-| \ |
| fit_ring_rad_in-| |-fit_rad_out |
| | / |
| ___| |-tip_rad_build |
|_ aperture_or-/_____|-fit_ring_rad_out __|
- SLEEVE FIT FUNNEL-
_ ___
| baffle_rad_build-\ |
| | |-tube_rad_build _
| | |-fit_ring_rad_out |fit_ring_height_build
| fit_bore_rad_build-| \ |
| fit_ring_rad_in-| |-fit_rad_out |
| | / |
| | | _|
| / /
| / / _
|tot_height_build | | |tip_height_build
| | | |
| | | |
| | | |
| | | |
| ___| |-tip_rad_build |
|_ aperture_or-/_____| _|
- FLAT DISK -
tube_rad_build-| |-fit_ring_rad_in
_ _____
| | | | |
| | | | | _
|tot_height_build | | | | |fit_ring_height_build
| | | | \ |
| fit_bore_rad_build-| | | |-fit_rad_out |
| ____| | | / |
|_ aperture_or-/__________|-fit_ring_rad_out _|
- FLANGED DISK -
tube_rad_build-| |-fit_ring_rad_in
_____ _
| | | |-fit_ring_rad_out |fit_ring_height_build
fit_bore_rad_build-| | | \ |
| | | |-fit_rad_out |
| | | / |
| | | |________ _ _|
_____| | |
aperture_or-/____________________| _| flange_height_build
*/
}
{// Dimension calculations
{// fit rings
// checks the type of fitting and determines the diameters and sizes of the fit tab, with global variables & horrible formatting
//the screw thread needs an outer diameter as fit, supporting tube diameter matching the female thread inner with pointy tips; heigth such that makes at least two full threads
// The press fit is made with some interference, 0.4mm tab depth, 1mm tab height
// The straight fit is made at build diameter and height as minimum thickness
// external radius to fit in the bore or female thread
fit_diam=fit_diam_nom + fit_diam_tweak;
fit_rad_out=
(fitting=="Press fit") ?
(1/2)*(fit_diam+pressfit_interference_diameter)
:
(1/2)*fit_diam;
echo(fit_rad_out=fit_rad_out);
// radius of tube supporting the ring
fit_ring_rad_out=
(tab_thickness_override!=0)?
fit_rad_out-tab_thickness_override
:
(fitting=="Screw thread" || fitting=="Fake thread") ?
fit_rad_out - 0.86603 * passo_vite -overmaterial
:
(fitting=="Press fit") ?
fit_rad_out-0.4
:
fit_rad_out;
echo(fit_ring_rad_out=fit_ring_rad_out);
echo(fit_ring_rad_in=fit_ring_rad_in);
fit_ring_rad_in=fit_ring_rad_out-wallth;
// rake of the tab
fit_tab_rake=
(tab_rake_override!=0)?
tan(90-tab_rake_override)
:
rake_overhang;
// height of the tab (the portion at full diameter)
fit_tab_height=
(ring_height_override!=0)?
ring_height_override-2*(tab_relief + fit_tab_rake*(fit_ring_rad_out-fit_rad_out))
:
(fitting=="Screw thread") ?
2*passo_vite
:
(fitting=="Fake thread" ) ?
2*passo_vite
: (
fitting=="Press fit") ?
1
:
wallth;
echo(fit_tab_height=fit_tab_height);
fit_ring_height_build= fit_tab_height + 2*(tab_relief + fit_tab_rake*(fit_rad_out-fit_ring_rad_out));
echo(fit_ring_height_build=fit_ring_height_build);
}//end fit rings------------------------------------------
{// bores and diameters for the tubes and tips
// max available inner optical bore radius, as restricted by the fitting ring
// in most cases can go until the fitting
// for some press fit, need to accomodate the flexing tab and its cut
//also if the tube diameter is user defined, may restrict it
fit_bore_rad_build=
( (mount=="Funnel tab flange" || mount=="Funnel flush flange" || mount=="Flat disk" || mount=="Flat tab flange")&&( fitting=="Press fit"))?
(fundiam==0)?
fit_ring_rad_in-wallth*(1+pressfit_cut_size)
:
min(fundiam/2, (fit_ring_rad_in-wallth*(1+pressfit_cut_size)))
:
(mount=="Tub tip fit" || mount=="Tub sleeve fit")?
fit_ring_rad_in
:
(mount== "Funnel neck fit" || fundiam==0)?
fit_ring_rad_in
:
min(fundiam/2, fit_ring_rad_in);
tube_rad_build=
( mount=="Tub tip fit")?
max(fundiam/2, fit_ring_rad_out)
:
fit_bore_rad_build+wallth;
echo(tube_rad_build=tube_rad_build);
// available outer diameter for the tip
tip_rad_build=
( mount=="Tub tip fit")?
fit_bore_rad_build+wallth
:
(topdiam==0)?
tube_rad_build
:
min(topdiam, tube_rad_build);
// for the Tub fit models, tip height overrides total height
// for all other models, the opposite
//fit ring height always overrides
tot_height_build=
(mount=="Tub tip fit")?
max(funneldepth, taph, fit_ring_height_build)
:
(mount=="Tub sleeve fit")?
max(funneldepth, taph + fit_ring_height_build + rake_overhang*(tube_rad_build-tip_rad_build))
:
max(funneldepth, fit_ring_height_build);
tip_height_build=
((mount!="Tub tip fit")||(mount!="Tub sleeve fit"))?
min(taph, tot_height_build)
:
(mount=="Tub tip fit")?
max(taph, fit_ring_height_build)
:
taph;
// Determines the main aperture DIAMETER of the funnel, either user defined or auto with a tiny 0.2mm baffle, overrides the user defined if too small
aperture_od=
(odstop==0)?
2*(tip_rad_build-wallth - 0.4 )
:
min(odstop, 2*(tip_rad_build-wallth - 0.4 )) ;
// Determines the radius of the main baffle, either auto (rake 1/10 or 0.2mm baffle on top) or user defined
baffle_rad_build=
(dbaffle==0)?
min(aperture_od/2 + (1/10)* tot_height_build, tube_rad_build -2*wallth-0.4)
:
dbaffle;
// base flange overrides
flange_rad_build=
(flangediam==0)?
fit_rad_out+3
:
max(flangediam/2, fit_ring_rad_out);
echo(flange_rad_build=flange_rad_build);
flange_height_build=
(base_thick==0)?
2
:
max(base_thick, wallth);
echo(flange_height_build=flange_height_build);
} // end bores
} // end calculations--------------------
} //end geometry setup-------------------
{//utility modules-----------------
module crossection(){
//cuts half of the body to make the inside visible
if(cross_section=="Cross section"){
difference(){
children();
linear_extrude(200, center=true)
polygon(
points=[
[100,-100],[100,0],[-100,0],[-100,-100]]);}
}
else {children();}
}
//clean everything below zero
module clean_negative(){
difference(){
children();
rotate_extrude($fn=divs)
polygon(
points=[
[0, 0],[100,0],
[100, -100], [0, -100],
[0,0]
]
);
}}
} // end utility modules
{// screw design modules-----------
// Created 2016-2017 by Ryan A. Colyer.
// This work is released with CC0 into the public domain.
// https://creativecommons.org/publicdomain/zero/1.0/
//
// https://www.thingiverse.com/thing:1686322
//
// v2.1
// This generates a closed polyhedron from an array of arrays of points
module ClosePoints(pointarrays) {
function recurse_avg(arr, n=0, p=[0,0,0]) = (n>=len(arr)) ? p :
recurse_avg(arr, n+1, p+(arr[n]-p)/(n+1));
N = len(pointarrays);
P = len(pointarrays[0]);
NP = N*P;
lastarr = pointarrays[N-1];
midbot = recurse_avg(pointarrays[0]);
midtop = recurse_avg(pointarrays[N-1]);
faces_bot = [
for (i=[0:P-1])
[0,i+1,1+(i+1)%len(pointarrays[0])]
];
loop_offset = 1;
bot_len = loop_offset + P;
faces_loop = [
for (j=[0:N-2], i=[0:P-1], t=[0:1])
[loop_offset, loop_offset, loop_offset] + (t==0 ?
[j*P+i, (j+1)*P+i, (j+1)*P+(i+1)%P] :
[j*P+i, (j+1)*P+(i+1)%P, j*P+(i+1)%P])
];
top_offset = loop_offset + NP - P;
midtop_offset = top_offset + P;
faces_top = [
for (i=[0:P-1])
[midtop_offset,top_offset+(i+1)%P,top_offset+i]
];
points = [
for (i=[-1:NP])
(i<0) ? midbot :
((i==NP) ? midtop :
pointarrays[floor(i/P)][i%P])
];
faces = concat(faces_bot, faces_loop, faces_top);
polyhedron(points=points, faces=faces);
}
// This creates a vertical rod at the origin with external threads. It uses
// metric standards by default.
module ScrewThread(outer_diam, height, pitch=0, tooth_angle=30, tolerance=0.4, tip_height=0, tooth_height=0, tip_min_fract=0) {
pitch = (pitch==0) ? ThreadPitch(outer_diam) : pitch;
tooth_height = (tooth_height==0) ? pitch : tooth_height;
tip_min_fract = (tip_min_fract<0) ? 0 :
((tip_min_fract>0.9999) ? 0.9999 : tip_min_fract);
outer_diam_cor = outer_diam + 0.25*tolerance; // Plastic shrinkage correction
inner_diam = outer_diam - tooth_height/tan(tooth_angle);
or = (outer_diam_cor < screw_resolution) ?
screw_resolution/2 : outer_diam_cor / 2;
ir = (inner_diam < screw_resolution) ? screw_resolution/2 : inner_diam / 2;
height = (height < screw_resolution) ? screw_resolution : height;
steps_per_loop_try = ceil(2*3.14159265359*or / screw_resolution);
steps_per_loop = (steps_per_loop_try < 4) ? 4 : steps_per_loop_try;
hs_ext = 3;
hsteps = ceil(3 * height / pitch) + 2*hs_ext;
extent = or - ir;
tip_start = height-tip_height;
tip_height_sc = tip_height / (1-tip_min_fract);
tip_height_ir = (tip_height_sc > tooth_height/2) ?
tip_height_sc - tooth_height/2 : tip_height_sc;
tip_height_w = (tip_height_sc > tooth_height) ? tooth_height : tip_height_sc;
tip_wstart = height + tip_height_sc - tip_height - tip_height_w;
function tooth_width(a, h, pitch, tooth_height, extent) =
let(
ang_full = h*360.0/pitch-a,
ang_pn = atan2(sin(ang_full), cos(ang_full)),
ang = ang_pn < 0 ? ang_pn+360 : ang_pn,
frac = ang/360,
tfrac_half = tooth_height / (2*pitch),
tfrac_cut = 2*tfrac_half
)
(frac > tfrac_cut) ? 0 : (
(frac <= tfrac_half) ?
((frac / tfrac_half) * extent) :
((1 - (frac - tfrac_half)/tfrac_half) * extent)
);
pointarrays = [
for (hs=[0:hsteps])
[
for (s=[0:steps_per_loop-1])
let(
ang_full = s*360.0/steps_per_loop,
ang_pn = atan2(sin(ang_full), cos(ang_full)),
ang = ang_pn < 0 ? ang_pn+360 : ang_pn,
h_fudge = pitch*0.001,
h_mod =
(hs%3 == 2) ?
((s == steps_per_loop-1) ? tooth_height - h_fudge : (
(s == steps_per_loop-2) ? tooth_height/2 : 0)) : (
(hs%3 == 0) ?
((s == steps_per_loop-1) ? pitch-tooth_height/2 : (
(s == steps_per_loop-2) ? pitch-tooth_height + h_fudge : 0)) :
((s == steps_per_loop-1) ? pitch-tooth_height/2 + h_fudge : (
(s == steps_per_loop-2) ? tooth_height/2 : 0))
),
h_level =
(hs%3 == 2) ? tooth_height - h_fudge : (
(hs%3 == 0) ? 0 : tooth_height/2),
h_ub = floor((hs-hs_ext)/3) * pitch
+ h_level + ang*pitch/360.0 - h_mod,
h_max = height - (hsteps-hs) * h_fudge,
h_min = hs * h_fudge,
h = (h_ub < h_min) ? h_min : ((h_ub > h_max) ? h_max : h_ub),
ht = h - tip_start,
hf_ir = ht/tip_height_ir,
ht_w = h - tip_wstart,
hf_w_t = ht_w/tip_height_w,
hf_w = (hf_w_t < 0) ? 0 : ((hf_w_t > 1) ? 1 : hf_w_t),
ext_tip = (h <= tip_wstart) ? extent : (1-hf_w) * extent,
wnormal = tooth_width(ang, h, pitch, tooth_height, ext_tip),
w = (h <= tip_wstart) ? wnormal :
(1-hf_w) * wnormal +
hf_w * (0.1*screw_resolution + (wnormal * wnormal * wnormal /
(ext_tip*ext_tip+0.1*screw_resolution))),
r = (ht <= 0) ? ir + w :
( (ht < tip_height_ir ? ((2/(1+(hf_ir*hf_ir))-1) * ir) : 0) + w)
)
[r*cos(ang), r*sin(ang), h]
]
];
ClosePoints(pointarrays);
}
// This creates a threaded hole in its children using metric standards by
// default.
module ScrewHole(outer_diam, height, position=[0,0,0], rotation=[0,0,0], pitch=0, tooth_angle=30, tolerance=0.4, tooth_height=0) {
extra_height = 0.001 * height;
difference() {
children();
translate(position)
rotate(rotation)
translate([0, 0, -extra_height/2])
ScrewThread(1.01*outer_diam + 1.25*tolerance, height + extra_height,
pitch, tooth_angle, tolerance, tooth_height=tooth_height);
}
}
// example from rcoyle
// Solid rod on the bottom, internal threads on the top.
// Flips around x-axis after printing to pair with RodStart.
module RodEnd(diameter, height, thread_len=0, thread_diam=0, thread_pitch=0) {
// A reasonable default.
thread_diam = (thread_diam==0) ? 0.75*diameter : thread_diam;
thread_len = (thread_len==0) ? 0.5*diameter : thread_len;
thread_pitch = (thread_pitch==0) ? ThreadPitch(thread_diam) : thread_pitch;
ScrewHole(thread_diam, thread_len, [0, 0, height], [180,0,0], thread_pitch)
cylinder(r=diameter/2, h=height, $fn=24*diameter);
}
// pattas modifications-------------------
// nominal screw hole
module ScrewHoleNominal(outer_diam, height, position=[0,0,0], rotation=[0,0,0], pitch=0, tooth_angle=30, tolerance=0.0, tooth_height=0) {
extra_height = 0.001 * height;
difference() {
children();
translate(position)
rotate(rotation)
translate([0, 0, -extra_height/2])
ScrewThread(1.001*outer_diam , height + extra_height,
pitch, tooth_angle, tolerance, tooth_height=tooth_height);
}
}
// ghiera nominale
// the module used to tap the thread
module TapNominal(diameter, height, thread_len, thread_diam, thread_pitch) {
ScrewHoleNominal(thread_diam, thread_len, [0, 0, height], [180,0,0], thread_pitch)
cylinder(r=diameter/2, h=height, $fn=24*diameter);
}
}// end screw modules
{// baffle modules -------------------------------
//single baffle module; zero at top; overhang slightly smaller than others to avoid useless details
module baffle( or, ir,rake_overhang) {
rotate_extrude($fn=divs)
polygon(
points=[
[or, 0],[ir,0 ], [or,-0.99*rake_overhang*(or-ir)],[or, 0]
] ); }
// Conical and tilted array of baffles
//start with the centered flange and sweeps until the offsetted tip aperture
//base of baffles may protrude below start
module bafflecone(antall, start, stop, aperture_top, aperture_bottom, decenter_top, decenter_bottom, tuberad, rake_overhang) {
if(antall>0){
bafflespacing=(stop-start)/antall;
for(i=[0:(antall-1)]){
translate([decenter_top*i/antall + decenter_bottom*(antall-i)/antall,0, i*bafflespacing + start])
baffle( tuberad+ aperture_bottom + (aperture_top-aperture_bottom)*(i-1)/antall, aperture_bottom + (aperture_top-aperture_bottom)*i/antall , rake_overhang);
} }}
// straight array of baffles to fit inside a tube, spacing determined by the relative spacing ratio (smaller baffles, more baffles, capped by antall), baffles start at start pointing at start
module baffletube( ratio, antall, start, stop, or, ir , rake_overhang){
if(ir<or){
nbaffles=min (antall, abs(floor (stop-start)/((or-ir)*ratio)));
step= (start-stop)/ nbaffles;
for(i=[0:(nbaffles-1)]){
translate([0,0, start-i*step])
baffle(or, ir, rake_overhang);
} } }
} // end baffle modules
{//Funnel tube module and stops for bottom print---------------
// module for internals of the standard tube
//zero at top
module tubeint ( tiprad, tuberad, wallthick, tiplength, totlength ,rake_overhang){
rotate_extrude($fn=divs)
polygon(
points=[
[tiprad-wallthick, 0],[tiprad-wallthick,-tiplength ],[tuberad-wallthick, - (tiplength + rake_overhang*(abs(tuberad-tiprad)))],[tuberad-wallthick, -totlength ], [tuberad+0.1,-totlength ], [tuberad+0.1, 0],[tiprad-wallthick, 0]
]);}
//module for cutting the externals of the tube
module tubeout ( tiprad, tuberad, wallthick, tiplength, totlength, rake_overhang){
taperstart= min(totlength -1, tiplength + rake_overhang)*abs(tuberad-tiprad); // makes sure that the tip taper gets to the external tube diameter at the base
rotate_extrude($fn=divs)
polygon(
points=[
[tiprad, overmaterial],[tiprad,-tiplength ],[tuberad, - taperstart],[tuberad, -(totlength + 100)], [tuberad+100,-(totlength + 100) ], [tuberad+100, overmaterial], [tiprad,overmaterial]
]);}
//standard stop module, only the top baffle internals
module mainstop ( aperture, tuberad, rake_overhang){
rotate_extrude($fn=divs)
polygon(
points=[
[aperture, 0],[2*tuberad + aperture,0],[2*tuberad + aperture,-(rake_overhang)* 2*tuberad ]
]);}
// rewritten halfmoon module
// it is just a wedge
module halfstop(tuberad){
translate([0,0,0])
rotate(90,[1,0,0])
linear_extrude(height=2*tuberad+1, center=true)
polygon(
points=[
[-2*tuberad,0],[0,0],
[-2*tuberad, -4*tuberad], [-2*tuberad,0]
]);}
{//center stop modules --------------
//center stop modules, needs radius and thickness
//zero is at the top
module stopg(rad,thick, rake_overhang){
translate([0,0,-thick])
if ((rad-rake_overhang*thick)>0){
// check that the overhang cone is printable from the platform, so gets truncated, overhang build 2 to 1
rotate_extrude($fn=divs)
polygon(
points=[
[0,0],[0, thick],[rad,thick],[rad-rake_overhang*thick,0],[0,0]
]);}
else{
//builds a floating cone
rotate_extrude($fn=divs)
polygon(
points=[
[0, thick],[rad, thick], [0.5, thick - rad*rake_standard+ 0.5], [0, thick - rad*rake_overhang + 0.5],[0,thick]
]);}}
// spiders for supporting center module
// inputs: (number of), max outer radius, brace width, thickness available, radius of the stop to support
// zero at top of stop
module spiderg(no, orad, width,rad, thick , rake_overhang){
ht =min(width, thick); // how tall the spider
for(i=[0:no]){ //makes many spiders
rotate(i*360/no, [ 0,0,1]){
if ((rad-rake_overhang*thick)>0){
// check that the stop cone is printable from the platform, and spiders too will be printed from the platform
translate ([orad,0,-ht/2])
cube([2*orad,ht,ht],true);
}
else //makes a raked overhang
{
translate([0,0,- rad*rake_overhang + ht+ 0.5])
difference(){
rotate(90, [1,0,0])
linear_extrude(width, center=true)
polygon(
points=[
[0, -ht], [0, 0],[orad, 0 ], [orad, - 0.9*rake_overhang*orad], [0,-ht]
]);
rotate_extrude($fn=divs)
polygon(
points=[
[0,-thick], [0, - 2*orad +2], [orad+1, -2*orad+2], [orad+1,-thick], [0,-thick]
] );}}}}}
//spiders and stop combined
module centerstopd(no, orad, width,rad, thick, rake_overhang){
union()
stopg(rad,thick,rake_overhang);
spiderg(no, orad, width,rad, thick ,rake_overhang);
}
// magic stop that removes all aberration
module magicstop(tiprad){
rotate_extrude($fn=divs)
polygon(
points=[
[0,0], [tiprad,0],[tiprad,-1], [0,-1],[0,0]
]);
}
} // end center stop modules
} //end funnel tip modules
{// Flat printed stops and cap modules-------------------
// zero is end surface, flat, build goes down
// support ring and external aperture, for bottom-printed flat, shifted and rotated
// fitheigth is the heigth of tube for tabs
module flatring(tiprad, thick, fitheigth, aperture, off, offangle){
intersection(){
union(){
// support ring
rotate_extrude($fn=divs)
polygon(
points=[
[ tiprad-thick-overmaterial, 0],[tiprad+2*overmaterial,0],
[tiprad+2*overmaterial,-thick-fitheigth-overmaterial], [tiprad-thick -overmaterial,-thick-fitheigth-overmaterial],
[ tiprad-thick-overmaterial, 0]
]) ;
//aperture, shifted and rotated
rotate(offangle,[0,0,1])
translate([off, 0,0])
rotate_extrude($fn=divs)
polygon(
points=[
[ aperture/2, 0], [aperture/2, -thick/3], [aperture/2 + thick/2, -thick],
[2*tiprad,-thick], [2*tiprad, 0],
[ aperture/2, 0]
]) ;
}
//trim outer material by intersection
rotate_extrude($fn=divs)
polygon(
points=[
[ 0,0], [0, -thick-fitheigth], [tiprad+overmaterial, -thick-fitheigth],[tiprad + overmaterial, 0], [0,0]
]) ;
}
}
// center stop with spiders
//thick is the main measure, both disk thickness and spiders
module flatstop (tiprad, thick, aperture, off, spiderwidth, spidernumber){
intersection(){
union(){
translate([off,0,0]){ // the center offset
// the central stop
rotate_extrude($fn=divs)
polygon( points=[
[0,0], [aperture/2, 0],
[aperture/2, -thick/3], [aperture/2-thick/2, -thick],
[0, -thick], [0,0]
]);
// the spiders, with chamfered profile
for (i=[0:(spidernumber-1)]){
rotate((i +1/2 )*360/spidernumber , [0,0,1])
rotate(90,[1,0,0])
linear_extrude(2*tiprad)
polygon( points=[
[-thick/2, 0], [thick/2,0], [thick/2, -thick/3],
[thick/4, -thick], [-thick/4, -thick,],[-thick/2, -thick/3],[-thick/2,0]
]); }
}}
// outer trimming
rotate_extrude($fn=divs)
polygon( points=[
[ 0,overmaterial], [0,-thick-overmaterial], [tiprad, -thick-overmaterial],[tiprad, overmaterial], [0,overmaterial]
]) ;
}}
// half moon stop
module flatmoon(tiprad, thick, off){
intersection(){
// the half stop
rotate(90,[1,0,0])
linear_extrude(2*tiprad, center=true)
polygon( points=[
[off, 0], [off, -thick/3],
[off-thick/2, -thick],
[-2*tiprad, -thick], [-2*tiprad, 0],
[off,0]
]);
// outer trimming
rotate_extrude($fn=divs)
polygon( points=[
[ 0,overmaterial], [0,-thick-overmaterial], [tiprad, -thick-overmaterial],[tiprad, overmaterial], [0,overmaterial]
]) ;
}
}
module flat_aperture(outer_rad, aperture, off, offangle){
// combines in one module the different flat apertures
//makes a thin aperture stop, to fit inside a flange afterwards
flatring(outer_rad, wallth, wallth, aperture, off, offangle); // the standard aperture
if(tip=="Half Moon"){ flatmoon(outer_rad, wallth, halfmoon* aperture/2);}
else if (tip=="Center Stop") {flatstop(outer_rad, wallth, idstop, wspider,spidernumber);}
else if(tip=="Stop that removes all aberrations"){flatring(outer_rad, wallth, wallth, 0, 0,0);}
else{ } //adds nothing , leaves the standard aperture
}
} // end flat printed stop and cap modules