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