summaryrefslogtreecommitdiffabout
path: root/fanduct.scad
blob: 302ea07bf4fbd80ce268dbb19eb172f05899b99d (plain)
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
use <snapper.scad>;
extrusion_width=.5; layer_height=.2;		// print parameters

epsilon=.005;		// for finer cuts

function hypothenuse(a,b) = sqrt(pow(a,2)+pow(b,2));

silicone_shell = 2;
heater_clearance = max(
	hypothenuse(16/2     +silicone_shell, 20-4.5 +silicone_shell),	// E3D v6
	hypothenuse(11.5-4.5 +silicone_shell, 15.5   +silicone_shell)	// E3D volcano
);

fanduct_elevation = 3;							// fanduct elevation above nozzle tip
fanduct_blowtarget = -2;						// what to blow at
fanduct_h = 6;								// inner height of the duct
fanduct_w = 7;								// inner width of the duct
fanduct_shell=1.2;							// shell thickness
fanduct_ir = heater_clearance+5;					// inner radius

jet_angle = 60-2;		// angular width of the jet

inlet_w = 12.5;		// inlet width
inlet_h = 17;		// inlet height
inlet_short_l = 7;	// inlet length of protrusion (or depth of intrusion:))
inlet_away = 15;	// how far away inlet is

inlet_long_l = inlet_short_l+inlet_h;
hotend_clearance = heater_clearance;

nozzles_apart = 18;		// distance between nozzles for dual hotend
space_behind_nozzle = 10;	// space behind the nozzle where we're allowed to go
				// without the fear of hitting carriage

snapper_d = 8; snapper_overlap=0.2;	// snip snap

smooth_f = 120;

type="circular"; 	// circular|3jets
ductshape="square"; 	// square|round
dual=false;		// dual or single

to_midduct = fanduct_ir+fanduct_shell+fanduct_w/2;
dual_spots = [ [+space_behind_nozzle, -(to_midduct+nozzles_apart/2)],
	       [-         to_midduct, -(to_midduct+nozzles_apart/2)],
	       [-         to_midduct, 0] ];

module fanduct(type=type,ductshape=ductshape,dual=dual) {
 //	***	duct is all around!
 module duct(what) {
  module single() {
   if(what=="in") {
    sh = fanduct_w+2*fanduct_shell; sv = fanduct_h+2*fanduct_shell;
    smax = max(sh,sv);
    rotate_extrude($fn=smooth_f)
     if(ductshape=="round")
      translate([sh/2+fanduct_ir,sv/2])
      scale([sh/smax,sv/smax])
      circle(d=smax,$fn=4*smax);
     else if(ductshape=="square")
      translate([fanduct_ir,0])
      square([sh,sv]);
   }else if(what=="out") {
    sh = fanduct_w; sv = fanduct_h;
    smax = max(sh,sv);
    rotate_extrude($fn=smooth_f)
     if(ductshape=="round")
      translate([sh/2+fanduct_shell+fanduct_ir,sv/2+fanduct_shell])
      scale([sh/smax,sv/smax])
      circle(d=smax,$fn=4*smax);
     else if(ductshape=="square")
      translate([fanduct_ir+fanduct_shell,fanduct_shell])
      union() {
       square([sh,sv/2]);
       translate([sh/2,sv/2])
       scale([sh/smax,sv/smax])
       circle(d=smax,$fn=36);
      }
   }
  }
  module dual() {
   module hulls(spots=dual_spots) {
    for(my=[0,1]) mirror([0,my,0]) for(pn=[0:1:len(spots)-2]) hull() {
     for(p=[spots[pn],spots[pn+1]]) translate(p) children();
    }
   }
   if(what=="in") {
    hulls() cylinder(d=fanduct_w+2*fanduct_shell,h=fanduct_h+2*fanduct_shell);
   }else if(what=="out") {
    sh = fanduct_w; sv = fanduct_h;
    smax = max(sh,sv);
    translate([0,0,fanduct_shell]) hulls() {
     cylinder(d=fanduct_w,h=fanduct_h/2);
     translate([0,0,fanduct_h/2])
     scale([sh/smax,sh/smax,sv/smax])
     intersection() {
      sphere(d=smax,$fn=36);
      translate([0,0,-1])
      cylinder(d=smax+2,h=smax+2,$fn=36);
     }
    }
   }
  }

  if(dual) dual();
  else single();
 }

 //	***	bumps for easier position adjustments in line with hotend
 module marks(what) {
  if(what=="in") {
   for(y=[-1,1]) translate([0,dual?y*nozzles_apart/2:0,0])
    hull() for(z=[0,-fanduct_shell-fanduct_h/2])
     translate([0,y*(fanduct_ir+fanduct_shell+fanduct_w/2),fanduct_shell*2+fanduct_h+z])
     rotate([90,0,0]) {
      cylinder(r=fanduct_shell,h=fanduct_w,center=true,$fn=30);
      for(z=[-1,1]) translate([0,0,z*fanduct_w/2])
       sphere(r=fanduct_shell,$fn=30);
     }
  }
 }

