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