chiark / gitweb /
topeak-mtx-tortec-expeditionrack-adapter: demo wip
[reprap-play.git] / topeak-mtx-tortec-expeditionrack-adapter.scad
1 // -*- C -*-
2
3 // brk_*: "bracket", the Topeak MTX bracket
4 // rack_*: the Tortec rack
5 // adapt_*: the adapter, ie this file
6
7 include <utils.scad>
8
9 // strength factor, set to 1 for real prints
10 //$strf = 0.33;
11 $strf = 1;
12
13 brk_recess_actual = 5.20;
14
15 rack_rail_dia = 10.40 + 0.30;
16 rack_width_inner = 115.86 - 1.0; // between insides of rails
17
18 rear_elevation_nominal = 10.04;
19 // ^ top of rack to bottom of bracket, at rack cross rail (fam)
20 rear_to_front_distance = 230; // rack cross rail (fam) to very front end
21 rear_to_cross_rail = 43.05; // bolt centre to rail centre, rail to rear
22 rear_bolt_to_front_bolt = 155.4;
23 front_elevation_nominal = 3;
24
25 cross_rail_distance = 232.09;
26
27 general_gap_y = 1.0;
28
29 strap_w = 8.0 + 1.0;
30 strap_th = 2.5;
31 strap_barrel_dia = 14;
32 strap_guide_sz = 1;
33
34 brk_block_xw = 68.5;
35 brk_block_z = 14.55 - 0.00;
36
37 brk_bolt_dia = 5.0 + 0.5;
38 brk_nearbolt_recess_dia = 8.86 + 1.5;
39 brk_nearbolt_recess_depth = 1.09 + 0.25;
40
41 brk_bolt_eff_len = 11.78; // inside of recess, to end of bolt
42 brk_bolt_len_slop = 0.5;
43 brk_bolt_nut_th = 3.89;
44 brk_bolt_nut_across_flats = 7.86 + 0.50;
45
46 brk_overall_w = 90.07;
47
48 fit_slope_len = 5;
49
50 // "foreaftmaint" aka "fam" is the hook-like part that stops
51 // the adapter sliding forwards/backwards along the rails
52 foreaftmaint_r_slop = 0.0;
53 foreaftmaint_y_slop = -0.25;
54 foreaftmaint_top_block_zs = [34.0, 39.0]; // rearwards from bolt hole
55
56 main_sz_y = $strf * 12;
57 grasp_sz = $strf * 6;
58 grasp_thin_sz = $strf * 0.5;
59 beside_strap_sz = $strf * 8;
60 main_sz_core_z = $strf * 12;
61
62 // "length" in for-aft direction of interaction with rack rail
63 min_on_rail_sz_z = $strf * 18;
64
65 // when printer produces support
66 support_around = 1.7; // how far does the support extend around (in XY)
67 support_remnant = 0.75; // how much frass remains attached (Z height)
68
69 $fa=10;
70 $fs=1;
71
72 // calculated
73
74 bolt_z = -brk_block_z/2;
75
76 main_sz_rhs_z = max(min_on_rail_sz_z, beside_strap_sz*2 + strap_w);
77 main_sz_lhs_z = min_on_rail_sz_z;
78
79 main_sz_x_fam = main_sz_y;
80
81 brk_bottom_y = -brk_recess_actual;
82 adapt_main_top_y = brk_bottom_y - general_gap_y;
83
84 // on LHS, so -ve
85 rack_rail_x = -(rack_width_inner/2 + rack_rail_dia/2);
86 rack_rail_outer_x = -(rack_width_inner/2 + rack_rail_dia);
87
88 grasp_large_r = (rack_rail_dia + grasp_sz)/2;
89 grasp_small_r = (rack_rail_dia + grasp_thin_sz)/2;
90 grasp_large_x = rack_rail_outer_x + grasp_large_r;
91 grasp_small_x = rack_rail_outer_x + grasp_small_r;
92
93 block_x = grasp_large_x + grasp_large_r;
94 block_y_min = adapt_main_top_y - main_sz_y;
95
96 strap_barrel_x = rack_width_inner/2 + strap_barrel_dia/2;
97
98 rack_shear_ratio = -rear_elevation_nominal / rear_to_front_distance;
99
100 front_to_cross_rail =
101   cross_rail_distance * sqrt(1 - rack_shear_ratio * rack_shear_ratio)
102   - rear_bolt_to_front_bolt
103   - rear_to_cross_rail;
104
105 brk_bolt_nut_top_y = -brk_nearbolt_recess_depth
106   - brk_bolt_eff_len + brk_bolt_nut_th + brk_bolt_len_slop;
107                        
108 brk_bolt_nut_r = brk_bolt_nut_across_flats/2 / cos(360/12);
109
110 function elevation_of_bolt_for(z) = rear_elevation_nominal
111   + front_elevation_nominal
112   + (z - brk_block_z/2) * rack_shear_ratio;
113
114 function rack_rail_y_of_elevation(elevation_nominal) =
115   brk_bottom_y - elevation_nominal - general_gap_y  - rack_rail_dia/2;
116
117 echo(rack_shear_ratio);
118
119 module GraspElevation(){
120   hull(){
121     translate([ grasp_large_x, adapt_main_top_y - grasp_large_r ])
122       circle(grasp_large_r);
123
124     translate([ grasp_small_x, $rack_rail_y - rack_rail_dia/2 ])
125       circle(grasp_small_r);
126
127     translate([ rack_rail_x + grasp_large_r/2,
128                 $rack_rail_y - rack_rail_dia/2 ])
129       circle(grasp_small_r);
130
131     translate([ grasp_large_x, $rack_rail_y + rack_rail_dia/2 ])
132       circle(grasp_large_r);
133
134     translate([ grasp_large_x + grasp_large_r/2,
135                 $rack_rail_y + rack_rail_dia/2 ])
136       circle(grasp_large_r);
137   }
138 }
139
140 module BlockElevation(){
141   hull(){
142     rectfromto([ +block_x, adapt_main_top_y ],
143                [ -block_x, block_y_min ]);
144     rectfromto([ -grasp_large_x, adapt_main_top_y ],
145                [ +grasp_large_x, adapt_main_top_y - 0.1 ]);
146   }
147   hull(){
148     rectfromto([ +block_x, adapt_main_top_y ],
149                [ -block_x, block_y_min ]);
150     rectfromto([ grasp_large_x, block_y_min ],
151                [ 0, block_y_min + 0.1 ]);
152   }
153 }
154
155 module MainExtrude(z){
156   linextr(0, z)
157     children();
158 }
159 module RackShear(){
160   s = rack_shear_ratio * $reverse_sign;
161   multmatrix([ [ 1, 0,  0, 0 ],
162                [ 0, 1, s , 0 ],
163                [ 0, 0,  1, 0 ],
164                [ 0, 0,  0, 1 ] ])
165     children();
166 }
167
168 module GraspFixingElevation(){
169   intersection(){
170     union(){
171       hull(){
172         mirror([1,0]) {
173           GraspElevation();
174         }
175         translate([ -block_x, block_y_min ] + [0,0.1]*1 )
176           circle(0.1);
177       }
178       translate([ strap_barrel_x, $strap_barrel_y ])
179         circle(strap_barrel_dia/2 + strap_guide_sz);
180     }
181     union(){
182       rectfromto([0, $rack_rail_y],
183                  [rack_width_inner, 50]);
184       intersection(){
185         translate([ rack_rail_x, $rack_rail_y ])
186           circle(r = rack_width_inner/2 - rack_rail_x);
187         polygon([ [ -block_x-0.1, 0 ],
188                   [ rack_width_inner/2, 0 ],
189                   $rail_fixing_fit_corner,
190                   $rail_fixing_fit_corner + [-1,-1] * fit_slope_len,
191                   [ -grasp_large_x - grasp_large_r*2, block_y_min ],
192                   [ -block_x-0.1 -2, block_y_min +2 ]]);
193       }
194     }
195   }
196 }
197
198 module StrapBarrelElevation(){
199   translate([ strap_barrel_x, $strap_barrel_y ])
200     circle(strap_barrel_dia/2);
201 }
202
203 // Bracket support block, goes up inside bracket
204 // Z origin is bolt hole
205 module BrkBlock(){
206   difference(){
207     linextr( -brk_block_z/2,
208              +brk_block_z/2 ) {
209       rectfromto([ -brk_block_xw/2, adapt_main_top_y - 0.1 ],
210                  [ +brk_block_xw/2, 0 ]);
211     }
212     linextr_y_xz( -50, 10 ) {
213       translate([ 0, brk_block_z + bolt_z ])
214         square(center=true,
215                [ main_sz_x_fam + support_around*2,
216                  support_remnant *2 ]);
217     }
218   }
219 }
220
221 // Z origin is bolt hole
222 module BoltHole(){
223   linextr_y_xz( -100, 10 )
224     circle(brk_bolt_dia/2);
225
226   linextr_y_xz( -brk_nearbolt_recess_depth, 10)
227     circle(brk_nearbolt_recess_dia/2);
228
229   linextr_y_xz( -100, brk_bolt_nut_top_y ) {
230     circle( r= brk_bolt_nut_r, $fn = 6 );
231     translate([ 0, brk_bolt_nut_across_flats/2 ])
232       circle( r=brk_bolt_nut_r/2, $fn = 4);
233   }
234 }
235
236 module IfFam(){
237   if ($foreaftmaint_dz) {
238     children();
239   }
240 }
241
242 module FamLinextr(){
243   IfFam()
244     linextr_x_yz(-main_sz_x_fam/2, +main_sz_x_fam/2)
245     rotate(-90)
246     children();
247 }
248
249 module FamGraspElevation(){
250   hull(){
251     ybot = $rack_rail_y - rack_rail_dia/2 + grasp_large_r
252       - fit_slope_len * 0.5;
253     for (y = [
254               ybot,
255               adapt_main_top_y - grasp_large_r
256               ])
257       for (dx= [/*-1,*/ +1] * rack_rail_dia/2)
258         translate([ -$foreaftmaint_rail_z + dx, y ])
259           circle(r= grasp_large_r);
260   }
261 }
262
263 module FamStemElevation(){
264   hull(){
265     rectfromto([ -$foreaftmaint_rail_z, adapt_main_top_y ],
266                [ 0, block_y_min]);
267     translate([
268                -$foreaftmaint_rail_z,
269                $rack_rail_y +
270                rack_shear_ratio * $foreaftmaint_rail_z * $reverse_sign,
271                ])
272       square([0.1, rack_rail_dia * 0.5], center=true);
273   }
274 }
275
276 module Principal(){
277   // calculated
278   $rack_rail_y = rack_rail_y_of_elevation($elevation_nominal);
279
280   $strap_barrel_y = $rack_rail_y + rack_rail_dia/2 + strap_barrel_dia/2;
281
282   $rail_fixing_fit_corner = [
283     rack_width_inner/2,
284     $rack_rail_y - rack_rail_dia/2
285   ];
286
287   $foreaftmaint_rail_z = brk_block_z/2 + $foreaftmaint_dz - foreaftmaint_y_slop;
288
289   translate([0,0,brk_block_z/2])
290   mirror([0,0, $reverse_sign > 0 ? 0 : 1])
291   translate([0,0,-brk_block_z/2])
292   difference(){
293     union(){
294       MainExtrude(main_sz_lhs_z){
295         GraspElevation();
296       }
297       RackShear() MainExtrude(main_sz_rhs_z){
298         StrapBarrelElevation();
299       }
300       translate([ 0,0, brk_block_z/2]) {
301         BrkBlock();
302       }
303
304       difference(){
305         union(){
306           MainExtrude(main_sz_core_z){
307             BlockElevation();
308           }
309           if ($strf<1) {
310             MainExtrude(max(brk_block_z, main_sz_rhs_z)){
311               rectfromto([-8, adapt_main_top_y + 0.1],
312                          [+8, block_y_min]);
313               rectfromto([-block_x -5,  adapt_main_top_y],
314                          [-grasp_large_x, block_y_min]);
315             }
316           }
317           RackShear() MainExtrude(main_sz_rhs_z){
318             GraspFixingElevation();
319           }
320         }
321
322         translate([0,0, main_sz_rhs_z/2]) linextr(-strap_w/2, +strap_w/2) {
323           translate([ rack_width_inner/2 - strap_th, 0 ])
324             rectfromto([ 0, -50 ], [ 50, 50 ]);
325         }
326       }
327
328       FamLinextr(){
329         rectfromto([ -foreaftmaint_top_block_zs[0] + bolt_z, 0 ],
330                    [ -foreaftmaint_top_block_zs[1] + bolt_z, block_y_min] );
331         FamGraspElevation();
332       }
333       intersection(){
334         union(){
335           RackShear()
336             FamLinextr()
337             FamGraspElevation();
338           FamLinextr()
339             FamStemElevation();
340         }
341         translate([ 0,
342                     adapt_main_top_y - 50,
343                     $foreaftmaint_rail_z ])
344           cube(center=true, 100);
345       }
346     }
347
348     RackShear() linextr(-10, main_sz_lhs_z+main_sz_rhs_z) {
349       for (mx=[0,1]) {
350         mirror([mx,0]) {
351           translate([ rack_rail_x, $rack_rail_y ]){
352             hull(){
353               for (dx = [-rack_rail_dia, 0])
354                 translate([dx, 0])
355                   circle(r= rack_rail_dia/2);
356             }
357           }
358         }
359       }
360     }
361
362     RackShear() IfFam(){
363       // Distance from bolt hole, in backwards direction
364       cr = rack_rail_dia/2 + foreaftmaint_r_slop;
365       translate([ 0, $rack_rail_y, $foreaftmaint_rail_z ])
366         linextr_x_yz(+rack_rail_x,
367                      -rack_rail_x) {
368         hull(){
369           for (dy=[0,50]) {
370             translate([-dy,0])
371               circle(r= cr);
372           }
373         }
374         hull(){
375           for (dd=[[0,0], [-1,-1], [-1,+1]]) {
376             translate(
377                       [-1, 0] * (rack_rail_dia - fit_slope_len)
378                       + 20 * dd
379                       )
380               circle(r= cr);
381           }
382         }
383       }
384     }
385
386     translate([ 0,0, brk_block_z/2]) BoltHole();
387   }
388 }
389
390 module ForRackForDemo(){
391   elevation = elevation_of_bolt_for(rear_to_cross_rail);
392   rack_rail_y = rack_rail_y_of_elevation(elevation);
393
394   rotate([-atan(rack_shear_ratio), 0,0])
395     translate([0, rack_rail_y, brk_block_z/2 + rack_rail_y*rack_shear_ratio])
396     children();
397 }
398
399 module RackForDemoRails(){
400   ForRackForDemo() {
401     for (m=[0]) mirror([m,0,0]) {
402       linextr(-(50 + cross_rail_distance), 50 + rear_to_cross_rail)
403         translate([rack_rail_x, 0])
404         circle(r= rack_rail_dia/2);
405     }
406   }
407 }
408
409 module RackForDemoCrosses(){
410   ForRackForDemo() {
411     translate([0,0, rear_to_cross_rail])
412       linextr_x_yz(rack_rail_x, -rack_rail_x)
413       circle(r= rack_rail_dia/2);
414
415     translate([0,0, rear_to_cross_rail - cross_rail_distance])
416       linextr_x_yz(rack_rail_x, -rack_rail_x)
417       circle(r= rack_rail_dia/2);
418   }
419 }
420
421 module Front(){ ////toplevel
422   // xxx elevation is wrong
423   Principal($reverse_sign = -1,
424             $elevation_nominal=
425       elevation_of_bolt_for(rear_to_cross_rail + rear_bolt_to_front_bolt),
426             $foreaftmaint_dz= front_to_cross_rail);
427 }
428
429 module Rear(){ ////toplevel
430   Principal($reverse_sign = +1,
431             $elevation_nominal=
432       elevation_of_bolt_for(rear_to_cross_rail),
433             $foreaftmaint_dz= rear_to_cross_rail);
434 }
435
436 module SomeDemo(){
437   rotate([90, 0, 0]){
438     children();
439
440     color("blue")
441       translate([ 0, -2, -4 ])
442       square(center=true, [ brk_overall_w, 1 ]);
443
444     color("red")
445       translate([ 0, -brk_nearbolt_recess_depth, -4 ])
446       linextr_y_xz(-brk_bolt_eff_len, 0)
447       circle(r = brk_bolt_dia/2);
448
449   }
450 }
451
452 module FrontDemo(){ ////toplevel
453   SomeDemo() Front();
454 }
455 module RearDemo(){ ////toplevel
456   SomeDemo() Rear();
457 }
458 module RearRackDemo(){ ////toplevel
459   rotate([atan(rack_shear_ratio),0,0]) SomeDemo() {
460     Rear();
461     translate([0, 0, -rear_bolt_to_front_bolt])
462       Front();
463     %RackForDemoRails();
464     color("blue") RackForDemoCrosses();
465   }
466 }