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