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