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