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