 //	***	output
 module output(what,type=type) {
  module guideline(xyxy) {
   module pin(xy) {
    translate([xy[0],xy[1],0])
    cylinder(d=2*extrusion_width,h=2*fanduct_shell+inlet_h,$fn=6);
   }
   xyxyxy=concat(xyxy,[[0,dual?nozzles_apart/2:0]]);
   for(i=[0:1:len(xyxyxy)-2])
    hull() for(j=[i,i+1]) pin(xyxyxy[j]);
  }

  module circus(what) {
   if(what=="in") {
    difference() {
     rotate_extrude($fn=smooth_f)
      polygon([
       [0,-fanduct_elevation+fanduct_blowtarget+epsilon],
       [fanduct_ir+fanduct_shell,fanduct_shell+fanduct_h/2],
       [fanduct_ir+fanduct_shell+fanduct_w/2,0],
       [0,-fanduct_elevation+fanduct_blowtarget-epsilon]]);
     translate([0,0,-1])
     cylinder(r=hotend_clearance,h=fanduct_h+2*fanduct_shell+2,$fn=smooth_f);
     mirror([0,0,1])
     translate([0,0,-epsilon])
     cylinder(r=fanduct_ir+2*fanduct_shell+fanduct_w+1,h=fanduct_elevation+.1+2);
    }
   }else if(what=="out") {
    rotate_extrude($fn=smooth_f)
    polygon([
     [0,-fanduct_elevation+fanduct_blowtarget+epsilon],
     [fanduct_ir+fanduct_shell+1,fanduct_h/2],
     [fanduct_ir+fanduct_w/2+fanduct_shell+1,fanduct_shell],
     [0,-fanduct_elevation+fanduct_blowtarget-epsilon]]);
   }else if(what=="airguides") {
    inr = fanduct_ir+fanduct_shell; our = inr+fanduct_w;
    union() {
     for(my=[0,1]) mirror([0,my,0]) {
      guideline([
       [-our,inlet_w/6],
       [-inr*sin(60),inr*cos(60)]
      ]);
      a0=30; as=15; a1=180;
      for(a=[a0+as:as:a1]) {
       f = as/(a1-a+as);
       rotate([0,0,a]) guideline([[-inr-fanduct_w*f,0]]);
      }
      guideline([
       [-our+fanduct_w*cos(30)*3/4,fanduct_w*sin(30)*3/4],
       [-inr*cos(10),inr*sin(10)]
      ]);
     }
    }/*union*/
   }/*airguides*/
  }

  module jets(what) {
   od = fanduct_h*2/3+fanduct_shell;
   md = fanduct_ir+fanduct_shell+fanduct_w/2;
   jww = 2*md*sin(jet_angle/2);
   difference() {
    for(a=[0:120:359]) rotate([0,0,a]) {
     if(what=="in") {
      hull() {
       intersection() {
	translate([md-fanduct_w/2,-jww/2,0])
	cube(size=[fanduct_shell+fanduct_w/2,jww,od]);
	duct(what=what);
       }
       translate([0,0,-fanduct_elevation]) sphere(r=.5);
      }
     }else if(what=="out") {
      hull() {
       intersection() {
	translate([md-fanduct_w/2,-jww/2+fanduct_shell,fanduct_shell])
	cube(size=[fanduct_w/2,jww-2*fanduct_shell,od-2*fanduct_shell]);
	duct(what=what);
       }
       translate([0,0,-fanduct_elevation]) sphere(r=.2);
      }
     }
    }
    if(what=="in") {
     translate([0,0,-fanduct_elevation-2+epsilon])
     cylinder(r=fanduct_ir+fanduct_shell*2+fanduct_w+1,h=fanduct_elevation+2);
     translate([0,0,-hotend_clearance])
     rotate([0,0,30])
     cylinder(r1=hotend_clearance*2,r2=0,h=hotend_clearance*2,$fn=6);
    }
   }
  }

  module dual(what=what) {
   module hulls(spots=dual_spots) {
    for(my=[0,1]) mirror([0,my,0]) for(pn=[0:1:len(spots)-2]) hull() {
     for(p=[spots[pn],spots[pn+1]]) translate(p) children(0);
     children([1:$children-1]);
    }
   }
   if(what=="in") {
    cfn= 4; // clearance cutout $fn
    difference() {
     hulls() {
      cylinder(d=fanduct_w+2*fanduct_shell,h=2*fanduct_shell+fanduct_h/2);
      translate([0,-nozzles_apart/2,-fanduct_elevation-fanduct_blowtarget]) sphere(d=.1);
     }
     translate([0,0,epsilon]) hull() for(my=[0:1]) mirror([0,my,0]) for(s=dual_spots) translate(s)
      mirror([0,0,1]) cylinder(d=fanduct_w+2*fanduct_shell+2,h=fanduct_elevation-fanduct_blowtarget+1);
     for(s=[-1,1]) translate([0,s*nozzles_apart/2,-1])
      rotate([0,0,180/cfn]) cylinder(r=hotend_clearance/cos(180/cfn),h=fanduct_h+2*fanduct_shell+2,$fn=cfn);
    }
   }else if(what=="out") {
    hulls() {
     translate([0,0,fanduct_shell]) cylinder(d=fanduct_w,h=fanduct_h/2-fanduct_shell/2);
     translate([0,-nozzles_apart/2,-fanduct_elevation+fanduct_blowtarget]) sphere(d=.1);
    }
   }else if(what=="airguides") {
    far = fanduct_ir+fanduct_shell+fanduct_w;
    near = fanduct_ir;
    union() {
     for(my=[0,1]) mirror([0,my,0]) {
      guideline([ [-far             ,0], [0,0] ]);
      guideline([ [-far             ,inlet_w/2/4],
                  [-near            ,nozzles_apart/2] ]);
      guideline([ [-near-fanduct_w/3,nozzles_apart/2+near+fanduct_w/3] ]);
      guideline([ [0                ,nozzles_apart/2+near+fanduct_w/2] ]);
     }
    }
   }
  }

