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