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