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