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