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