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