summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-12-22 20:45:48 +0100
committerxengineering <me@xengineering.eu>2024-01-02 14:24:06 +0100
commit7224aa0c74ae51f49e87e9c18bc94c2761dadf24 (patch)
treec24030d497b17994abccfa81c807c3610e42e703
parentdea6ba3ed5d3878580cc0c1a9e102528ff7bf998 (diff)
downloadsoundbox-7224aa0c74ae51f49e87e9c18bc94c2761dadf24.tar
soundbox-7224aa0c74ae51f49e87e9c18bc94c2761dadf24.tar.zst
soundbox-7224aa0c74ae51f49e87e9c18bc94c2761dadf24.zip
mech: Add initial state
This code used to be developed outside a Git repository. It is moved here to support the development workflow by frequent commits.
-rw-r--r--mech/Makefile19
-rw-r--r--mech/assembly.scad13
-rw-r--r--mech/back.scad7
-rw-r--r--mech/bottom.scad16
-rw-r--r--mech/common.scad16
-rw-r--r--mech/front.scad7
-rw-r--r--mech/pcb_case.scad112
-rw-r--r--mech/top.scad9
8 files changed, 199 insertions, 0 deletions
diff --git a/mech/Makefile b/mech/Makefile
new file mode 100644
index 0000000..1f80d35
--- /dev/null
+++ b/mech/Makefile
@@ -0,0 +1,19 @@
+PARTS := bottom top back front
+BUILD_DIR := ./build
+STL := $(PARTS:%=$(BUILD_DIR)/%.stl)
+GCODE := $(PARTS:%=$(BUILD_DIR)/%.gcode)
+
+.PHONY: all
+all: $(GCODE)
+
+$(BUILD_DIR)/%.gcode: $(BUILD_DIR)/%.stl
+ mkdir -p $(dir $@)
+ prusa-slicer --output $@ --export-gcode $<
+
+$(BUILD_DIR)/%.stl: %.scad
+ mkdir -p $(dir $@)
+ openscad --export-format binstl -o $@ $<
+
+.PHONY: clean
+clean:
+ rm -rf $(BUILD_DIR)
diff --git a/mech/assembly.scad b/mech/assembly.scad
new file mode 100644
index 0000000..3df96c8
--- /dev/null
+++ b/mech/assembly.scad
@@ -0,0 +1,13 @@
+use <bottom.scad>
+use <top.scad>
+use <back.scad>
+use <front.scad>
+
+module assembly() {
+ bottom();
+// top();
+ back();
+// front();
+}
+
+assembly();
diff --git a/mech/back.scad b/mech/back.scad
new file mode 100644
index 0000000..16f6c2e
--- /dev/null
+++ b/mech/back.scad
@@ -0,0 +1,7 @@
+include <common.scad>
+
+module back() {
+ pcb_case_panel_back(dim, t);
+}
+
+rotate([0,90,0]) back();
diff --git a/mech/bottom.scad b/mech/bottom.scad
new file mode 100644
index 0000000..cac355e
--- /dev/null
+++ b/mech/bottom.scad
@@ -0,0 +1,16 @@
+include <common.scad>
+
+module bottom() {
+ union () {
+ pcb_case_shell_bottom(
+ dim, t, h, [
+ base_socket,
+ base_socket + dx,
+ base_socket + dy,
+ base_socket + dx + dy
+ ]
+ );
+ }
+}
+
+bottom();
diff --git a/mech/common.scad b/mech/common.scad
new file mode 100644
index 0000000..c433447
--- /dev/null
+++ b/mech/common.scad
@@ -0,0 +1,16 @@
+use <pcb_case.scad>
+
+$fa = 12; // default is 12
+$fs = 0.5; // default is 2
+
+t = 2;
+tol = 1;
+base_socket = [3/2+2.3+2*t+tol,3/2+2.1+2.7+t+tol];
+dx = [28.9,0];
+dy = [0,58.1];
+dim = [
+ base_socket[0] + dx[0] + 3/2 + 4 + 2*t + tol,
+ base_socket[1] + dy[1] + 3/2 + 2 + 0.9 + 6 + t + tol,
+ 39 // TODO
+];
+h = 10; // TODO
diff --git a/mech/front.scad b/mech/front.scad
new file mode 100644
index 0000000..e35c146
--- /dev/null
+++ b/mech/front.scad
@@ -0,0 +1,7 @@
+include <common.scad>
+
+module front() {
+ pcb_case_panel_front(dim, t);
+}
+
+rotate([0,90,0]) front();
diff --git a/mech/pcb_case.scad b/mech/pcb_case.scad
new file mode 100644
index 0000000..bbfe9bc
--- /dev/null
+++ b/mech/pcb_case.scad
@@ -0,0 +1,112 @@
+// A generic parametric PCB case
+
+nut_h = 3;
+nut_d = 4.15;
+nut_r = nut_d / 2;
+bolt_d = 3;
+bolt_r = bolt_d / 2;
+
+module rounded_cube(dim, radius) {
+ range_y = [radius, dim[1]-radius];
+ range_z = [radius, dim[2]-radius];
+ height = dim[0];
+
+ hull() {
+ for (y=range_y, z=range_z) {
+ translate([0,y,z]) rotate([0,90,0]) cylinder(r=radius, h=height);
+ }
+ }
+}
+
+module shell_base(dim, t) {
+ radius = t;
+ difference() {
+ rounded_cube(dim, radius);
+ translate([0,0,dim[2]/2])
+ cube([dim[0], dim[1], dim[2]/2]);
+ translate([3*t, t, t])
+ rounded_cube([dim[0]-6*t, dim[1]-2*t, dim[2]-2*t], radius);
+ translate([0, 2*t, 2*t])
+ rounded_cube([dim[0], dim[1]-4*t, dim[2]-4*t], radius);
+ for (x_off = [t, dim[0]-2*t]) {
+ translate([x_off, t, t])
+ rounded_cube([t, dim[1]-2*t, dim[2]-2*t], radius);
+ }
+ for (x = [dim[0]/4, dim[0]-dim[0]/4]) {
+ translate([x,0,dim[2]/2-1.5*bolt_d])
+ rotate([-90,0,0])
+ cylinder(r=bolt_r, h=1.1*t);
+ }
+ }
+}
+
+module shell_connector(dim, t) {
+ size_x = dim[0]-6*t;
+ size_y = 2*nut_h;
+ size_z = dim[2]/2+3*bolt_d;
+
+ difference () {
+ // base body
+ translate([3*t,dim[1]-t-size_y,0])
+ cube([size_x,size_y,size_z]);
+
+ // bolt holes
+ for (x = [dim[0]/4, dim[0]-dim[0]/4]) {
+ translate([x,dim[1]-t,dim[2]/2+1.5*bolt_d])
+ rotate([90,0,0])
+ cylinder(r=bolt_r, h=size_y);
+ }
+
+ // nut holes
+ for (x = [dim[0]/4, dim[0]-dim[0]/4]) {
+ translate([x,dim[1]-t-size_y,dim[2]/2+1.5*bolt_d])
+ rotate([-90,0,0])
+ cylinder(r=nut_r, h=nut_h);
+ }
+ }
+
+ echo(min_shell_bolt_length=t+size_y);
+}
+
+module pcb_case_shell(dim, t, h, sockets) {
+ difference () {
+ union() {
+ shell_base(dim, t);
+ shell_connector(dim, t);
+ for (socket = [0:len(sockets)-1]) {
+ translate([sockets[socket][0], sockets[socket][1], 0])
+ cylinder(d=nut_d+2, h=h);
+ }
+ }
+ for (socket = [0:len(sockets)-1]) {
+ translate([sockets[socket][0], sockets[socket][1], 0]) {
+ cylinder(d=bolt_d, h=h);
+ cylinder(d=0.9*nut_d, h=nut_h);
+ }
+ }
+ }
+}
+
+module pcb_case_shell_bottom(dim, t, h, sockets) {
+ pcb_case_shell(dim, t, h, sockets);
+}
+
+module pcb_case_shell_top(dim, t) {
+ translate([0,dim[1],dim[2]])
+ rotate([180,0,0])
+ pcb_case_shell(dim, t, 0, []);
+}
+
+module pcb_case_panel(dim, t) {
+ rounded_cube([t,dim[1]-2*t,dim[2]-2*t], t);
+}
+
+module pcb_case_panel_back(dim, t) {
+ translate([t,t,t])
+ pcb_case_panel(dim, t);
+}
+
+module pcb_case_panel_front(dim, t) {
+ translate([dim[0]-2*t,t,t])
+ pcb_case_panel(dim, t);
+}
diff --git a/mech/top.scad b/mech/top.scad
new file mode 100644
index 0000000..55882f0
--- /dev/null
+++ b/mech/top.scad
@@ -0,0 +1,9 @@
+include <common.scad>
+
+module top() {
+ difference() {
+ pcb_case_shell_top(dim, t);
+ }
+}
+
+rotate([180,0,0]) top();