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