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