]> mj.ucw.cz Git - home-hw.git/blob - bsb/case/case.scad
FIXME'd
[home-hw.git] / bsb / case / case.scad
1 // x,y is [0,0] at near left PCB screw
2 // z=0 is the bottom of the PCB
3
4 wall_thickness = 1.8;
5 front_panel_thickness = 1.35;
6
7 // Measured between PCB screws
8 pcb_width = 66;         // x
9 pcb_length = 58.4;      // y
10
11 // From screws to PCB edges
12 pcb_left = 5;
13 pcb_right = 5;
14 pcb_front = 5.2;
15 pcb_back = 10;
16 pcb_thickness = 1.5;
17
18 // Interior dimensions relative to z=0
19 box_height = 26;
20 box_depth = 4;
21
22 // Screw dimensions
23 screw_inside_diam = 2.5;
24 screw_outside_diam = 3.2;
25 screw_head_diam = 6;
26 screw_head_height = 1.4;
27 screw_length = 14;              // really 12, but make the hole deeper
28
29 // Screw holders
30 holder_size = 3*2.5;
31
32 // Cable hole
33 cable_x = 9;
34 cable_z = 6.5;
35 cable_diameter = 8;
36
37 // Holes in front panel
38 ref_x = pcb_width + 3.8;
39 led1_x = ref_x - 63;
40 led2_x = ref_x - 45;
41 led3_x = ref_x - 40;
42 led4_x = ref_x - 35;
43 led_z = 6.2;
44 led_diameter = 3.1;
45 usb_left = ref_x - 26;
46 usb_right = ref_x - 17;
47 usb_bottom = 13.5;
48 usb_top = 17.5;
49
50 // Lid
51 lid_smaller = 0.2;
52 lid_left = pcb_left - lid_smaller;
53 lid_right = pcb_right - lid_smaller;
54 lid_front = pcb_front - lid_smaller;
55 lid_back = pcb_back - lid_smaller;
56 lid_thickness = 1.8;
57 text_depth = 0.8;
58
59 over = 0.1;
60 $fn = 50;
61
62 module led_hole() {
63         rotate([-90, 0, 0])
64                 cylinder(h = front_panel_thickness + 2*over, d = led_diameter);
65 }
66
67 module screw_holder() {
68         translate([-holder_size/2, -holder_size/2, -box_depth - over])
69                 cube([holder_size, holder_size, box_depth + over]);
70 }
71
72 module screw_hole() {
73         translate([0, 0, -box_depth - wall_thickness - over])
74                 union() {
75                         cylinder(h = box_depth + wall_thickness + 2*over, d = screw_outside_diam);
76                         cylinder(h = screw_head_height, d1 = screw_head_diam, d2 = screw_outside_diam);
77                 }
78 }
79
80 module bottom_base() {
81         union() {
82                 difference() {
83                         // Exterior
84                         translate([-wall_thickness - pcb_left, -front_panel_thickness - pcb_front, -wall_thickness - box_depth])
85                                 cube([wall_thickness + pcb_left + pcb_width + pcb_right + wall_thickness,
86                                       front_panel_thickness + pcb_front + pcb_length + pcb_back + wall_thickness,
87                                       wall_thickness + box_depth + box_height]);
88
89                         // Interior
90                         translate([-pcb_left, -pcb_front, -box_depth])
91                                 cube([pcb_left + pcb_width + pcb_right, pcb_front + pcb_length + pcb_back, box_depth + box_height + over]);
92
93                         // USB connector hole
94                         translate([usb_left, -front_panel_thickness - pcb_front - over, usb_bottom])
95                                 cube([usb_right - usb_left, front_panel_thickness + 2*over, usb_top - usb_bottom]);
96
97                         // LED holes
98                         translate([led1_x, -pcb_front - front_panel_thickness - over, led_z])
99                                 led_hole();
100                         translate([led2_x, -pcb_front - front_panel_thickness - over, led_z])
101                                 led_hole();
102                         translate([led3_x, -pcb_front - front_panel_thickness - over, led_z])
103                                 led_hole();
104                         translate([led4_x, -pcb_front - front_panel_thickness - over, led_z])
105                                 led_hole();
106
107                         // BSB cable hole
108                         translate([cable_x, pcb_length + pcb_back - over, cable_z])
109                                 rotate([-90, 0, 0])
110                                         cylinder(h = wall_thickness + 2*over, d = cable_diameter);
111                 }
112         }
113 }
114
115 module bottom() {
116         difference() {
117                 union() {
118                         bottom_base();
119
120                         // Screw holder
121                         screw_holder();
122                         translate([pcb_width, 0, 0]) screw_holder();
123                         translate([0, pcb_length, 0]) screw_holder();
124                         translate([pcb_width, pcb_length, 0]) screw_holder();
125                 }
126
127                 // Screw holes
128                 screw_hole();
129                 translate([pcb_width, 0, 0]) screw_hole();
130                 translate([0, pcb_length, 0]) screw_hole();
131                 translate([pcb_width, pcb_length, 0]) screw_hole();
132         }
133 }
134
135 module lid_text(overshoot = 0) {
136         translate([pcb_width / 2, 10, -text_depth/2])
137         rotate(0)
138         scale([0.8, 0.8, 1])
139                 linear_extrude(text_depth + overshoot, center = true)
140                 text("USB – BSB", font = "Liberation Serif", halign="center");
141 }
142
143 module lid_screw_hole() {
144         translate([0, 0, -box_height + pcb_thickness])
145                 difference() {
146                         translate([-holder_size/2, -holder_size/2, 0])
147                                 cube([holder_size, holder_size, box_height - pcb_thickness - lid_thickness + over]);
148                         translate([0, 0, -over])
149                                 cylinder(h = screw_length - pcb_thickness - box_depth - wall_thickness + over, d = screw_inside_diam);
150                 }
151 }
152
153 module lid() {
154         difference() {
155                 union() {
156                         translate([-lid_left, -lid_front, -lid_thickness])
157                                 cube([lid_left + pcb_width + lid_right, lid_front + pcb_length + lid_back, lid_thickness]);
158                         lid_screw_hole();
159                         translate([pcb_width, 0, 0]) lid_screw_hole();
160                         translate([0, pcb_length, 0]) lid_screw_hole();
161                         translate([pcb_width, pcb_length, 0]) lid_screw_hole();
162                 }
163
164                 // Text
165                 lid_text(over);
166         }
167 }
168
169 module pcb() {
170         translate([-pcb_left, -pcb_front, 0])
171                 cube([pcb_left + pcb_width + pcb_right, pcb_front + pcb_length + pcb_back, pcb_thickness]);
172 }
173
174 // bottom();
175 // color([1, 0, 1]) pcb();
176 color([1, 0, 0]) translate([0, 0, box_height]) lid();
177 // color([0, 0, 1]) translate([0, 0, box_height]) lid_text(0);