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; // top of rack to bottom of bracket
19 rear_to_front_distance = 230;
20
21 general_gap_y = 1.0;
22
23 strap_w = 8.0 + 1.0;
24 strap_th = 2.5;
25 strap_barrel_dia = 14;
26 strap_guide_sz = 1;
27
28 brk_block_xw = 68.5;
29 brk_block_z = 14.55 - 0.75;
30
31 brk_bolt_dia = 4.0 + 0.5;
32 brk_nearbolt_recess_dia = 8.86 + 1.5;
33 brk_nearbolt_recess_depth = 1.09 + 0.25;
34
35 brk_bolt_eff_len = 11.78 - 1.0; // inside of recess, to end of bolt
36 brk_bolt_len_slop = 2.0;;
37 brk_bolt_nut_th = 3.89;
38 brk_bolt_nut_across_flats = 7.86 + 0.50;
39
40 brk_overall_w = 90.07;
41
42 fit_slope_len = 5;
43
44 foreaftmaint_r_slop = 0.75;
45
46 main_sz_y = $strf * 20;
47 grasp_sz = $strf * 12;
48 beside_strap_sz = $strf * 8;
49
50 $fa=10;
51 $fs=1;
52
53 // calculated
54
55 main_sz_z = beside_strap_sz*2 + strap_w;
56
57 brk_bottom_y = -brk_recess_actual;
58 adapt_main_top_y = brk_bottom_y + general_gap_y;
59
60 // on LHS, so -ve
61 rack_rail_x = -(rack_width_inner/2 + rack_rail_dia/2);
62 rack_rail_outer_x = -(rack_width_inner/2 + rack_rail_dia);
63
64 grasp_large_r = (rack_rail_dia + grasp_sz)/2;
65 grasp_large_x = rack_rail_outer_x + grasp_large_r;
66
67 block_x = grasp_large_x + grasp_large_r/2;
68 block_y_min = adapt_main_top_y - main_sz_y;
69
70 strap_barrel_x = rack_width_inner/2 + strap_barrel_dia/2;
71
72 rack_shear_ratio = rear_elevation_nominal / rear_to_front_distance;
73
74 brk_bolt_nut_top_y = -brk_nearbolt_recess_depth
75   - brk_bolt_eff_len + brk_bolt_nut_th + brk_bolt_len_slop;
76                        
77 brk_bolt_nut_r = brk_bolt_nut_across_flats/2 / cos(360/12);
78
79 module GraspElevation(){
80   hull(){
81     translate([ grasp_large_x, adapt_main_top_y - grasp_large_r ])
82       circle(grasp_large_r);
83
84     translate([ grasp_large_x, $rack_rail_y - rack_rail_dia/2 ])
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 }
91
92 module BlockElevation(){
93   hull(){
94     rectfromto([ +block_x, adapt_main_top_y ],
95                [ -block_x, block_y_min ]);
96     rectfromto([ -grasp_large_x, adapt_main_top_y ],
97                [ +grasp_large_x, adapt_main_top_y - 0.1 ]);
98   }
99 }
100
101 module MainExtrude(){
102   linextr(0, main_sz_z)
103     children();
104 }
105 module RackShear(){
106   s = rack_shear_ratio;
107   multmatrix([ [ 1, 0,  0, 0 ],
108                [ 0, 1, s , 0 ],
109                [ 0, 0,  1, 0 ],
110                [ 0, 0,  0, 1 ] ])
111     children();
112 }
113
114 module GraspFixingElevation(){
115   intersection(){
116     union(){
117       mirror([1,0]) GraspElevation();
118       translate([ strap_barrel_x, $strap_barrel_y ])
119         circle(strap_barrel_dia/2 + strap_guide_sz);
120     }
121     union(){
122       rectfromto([0, $rack_rail_y],
123                  [rack_width_inner, 50]);
124       intersection(){
125         translate([ rack_rail_x, $rack_rail_y ])
126           circle(r = rack_width_inner/2 - rack_rail_x);
127         polygon([ [ 0, 0 ],
128                   [ rack_width_inner/2, 0 ],
129                   $rail_fixing_fit_corner,
130                   $rail_fixing_fit_corner + [-1,-1] * fit_slope_len,
131                   [ -block_x, block_y_min ],
132                   [ 0, block_y_min ]]);
133       }
134     }
135   }
136 }
137
138 module StrapBarrelElevation(){
139   translate([ strap_barrel_x, $strap_barrel_y ])
140     circle(strap_barrel_dia/2);
141 }
142
143 // Bracket support block, goes up inside bracket
144 // Z origin is bolt hole
145 module BrkBlock(){
146   linextr( -brk_block_z/2,
147            +brk_block_z/2 ) {
148     rectfromto([ -brk_block_xw/2, adapt_main_top_y - 0.1 ],
149                [ +brk_block_xw/2, 0 ]);
150   }
151 }
152
153 // Z origin is bolt hole
154 module BoltHole(){
155   linextr_y_xz( -100, 10 )
156     circle(brk_bolt_dia/2);
157
158   linextr_y_xz( -brk_nearbolt_recess_depth, 10)
159     circle(brk_nearbolt_recess_dia/2);
160
161   linextr_y_xz( -100, brk_bolt_nut_top_y ) {
162     circle( r= brk_bolt_nut_r, $fn = 6 );
163     translate([ 0, brk_bolt_nut_across_flats/2 ])
164       circle( r=brk_bolt_nut_r/2, $fn = 4);
165   }
166 }
167
168 module Principal(){
169   // calculated
170   $rack_rail_y = brk_bottom_y - $elevation_nominal
171     - general_gap_y  - rack_rail_dia/2;
172
173   $strap_barrel_y = $rack_rail_y + rack_rail_dia/2 + strap_barrel_dia/2;
174
175   $rail_fixing_fit_corner = [
176     rack_width_inner/2,
177     $rack_rail_y - rack_rail_dia/2
178   ];
179
180   $foreaftmaint_rail_z = brk_block_z/2 + $foreaftmaint_dz;
181   $foreaftmaint_rail_y = $rack_rail_y
182     + $foreaftmaint_rail_z * rack_shear_ratio;
183
184   difference(){
185     union(){
186       MainExtrude(){
187         GraspElevation();
188       }
189       RackShear() MainExtrude(){
190         StrapBarrelElevation();
191       }
192       translate([ 0,0, brk_block_z/2]) {
193         BrkBlock();
194       }
195
196       difference(){
197         union(){
198           MainExtrude(){
199             BlockElevation();
200           }
201           RackShear() MainExtrude(){
202             GraspFixingElevation();
203           }
204         }
205
206         translate([0,0, main_sz_z/2]) linextr(-strap_w/2, +strap_w/2) {
207           translate([ rack_width_inner/2 - strap_th, 0 ])
208             rectfromto([ 0, -50 ], [ 50, 50 ]);
209         }
210       }
211     }
212
213     RackShear() linextr(-10, main_sz_z+10) {
214       for (mx=[0,1]) {
215         mirror([mx,0]) {
216           translate([ rack_rail_x, $rack_rail_y ]){
217             hull(){
218               for (dx = [-rack_rail_dia, 0])
219                 translate([dx, 0])
220                   circle(r= rack_rail_dia/2);
221             }
222           }
223         }
224       }
225     }
226
227     // Distance from bolt hole, in backwards direction
228     if ($foreaftmaint_dz) {
229       translate([ 0, $foreaftmaint_rail_y, $foreaftmaint_rail_z ]){
230         linextr_x_yz(+rack_rail_x,
231                      -rack_rail_x) {
232           hull(){
233             for (dy=[0,50]) {
234               translate([-dy,0])
235                 circle(r= rack_rail_dia/2 + foreaftmaint_r_slop);
236             }
237           }
238         }
239       }
240     }
241
242     translate([ 0,0, brk_block_z/2]) BoltHole();
243   }
244 }
245
246 module Front(){ ////toplevel
247   Principal($elevation_nominal=0, $foreaftmaint_dz=0);
248 }
249
250 module Rear(){ ////toplevel
251   Principal($elevation_nominal=rear_elevation_nominal,
252             $foreaftmaint_dz= 9.65);
253 }
254
255 module Demo(){ ////toplevel
256   rotate([90, 0, 0]){
257
258     Rear();
259
260     color("blue")
261       translate([ 0, -2, -4 ])
262       square(center=true, [ brk_overall_w, 1 ]);
263
264   }
265 }