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