chiark / gitweb /
filamentspool: Provide comments for "fdia" and "lightduty"
[reprap-play.git] / filamentspool.scad
1 // -*- C -*-
2
3 fdia=2.85; // or 1.75
4 lightduty=false; // or true
5
6
7 slop=0.5;
8 bigslop=slop*2;
9
10 function selsz(sm,lt,lg) = fdia < 2 ? sm : lightduty ? lt : lg;
11 function usedove() = selsz(true,true,false);
12
13 num_arms = selsz(3,3,4);
14
15 channelslop=selsz(slop,0.75,slop);
16
17 exteffrad = 70;
18 hubeffrad = selsz(30, 82, 40);
19 hubbigrad = selsz(20, 38, 38);
20 hublwidth = selsz(3, 2.5, 4);
21 hubstemwidth = 2;
22 hublthick = 10;
23 hubaxlerad = selsz(5, 28/2, 28/2);
24 totalheightfromtower = 240;
25 axletowerfudgebend = 0;
26 axleaxlefudgebend = 3;
27 axlepadlen = 1.0;
28
29 armend_length = 120;
30
31 prongthick=selsz(5,4,5);
32 prongwidth=selsz(5,4,5);
33 prongribwidth=3;
34 prongribheight=selsz(0,0,4);
35 ratchetstep=15;
36 ratchettooth=3;
37 ratchettoothheight=5;
38 ratchettoothsmoothr=1;
39 ratchettoothslope=0.75;
40 overlap=0.5;
41 cupwidth=selsz(40,25,50);
42 cupheight=selsz(55,25,55);
43
44 cupstrong_dx=selsz(0,0,-10);
45
46 propxshift = -6;
47
48 doveclipheight = 10;
49
50 teethh=3;
51 teethgapx=4+fdia;
52
53 prongstalkxwidth=3;
54
55 stalklength=selsz(35,25,55);
56 overclipcupgap=5;
57 overclipdepth=15;
58 overcliproundr=2.0;
59 overclipthick=1.0;
60 overclipcupnextgap=selsz(20,15,20);
61
62 hubaxlelen = selsz(25, 62.5, 77.5);
63 echo(hubaxlelen);
64
65 overclipsmaller=-2.5;
66 overclipbigger=0.0;
67
68 wingspoke=2.5;
69 wingsize=6;
70 wingthick=3;
71
72 armendwallthick=selsz(2.5, 1.8, 2.5);
73 armendbasethick=selsz(1.2, 1.2, 1.2);
74
75 axlehorizoffset = 12.5;
76 axlevertheight = 100;
77 towercliph = 16;
78 towerclipcount = 3;
79 towerpillarw = 5;
80
81 axlepinrad = 2;
82 axlepintabrad = 5;
83
84 washerthick = 1.2;
85 washerthinthick = 0.8;
86 washerverythinthick = 0.4;
87 washerrad = hubaxlerad + 7.5;
88 frictionwasherarmwidth = 3;
89 frictionwasherextrapush = 1.0;
90
91 ratchetpawl=ratchetstep-ratchettooth-bigslop*2;
92
93 nondove_armhole_x = 32;
94 nondove_armhole_hole = 4 + 0.8;
95 nondove_armhole_support = 7;
96 nondove_armhole_wall = 3.2;
97 nondove_armhole_slop = 0.5;
98 nondove_armhole_slop_x = 0.5;
99
100 nondove_armbase = nondove_armhole_x + nondove_armhole_hole/2 +
101   nondove_armhole_support;
102 echo(nondove_armbase);
103
104 include <doveclip.scad>
105 include <cliphook.scad>
106 include <filamentteeth.scad>
107 include <axlepin.scad>
108
109 channelwidth = prongthick + channelslop;
110 channeldepth = prongwidth + ratchettoothheight;
111 totalwidth = armendwallthick*2 + channelwidth;
112 totalheight = channeldepth + armendbasethick;
113 stalkwidth = prongwidth + prongstalkxwidth;
114
115 module ArmEnd(length=armend_length){ ////toplevel
116   if (usedove()) {
117     translate([ratchettoothsmoothr, channelwidth/2, -armendbasethick]) {
118       rotate([0,0,-90])
119         DoveClipPairBase(h=doveclipheight);
120     }
121   } else {
122     difference(){
123       translate([1, -armendwallthick, -armendbasethick])
124         mirror([1,0,0])
125         cube([nondove_armbase+1, totalwidth, totalheight]);
126       translate([-nondove_armbase + nondove_armhole_x,
127                  -armendwallthick + totalwidth/2,
128                  -armendbasethick -1])
129         cylinder(r= nondove_armhole_hole/2, h=totalheight+2, $fn=10);
130     }
131   }
132
133   difference(){
134     translate([0, -armendwallthick, -armendbasethick])
135       cube([length, totalwidth, totalheight]);
136     translate([-1, 0, 0])
137       cube([length+1 - ratchettooth, channelwidth, channeldepth+1]);
138     translate([-1, 0, ratchettoothheight])
139       cube([length+2, channelwidth, channeldepth+1]);
140   }
141   for (dx = [0 : ratchetstep : length - ratchetstep]) translate([dx,0,0]) {
142     translate([ratchettoothsmoothr+0.5, armendwallthick/2, 0]) minkowski(){
143       rotate([90,0,0])
144         cylinder($fn=20, r=ratchettoothsmoothr, h=armendwallthick);
145       multmatrix([      [       1, 0, ratchettoothslope, 0      ],
146                         [       0,      1,      0,      0       ],
147                         [       0,      0,      1,      0       ],
148                         [       0,      0,      0,      1       ]])
149         cube([ratchettooth - ratchettoothsmoothr*2,
150               channelwidth, ratchettoothheight - ratchettoothsmoothr]);
151     }
152   }
153 }
154
155 module FilamentCupHandle(){
156   pawlusewidth = ratchetpawl-ratchettoothsmoothr*2;
157   mirror([0,1,0]) {
158     cube([stalklength, stalkwidth, prongthick]);
159     translate([stalklength, stalkwidth/2, 0])
160       cylinder(r=stalkwidth/2, h=prongthick, $fn=20);
161     translate([ratchettoothsmoothr, stalkwidth, 0]) {
162       minkowski(){
163         cylinder($fn=20,r=ratchettoothsmoothr, h=1);
164         multmatrix([    [       1, -ratchettoothslope, 0, 0     ],
165                         [       0,      1,      0,      0       ],
166                         [       0,      0,      1,      0       ],
167                         [       0,      0,      0,      1       ]])
168           cube([pawlusewidth,
169                 ratchettoothheight - ratchettoothsmoothr,
170                 prongthick - 1]);
171       }
172     }
173   }
174 }
175
176 module FilamentCupCup(){
177   for (my=[0,1]) mirror([0,my,0]) {
178     translate([0, cupwidth/2, 0])
179       cube([cupheight + prongwidth, prongwidth, prongthick]);
180   }
181 }
182
183 module FilamentCup() { ////toplevel
184   FilamentCupHandle();
185
186   gapy = prongwidth;
187   dy = cupwidth/2 + gapy + overclipcupgap;
188   baselen = dy+cupwidth/2;
189
190   translate([0, dy, 0])
191     FilamentCupCup();
192   cube([prongwidth, baselen+1, prongthick]);
193
194   translate([cupstrong_dx, prongwidth, 0]) {
195     cube([prongwidth, baselen-prongwidth, prongthick]);
196     for (y = [0, .33, .67, 1])
197       translate([0, (baselen - prongwidth) * y, 0])
198         cube([-cupstrong_dx + 1, prongwidth, prongthick]);
199   }
200   if (cupstrong_dx != 0) {
201     rotate([0,0,45])
202       translate([-prongwidth*.55, -prongwidth*2.1, 0])
203       cube([prongwidth*(2.65), prongwidth*4.2, prongthick]);
204   }
205
206   translate([0, -0.2, 0])
207     cube([prongribwidth, baselen, prongthick + prongribheight]);
208
209   if (prongribheight > 0) {
210     translate([-prongwidth, baselen, 0])
211       cube([cupheight/2, prongwidth + prongribheight, prongribwidth]);
212   }
213
214   midrad = cupwidth/2 + prongwidth/2;
215
216   propshift = stalklength - overclipdepth - prongthick + propxshift;
217   proptaken = propshift;
218   echo(midrad, propshift, proptaken);
219
220   translate([propshift, -1, 0]) {
221     // something is wrong with the y calculation
222     cube([prongwidth,
223           gapy+2,
224           prongthick]);
225   }
226   for (y = [overclipcupgap, overclipcupgap+overclipcupnextgap]) {
227     translate([cupstrong_dx, y + prongwidth, 0])
228       rotate([0,0, 102 + fdia])
229       FilamentTeeth(fdia=fdia, h=teethh);
230   }
231   for (x = [-0.3, -1.3]) {
232     translate([cupheight + overclipcupnextgap*x, baselen + prongwidth, 0])
233       rotate([0,0, 12 + fdia])
234       FilamentTeeth(fdia=fdia, h=teethh);
235   }      
236 }
237
238 module CupSecuringClipSolid(w,d,h1,h2){
239   rotate([0,-90,0]) translate([0,-h1/2,-w/2]) linear_extrude(height=w) {
240     polygon(points=[[0,0], [d,0], [d,h2], [0,h1]]);
241   }
242 }
243
244 module CupSecuringClipSolidSmooth(xrad=0, xdepth=0){
245   hbase = totalheight + prongstalkxwidth - overcliproundr*2;
246   minkowski(){
247     CupSecuringClipSolid(w=totalwidth,
248                          d=overclipdepth + xdepth,
249                          h1=hbase - overclipsmaller,
250                          h2=hbase + overclipbigger);
251     cylinder($fn=20, h=0.01, r=overcliproundr+xrad);
252   }
253 }
254
255 module CupSecuringClip(){ ////toplevel
256   wingswidth = wingspoke*2 + overclipthick*2 + overcliproundr*2 + totalwidth;
257   difference(){
258     union(){
259       CupSecuringClipSolidSmooth(xrad=overclipthick, xdepth=0);
260       translate([-wingswidth/2, -wingsize/2, 0])
261         cube([wingswidth, wingsize, wingthick]);
262       translate([-wingsize/2, -wingswidth/2, 0])
263         cube([wingsize, wingswidth, wingthick]);
264     }
265     translate([0,0,-0.1])
266       CupSecuringClipSolidSmooth(xrad=0, xdepth=0.2);
267   }
268 }
269
270 module ArmDoveClipPin(){ ////toplevel
271   DoveClipPin(h=doveclipheight);
272 }
273
274 module TowerDoveClipPin(){ ////toplevel
275   DoveClipPin(h=towercliph/2);
276 }
277
278 module Hub(){ ////toplevel
279   axlerad = hubaxlerad + slop;
280   xmin = axlerad+hublwidth/2;
281   xmax = hubbigrad-hublwidth/2;
282   hole = hubeffrad - hubbigrad - DoveClip_depth() - hublwidth*2;
283   holewidth = DoveClipPairSane_width() - hubstemwidth*2;
284   nondove_allwidth = nondove_armhole_wall*2 + totalwidth;
285   difference(){
286     union(){
287       difference(){
288         cylinder($fn=60, h=hublthick, r=hubbigrad);
289         translate([0,0,-1])
290           cylinder($fn=30, h=hublthick+2, r=(hubbigrad-hublwidth));
291       }
292       cylinder(h=hubaxlelen, r=axlerad+hublwidth);
293       for (ang=[0 : 360/num_arms : 359])
294         rotate([0,0,ang]) {
295           if (usedove()){
296             difference() {
297               translate([hubeffrad,0,0])
298                 DoveClipPairSane(h=doveclipheight,
299                                  baseextend = (hubeffrad - DoveClip_depth()
300                                                - hubbigrad + hublwidth));
301               if (hole>hublwidth && holewidth > 2) {
302                 translate([hubbigrad + hublwidth, -holewidth/2, -1])
303                   cube([hole, holewidth, hublthick+2]);
304               }
305             }
306           } else {
307             difference(){
308               translate([0,
309                          -nondove_allwidth/2,
310                          0])
311                 cube([hubeffrad + nondove_armhole_x
312                       + nondove_armhole_hole/2 + nondove_armhole_support,
313                       nondove_allwidth,
314                       nondove_armhole_wall + totalheight]);
315               translate([hubeffrad - nondove_armhole_slop_x,
316                          -nondove_allwidth/2
317                          + nondove_armhole_wall - nondove_armhole_slop,
318                          nondove_armhole_wall])
319                 cube([nondove_armhole_x + 50,
320                       totalwidth + nondove_armhole_slop*2,
321                       totalheight + 1]);
322               translate([hubeffrad + nondove_armhole_x, 0, -20])
323                 cylinder(r= nondove_armhole_hole/2, h=50, $fn=10);
324             }
325           }
326         }
327       for (ang = [0 : 180/num_arms : 359])
328         rotate([0,0,ang]) rotate([90,0,0]) {
329           translate([0,0,-hublwidth/2])
330             linear_extrude(height=hublwidth)
331             polygon([[xmin,0.05], [xmax,0.05],
332                      [xmax,hublthick-0.2], [xmin, hubaxlelen-0.2]]);
333         }
334     }
335     translate([0,0,-1]) cylinder($fn=60, h=hubaxlelen+2, r=axlerad);
336   }
337 }
338
339 module ArmExtender(){ ////toplevel
340   DoveClipExtender(length=exteffrad-hubeffrad,
341                    ha=doveclipheight,
342                    hb=doveclipheight);
343 }
344
345 module FsAxlePin(){ ////toplevel
346   AxlePin(hubaxlerad, washerrad*2, axlepinrad, axlepintabrad, slop);
347 }
348
349 module Axle(){ ////toplevel
350   pillarswidth = DoveClipPairSane_width(towerclipcount);
351
352   rotate([0,0, -( axleaxlefudgebend + atan(slop/hubaxlelen) ) ])
353   translate([-axlehorizoffset, -axlevertheight, 0]) {
354     rotate([0,0,-axletowerfudgebend])
355     rotate([0,0,-90])
356       DoveClipPairSane(h=towercliph, count=towerclipcount, baseextend=3);
357     translate([0, DoveClip_depth(), 0])
358     rotate([0,0,90])
359       ExtenderPillars(axlevertheight - DoveClip_depth(),
360                       pillarswidth, towercliph,
361                       pillarw=towerpillarw);
362   }
363
364   axleclearlen = hubaxlelen + slop*4 + washerthick*2 + axlepadlen;
365   axlerad = hubaxlerad-slop;
366   bump = axlerad * 0.2;
367   shift = axlerad-bump;
368   joinbelowallow = 3;
369
370   intersection(){
371     translate([0, 0, shift]) {
372       difference() {
373         union(){
374           translate([-1, 0, 0])
375             rotate([0,90,0])
376             cylinder($fn=60,
377                      r = axlerad,
378                      h = 1 + axleclearlen + axlepinrad*2 + 2);
379           mirror([1,0,0]) rotate([0,90,0])
380             cylinder(r = axlerad*1.75, h = 3);
381           intersection(){
382             mirror([1,0,0])
383               translate([axlehorizoffset - pillarswidth/2, 0, 0])
384               rotate([0,90,0])
385               cylinder($fn=60,
386                        r = towercliph - shift,
387                        h = pillarswidth);
388             translate([-50, -joinbelowallow, -50])
389               cube([100, joinbelowallow+50, 100]);
390           }
391         }
392         rotate([90,0,0])
393         translate([axleclearlen + axlepinrad/2, 0, -25])
394           cylinder(r = axlepinrad + slop, h=50);
395       }
396     }
397     translate([-50,-50,0]) cube([100,100,100]);
398   }
399 }
400
401 module washer(thick){
402   Washer(hubaxlerad, washerrad, thick, slop);
403 }
404
405 module AxleWasher(){ ////toplevel
406   washer(thick=washerthick);
407 }
408
409 module AxleThinWasher(){ ////toplevel
410   washer(thick=washerthinthick);
411 }
412
413 module AxleVeryThinWasher(){ ////toplevel
414   washer(thick=washerverythinthick);
415 }
416
417 module AxleFrictionWasher(){ ////toplevel
418   difference(){
419     cylinder(h=washerthick, r=washerrad);
420     translate([0,0,-1]) cylinder(h=washerthick+2, r=hubaxlerad+slop);
421   }
422   frarmr = hubbigrad;
423   frarmw = frictionwasherarmwidth;
424   frarmpawlr = hublwidth;
425   frarmpawlpush = slop*4 + frictionwasherextrapush;
426   for (ang=[0,180]) rotate([0,0,ang]) {
427     translate([washerrad-1, -frarmw/2, 0])
428       cube([frarmr - washerrad + 1, frarmw, washerthick]);
429     intersection(){
430       translate([frarmr - frarmpawlr, -50, 0])
431         cube([frarmpawlr, 100, 50]);
432       rotate([0,90,0])
433         cylinder(h = 50, r = frarmpawlpush, $fn=36);
434     }
435   }
436 }
437
438 module TowerExtender(){ ////toplevel
439   l = totalheightfromtower - axlevertheight;
440   echo("TowerExtender",l);
441   DoveClipExtender(length = l,
442                    ha = towercliph, hb = towercliph,
443                    counta = towerclipcount, countb = towerclipcount,
444                    pillarw = towerpillarw);
445 }
446
447 module FilamentCupPair(){ ////toplevel
448   FilamentCup();
449   translate([cupheight + prongthick*3,
450              cupwidth/2*1.7,
451              0])
452     rotate([0,0,180]) FilamentCup();
453 }
454
455 //----- storarm -----
456
457 storarm_hooklen = 8;
458 storarm_hookheight = 5;
459 storarm_thick = 10;
460 storarm_axleslop = 4;
461
462 storarm_base_w = 30;
463 storarm_base_h = 100;
464 storarm_base_d = 15;
465 storarm_base_mind = 2;
466
467 storarm_cope_hubaxle_mk1 = true;
468
469 storarm_screw_hole = 4;
470 storarm_screw_hole_slop = 0.5;
471 storarm_besides_hole = 4;
472
473 storarm_under_hole = 5;
474 storarm_screw_hole_head = 8.8;
475 storarm_screw_hole_head_slop = 1.5;
476
477 // calculated
478
479 storarm_axlerad = hubaxlerad - storarm_axleslop;
480 storarm_mainlen = hubaxlelen*2 + storarm_axleslop
481   + (storarm_cope_hubaxle_mk1 ? 10 : 0);
482 storarm_totlen = storarm_mainlen + storarm_hooklen;
483
484 storarm_mid_off_y = storarm_axlerad;
485
486 storarm_base_off_y = storarm_mid_off_y + storarm_base_h/2;
487
488 module StorageArmDiagPartSide(xmin, xmax){
489   xsz = xmax-xmin;
490   yuse = storarm_thick/2;
491
492   intersection(){
493     translate([xmin-1, -storarm_axlerad, storarm_thick/2])
494       rotate([0,90,0])
495       cylinder(r=storarm_axlerad, h=xsz+2, $fn=60);
496     translate([xmin, -yuse, 0])
497       cube([xsz, yuse, storarm_thick]);
498   }
499 }
500
501 module StorageArmDiagPart(xmin, xmax, shear, adjbot){
502   hull(){
503     StorageArmDiagPartSide(xmin,xmax);
504
505     multmatrix([[1,0,0,0],
506                 [shear,1,0,0],
507                 [0,0,1,0],
508                 [0,0,0,1]])
509       translate([0, -storarm_axlerad*2 + adjbot, 0])
510       mirror([0,1,0])
511       StorageArmDiagPartSide(xmin,xmax);
512   }
513 }
514
515 module StorageArmBaseTemplate(){
516   square([storarm_base_w, storarm_base_h]);
517 }
518
519 module StorageArmAtMountingHoles(){
520   bes = storarm_besides_hole + storarm_screw_hole;
521
522   x0 = bes;
523   x1 = storarm_base_w-bes;
524   y1 = storarm_base_h - bes;
525   y0 = bes;
526
527   for (pos=[ [x0, y1],
528              [x1, y1],
529              [x1, y0] ]) {
530     rotate([0,90,0])
531       translate([pos[0] - storarm_base_w,
532                  pos[1] - storarm_base_off_y, -storarm_base_d])
533       children();
534   }
535 }
536
537 module StorageArmRight(){ ////toplevel
538   shear = storarm_hookheight / (storarm_mainlen/2);
539
540   StorageArmDiagPart(-1, storarm_mainlen/2+1, shear, 0);
541   StorageArmDiagPart(storarm_mainlen/2-1, storarm_mainlen+1, shear/2,
542                      storarm_hookheight/2);
543
544   translate([0, storarm_hookheight, 0])
545     StorageArmDiagPart(storarm_mainlen, storarm_totlen,
546                        shear/2, -storarm_hookheight/2);
547
548   difference(){
549     union(){
550       hull(){
551         translate([-storarm_base_d, -storarm_base_off_y, storarm_base_w])
552           rotate([0,90,0])
553           linear_extrude(height=storarm_base_mind)
554           StorageArmBaseTemplate();
555         StorageArmDiagPart(-1, 0, shear, 0);
556       }
557       StorageArmAtMountingHoles(){
558         cylinder(r= storarm_screw_hole_head/2,
559                  h=10);
560       }
561     }
562     StorageArmAtMountingHoles(){
563       translate([0,0,-1])
564         cylinder(r= (storarm_screw_hole + storarm_screw_hole_slop)/2 ,
565                  h=20);
566       translate([0,0,storarm_under_hole])
567         cylinder(r= (storarm_screw_hole_head + storarm_screw_hole_head_slop)/2,
568                  h=20);
569     }
570   }
571 }
572
573 module StorageArmLeft(){ ////toplevel
574   mirror([1,0,0]) StorageArmRight();
575 }
576
577 module StorArmHoleTest(){ ////toplevel
578   sz = storarm_screw_hole_head + storarm_besides_hole*2;
579   intersection(){
580     StorageArmRight();
581     translate([-50, -storarm_base_off_y, -1])
582       cube([100, sz, sz+1]);
583   }
584 }
585
586
587 module Demo(){
588   translate([-hubeffrad-30,50,0]) Hub();
589   ArmEnd();
590   translate([0,50,0]) FilamentCup();
591 }
592
593 //ArmEnd();
594 //FilamentCup();
595 //FilamentCupPair();
596 //CupSecuringClip();
597 //Hub();
598 //ArmExtender();
599 //Axle();
600 //AxleWasher();
601 //AxlePin();
602 //AxleFrictionWasher();
603 //StorageArmLeft();
604 //StorArmHoleTest();
605 //Demo();