chiark / gitweb /
topeak-mtx-tortec-expeditionrack-adapter: fix test vsn
[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 = 4.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 - 1.0; // inside of recess, to end of bolt
39 brk_bolt_len_slop = 2.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 echo(rack_shear_ratio);
98
99 module GraspElevation(){
100   hull(){
101     translate([ grasp_large_x, adapt_main_top_y - grasp_large_r ])
102       circle(grasp_large_r);
103
104     translate([ grasp_small_x, $rack_rail_y - rack_rail_dia/2 ])
105       circle(grasp_small_r);
106
107     translate([ rack_rail_x + grasp_large_r/2,
108                 $rack_rail_y - rack_rail_dia/2 ])
109       circle(grasp_small_r);
110
111     translate([ grasp_large_x, $rack_rail_y + rack_rail_dia/2 ])
112       circle(grasp_large_r);
113
114     translate([ grasp_large_x + grasp_large_r/2,
115                 $rack_rail_y + rack_rail_dia/2 ])
116       circle(grasp_large_r);
117   }
118 }
119
120 module BlockElevation(){
121   hull(){
122     rectfromto([ +block_x, adapt_main_top_y ],
123                [ -block_x, block_y_min ]);
124     rectfromto([ -grasp_large_x, adapt_main_top_y ],
125                [ +grasp_large_x, adapt_main_top_y - 0.1 ]);
126   }
127   hull(){
128     rectfromto([ +block_x, adapt_main_top_y ],
129                [ -block_x, block_y_min ]);
130     rectfromto([ grasp_large_x, block_y_min ],
131                [ 0, block_y_min + 0.1 ]);
132   }
133 }
134
135 module MainExtrude(z){
136   linextr(0, z)
137     children();
138 }
139 module RackShear(){
140   s = rack_shear_ratio;
141   multmatrix([ [ 1, 0,  0, 0 ],
142                [ 0, 1, s , 0 ],
143                [ 0, 0,  1, 0 ],
144                [ 0, 0,  0, 1 ] ])
145     children();
146 }
147
148 module GraspFixingElevation(){
149   intersection(){
150     union(){
151       hull(){
152         mirror([1,0]) {
153           GraspElevation();
154         }
155         translate([ -block_x, block_y_min ] + [0,0.1]*1 )
156           circle(0.1);
157       }
158       translate([ strap_barrel_x, $strap_barrel_y ])
159         circle(strap_barrel_dia/2 + strap_guide_sz);
160     }
161     union(){
162       rectfromto([0, $rack_rail_y],
163                  [rack_width_inner, 50]);
164       intersection(){
165         translate([ rack_rail_x, $rack_rail_y ])
166           circle(r = rack_width_inner/2 - rack_rail_x);
167         polygon([ [ -block_x-0.1, 0 ],
168                   [ rack_width_inner/2, 0 ],
169                   $rail_fixing_fit_corner,
170                   $rail_fixing_fit_corner + [-1,-1] * fit_slope_len,
171                   [ -grasp_large_x - grasp_large_r*2, block_y_min ],
172                   [ -block_x-0.1 -2, block_y_min +2 ]]);
173       }
174     }
175   }
176 }
177
178 module StrapBarrelElevation(){
179   translate([ strap_barrel_x, $strap_barrel_y ])
180     circle(strap_barrel_dia/2);
181 }
182
183 // Bracket support block, goes up inside bracket
184 // Z origin is bolt hole
185 module BrkBlock(){
186   linextr( -brk_block_z/2,
187            +brk_block_z/2 ) {
188     rectfromto([ -brk_block_xw/2, adapt_main_top_y - 0.1 ],
189                [ +brk_block_xw/2, 0 ]);
190   }
191 }
192
193 // Z origin is bolt hole
194 module BoltHole(){
195   linextr_y_xz( -100, 10 )
196     circle(brk_bolt_dia/2);
197
198   linextr_y_xz( -brk_nearbolt_recess_depth, 10)
199     circle(brk_nearbolt_recess_dia/2);
200
201   linextr_y_xz( -100, brk_bolt_nut_top_y ) {
202     circle( r= brk_bolt_nut_r, $fn = 6 );
203     translate([ 0, brk_bolt_nut_across_flats/2 ])
204       circle( r=brk_bolt_nut_r/2, $fn = 4);
205   }
206 }
207
208 module AsForeAftMaint(){
209   if ($foreaftmaint_dz) {
210     children();
211   }
212 }
213
214 module Principal(){
215   // calculated
216   $rack_rail_y = brk_bottom_y - $elevation_nominal
217     - general_gap_y  - rack_rail_dia/2;
218
219   $strap_barrel_y = $rack_rail_y + rack_rail_dia/2 + strap_barrel_dia/2;
220
221   $rail_fixing_fit_corner = [
222     rack_width_inner/2,
223     $rack_rail_y - rack_rail_dia/2
224   ];
225
226   $foreaftmaint_rail_z = brk_block_z/2 + $foreaftmaint_dz;
227   $foreaftmaint_rail_y = $rack_rail_y
228     + $foreaftmaint_rail_z * rack_shear_ratio;
229
230   difference(){
231     union(){
232       MainExtrude(main_sz_lhs_z){
233         GraspElevation();
234       }
235       RackShear() MainExtrude(main_sz_rhs_z){
236         StrapBarrelElevation();
237       }
238       translate([ 0,0, brk_block_z/2]) {
239         BrkBlock();
240       }
241
242       difference(){
243         union(){
244           MainExtrude(main_sz_core_z){
245             BlockElevation();
246           }
247           if ($strf<1) {
248             MainExtrude(max(brk_block_z, main_sz_rhs_z)){
249               rectfromto([-8, 0],
250                          [+8, block_y_min]);
251               rectfromto([-block_x -5,  adapt_main_top_y],
252                          [-grasp_large_x, block_y_min]);
253             }
254           }
255           RackShear() MainExtrude(main_sz_rhs_z){
256             GraspFixingElevation();
257           }
258         }
259
260         translate([0,0, main_sz_rhs_z/2]) linextr(-strap_w/2, +strap_w/2) {
261           translate([ rack_width_inner/2 - strap_th, 0 ])
262             rectfromto([ 0, -50 ], [ 50, 50 ]);
263         }
264       }
265
266       RackShear() AsForeAftMaint(){
267         linextr_x_yz(-main_sz_x_fam/2,
268                      +main_sz_x_fam/2){
269           rotate(-90)
270           difference(){
271             union(){
272               rectfromto([ -$foreaftmaint_rail_z, adapt_main_top_y ],
273                          [ 0, block_y_min]);
274               hull(){
275                 ybot = $foreaftmaint_rail_y - rack_rail_dia/2 + grasp_large_r
276                   - fit_slope_len * 0.5;
277                 for (y = [
278                           ybot,
279                           adapt_main_top_y - grasp_large_r
280                           ])
281                   for (dx= [-1,+1] * rack_rail_dia/2)
282                     translate([ -$foreaftmaint_rail_z + dx, y ])
283                       circle(r= grasp_large_r);
284               }
285             }
286             translate([0, adapt_main_top_y])
287                rectfromto([-500, 0], [500, 500]);
288           }
289         }
290       }
291     }
292
293     RackShear() linextr(-10, main_sz_lhs_z+main_sz_rhs_z) {
294       for (mx=[0,1]) {
295         mirror([mx,0]) {
296           translate([ rack_rail_x, $rack_rail_y ]){
297             hull(){
298               for (dx = [-rack_rail_dia, 0])
299                 translate([dx, 0])
300                   circle(r= rack_rail_dia/2);
301             }
302           }
303         }
304       }
305     }
306
307     RackShear() AsForeAftMaint(){
308       // Distance from bolt hole, in backwards direction
309       cr = rack_rail_dia/2 + foreaftmaint_r_slop;
310       translate([ 0, $foreaftmaint_rail_y, $foreaftmaint_rail_z ])
311         linextr_x_yz(+rack_rail_x,
312                      -rack_rail_x) {
313         hull(){
314           for (dy=[0,50]) {
315             translate([-dy,0])
316               circle(r= cr);
317           }
318         }
319         hull(){
320           for (dd=[[0,0], [-1,-1], [-1,+1]]) {
321             translate(
322                       [-1, 0] * (rack_rail_dia - fit_slope_len)
323                       + 20 * dd
324                       )
325               circle(r= cr);
326           }
327         }
328       }
329     }
330
331     translate([ 0,0, brk_block_z/2]) BoltHole();
332   }
333 }
334
335 module Front(){ ////toplevel
336   // xxx elevation is wrong
337   Principal($elevation_nominal=
338       elevation_of_bolt_for(rear_to_cross_rail + rear_bolt_to_front_bolt),
339             $foreaftmaint_dz= 0);
340 }
341
342 module Rear(){ ////toplevel
343   Principal($elevation_nominal=
344       elevation_of_bolt_for(rear_to_cross_rail),
345             $foreaftmaint_dz= rear_to_cross_rail);
346 }
347
348 module SomeDemo(){
349   rotate([90, 0, 0]){
350     children();
351
352     color("blue")
353       translate([ 0, -2, -4 ])
354       square(center=true, [ brk_overall_w, 1 ]);
355
356   }
357 }
358
359 module FrontDemo(){ ////toplevel
360   SomeDemo() Front();
361 }
362 module RearDemo(){ ////toplevel
363   SomeDemo() Rear();
364 }