/[qspeakers]/branches/qtcharts/bandpassbox_cutting_template.scad
ViewVC logotype

Contents of /branches/qtcharts/bandpassbox_cutting_template.scad

Parent Directory Parent Directory | Revision Log Revision Log


Revision 298 - (show annotations)
Wed Nov 25 13:12:53 2020 UTC (6 months, 2 weeks ago) by ben
File size: 5201 byte(s)
Fixup openSCAD templates.

1 /* loudspeaker __MODEL__ */
2 loudspeaker_number = __NUMBER__;
3 margin = __MARGIN__; /* cm */
4 loudspeaker_diameter = __DIAMETER__; /* cm */
5 internal_closed_box_volume = __SEALEDBOXVOLUME__; /* dm³ (Liter) */
6
7 internal_closed_box_width = loudspeaker_diameter + margin; /* cm (x)*/
8 internal_closed_box_height = max((loudspeaker_diameter + margin) * loudspeaker_number, 1.618 * internal_closed_box_width); /* cm (z)*/
9 internal_closed_box_depth = internal_closed_box_volume * 1000 / (internal_closed_box_width * internal_closed_box_height); /* cm (y)*/
10
11 saw_thick = __SAWTHICK__; /* saw cut thick in cm */
12 wood_thick = __WOODTHICK__; /* board thick in cm */
13
14 vertical_center = (internal_closed_box_height + (2 * wood_thick)) / 2;
15 horizontal_center = (internal_closed_box_width + (2 * wood_thick)) / 2;
16
17 module board(width, height) {
18 square(size = [width, height], center = false);
19 }
20
21 module speaker(diam, x, y){
22 translate([x, y, 0])
23 circle($fn=360, d=diam, true);
24 }
25
26 module board_speaker(width, height, diam){
27 difference() {
28 board(width, height);
29 for (i = [0:loudspeaker_number-1]) {
30 speaker(diam, width / 2, margin + (diam / 2) + i * (diam + margin));
31 }
32 }
33 }
34
35 /* boards */
36 front_width = internal_closed_box_width + (2 * wood_thick); /* cm */
37 front_height = internal_closed_box_height + (2 * wood_thick); /* cm */
38 side_depth = internal_closed_box_depth; /* cm */
39 side_height = internal_closed_box_height; /* cm */
40 top_width = front_width; /* cm */
41 top_depth = side_depth; /* cm */
42
43 /* two times */
44 for (i = [0:1]) {
45 translate([0, i*(max(front_height,front_width,side_depth,side_height) + saw_thick), 0]) {
46 /* one board with speaker */
47 translate([0, 0, 0])
48 board_speaker(front_width, front_height, loudspeaker_diameter);
49
50 /* one back board */
51 translate([1 * (front_width + saw_thick), 0, 0])
52 board(front_width, front_height);
53
54 /* two side boards */
55 for (j = [0:1]) {
56 translate([2 * (front_width + saw_thick) + j * (side_depth + saw_thick), 0, 0])
57 board(side_depth, side_height);
58 }
59
60 /* two top/bottom boards */
61 for (j = [0:1]) {
62 translate([j * (top_width + saw_thick) + (2 * (side_depth + saw_thick)) + (2 * (front_width + saw_thick)), 0, 0])
63 board(top_width, top_depth);
64 }
65 }
66 }
67
68 internal_ported_box_volume = __PORTEDBOXVOLUME__; /* dm³ (Liter) */
69 ported_box_port_number = __PORTEDBOXPORTNUMBER__;
70 ported_box_port_slot_activated = __PORTEDBOXPORTSLOTACTIVATED__;
71 ported_box_port_slot_width = __PORTEDBOXPORTSLOTWIDTH__;
72 ported_box_port_slot_height = __PORTEDBOXPORTSLOTHEIGHT__;
73 ported_box_port_diameter = __PORTEDBOXPORTDIAMETER__;
74 ported_box_port_length = __PORTEDBOXPORTLENGTH__;
75
76 internal_ported_box_width = internal_closed_box_width; /* cm (x)*/
77 internal_ported_box_height = internal_closed_box_height; /* cm (z) */
78 internal_ported_box_depth = internal_ported_box_volume * 1000 / (internal_ported_box_width * internal_ported_box_height); /* cm (y)*/
79
80 module port(diam, slot, width, height, x, y)
81 {
82 if (slot == true) {
83 translate([x, y, 0]) {
84 square(size = [width, height], center = false);
85 }
86 } else {
87 translate([x, y, 0]) {
88 circle($fn=360, d=diam, true);
89 }
90 }
91 }
92
93 module board_port(width, height, diam){
94 difference() {
95 board(width, height);
96
97 /* calculate ports distribition */
98 port_placing = (internal_ported_box_width + (2 * wood_thick)) / (ported_box_port_number + 1);
99 for (i = [1:ported_box_port_number]) {
100 if (ported_box_port_slot_activated == false) {
101 /* circular ports, center is used */
102 port(ported_box_port_diameter, ported_box_port_slot_activated, ported_box_port_slot_width, ported_box_port_slot_height, i * port_placing, wood_thick + margin + ported_box_port_diameter / 2);
103 } else {
104 /* slot ports, left corner is used */
105 port(ported_box_port_diameter, ported_box_port_slot_activated, ported_box_port_slot_width, ported_box_port_slot_height, (i * port_placing) - (ported_box_port_slot_width / 2),wood_thick);
106 }
107 }
108 }
109 }
110
111 /* boards */
112 ported_front_width = front_width; /* cm */
113 ported_front_height = front_height; /* cm */
114 ported_side_depth = internal_ported_box_depth; /* cm */
115 ported_side_height = internal_ported_box_height; /* cm */
116 ported_top_width = front_width; /* cm */
117 ported_top_depth = ported_side_depth; /* cm */
118
119 /* two times */
120 if (true) {
121 for (i = [2:3]) {
122 translate([0, i*(max(front_height,front_width,side_depth,side_height) + saw_thick), 0]) {
123 /* one board with port */
124 translate([0, 0, 0])
125 board_port(ported_front_width, ported_front_height, ported_box_port_diameter);
126
127 /* two side boards */
128 for (j = [0:1]) {
129 translate([2 * (front_width + saw_thick) + j * (side_depth + saw_thick), 0, 0])
130 board(ported_side_depth, ported_side_height);
131 }
132
133 /* two top/bottom boards */
134 for (j = [0:1]) {
135 translate([j * (top_width + saw_thick) + (2 * (side_depth + saw_thick)) + (2 * (front_width + saw_thick)), 0, 0])
136 board(ported_top_width, ported_top_depth);
137 }
138 }
139 }
140 }

  ViewVC Help
Powered by ViewVC 1.1.26