  if(dual) dual(what);
  else if(type=="circular") circus(what);
  else if(type=="3jets") jets(what);
 }

 //	***	air intake
 module intake(what) {
  module placeit() {
   translate([-fanduct_ir-2*fanduct_shell-fanduct_w-inlet_away,0,fanduct_shell])
   rotate([0,-90,0])
   children();
  }
  if(what=="in") {
   placeit() translate([0,-inlet_w/2,0]) {
    difference() {
     cube(size=[inlet_h,inlet_w,inlet_long_l+fanduct_shell]);
     translate([inlet_h+fanduct_shell,0,inlet_long_l+fanduct_shell])
     rotate([-90,0,0])
     translate([0,0,-1])
     cylinder(r=inlet_h,h=inlet_w+2*fanduct_shell+2,$fn=inlet_h*4);
    }
    // supports
    for(i=[-1,0,1])
     translate([-fanduct_shell,
      (i+1)*(inlet_w-extrusion_width)/2,
     -inlet_away-fanduct_w/2])
     cube(size=[fanduct_shell+1,
      extrusion_width,
      inlet_long_l+fanduct_shell+inlet_away+fanduct_w/2]);
   }
   hull() {
    placeit() translate([-fanduct_shell,-inlet_w/2-fanduct_shell,0])
    cube(size=[inlet_h+2*fanduct_shell,inlet_w+2*fanduct_shell,fanduct_shell]);
    translate([-fanduct_ir-fanduct_shell-fanduct_w/2,0,0])
    translate([0,-inlet_w/2-fanduct_shell/2,0])
    cube(size=[1,inlet_w+fanduct_shell,fanduct_shell*2+fanduct_h]);
   }
  }else if(what=="out") {
   placeit() translate([fanduct_shell,-inlet_w/2+fanduct_shell,0])
   cube(size=[inlet_h-2*fanduct_shell,inlet_w-2*fanduct_shell,inlet_long_l+fanduct_shell+1]);
   hull() {
    placeit() translate([fanduct_shell,-inlet_w/2+fanduct_shell,0])
    cube(size=[inlet_h-2*fanduct_shell,inlet_w-2*fanduct_shell,fanduct_shell]);
    translate([-fanduct_ir-fanduct_shell-fanduct_w/2,0,fanduct_shell])
    translate([0,-inlet_w/2+fanduct_shell,0])
    cube(size=[1,inlet_w-2*fanduct_shell,fanduct_h]);
   }
  }
 }

 //	***	DUCT TAILS!!! WOO-OO! (every day they're out there making duct tails…)
 module tails(what) {
  if(dual) {
   // XXX: not sure if it will ever be
  }else{
   if(what=="in") {
    for(mx=[0,1]) mirror([mx,0,0])
    translate([fanduct_ir+fanduct_shell+fanduct_w/2,0,fanduct_shell+fanduct_h/2])
    rotate([90,0,90])
    translate([0,0,-snapper_d/2])
    snapper(d=snapper_d,o=snapper_overlap,side=0,l=fanduct_h*3/2+fanduct_shell);
   }
  }
 }

 module parts(what) {
  union() {
   duct(what);
   marks(what);
   output(what);
   intake(what);
   tails(what);
  }
 }

 difference() {
  parts("in");
  parts("out");
 }
 intersection() {
  union() {
   output("airguides");
   sphere(d=epsilon);
  }
  union() {
   duct("in"); output("in"); intake("in");
  }
 }
}

view="*"; // hcut|vcut|*

hinfinity=4*(fanduct_ir+fanduct_shell*2+fanduct_w+inlet_away);
vinfinity=2*(fanduct_shell*2+fanduct_h+inlet_h);
if(view=="hcut") {
 difference() {
  fanduct();
  translate([-hinfinity/2,-hinfinity/2,fanduct_shell+fanduct_h/2])
  cube(size=[hinfinity,hinfinity,vinfinity]);
 }
}else if(view=="vcut") {
 difference() {
  fanduct();
  translate([-hinfinity/2,0,-vinfinity/2])
  cube(size=[hinfinity,hinfinity,vinfinity]);
 }
}else fanduct();
/* vim:set sw=1 ai: */