chiark / gitweb /
6de109a600b3cc29e3525e0d401ed52322e7d0e1
[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.33;
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 rack cross rail (fam)
20 rear_to_front_distance = 230; // rack cross rail (fam) to very front end
21 rear_to_cross_rail = 43.05; // bolt centre to rail centre, rail to rear
22 rear_bolt_to_front_bolt = 155.4;
23 front_to_cross_rail = 43.05; // XXX // bolt centre to rail centre, rail to front
24
25 general_gap_y = 1.0;
26
27 strap_w = 8.0 + 1.0;
28 strap_th = 2.5;
29 strap_barrel_dia = 14;
30 strap_guide_sz = 1;
31
32 brk_block_xw = 68.5;
33 brk_block_z = 14.55 - 0.00;
34
35 brk_bolt_dia = 5.0 + 0.5;
36 brk_nearbolt_recess_dia = 8.86 + 1.5;
37 brk_nearbolt_recess_depth = 1.09 + 0.25;
38
39 brk_bolt_eff_len = 11.78; // inside of recess, to end of bolt
40 brk_bolt_len_slop = 0.5;
41 brk_bolt_nut_th = 3.89;
42 brk_bolt_nut_across_flats = 7.86 + 0.50;
43
44 brk_overall_w = 90.07;
45
46 fit_slope_len = 5;
47
48 // "foreaftmaint" aka "fam" is the hook-like part that stops
49 // the adapter sliding forwards/backwards along the rails
50 foreaftmaint_r_slop = 0.0;
51 foreaftmaint_y_slop = -0.25;
52 foreaftmaint_top_block_zs = [34.0, 39.0]; // rearwards from bolt hole
53
54 main_sz_y = $strf * 12;
55 grasp_sz = $strf * 6;
56 grasp_thin_sz = $strf * 0.5;
57 beside_strap_sz = $strf * 8;
58 main_sz_core_z = $strf * 12;
59
60 // "length" in for-aft direction of interaction with rack rail
61 min_on_rail_sz_z = $strf * 18;
62
63 // when printer produces support
64 support_around = 1.7; // how far does the support extend around (in XY)
65 support_remnant = 0.75; // how much frass remains attached (Z height)
66
67 $fa=10;
68 $fs=1;
69
70 // calculated
71
72 bolt_z = -brk_block_z/2;
73
74 main_sz_rhs_z = max(min_on_rail_sz_z, beside_strap_sz*2 + strap_w);
75 main_sz_lhs_z = min_on_rail_sz_z;
76
77 main_sz_x_fam = main_sz_y;
78
79 brk_bottom_y = -brk_recess_actual;
80 adapt_main_top_y = brk_bottom_y - general_gap_y;
81
82 // on LHS, so -ve
83 rack_rail_x = -(rack_width_inner/2 + rack_rail_dia/2);
84 rack_rail_outer_x = -(rack_width_inner/2 + rack_rail_dia);
85
86 grasp_large_r = (rack_rail_dia + grasp_sz)/2;
87 grasp_small_r = (rack_rail_dia + grasp_thin_sz)/2;
88 grasp_large_x = rack_rail_outer_x + grasp_large_r;
89 grasp_small_x = rack_rail_outer_x + grasp_small_r;
90
91 block_x = grasp_large_x + grasp_large_r;
92 block_y_min = adapt_main_top_y - main_sz_y;
93
94 strap_barrel_x = rack_width_inner/2 + strap_barrel_dia/2;
95
96 rack_shear_ratio = -rear_elevation_nominal / rear_to_front_distance;
97
98 brk_bolt_nut_top_y = -brk_nearbolt_recess_depth
99   - brk_bolt_eff_len + brk_bolt_nut_th + brk_bolt_len_slop;
100                        
101 brk_bolt_nut_r = brk_bolt_nut_across_flats/2 / cos(360/12);
102
103 function elevation_of_bolt_for(z) = rear_elevation_nominal
104   + (z - brk_block_z/2) * rack_shear_ratio;
105
106 function rack_rail_y_of_elevation(elevation_nominal) =
107   brk_bottom_y - elevation_nominal - general_gap_y  - rack_rail_dia/2;
108
109 echo(rack_shear_ratio);
110
111 module GraspElevation(){
112   hull(){
113     translate([ grasp_large_x, adapt_main_top_y - grasp_large_r ])
114       circle(grasp_large_r);
115
116     translate([ grasp_small_x, $rack_rail_y - rack_rail_dia/2 ])
117       circle(grasp_small_r);
118
119     translate([ rack_rail_x + grasp_large_r/2,
120                 $rack_rail_y - rack_rail_dia/2 ])
121       circle(grasp_small_r);
122
123     translate([ grasp_large_x, $rack_rail_y + rack_rail_dia/2 ])
124       circle(grasp_large_r);
125
126     translate([ grasp_large_x + grasp_large_r/2,
127                 $rack_rail_y + rack_rail_dia/2 ])
128       circle(grasp_large_r);
129   }
130 }
131
132 module BlockElevation(){
133   hull(){
134     rectfromto([ +block_x, adapt_main_top_y ],
135                [ -block_x, block_y_min ]);
136     rectfromto([ -grasp_large_x, adapt_main_top_y ],
137                [ +grasp_large_x, adapt_main_top_y - 0.1 ]);
138   }
139   hull(){
140     rectfromto([ +block_x, adapt_main_top_y ],
141                [ -block_x, block_y_min ]);
142     rectfromto([ grasp_large_x, block_y_min ],
143                [ 0, block_y_min + 0.1 ]);
144   }
145 }
146
147 module MainExtrude(z){
148   linextr(0, z)
149     children();
150 }
151 module RackShear(){
152   s = rack_shear_ratio * $reverse_sign;
153   multmatrix([ [ 1, 0,  0, 0 ],
154                [ 0, 1, s , 0 ],
155                [ 0, 0,  1, 0 ],
156                [ 0, 0,  0, 1 ] ])
157     children();
158 }
159
160 module GraspFixingElevation(){
161   intersection(){
162     union(){
163       hull(){
164         mirror([1,0]) {
165           GraspElevation();
166         }
167         translate([ -block_x, block_y_min ] + [0,0.1]*1 )
168           circle(0.1);
169       }
170       translate([ strap_barrel_x, $strap_barrel_y ])
171         circle(strap_barrel_dia/2 + strap_guide_sz);
172     }
173     union(){
174       rectfromto([0, $rack_rail_y],
175                  [rack_width_inner, 50]);
176       intersection(){
177         translate([ rack_rail_x, $rack_rail_y ])
178           circle(r = rack_width_inner/2 - rack_rail_x);
179         polygon([ [ -block_x-0.1, 0 ],
180                   [ rack_width_inner/2, 0 ],
181                   $rail_fixing_fit_corner,
182                   $rail_fixing_fit_corner + [-1,-1] * fit_slope_len,
183                   [ -grasp_large_x - grasp_large_r*2, block_y_min ],
184                   [ -block_x-0.1 -2, block_y_min +2 ]]);
185       }
186     }
187   }
188 }
189
190 module StrapBarrelElevation(){
191   translate([ strap_barrel_x, $strap_barrel_y ])
192     circle(strap_barrel_dia/2);
193 }
194
195 // Bracket support block, goes up inside bracket
196 // Z origin is bolt hole
197 module BrkBlock(){
198   difference(){
199     linextr( -brk_block_z/2,
200              +brk_block_z/2 ) {
201       rectfromto([ -brk_block_xw/2, adapt_main_top_y - 0.1 ],
202                  [ +brk_block_xw/2, 0 ]);
203     }
204     linextr_y_xz( -50, 10 ) {
205       translate([ 0, brk_block_z + bolt_z ])
206         square(center=true,
207                [ main_sz_x_fam + support_around*2,
208                  support_remnant *2 ]);
209     }
210   }
211 }
212
213 // Z origin is bolt hole
214 module BoltHole(){
215   linextr_y_xz( -100, 10 )
216     circle(brk_bolt_dia/2);
217
218   linextr_y_xz( -brk_nearbolt_recess_depth, 10)
219     circle(brk_nearbolt_recess_dia/2);
220
221   linextr_y_xz( -100, brk_bolt_nut_top_y ) {
222     circle( r= brk_bolt_nut_r, $fn = 6 );
223     translate([ 0, brk_bolt_nut_across_flats/2 ])
224       circle( r=brk_bolt_nut_r/2, $fn = 4);
225   }
226 }
227
228 module IfFam(){
229   if ($foreaftmaint_dz) {
230     children();
231   }
232 }
233
234 module FamLinextr(){
235   IfFam()
236     linextr_x_yz(-main_sz_x_fam/2, +main_sz_x_fam/2)
237     rotate(-90)
238     children();
239 }
240
241 module FamGraspElevation(){
242   difference(){
243     hull(){
244       ybot = $rack_rail_y - rack_rail_dia/2 + grasp_large_r
245         - fit_slope_len * 0.5;
246       for (y = [
247                 ybot,
248                 adapt_main_top_y - grasp_large_r
249                 ])
250         for (dx= [-1,+1] * rack_rail_dia/2)
251           translate([ -$foreaftmaint_rail_z + dx, y ])
252             circle(r= grasp_large_r);
253     }
254     translate([0, adapt_main_top_y])
255       rectfromto([-500, 0], [500, 500]);
256   }
257 }
258
259 module Principal(){
260   // calculated
261   $rack_rail_y = rack_rail_y_of_elevation($elevation_nominal);
262
263   $strap_barrel_y = $rack_rail_y + rack_rail_dia/2 + strap_barrel_dia/2;
264
265   $rail_fixing_fit_corner = [
266     rack_width_inner/2,
267     $rack_rail_y - rack_rail_dia/2
268   ];
269
270   $foreaftmaint_rail_z = brk_block_z/2 + $foreaftmaint_dz - foreaftmaint_y_slop;
271
272   translate([0,0,brk_block_z/2])
273   mirror([0,0, $reverse_sign > 0 ? 0 : 1])
274   translate([0,0,-brk_block_z/2])
275   difference(){
276     union(){
277       MainExtrude(main_sz_lhs_z){
278         GraspElevation();
279       }
280       RackShear() MainExtrude(main_sz_rhs_z){
281         StrapBarrelElevation();
282       }
283       translate([ 0,0, brk_block_z/2]) {
284         BrkBlock();
285       }
286
287       difference(){
288         union(){
289           MainExtrude(main_sz_core_z){
290             BlockElevation();
291           }
292           if ($strf<1) {
293             MainExtrude(max(brk_block_z, main_sz_rhs_z)){
294               rectfromto([-8, adapt_main_top_y + 0.1],
295                          [+8, block_y_min]);
296               rectfromto([-block_x -5,  adapt_main_top_y],
297                          [-grasp_large_x, block_y_min]);
298             }
299           }
300           RackShear() MainExtrude(main_sz_rhs_z){
301             GraspFixingElevation();
302           }
303         }
304
305         translate([0,0, main_sz_rhs_z/2]) linextr(-strap_w/2, +strap_w/2) {
306           translate([ rack_width_inner/2 - strap_th, 0 ])
307             rectfromto([ 0, -50 ], [ 50, 50 ]);
308         }
309       }
310
311       FamLinextr(){
312         rectfromto([ -$foreaftmaint_rail_z, adapt_main_top_y ],
313                    [ 0, block_y_min]);
314         rectfromto([ -foreaftmaint_top_block_zs[0] + bolt_z, 0 ],
315                    [ -foreaftmaint_top_block_zs[1] + bolt_z, block_y_min] );
316         FamGraspElevation();
317       }
318       RackShear()
319         FamLinextr()
320         FamGraspElevation();
321     }
322
323     RackShear() linextr(-10, main_sz_lhs_z+main_sz_rhs_z) {
324       for (mx=[0,1]) {
325         mirror([mx,0]) {
326           translate([ rack_rail_x, $rack_rail_y ]){
327             hull(){
328               for (dx = [-rack_rail_dia, 0])
329                 translate([dx, 0])
330                   circle(r= rack_rail_dia/2);
331             }
332           }
333         }
334       }
335     }
336
337     RackShear() IfFam(){
338       // Distance from bolt hole, in backwards direction
339       cr = rack_rail_dia/2 + foreaftmaint_r_slop;
340       translate([ 0, $rack_rail_y, $foreaftmaint_rail_z ])
341         linextr_x_yz(+rack_rail_x,
342                      -rack_rail_x) {
343         hull(){
344           for (dy=[0,50]) {
345             translate([-dy,0])
346               circle(r= cr);
347           }
348         }
349         hull(){
350           for (dd=[[0,0], [-1,-1], [-1,+1]]) {
351             translate(
352                       [-1, 0] * (rack_rail_dia - fit_slope_len)
353                       + 20 * dd
354                       )
355               circle(r= cr);
356           }
357         }
358       }
359     }
360
361     translate([ 0,0, brk_block_z/2]) BoltHole();
362   }
363 }
364
365 module RackForDemo(){ ////toplevel
366   elevation = elevation_of_bolt_for(rear_to_cross_rail);
367   rack_rail_y = rack_rail_y_of_elevation(elevation);
368
369   rotate([-atan(rack_shear_ratio), 0,0])
370     translate([0, rack_rail_y, brk_block_z/2 + rack_rail_y*rack_shear_ratio]) {
371       for (m=[0]) mirror([m,0,0]) {
372         linextr(-50, 50 + rear_to_cross_rail)
373           translate([rack_rail_x, 0])
374           circle(r= rack_rail_dia/2);
375         }
376       translate([0,0, rear_to_cross_rail])
377         linextr_x_yz(rack_rail_x, -rack_rail_x)
378         circle(r= rack_rail_dia/2);
379     }
380 }
381
382 module Front(){ ////toplevel
383   // xxx elevation is wrong
384   Principal($reverse_sign = -1,
385             $elevation_nominal=
386       elevation_of_bolt_for(rear_to_cross_rail + rear_bolt_to_front_bolt),
387             $foreaftmaint_dz= front_to_cross_rail);
388 }
389
390 module Rear(){ ////toplevel
391   Principal($reverse_sign = +1,
392             $elevation_nominal=
393       elevation_of_bolt_for(rear_to_cross_rail),
394             $foreaftmaint_dz= rear_to_cross_rail);
395 }
396
397 module SomeDemo(){
398   rotate([90, 0, 0]){
399     children();
400
401     color("blue")
402       translate([ 0, -2, -4 ])
403       square(center=true, [ brk_overall_w, 1 ]);
404
405     color("red")
406       translate([ 0, -brk_nearbolt_recess_depth, -4 ])
407       linextr_y_xz(-brk_bolt_eff_len, 0)
408       circle(r = brk_bolt_dia/2);
409
410   }
411 }
412
413 module FrontDemo(){ ////toplevel
414   SomeDemo() Front();
415 }
416 module RearDemo(){ ////toplevel
417   SomeDemo() Rear();
418 }
419 module RearRackDemo(){ ////toplevel
420   rotate([atan(rack_shear_ratio),0,0]) SomeDemo() {
421     Rear();
422     %RackForDemo();
423   }
424 }