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