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