chiark / gitweb /
topeak-mtx-tortec-expeditionrack-adapter: adjust for shear not rotate
[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   - sqrt( pow( cross_rail_distance * rack_shear_ratio, 2 )
108           - pow(  front_to_rear_elevation_change, 2 ) )
109   ;
110
111 brk_bolt_nut_top_y = -brk_nearbolt_recess_depth
112   - brk_bolt_eff_len + brk_bolt_nut_th + brk_bolt_len_slop;
113                        
114 brk_bolt_nut_r = brk_bolt_nut_across_flats/2 / cos(360/12);
115
116 function elevation_of_bolt_for(z) = rear_elevation_nominal
117   + front_elevation_nominal
118   + (z - brk_block_z/2) * rack_shear_ratio;
119
120 function rack_rail_y_of_elevation(elevation_nominal) =
121   brk_bottom_y - elevation_nominal - general_gap_y  - rack_rail_dia/2;
122
123 echo(rack_shear_ratio);
124
125 module GraspElevation(){
126   hull(){
127     translate([ grasp_large_x, adapt_main_top_y - grasp_large_r ])
128       circle(grasp_large_r);
129
130     translate([ grasp_small_x, $rack_rail_y - rack_rail_dia/2 ])
131       circle(grasp_small_r);
132
133     translate([ rack_rail_x + grasp_large_r/2,
134                 $rack_rail_y - rack_rail_dia/2 ])
135       circle(grasp_small_r);
136
137     translate([ grasp_large_x, $rack_rail_y + rack_rail_dia/2 ])
138       circle(grasp_large_r);
139
140     translate([ grasp_large_x + grasp_large_r/2,
141                 $rack_rail_y + rack_rail_dia/2 ])
142       circle(grasp_large_r);
143   }
144 }
145
146 module BlockElevation(){
147   hull(){
148     rectfromto([ +block_x, adapt_main_top_y ],
149                [ -block_x, block_y_min ]);
150     rectfromto([ -grasp_large_x, adapt_main_top_y ],
151                [ +grasp_large_x, adapt_main_top_y - 0.1 ]);
152   }
153   hull(){
154     rectfromto([ +block_x, adapt_main_top_y ],
155                [ -block_x, block_y_min ]);
156     rectfromto([ grasp_large_x, block_y_min ],
157                [ 0, block_y_min + 0.1 ]);
158   }
159 }
160
161 module MainExtrude(z){
162   linextr(0, z)
163     children();
164 }
165 module RackShear(){
166   s = rack_shear_ratio * $reverse_sign;
167   multmatrix([ [ 1, 0,  0, 0 ],
168                [ 0, 1, s , 0 ],
169                [ 0, 0,  1, 0 ],
170                [ 0, 0,  0, 1 ] ])
171     children();
172 }
173
174 module GraspFixingElevation(){
175   intersection(){
176     union(){
177       hull(){
178         mirror([1,0]) {
179           GraspElevation();
180         }
181         translate([ -block_x, block_y_min ] + [0,0.1]*1 )
182           circle(0.1);
183       }
184       translate([ strap_barrel_x, $strap_barrel_y ])
185         circle(strap_barrel_dia/2 + strap_guide_sz);
186     }
187     union(){
188       rectfromto([0, $rack_rail_y],
189                  [rack_width_inner, 50]);
190       intersection(){
191         translate([ rack_rail_x, $rack_rail_y ])
192           circle(r = rack_width_inner/2 - rack_rail_x);
193         polygon([ [ -block_x-0.1, 0 ],
194                   [ rack_width_inner/2, 0 ],
195                   $rail_fixing_fit_corner,
196                   $rail_fixing_fit_corner + [-1,-1] * fit_slope_len,
197                   [ -grasp_large_x - grasp_large_r*2, block_y_min ],
198                   [ -block_x-0.1 -2, block_y_min +2 ]]);
199       }
200     }
201   }
202 }
203
204 module StrapBarrelElevation(){
205   translate([ strap_barrel_x, $strap_barrel_y ])
206     circle(strap_barrel_dia/2);
207 }
208
209 // Bracket support block, goes up inside bracket
210 // Z origin is bolt hole
211 module BrkBlock(){
212   difference(){
213     linextr( -brk_block_z/2,
214              +brk_block_z/2 ) {
215       rectfromto([ -brk_block_xw/2, adapt_main_top_y - 0.1 ],
216                  [ +brk_block_xw/2, 0 ]);
217     }
218     linextr_y_xz( -50, 10 ) {
219       translate([ 0, brk_block_z + bolt_z ])
220         square(center=true,
221                [ main_sz_x_fam + support_around*2,
222                  support_remnant *2 ]);
223     }
224   }
225 }
226
227 // Z origin is bolt hole
228 module BoltHole(){
229   linextr_y_xz( -100, 10 )
230     circle(brk_bolt_dia/2);
231
232   linextr_y_xz( -brk_nearbolt_recess_depth, 10)
233     circle(brk_nearbolt_recess_dia/2);
234
235   linextr_y_xz( -100, brk_bolt_nut_top_y ) {
236     circle( r= brk_bolt_nut_r, $fn = 6 );
237     translate([ 0, brk_bolt_nut_across_flats/2 ])
238       circle( r=brk_bolt_nut_r/2, $fn = 4);
239   }
240 }
241
242 module IfFam(){
243   if ($foreaftmaint_dz) {
244     children();
245   }
246 }
247
248 module FamLinextr(){
249   IfFam()
250     linextr_x_yz(-main_sz_x_fam/2, +main_sz_x_fam/2)
251     rotate(-90)
252     children();
253 }
254
255 module FamGraspElevation(){
256   hull(){
257     ybot = $rack_rail_y - rack_rail_dia/2 + grasp_large_r
258       - fit_slope_len * 0.5;
259     for (y = [
260               ybot,
261               adapt_main_top_y - grasp_large_r
262               ])
263       for (dx= [/*-1,*/ +1] * rack_rail_dia/2)
264         translate([ -$foreaftmaint_rail_z + dx, y ])
265           circle(r= grasp_large_r);
266   }
267 }
268
269 module FamStemElevation(){
270   hull(){
271     rectfromto([ -$foreaftmaint_rail_z, adapt_main_top_y ],
272                [ 0, block_y_min]);
273     translate([
274                -$foreaftmaint_rail_z,
275                $rack_rail_y +
276                rack_shear_ratio * $foreaftmaint_rail_z * $reverse_sign,
277                ])
278       square([0.1, rack_rail_dia * 0.5], center=true);
279   }
280 }
281
282 module Principal(){
283   // calculated
284   $rack_rail_y = rack_rail_y_of_elevation($elevation_nominal);
285
286   $strap_barrel_y = $rack_rail_y + rack_rail_dia/2 + strap_barrel_dia/2;
287
288   $rail_fixing_fit_corner = [
289     rack_width_inner/2,
290     $rack_rail_y - rack_rail_dia/2
291   ];
292
293   $foreaftmaint_rail_z = brk_block_z/2 + $foreaftmaint_dz - foreaftmaint_y_slop;
294
295   translate([0,0,brk_block_z/2])
296   mirror([0,0, $reverse_sign > 0 ? 0 : 1])
297   translate([0,0,-brk_block_z/2])
298   difference(){
299     union(){
300       MainExtrude(main_sz_lhs_z){
301         GraspElevation();
302       }
303       RackShear() MainExtrude(main_sz_rhs_z){
304         StrapBarrelElevation();
305       }
306       translate([ 0,0, brk_block_z/2]) {
307         BrkBlock();
308       }
309
310       difference(){
311         union(){
312           MainExtrude(main_sz_core_z){
313             BlockElevation();
314           }
315           if ($strf<1) {
316             MainExtrude(max(brk_block_z, main_sz_rhs_z)){
317               rectfromto([-8, adapt_main_top_y + 0.1],
318                          [+8, block_y_min]);
319               rectfromto([-block_x -5,  adapt_main_top_y],
320                          [-grasp_large_x, block_y_min]);
321             }
322           }
323           RackShear() MainExtrude(main_sz_rhs_z){
324             GraspFixingElevation();
325           }
326         }
327
328         translate([0,0, main_sz_rhs_z/2]) linextr(-strap_w/2, +strap_w/2) {
329           translate([ rack_width_inner/2 - strap_th, 0 ])
330             rectfromto([ 0, -50 ], [ 50, 50 ]);
331         }
332       }
333
334       FamLinextr(){
335         rectfromto([ -foreaftmaint_top_block_zs[0] + bolt_z, 0 ],
336                    [ -foreaftmaint_top_block_zs[1] + bolt_z, block_y_min] );
337         FamGraspElevation();
338       }
339       intersection(){
340         union(){
341           RackShear()
342             FamLinextr()
343             FamGraspElevation();
344           FamLinextr()
345             FamStemElevation();
346         }
347         translate([ 0,
348                     adapt_main_top_y - 50,
349                     $foreaftmaint_rail_z ])
350           cube(center=true, 100);
351       }
352     }
353
354     RackShear() linextr(-10, main_sz_lhs_z+main_sz_rhs_z) {
355       for (mx=[0,1]) {
356         mirror([mx,0]) {
357           translate([ rack_rail_x, $rack_rail_y ]){
358             hull(){
359               for (dx = [-rack_rail_dia, 0])
360                 translate([dx, 0])
361                   circle(r= rack_rail_dia/2);
362             }
363           }
364         }
365       }
366     }
367
368     RackShear() IfFam(){
369       // Distance from bolt hole, in backwards direction
370       cr = rack_rail_dia/2 + foreaftmaint_r_slop;
371       translate([ 0, $rack_rail_y, $foreaftmaint_rail_z ])
372         linextr_x_yz(+rack_rail_x,
373                      -rack_rail_x) {
374         hull(){
375           for (dy=[0,50]) {
376             translate([-dy,0])
377               circle(r= cr);
378           }
379         }
380         hull(){
381           for (dd=[[0,0], [-1,-1], [-1,+1]]) {
382             translate(
383                       [-1, 0] * (rack_rail_dia - fit_slope_len)
384                       + 20 * dd
385                       )
386               circle(r= cr);
387           }
388         }
389       }
390     }
391
392     translate([ 0,0, brk_block_z/2]) BoltHole();
393   }
394 }
395
396 module ForRackForDemo(){
397   elevation = elevation_of_bolt_for(rear_to_cross_rail);
398   rack_rail_y = rack_rail_y_of_elevation(elevation);
399
400   rotate([atan(
401                front_to_rear_elevation_change /
402                cross_rail_distance
403                ), 0,0])
404     translate([0, rack_rail_y, brk_block_z/2 + rack_rail_y*rack_shear_ratio])
405     children();
406 }
407
408 module RackForDemoRails(){
409   ForRackForDemo() {
410     for (m=[0]) mirror([m,0,0]) {
411       linextr(-(50 + cross_rail_distance), 50 + rear_to_cross_rail)
412         translate([rack_rail_x, 0])
413         circle(r= rack_rail_dia/2);
414     }
415   }
416 }
417
418 module RackForDemoCrosses(){
419   ForRackForDemo() {
420     for (z = [
421               rear_to_cross_rail,
422               rear_to_cross_rail - cross_rail_distance,
423               ]) {
424       translate([0,0,z])
425         linextr_x_yz(rack_rail_x, -rack_rail_x)
426         circle(r= rack_rail_dia/2, $fn=8);
427     }
428   }
429 }
430
431 module Front(){ ////toplevel
432   // xxx elevation is wrong
433   Principal($reverse_sign = -1,
434             $elevation_nominal=
435       elevation_of_bolt_for(rear_to_cross_rail + rear_bolt_to_front_bolt),
436             $foreaftmaint_dz= front_to_cross_rail);
437 }
438
439 module Rear(){ ////toplevel
440   Principal($reverse_sign = +1,
441             $elevation_nominal=
442       elevation_of_bolt_for(rear_to_cross_rail),
443             $foreaftmaint_dz= rear_to_cross_rail);
444 }
445
446 module SomeDemo(){
447   rotate([90, 0, 0]){
448     children();
449
450     color("blue")
451       translate([ 0, -2, -4 ])
452       square(center=true, [ brk_overall_w, 1 ]);
453
454     color("red")
455       translate([ 0, -brk_nearbolt_recess_depth, -4 ])
456       linextr_y_xz(-brk_bolt_eff_len, 0)
457       circle(r = brk_bolt_dia/2);
458
459   }
460 }
461
462 module FrontDemo(){ ////toplevel
463   SomeDemo() Front();
464 }
465 module RearDemo(){ ////toplevel
466   SomeDemo() Rear();
467 }
468 module RearRackDemo(){ ////toplevel
469   rotate([atan(rack_shear_ratio),0,0]) SomeDemo() {
470     Rear();
471     translate([0, 0, -rear_bolt_to_front_bolt])
472       Front();
473     %RackForDemoRails();
474     color("blue") RackForDemoCrosses();
475   }
476 }