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