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