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