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