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