chiark / gitweb /
533519efc0ecaf9c0a8972554d91aeff86d1e64b
[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 // tuning
18
19 tower_over_angle = 45;
20 tower_wall_thick = 1.6;
21 tower_base_height = 10;
22 tower_forehead_angle = 30;
23
24 //--- tests ---
25
26 test_width = 24;
27 test_height = 24;
28
29 test_thicks = [9,14,21];
30
31 module Tests(){ ////toplevel
32   for (thicki=[0:len(test_thicks)-1]) {
33     translate([thicki*test_width-0.5, 0, 0]) {
34       difference(){
35         cube([test_width,
36               test_thicks[thicki] + led_depth,
37               test_height]);
38         translate([test_width/2, -1, test_height/2])
39           rotate([-90,0,0])
40           cylinder(r=led_dia/2, h=led_depth+1, $fn=30);
41       }
42     }
43   }
44 }
45
46 //Tests();
47
48 //--- real thing ---
49
50 tower_overhang = led_dia * 2.5;
51
52 tower_over_max_y = tower_overhang * sin(tower_over_angle);
53 tower_over_max_z = tower_frontheight + tower_overhang * cos(tower_over_angle);
54 tower_total_max_z = tower_over_max_z + vert_space_inside + led_depth;
55 tower_rearwall_y = -(backfront_space_inside + tower_wall_thick);
56 led_head_y = tower_over_max_y/2;
57 led_head_z = tower_frontheight + tower_overhang*sin(tower_over_angle)/2;
58 backfront_mate_extra = (backfront_mate_size - (-tower_rearwall_y));
59
60 module TowerWallCrossSection(){
61   // generates a 2D shape - a polygon
62   // x is what is going to be -y
63   // y is what is going to be z
64   polygon([[0,                  0],
65            [0,                  tower_frontheight],
66            [-tower_over_max_y,  tower_over_max_z],
67            [-tower_over_max_y
68             + tan(tower_forehead_angle) * (vert_space_inside + led_depth),
69             tower_total_max_z],
70            [-tower_rearwall_y,  tower_total_max_z],
71            [-tower_rearwall_y,  0],
72            [-tower_rearwall_y, -tower_base_height],
73            [-backfront_mate_extra, -tower_base_height]],
74           convexity=5);
75 }
76
77 module TowerWallSomeEdge(front){
78   minkowski(){
79     difference(){
80       TowerWallCrossSection();
81       translate([front ? 0.10 : -0.10, 0])
82         TowerWallCrossSection();
83     }
84     circle(r=tower_wall_thick, $fn=8);
85   }
86 }
87
88 module TowerBulkCrossSection(){
89   intersection(){
90     TowerWallCrossSection();
91     union(){
92       translate([-led_head_y, led_head_z])
93         circle(r = led_depth);
94       TowerWallSomeEdge(true);
95       translate([-50, -50])
96         square([100, 50]);
97     }
98   }
99 }
100
101 module TowerRearWallCrossSection(){
102   intersection(){
103     TowerWallCrossSection();
104     union(){
105       intersection(){
106         translate([0,-10]) square([100, 10+led_head_z]);
107         TowerWallSomeEdge(false);
108       }
109       TowerBulkCrossSection();
110     }
111   }
112 }
113
114
115 module TowerCrossSectionDemo(){
116   %TowerWallCrossSection();
117   //TowerBulkCrossSection();
118   TowerRearWallCrossSection();
119 }
120
121 module TowerMain(){
122   for (mir=[0,1])
123     mirror([mir,0,0]) rotate([90,0,-90]) {
124       translate([0,0, tower_width/2-tower_wall_thick])
125         linear_extrude(height=tower_wall_thick)
126         TowerWallCrossSection();
127       translate([0,0,-1])
128         linear_extrude(height=tower_width/2+0.9)
129         TowerBulkCrossSection();
130       translate([0,0, tower_slot_width/2])
131         linear_extrude(height=(tower_width - tower_slot_width)/2 - 0.2)
132         TowerRearWallCrossSection();
133     }
134 }
135
136 module LedHole(){
137   translate([0, led_head_y, led_head_z])
138     rotate([90 + led_angle])
139     translate([0,0,-10])
140     cylinder(r=led_dia/2, h=led_depth+0.1+10, $fn=30);
141 }
142
143 module Tower(){
144   difference(){
145     TowerMain();
146     LedHole();
147   }
148 }
149
150 //TowerCrossSectionDemo();
151 //TowerWallSomeEdge(false);
152 //TowerWallFrontEdge();
153 Tower();