chiark / gitweb /
knifeblock: add BlockFrontTest
[reprap-play.git] / crossbar-computer-led-mount.scad
1 // -*- C -*-
2
3 led_dia = 5 + 0.6;
4 led_depth = 5;
5
6 led_tip_height_above_crossbar = 70;
7 led_angle = -60;
8 crossbar_dia = 25; // fixme
9
10 vert_space_inside = 8;
11 backfront_space_inside = 12;
12 width_space_inside = 10;
13
14 backfront_mate_size = 25;
15 tower_frontheight = 10;
16 tower_base_height = 20;
17 tower_slot_width = 3;
18
19 cableclamp_ctie_width = 4.0 + 1.0;
20 cableclamp_ctie_thick = 2.5 + 0.5;
21
22 lidclamp_ctie_width = 4.0 + 1.0;
23 lidclamp_ctie_thick = 2.5 + 0.5;
24
25 base_ctie_width = 4.0 + 1.0;
26 base_ctie_thick = 2.5 + 0.5;
27
28 tube_ctie_width = 4.0 + 1.0;
29 tube_ctie_thick = 2.5 + 0.5;
30
31 // tuning
32
33 tower_over_angle = 45;
34 tower_wall_thick = 1.6;
35 tower_forehead_angle = 30;
36 lid_wall_thick = 1.6;
37 lid_slop = 0.75;
38 //cableclamp_ctie_anchor = 5;
39 lidclamp_cableclamp_ctie_between = 0;
40 base_ctie_anchor = 5;
41 tube_ctie_anchor = 5;
42 protrusion_size = 2;
43 protrusion_none_frontback = 10;
44 protrusion_slop = 0.25;
45 cableclamp_ctie_z = tower_frontheight/2;
46
47 towerleg_backfront = 5;
48 towerleg_width = 3;
49 towerleg_foot_gap = 2;
50 towerleg_foot_backfront = 20;
51 towerleg_foot_width = 40;
52 towerleg_foot_height = 10;
53 towerleg_yslope = 0.7;
54 towerleg_xslope = 0.3;
55 echo(sqrt(towerleg_yslope*towerleg_yslope+towerleg_xslope*towerleg_xslope));
56
57 //--- tests ---
58
59 test_width = 24;
60 test_height = 24;
61
62 test_thicks = [9,14,21];
63
64 module Tests(){ ////toplevel
65   for (thicki=[0:len(test_thicks)-1]) {
66     translate([thicki*test_width-0.5, 0, 0]) {
67       difference(){
68         cube([test_width,
69               test_thicks[thicki] + led_depth,
70               test_height]);
71         translate([test_width/2, -1, test_height/2])
72           rotate([-90,0,0])
73           cylinder(r=led_dia/2, h=led_depth+1, $fn=30);
74       }
75     }
76   }
77 }
78
79 //Tests();
80
81 //--- real thing ---
82
83 // calculated
84
85 tower_overhang = led_dia * 2.5;
86 tower_width = width_space_inside + tower_wall_thick*2;
87
88 tower_over_max_y = tower_overhang * sin(tower_over_angle);
89 tower_over_max_z = tower_frontheight + tower_overhang * cos(tower_over_angle);
90 tower_total_max_z = tower_over_max_z + vert_space_inside + led_depth;
91 tower_rearwall_y = -(backfront_space_inside + tower_wall_thick);
92 led_head_y = tower_over_max_y/2;
93 led_head_z = tower_frontheight + tower_overhang*sin(tower_over_angle)/2;
94 backfront_mate_extra = (backfront_mate_size - (-tower_rearwall_y));
95
96 tower_height_contribution = led_head_z + tower_base_height;
97
98 base_ctie_anchor_eff = base_ctie_anchor+base_ctie_thick/2;
99 tube_ctie_anchor_eff = tube_ctie_anchor+tube_ctie_thick/2;
100
101 base_width = 0.7 * crossbar_dia;
102 base_backfront = backfront_mate_extra - tower_rearwall_y;
103 base_height = led_tip_height_above_crossbar - tower_height_contribution;
104
105 protrusion_frontback = base_backfront - protrusion_none_frontback;
106
107 echo(tower_height_contribution, base_height);
108
109 module TowerWallCrossSection(){
110   // generates a 2D shape - a polygon
111   // x is what is going to be -y
112   // y is what is going to be z
113   polygon([[0,                  0],
114            [0,                  tower_frontheight],
115            [-tower_over_max_y,  tower_over_max_z],
116            [-tower_over_max_y
117             + tan(tower_forehead_angle) * (vert_space_inside + led_depth),
118             tower_total_max_z],
119            [-tower_rearwall_y,  tower_total_max_z],
120            [-tower_rearwall_y,  0],
121            [-tower_rearwall_y, -tower_base_height],
122            [-backfront_mate_extra, -tower_base_height]],
123           convexity=5);
124 }
125
126 module TowerWallSomeEdge(front){
127   minkowski(){
128     difference(){
129       TowerWallCrossSection();
130       translate([front ? 0.10 : -0.10, 0])
131         TowerWallCrossSection();
132     }
133     circle(r=tower_wall_thick, $fn=8);
134   }
135 }
136
137 module TowerBulkCrossSection(){
138   intersection(){
139     TowerWallCrossSection();
140     union(){
141       translate([-led_head_y, led_head_z])
142         circle(r = led_depth);
143       TowerWallSomeEdge(true);
144       translate([-50, -50])
145         square([100, 50]);
146     }
147   }
148 }
149
150 module TowerRearWallCrossSection(){
151   intersection(){
152     TowerWallCrossSection();
153     union(){
154       intersection(){
155         translate([0,-10]) square([100, 10+led_head_z]);
156         TowerWallSomeEdge(false);
157       }
158       TowerBulkCrossSection();
159     }
160   }
161 }
162
163
164 module TowerCrossSectionDemo(){
165   %TowerWallCrossSection();
166   //TowerBulkCrossSection();
167   TowerRearWallCrossSection();
168 }
169
170 module TowerMain(){
171   for (mir=[0,1])
172     mirror([mir,0,0]) rotate([90,0,-90]) {
173       translate([0,0, tower_width/2-tower_wall_thick])
174         linear_extrude(height=tower_wall_thick) {
175         TowerWallCrossSection();
176       }
177       translate([0,0,-1])
178         linear_extrude(height=tower_width/2+0.9)
179         union(){
180           TowerBulkCrossSection();
181           hull(){
182             intersection(){
183               TowerWallCrossSection();
184               translate([-30, -30])
185                 square([30 + 0.1, 30 + tower_frontheight]);
186             }
187           }
188         }
189       translate([0,0, tower_slot_width/2])
190         linear_extrude(height=(tower_width - tower_slot_width)/2 - 0.2)
191         TowerRearWallCrossSection();
192     }
193 }
194
195 module LedHole(){
196   translate([0, led_head_y, led_head_z])
197     rotate([90 + led_angle, 0, 0])
198     translate([0,0,-10])
199     cylinder(r=led_dia/2, h=led_depth+1+10, $fn=26, $fa=10);
200 }
201
202 module TowerProper(){
203   difference(){
204     TowerMain();
205     LedHole();
206     // passages for cable ties
207     translate([0,
208                tower_rearwall_y/2,
209                cableclamp_ctie_z
210                + cableclamp_ctie_width/2 + lidclamp_ctie_thick/2
211                + lidclamp_cableclamp_ctie_between])
212       cube([50, lidclamp_ctie_width, lidclamp_ctie_thick], center=true);
213     translate([0,
214                 (backfront_mate_extra+tower_rearwall_y)/2,
215                 -tower_base_height
216                + max(protrusion_size + protrusion_slop + 0.1,
217                      base_ctie_anchor_eff)])
218       cube([50, base_ctie_width, base_ctie_thick], center=true);
219 //    for (extra_y=[0, -(cableclamp_ctie_thick + cableclamp_ctie_anchor)]) {
220 //      translate([-tower_width/2,
221 //               -cableclamp_ctie_thick/2 - tower_wall_thick + extra_y,
222 //               cableclamp_ctie_z])
223 //      cube([tower_wall_thick+2,
224 //            cableclamp_ctie_thick,
225 //            cableclamp_ctie_width], center=true);
226 //    }
227     for (mir=[0,1])
228      mirror([mir,0,0]) {
229         translate([tower_width/4, 20, cableclamp_ctie_z])
230           cube([cableclamp_ctie_thick,
231                 tower_wall_thick*2+1+40,
232                 cableclamp_ctie_width],
233                center=true);
234       }
235     translate([0, tower_rearwall_y, -tower_base_height])
236       BaseRegistrationProtrusion(protrusion_slop);
237   }
238 }
239
240 module Tower(){ ////toplevel
241   TowerProper();
242   for (mir=[0,1]) {
243     mirror([mir,0,0]){
244       translate([0,
245                  tower_rearwall_y + 0.1,
246                  -1])
247         mirror([0,0,1])
248         multmatrix([[1,0, towerleg_xslope,0],
249                     [0,1,-towerleg_yslope,0],
250                     [0,0,1,0],
251                     [0,0,0,1]])
252         cube([towerleg_width, towerleg_backfront, tower_base_height-2]);
253     }
254   }
255   translate([-towerleg_foot_width/2,
256              tower_rearwall_y - towerleg_foot_gap,
257              -tower_base_height])
258     mirror([0,1,0])
259     cube([towerleg_foot_width, towerleg_foot_backfront, towerleg_foot_height]);
260 }
261
262 module TowerMainHull(){
263   hull(){ TowerMain(); }
264 }
265
266 module Lid(){
267   intersection(){
268     difference(){
269       minkowski(){
270         TowerMainHull();
271         sphere(r=lid_wall_thick+lid_slop, $fn=8);
272       }
273       minkowski(){
274         TowerMainHull();
275         sphere(r=lid_slop, $fn=6);
276       }
277     }
278     translate([-50,-50,led_head_z]) cube([100,100,100]);
279   }
280 }
281
282 module LidT(){ ////toplevel
283   rotate([180,0,0]) Lid();
284 }
285
286 module BaseRegistrationProtrusion(extra){
287   size = protrusion_size + extra;
288   translate([0, base_backfront/2, 0]){
289     hull(){
290       translate([0,0, -0.5])
291         cube([protrusion_size*2, protrusion_frontback, 1.0], center=true);
292       translate([0, 0, protrusion_size-0.5])
293         cube([0.05, protrusion_frontback-protrusion_size*2, 1.0], center=true);
294     }
295   }
296 }
297
298 module Base(){
299   difference(){
300     mirror([0,0,1]){
301       hull(){
302         translate([-tower_width/2, 0, 0])
303           cube([tower_width, base_backfront, 0.1]);
304         translate([-base_width/2, 0, base_height])
305           cube([base_width, base_backfront, crossbar_dia/2]);
306       }
307     }
308     translate([0, base_backfront/2, -base_ctie_anchor_eff])
309       cube([100, base_ctie_width, base_ctie_thick], center=true);
310     translate([0, base_backfront/2, -base_height + tube_ctie_anchor_eff])
311       cube([100, tube_ctie_width, tube_ctie_thick], center=true);
312     translate([0, -1, -(base_height + crossbar_dia/2)])
313       rotate([-90,0,0])
314       cylinder(r=crossbar_dia/2, h=101);
315   }
316   BaseRegistrationProtrusion(0.0);
317 }
318
319 module BaseT(){ ////toplevel
320   rotate([90,0,0]) Base();
321 }
322
323 module Demo(){
324   Tower();
325   %Lid();
326   translate([0,0, 25]) Lid();
327   translate([0, tower_rearwall_y, -(tower_base_height+5)]) Base();
328 }
329
330 //TowerCrossSectionDemo();
331 //TowerWallSomeEdge(false);
332 //TowerWallFrontEdge();
333 //TowerMainHull();
334 //LidT();
335 //Tower();
336 //Lid();
337 //BaseRegistrationProtrusion();
338 //Base();
339 //BaseT();
340 //Demo();