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