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