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