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