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