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