summaryrefslogtreecommitdiff
path: root/another.scad
blob: 9f42f46aed2141eba0177f5973e7069e0d27e286 (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
draft=true;
layer_height=0.2; extrusion_width=0.4;
epsilon=0.01;
$fs=0.0125;

use <threads.scad>;
module pushfit_thread(h=10) {
 thr = 3/8 + .5/25.4;
 slit = 25.4*thr/2 + 0.4;
 if(draft) cylinder(d=thr*25.4,h=h);
 else english_thread(diameter=thr,threads_per_inch=28,length=h/25.4,internal=true);
 translate([-2,-slit,0]) cube([4,2*slit,h]);
}

module the_extruder(
 // motor properties
 gearbox_d = 36,
 mount_d = 28,					// the distance between opposite mounting holes
 mounthole_depth = 5,
 protrusion_d = 22, protrusion_h = 2.2,		// the dimensions of the protrusion on top of gearbox
 bore_d = 8, bore_l = 17.6,
 bore_dd = 7,
 // pulley properties
 pulley_d = 11.5, pulley_h=10,
 pulley_elevation = 1,				// pulley elevation above the protrusion
 teeth_elevation = 7.5,				// distance from the bottom of the pulley to its teeth
 // idler properties
 idler_d = 9.5, idler_h = 4, idler_id = 3,	// idler dimensions: outer and inner diameters and height
 // spring properties
 spring_d = 10, spring_lc = 9.6,		// spring diameter and compressed length
 // filament path properties
 filament_d = 1.75,
 filament_path_d = 2,
 filament_guide_d = 4,				// PTFE filament guide diameter
 // knob properties
 knob_h = 10,
 knob_bore_l = 4,
 knob_indent_d = 4,
 knob_indents = 12,

 // screw it
 mount_screw_d = 3, mount_screw_l = 20,
 mount_screwhead_d=6, mount_screwhead_h=3,

 // empty spaces
 idler_travel = 3,				// how far should idler travel when pressed
 idler_clearance=1,
 pulley_clearance=2,
 lever_v_clearance=.7,				// vertical clearance for the lever
 spring_d_clearance=1,
 protrusion_tolerance_h=.5,			// horizontal tolerance for the motor protrusion
 protrusion_tolerance_v=.5,			// vertical tolerance for the motor protrusion
 mount_screw_d_tolerance=.5,
 idler_v_tolerance=.5,
 knob_bore_d_tolerance=.6,

 what="lever",
 left=false,
 vitamins = true
) {
 lever_shell = mount_screwhead_h+0.5;
 lever_thickness=max(spring_d+layer_height*8,idler_h+idler_v_tolerance+2*lever_shell);
 lsd = idler_d-idler_clearance*2;
 longwing=gearbox_d/2+spring_d/2+lsd/2;
 h_ = (pulley_d+idler_d)/(2*sqrt(2));
 ri = sqrt( pow(h_,2) + pow(mount_d/2-h_,2) );
 spring_dl = idler_travel*longwing/ri;

 filament_elevation=protrusion_h+pulley_elevation+teeth_elevation;
 ls_z = filament_elevation; // leverspace mid-z
 body_h = max(protrusion_h+bore_l,mount_screw_l-mounthole_depth/2+mount_screwhead_h,ls_z*2);
 ls_h = lever_thickness+lever_v_clearance; // leverspace height

 module mirrorleft() {
  mirror([left?0:1,0,0]) children();
 }
 module place_idler() {
  rotate([0,0,45])
  translate([(pulley_d+idler_d)/2,0,0])
  children();
 }
 module finger_indent(d=lever_thickness,depth/*=1*/,r/*=15*/) {
  if(depth) {
   hh = (-4*pow(depth,2)+pow(d,2))/(8*depth);
   rr = depth+hh;
   translate([0,0,hh]) sphere(r=rr,$fn=2*PI*rr);
  }else if(r) {
   hh=sqrt(pow(r,2)-pow(d,2)/4);
   translate([0,0,hh]) sphere(r=r,$fn=2*PI*r);
  }
 }

 % if(vitamins) mirrorleft() {
  translate([0,0,-epsilon]) mirror([0,0,1]) cylinder(d=gearbox_d,h=1,$fn=60);
  for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0])
   cylinder(d=mount_screw_d,h=20,$fn=30);
  translate([0,0,-epsilon]) cylinder(d=protrusion_d,h=protrusion_h,$fn=30);
  translate([0,0,protrusion_h]) {
   difference() {
    cylinder(d=bore_d,h=bore_l,$fn=30);
    translate([-bore_d/2-1,bore_dd-bore_d/2,-1])
    cube([bore_d+2,bore_d/2,bore_l+2]);
   }
   translate([0,0,pulley_elevation]) {
    cylinder(d=pulley_d,h=pulley_h,$fn=30);
    translate([0,0,teeth_elevation]) {
     place_idler() {
      cylinder(d=idler_d,h=idler_h,center=true,$fn=30);
      cylinder(d=idler_id,h=lever_thickness+2,center=true,$fn=30);
     }//place idler
     // filament path
     rotate([0,0,45]) translate([(pulley_d-filament_path_d)/2,0,0]) {
      rotate([90,0,0]) cylinder(d=filament_d,h=gearbox_d*2,center=true,$fn=15);
      rotate([-90,0,0])
      translate([0,0,mount_d/sqrt(2)/2+mount_screw_d])
      pushfit_thread();
     }
    }//translate teeth
   }//translate pulley
  }//translate protrusion
 }//vitamins

 module lever() {
  translate([0,0,protrusion_h+pulley_elevation+teeth_elevation]) {
   difference() {
    union() {
     hull() {
      place_idler()
      cylinder(d=lsd,h=lever_thickness,center=true,$fn=60);
      translate([mount_d/2,0,0])
      cylinder(d=lsd,h=lever_thickness,center=true,$fn=60);
     }//hull
     hull() {
      translate([mount_d/2,0,0])
      cylinder(d=lsd,h=lever_thickness,center=true,$fn=60);
      translate([mount_d/2,-longwing,0]) rotate([0,90,0])
      cylinder(d=lever_thickness,h=lsd,center=true,$fn=60);
     }//hull
    }//union
 
    // filament path
    place_idler() translate([-(idler_d+filament_path_d)/2,0,0]) rotate([90,0,0]) {
     cylinder(d=filament_path_d,h=3*gearbox_d,center=true,$fn=30);
     translate([0,-filament_path_d/2/sqrt(2),0]) rotate([0,0,45])
     cube(size=[filament_path_d/2,filament_path_d/2,3*gearbox_d],center=true);
    }
    
    // idler space and mounting hole
    place_idler() {
     difference() {
      cylinder(d=idler_d+idler_clearance*2,h=idler_h+idler_v_tolerance,center=true,$fn=60);
      // supports
      for(y=[-lsd/2+extrusion_width:(lsd-2*extrusion_width)/3:lsd/2-extrusion_width])
       translate([-lsd/2-1,y-extrusion_width/2,-idler_h/2-idler_v_tolerance/2-1])
       cube(size=[lsd+2,extrusion_width,idler_h+idler_v_tolerance+2]);
     }
     cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=30);
     translate([0,0,lever_thickness/2-mount_screwhead_h]) 
     cylinder(d=mount_screwhead_d,h=mount_screwhead_h+1,$fn=2*PI*mount_screwhead_d);
    }
    // mounting screw hole
    translate([mount_d/2,0,0])
    cylinder(d=mount_screw_d+mount_screw_d_tolerance,h=lever_thickness+2,center=true,$fn=2*PI*mount_screw_d);
    
    // lever end
    translate([mount_d/2,0,0]) rotate([0,90,0]) {
     translate([0,-longwing,lsd/2]) finger_indent(d=lever_thickness-1,r=15);
     translate([0,-longwing,0])
     mirror([0,0,1])
     difference() {
      cylinder(d=spring_d+spring_d_clearance,h=lsd,$fn=2*PI*spring_d);
      sphere(d=spring_d*3/4,$fn=PI*spring_d);
     }
    }//rotate-translate
   }//difference
   // bridging patch
   place_idler()
   translate([0,0,lever_thickness/2-mount_screwhead_h])
   mirror([0,0,1])
   cylinder(d=mount_screwhead_d,h=layer_height);
  }//translate
 }//lever module
 
 module body() {
  difference() {
   union() {
   cylinder(d=gearbox_d,h=body_h,$fn=2*PI*gearbox_d);
    // finger and spring support
    fsw = gearbox_d/2+mount_screwhead_d/2;
    translate([-gearbox_d/2,0,0]) difference() {
     union() {
      hull() {
       translate([0,-longwing,ls_z])
       rotate([0,90,0])
       cylinder(d=lever_thickness,h=fsw,$fn=2*PI*lever_thickness);
       hh=body_h-ls_z;
       translate([0,0,ls_z-lever_thickness/2])
       mirror([0,1,0]) cube(size=[fsw,longwing-hh+lever_thickness/sqrt(2),hh+lever_thickness/2]);
       hhh=ls_z;
       translate([0,0,0])
       mirror([0,1,0]) cube(size=[fsw,longwing-hhh+lever_thickness/sqrt(2),hhh+lever_thickness/2]);
      }
     }
     translate([0,-longwing,ls_z]) rotate([0,-90,0])
     finger_indent(d=lever_thickness-1,r=15);
    } // translate
    
    // pushfit bracket
    translate([0,0,filament_elevation])
    rotate([0,0,45]) translate([pulley_d/2,0,0])
    rotate([-90,0,0])
    translate([0,0,mount_d/sqrt(2)/2+mount_screw_d-gearbox_d/2/*TODO:*/])
    cylinder(r=min(body_h-filament_elevation,filament_elevation)/sin(60)-epsilon,h=10+gearbox_d/2/*TODO:*/,$fn=6);
   }//union (first child of difference)
   // protrusion
   translate([0,0,-1])
   cylinder(d=protrusion_d+protrusion_tolerance_h,h=protrusion_h+protrusion_tolerance_v+1,$fn=2*PI*protrusion_d);
   // mount screw holes
   for(zr=[0:90:359]) rotate([0,0,zr]) translate([mount_d/2,0,0]) {
    translate([0,0,mount_screw_l-mounthole_depth/2-layer_height-1])
    mirror([0,0,1])
    cylinder(d=mount_screw_d+mount_screw_d_tolerance,
             h=mount_screw_l-mounthole_depth/2-layer_height+1,
	     $fn=2*PI*mount_screw_d);
    translate([0,0,mount_screw_l-mounthole_depth/2])
    cylinder(d=mount_screwhead_d,h=body_h+1,$fn=2*PI*mount_screwhead_d);
   }//for
   // pushfit threads
   translate([0,0,filament_elevation])
   rotate([0,0,45]) translate([pulley_d/2,0,0])
   rotate([-90,0,0])
   translate([0,0,mount_d/sqrt(2)/2+mount_screw_d+epsilon])
   rotate([0,0,180]) {
    pushfit_thread(h=10);
    cylinder(d=filament_guide_d,h=gearbox_d,center=true,$fn=2*PI*filament_guide_d);
    translate([0,-filament_guide_d/2/sqrt(2),0])
    rotate([0,0,45])
    cube(size=[filament_guide_d/2,filament_guide_d/2,gearbox_d],center=true);
   }
   // pulley
   cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=2*PI*(pulley_d+pulley_clearance));
   // leverspace
   hull() for(x=[0,gearbox_d])
   rotate([0,0,45])
   translate([x,0,ls_z-ls_h/2])
   cylinder(d=idler_d+idler_clearance,h=ls_h,$fn=2*PI*idler_d);
   
   a=cos(45)*(pulley_d+idler_d)/2;
   b=mount_d/2-a;
   x=sqrt(pow(a,2)+pow(b,2));
   translate([mount_d/2,0,ls_z])
   intersection() {
    r = x+idler_d/2+1;/* TODO: */
    cylinder(r=r,h=ls_h,center=true);
    translate([-r-1,0,-1]) cube(size=[2*r+2,r+1,ls_h+2]);
   }
   
   rotate([0,0,-45])
   translate([0,0,ls_z-ls_h/2])
   cube(size=[gearbox_d,gearbox_d,lever_thickness+lever_v_clearance]);
   translate([0,0,ls_z-ls_h/2]) {
    translate([mount_screwhead_d/2,0,0])
    mirror([0,1,0])
    cube(size=[gearbox_d,gearbox_d/2+1,lever_thickness+lever_v_clearance]);
   }
   //translate([-mount_d/2,-longwing,filament_elevation])
   translate([mount_d/2,-longwing,filament_elevation])
   rotate([0,-90,0]) difference() {
    cylinder(d=spring_d+spring_d_clearance,h=spring_lc+spring_dl,$fn=PI*spring_d);
    translate([0,0,spring_lc+spring_dl]) sphere(d=spring_d*3/4,$fn=PI*spring_d);
   }
   //sphere(d=spring_d*3/4,$fn=PI*spring_d);
   *difference() {
    // spring support
    translate([0,-longwing,filament_elevation])
    sphere(d=spring_d*3/4,$fn=PI*spring_d);
   }
    
  }//difference

  intersection() {
   difference() {
    translate([0,0,ls_z-ls_h/2-epsilon])
    cylinder(d=gearbox_d,h=ls_h+2*epsilon,$fn=2*PI*gearbox_d);
    cylinder(d=pulley_d+pulley_clearance,h=body_h+1,$fn=2*PI*(pulley_d+pulley_clearance));
   }
   // supports
   // TODO: hardcoded stuff below…
   if(false) { // parallel
    for(y=[-gearbox_d:4:gearbox_d])
     translate([0,y-extrusion_width/2,0])
     cube(size=[gearbox_d,extrusion_width,body_h]);
   }else{ // radial
    for(zr=[-65:(65+50)/7:50])
     rotate([0,0,zr]) translate([0,-extrusion_width/2,0])
     cube(size=[gearbox_d,extrusion_width,body_h]);
   }
  }

 }//body module

 module knob() {
  ch = knob_indent_d/2;
  translate([0,0,body_h+epsilon]) {
   mirror([0,0,1]) translate([0,0,-epsilon]) {
    difference() {
     cylinder(d=pulley_d,h=knob_bore_l,$fn=pulley_d*PI*2);
     translate([0,0,-1]) difference() {
      cylinder(d=bore_d+knob_bore_d_tolerance,h=knob_bore_l+2);
      translate([-bore_d/2-1,bore_dd-bore_d/2+knob_bore_d_tolerance/2,-1])
      cube([bore_d+2,bore_d/2,knob_bore_l+4]);
     }
    }
   }
   difference() {
    union() {
     cylinder(d1=gearbox_d-2*ch,d2=gearbox_d,h=ch+epsilon,$fn=PI*gearbox_d*2);
     translate([0,0,ch])
     cylinder(d=gearbox_d,h=knob_h-2*ch+epsilon,$fn=PI*gearbox_d*2);
     translate([0,0,knob_h-ch])
     cylinder(d1=gearbox_d,d2=gearbox_d-2*ch,h=ch,$fn=PI*gearbox_d*2);
    }
    for(a=[0:360/knob_indents:359]) rotate([0,0,a])
     translate([0,gearbox_d/2,-1])
     cylinder(d=knob_indent_d,h=knob_h+2,$fn=knob_indent_d*PI*2);
   }
  }
 }//knob module
 
 mirrorleft()
 if(what=="lever") color("green",0.7) lever();
 else if(what=="body") color("yellow",0.7) body();
 else if(what=="knob") color("red",0.7) knob();
 else if(what=="both" || what=="*") {
  color("green",0.7) lever();
  color("yellow",0.7) body();
  color("red",0.7) knob();
 }
}

the_extruder(what="both",left=false);