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