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