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