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