chiark / gitweb /
ab337051d97a474f6fb64694d8e7351003425e2d
[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_z = 70;
7 led_angle = -60;
8
9 vert_space_inside = 8;
10 backfront_space_inside = 12;
11
12 backfront_mate_size = 25;
13 tower_frontheight = 20;
14 tower_width = 18;
15 tower_slot_width = 3;
16
17 cableclamp_ctie_width = 3 + 0.5;
18 cableclamp_ctie_thick = 2 + 0.5;
19
20 lidclamp_ctie_width = 3 + 0.5;
21 lidclamp_ctie_thick = 2 + 0.5;
22
23 base_ctie_width = 4 + 0.5;
24 base_ctie_thick = 2 + 0.5;
25
26 // tuning
27
28 tower_over_angle = 45;
29 tower_wall_thick = 1.6;
30 tower_base_height = 10;
31 tower_forehead_angle = 30;
32 lid_wall_thick = 1.6;
33 lid_slop = 0.75;
34
35 //--- tests ---
36
37 test_width = 24;
38 test_height = 24;
39
40 test_thicks = [9,14,21];
41
42 module Tests(){ ////toplevel
43   for (thicki=[0:len(test_thicks)-1]) {
44     translate([thicki*test_width-0.5, 0, 0]) {
45       difference(){
46         cube([test_width,
47               test_thicks[thicki] + led_depth,
48               test_height]);
49         translate([test_width/2, -1, test_height/2])
50           rotate([-90,0,0])
51           cylinder(r=led_dia/2, h=led_depth+1, $fn=30);
52       }
53     }
54   }
55 }
56
57 //Tests();
58
59 //--- real thing ---
60
61 tower_overhang = led_dia * 2.5;
62
63 tower_over_max_y = tower_overhang * sin(tower_over_angle);
64 tower_over_max_z = tower_frontheight + tower_overhang * cos(tower_over_angle);
65 tower_total_max_z = tower_over_max_z + vert_space_inside + led_depth;
66 tower_rearwall_y = -(backfront_space_inside + tower_wall_thick);
67 led_head_y = tower_over_max_y/2;
68 led_head_z = tower_frontheight + tower_overhang*sin(tower_over_angle)/2;
69 backfront_mate_extra = (backfront_mate_size - (-tower_rearwall_y));
70
71 module TowerWallCrossSection(){
72   // generates a 2D shape - a polygon
73   // x is what is going to be -y
74   // y is what is going to be z
75   polygon([[0,                  0],
76            [0,                  tower_frontheight],
77            [-tower_over_max_y,  tower_over_max_z],
78            [-tower_over_max_y
79             + tan(tower_forehead_angle) * (vert_space_inside + led_depth),
80             tower_total_max_z],
81            [-tower_rearwall_y,  tower_total_max_z],
82            [-tower_rearwall_y,  0],
83            [-tower_rearwall_y, -tower_base_height],
84            [-backfront_mate_extra, -tower_base_height]],
85           convexity=5);
86 }
87
88 module TowerWallSomeEdge(front){
89   minkowski(){
90     difference(){
91       TowerWallCrossSection();
92       translate([front ? 0.10 : -0.10, 0])
93         TowerWallCrossSection();
94     }
95     circle(r=tower_wall_thick, $fn=8);
96   }
97 }
98
99 module TowerBulkCrossSection(){
100   intersection(){
101     TowerWallCrossSection();
102     union(){
103       translate([-led_head_y, led_head_z])
104         circle(r = led_depth);
105       TowerWallSomeEdge(true);
106       translate([-50, -50])
107         square([100, 50]);
108     }
109   }
110 }
111
112 module TowerRearWallCrossSection(){
113   intersection(){
114     TowerWallCrossSection();
115     union(){
116       intersection(){
117         translate([0,-10]) square([100, 10+led_head_z]);
118         TowerWallSomeEdge(false);
119       }
120       TowerBulkCrossSection();
121     }
122   }
123 }
124
125
126 module TowerCrossSectionDemo(){
127   %TowerWallCrossSection();
128   //TowerBulkCrossSection();
129   TowerRearWallCrossSection();
130 }
131
132 module TowerMain(){
133   for (mir=[0,1])
134     mirror([mir,0,0]) rotate([90,0,-90]) {
135       translate([0,0, tower_width/2-tower_wall_thick])
136         linear_extrude(height=tower_wall_thick) {
137         TowerWallCrossSection();
138       }
139       translate([0,0,-1])
140         linear_extrude(height=tower_width/2+0.9)
141         union(){
142           TowerBulkCrossSection();
143           hull(){
144             intersection(){
145               TowerWallCrossSection();
146               translate([-30, -30])
147                 square([30 + 0.1, 30 + tower_frontheight]);
148             }
149           }
150         }
151       translate([0,0, tower_slot_width/2])
152         linear_extrude(height=(tower_width - tower_slot_width)/2 - 0.2)
153         TowerRearWallCrossSection();
154     }
155 }
156
157 module LedHole(){
158   translate([0, led_head_y, led_head_z])
159     rotate([90 + led_angle])
160     translate([0,0,-10])
161     cylinder(r=led_dia/2, h=led_depth+0.1+10, $fn=30);
162 }
163
164 module Tower(){ ////toplevel
165   difference(){
166     TowerMain();
167     LedHole();
168     // passages for cable ties
169     translate([0,
170                tower_rearwall_y/2,
171                tower_frontheight/2
172                + cableclamp_ctie_width/2 + lidclamp_ctie_thick/2])
173       cube([50, lidclamp_ctie_width, lidclamp_ctie_thick], center=true);
174     translate([0,
175                 (backfront_mate_extra+tower_rearwall_y)/2,
176                 -tower_base_height/2])
177       cube([50, base_ctie_width, base_ctie_thick], center=true);
178     for (mir=[0,1])
179       mirror([mir,0,0]) {
180         translate([tower_width/4, 20, tower_frontheight/2])
181           cube([cableclamp_ctie_thick,
182                 tower_wall_thick*2+1+40,
183                 cableclamp_ctie_width],
184                center=true);
185       }
186   }
187 }
188
189 module TowerMainHull(){
190   hull(){ TowerMain(); }
191 }
192
193 module Lid(){
194   intersection(){
195     difference(){
196       minkowski(){
197         TowerMainHull();
198         sphere(r=lid_wall_thick+lid_slop, $fn=4);
199       }
200       minkowski(){
201         TowerMainHull();
202         sphere(r=lid_slop, $fn=4);
203       }
204     }
205     translate([-50,-50,led_head_z]) cube([100,100,100]);
206   }
207 }
208
209 module LidT(){ ////toplevel
210   rotate([180,0,0]) Lid();
211 }
212
213 module Demo(){
214   Tower();
215   translate([0,0, 25]) Lid();
216 }
217
218 //TowerCrossSectionDemo();
219 //TowerWallSomeEdge(false);
220 //TowerWallFrontEdge();
221 //TowerMainHull();
222 //LidT();
223 //Tower();
224 //Lid();
225 Demo();