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

Contents of /branches/qtcharts/portedbox_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: 3773 byte(s)
Fixup openSCAD templates.

1 loudspeaker_number = __NUMBER__;
2 margin = __MARGIN__; /* cm */
3 loudspeaker_diameter = __DIAMETER__; /* cm */
4 internal_ported_box_volume = __PORTEDBOXVOLUME__; /* dmĀ³ (Liter) */
5 ported_box_port_number = __PORTEDBOXPORTNUMBER__;
6 ported_box_port_slot_activated = __PORTEDBOXPORTSLOTACTIVATED__;
7 ported_box_port_slot_width = __PORTEDBOXPORTSLOTWIDTH__;
8 ported_box_port_slot_height = __PORTEDBOXPORTSLOTHEIGHT__;
9 ported_box_port_diameter = __PORTEDBOXPORTDIAMETER__;
10 ported_box_port_length = __PORTEDBOXPORTLENGTH__;
11
12 internal_ported_box_width = loudspeaker_diameter + margin; /* cm (x)*/
13 internal_ported_box_height = max((ported_box_port_diameter + margin) + ((loudspeaker_diameter + margin) * loudspeaker_number), 1.618 * internal_ported_box_width); /* cm (z)*/
14 internal_ported_box_depth = internal_ported_box_volume * 1000 / (internal_ported_box_width * internal_ported_box_height); /* cm (y)*/
15
16 saw_thick = __SAWTHICK__; /* saw cut thick in cm */
17 wood_thick = __WOODTHICK__; /* board thick in cm */
18
19 vertical_center = (internal_ported_box_height + (2 * wood_thick)) / 2;
20 horizontal_center = (internal_ported_box_width + (2 * wood_thick)) / 2;
21
22 module board(width, height) {
23 square(size = [width, height], center = false);
24 }
25
26 module speaker(diam, x, y){
27 translate([x, y, 0])
28 circle($fn=360, d=diam, true);
29 }
30
31 module port(diam, slot, width, height, x, y)
32 {
33 if (slot == true) {
34 translate([x, y, 0]) {
35 square(size = [width, height], center = false);
36 }
37 } else {
38 translate([x, y, 0]) {
39 circle($fn=360, d=diam, true);
40 }
41 }
42 }
43
44 module board_speaker_port(width, height, diam){
45 difference() {
46 board(width, height);
47
48 /* calculate ports distribition */
49 port_placing = (internal_ported_box_width + (2 * wood_thick)) / (ported_box_port_number + 1);
50 for (i = [1:ported_box_port_number]) {
51 if (ported_box_port_slot_activated == false) {
52 /* circular ports, center is used */
53 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);
54 } else {
55 /* slot ports, left corner is used */
56 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);
57 }
58 }
59
60 for (i = [0:loudspeaker_number-1]) {
61 if (ported_box_port_slot_activated == false) {
62 speaker(diam, width / 2, margin + (diam / 2) + (ported_box_port_diameter + margin) + i * (diam + margin));
63 }
64 }
65 }
66 }
67
68 /* boards */
69 front_width = internal_ported_box_width + (2 * wood_thick); /* cm */
70 front_height = internal_ported_box_height + (2 * wood_thick); /* cm */
71 side_depth = internal_ported_box_depth; /* cm */
72 side_height = internal_ported_box_height; /* cm */
73 top_width = front_width; /* cm */
74 top_depth = side_depth; /* cm */
75
76 /* two times */
77 for (i = [0:1]) {
78 translate([0, i*(max(front_height,front_width,side_depth,side_height) + saw_thick), 0]) {
79 /* one board with speaker */
80 translate([0, 0, 0])
81 board_speaker_port(front_width, front_height, loudspeaker_diameter);
82
83 /* one back board */
84 translate([1 * (front_width + saw_thick), 0, 0])
85 board(front_width, front_height);
86
87 /* two side boards */
88 for (j = [0:1]) {
89 translate([2 * (front_width + saw_thick) + j * (side_depth + saw_thick), 0, 0])
90 board(side_depth, side_height);
91 }
92
93 /* two top/bottom boards */
94 for (j = [0:1]) {
95 translate([j * (top_width + saw_thick) + (2 * (side_depth + saw_thick)) + (2 * (front_width + saw_thick)), 0, 0])
96 board(top_width, top_depth);
97 }
98 }
99 }

  ViewVC Help
Powered by ViewVC 1.1.26