chiark / gitweb /
5724dcce584482899a2f0f6b260753425b3fe83a
[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 Hub(){ ////toplevel
206   difference(){
207     cylinder($fn=60, h=hublthick, r=hubbigrad);
208     translate([0,0,-1])
209       cylinder($fn=30, h=hublthick+2, r=(hubbigrad-hublwidth));
210   }
211   axlerad = hubaxlerad + slop;
212   difference(){
213     cylinder(h=hubaxlelen, r=axlerad+hublwidth);
214     translate([0,0,-1]) cylinder($fn=60, h=hubaxlelen+2, r=axlerad);
215   }
216   hole = hubeffrad - hubbigrad - DoveClip_depth() - hublwidth*2;
217   holewidth = DoveClipPairSane_width() - hubstemwidth*2;
218   for (ang=[0,120,240])
219     rotate([0,0,ang]) {
220       difference() {
221         translate([hubeffrad,0,0])
222           DoveClipPairSane(h=doveclipheight,
223                            baseextend = (hubeffrad - DoveClip_depth()
224                                          - hubbigrad + hublwidth));
225         if (hole>hublwidth && holewidth > 2) {
226           translate([hubbigrad + hublwidth, -holewidth/2, -1])
227             cube([hole, holewidth, hublthick+2]);
228         }
229       }
230     }
231   xmin = axlerad+hublwidth/2;
232   xmax = hubbigrad-hublwidth/2;
233   for (ang = [0 : 60 : 359])
234     rotate([0,0,ang]) rotate([90,0,0]) {
235       translate([0,0,-hublwidth/2])
236         linear_extrude(height=hublwidth)
237         polygon([[xmin,0.05], [xmax,0.05],
238                  [xmax,hublthick-0.2], [xmin, hubaxlelen-0.2]]);
239     }
240 }
241
242 module ArmExtender(){ ////toplevel
243   DoveClipExtender(length=exteffrad-hubeffrad,
244                    ha=doveclipheight,
245                    hb=doveclipheight);
246 }
247
248 module AxlePin(){ ////toplevel
249   pinr = axlepinrad - slop;
250   intersection(){
251     translate([0, 0, pinr*0.7]) {
252       translate([0, -washerrad, 0]) rotate([-90,0,0])
253         cylinder(r=pinr, h=washerrad*2, $fn=10);
254       translate([-axlepintabrad, hubaxlerad, -axlepinrad])
255         cube([axlepintabrad*2, axlepinrad*2, axlepinrad*2]);
256     }
257     translate([-50,-50,0]) cube([100,100,50]);
258   }
259 }
260
261 module Axle(){ ////toplevel
262   pillarswidth = DoveClipPairSane_width(towerclipcount);
263
264 if(0)
265   rotate([0,0, -( axleaxlefudgebend + atan(slop/hubaxlelen) ) ])
266   translate([-axlehorizoffset, -axlevertheight, 0]) {
267     rotate([0,0,-axletowerfudgebend])
268     rotate([0,0,-90])
269       DoveClipPairSane(h=towercliph, count=towerclipcount, baseextend=3);
270     translate([0, DoveClip_depth(), 0])
271     rotate([0,0,90])
272       ExtenderPillars(axlevertheight - DoveClip_depth(),
273                       pillarswidth, towercliph,
274                       pillarw=towerpillarw);
275   }
276
277   axleclearlen = hubaxlelen + slop*4 + washerthick*2 + axlepadlen;
278   axlerad = hubaxlerad-slop;
279   bump = axlerad * 0.2;
280   shift = axlerad-bump;
281   joinbelowallow = 3;
282
283   intersection(){
284     translate([0, 0, shift]) {
285       difference() {
286         union(){
287           translate([-1, 0, 0])
288             rotate([0,90,0])
289             cylinder($fn=60,
290                      r = axlerad,
291                      h = 1 + axleclearlen + axlepinrad*2 + 2);
292           mirror([1,0,0]) rotate([0,90,0])
293             cylinder(r = axlerad*1.75, h = 3);
294           intersection(){
295             mirror([1,0,0])
296               translate([axlehorizoffset - pillarswidth/2, 0, 0])
297               rotate([0,90,0])
298               cylinder($fn=60,
299                        r = towercliph - shift,
300                        h = pillarswidth);
301             translate([-50, -joinbelowallow, -50])
302               cube([100, joinbelowallow+50, 100]);
303           }
304         }
305         rotate([90,0,0])
306         translate([axleclearlen + axlepinrad/2, 0, -25])
307           cylinder(r = axlepinrad + slop, h=50);
308       }
309     }
310     translate([-50,-50,0]) cube([100,100,100]);
311   }
312 }
313
314 module AxleWasher(){ ////toplevel
315   difference(){
316     cylinder(h=washerthick, r=washerrad);
317     translate([0,0,-1]) cylinder(h=washerthick+2, r=hubaxlerad+slop);
318   }
319 }
320
321 module TowerExtender(){ ////toplevel
322   l = totalheightfromtower - axlevertheight;
323   echo("TowerExtender",l);
324   DoveClipExtender(length = l,
325                    ha = towercliph, hb = towercliph,
326                    counta = towerclipcount, countb = towerclipcount,
327                    pillarw = towerpillarw);
328 }
329
330 //ArmEnd();
331 //FilamentCup();
332 //CupSecuringClip();
333 //Hub();
334 //ArmExtender();
335 //Axle();
336 //AxleWasher();
337 //AxlePin();