From 4c2d7bc73e8b460015b47f5835f09f90e702cd3b Mon Sep 17 00:00:00 2001 From: Jochen Vothknecht <jochen3120@gmail.com> Date: Fri, 18 Mar 2022 08:24:22 +0100 Subject: [PATCH] Integrating the ingenious concept of design parameterization from openscad-meistern.de --- cad/CyanStripe/Case.scad | 18 +++++----- cad/CyanStripe/PCB.scad | 76 ++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/cad/CyanStripe/Case.scad b/cad/CyanStripe/Case.scad index 494fc8e..dfe891a 100644 --- a/cad/CyanStripe/Case.scad +++ b/cad/CyanStripe/Case.scad @@ -13,8 +13,8 @@ $E = 0.001; // ε plexi = 3; // c = case -c_sx = pcb_w() + 0; -c_sy = pcb_h() + 0; +c_sx = PCB("pcb_sx") + 0; +c_sy = PCB("pcb_sy") + 0; c_sz = 20; c_fs = 15; // frontSpace = pcb to upper plexi @@ -22,15 +22,15 @@ c_fs = 15; // frontSpace = pcb to upper plexi module frontPlexiOutline() { /* pcbScrewHoles() - circle(d=M3()*2); */ + circle(d=PCB("M3")*2); */ - txy = sc_left_off()+M3(); + txy = PCB("sc_left_off")+PCB("M3"); - translate([-pcb_w()/2, -pcb_h()/2]) - mixedRoundRect(txy, txy, [0, pcb_edge_r(), 0, M3()]); + translate([-PCB("pcb_sx")/2, -PCB("pcb_sy")/2]) + mixedRoundRect(txy, txy, [0, PCB("pcb_edge_r"), 0, PCB("M3")]); - translate([-pcb_w()/2, pcb_h()/2 - txy]) - mixedRoundRect(txy, txy, [pcb_edge_r(), 0, M3(), 0]); + translate([-PCB("pcb_sx")/2, PCB("pcb_sy")/2 - txy]) + mixedRoundRect(txy, txy, [PCB("pcb_edge_r"), 0, PCB("M3"), 0]); } @@ -54,7 +54,7 @@ if ($preview) { pcb3D(); - translate([0, 0, pcb_t()*3]) + translate([0, 0, PCB("pcb_t")+aj_h()]) frontPlexi(); } else if ($part == "CoverGlass") { diff --git a/cad/CyanStripe/PCB.scad b/cad/CyanStripe/PCB.scad index e7ceab4..09d778b 100644 --- a/cad/CyanStripe/PCB.scad +++ b/cad/CyanStripe/PCB.scad @@ -10,14 +10,40 @@ $E = 0.01; // ε // note: using constant functions here because they get imported via `use` -function pcb_t() = 1.6; +// exporting *everything* as a constant function is bad. +// taking the ingenious concept from `Project 4` of the book from openscad-meistern.de + +pcb_data = [ + + ["pcb_t", 1.6], + ["pcb_sx", 75.5], + ["pcb_sy", 65.0], + + ["pcb_edge_r", 3.0], + + ["M3", 3.2], + + // LED terminal data + ["tled_x", 5.75 + 23], + ["tled_y", [-18.5, 0, 18.5]], + + // co = cut-out + ["co_w", 6.1], + ["co_h", 18.0], + ["co_x", -34.7], + ["co_y", -8.6], + + + ["sc_left_off", 5.0], // left side screw holes offset from edge + + +]; + +function PCB(key) = [ for (d=pcb_data) if (d[0] == key) d[1] ][0]; + -function pcb_w() = 75.5; -function pcb_h() = 65.0; -function pcb_edge_r() = 3; -function M3() = 3.2; // x is all the same and y is +- 18.5 and 0 as there are three of them function terminals_x() = 28.75; @@ -30,18 +56,6 @@ function tpow_y() = 14.50; // function tpow_sy() = 11.50; // function tpow_sz() = 3.00; // TODO: measure!! -tled_y = [18.5, 0, -18.5]; -function tled_x() = 5.75 + 23; -function tled_y(i) = tled_y(i); - -function sc_left_off() = 5.0; // left side screw holes offset from edge - -// co = cut-out -co_w = 6.1; -co_h = 18.0; -co_x = -34.7; -co_y = -8.6; - module pcbScrewHoles(tz=0) { @@ -53,17 +67,17 @@ module pcbScrewHoles(tz=0) { module pcbOutline() { difference() { - roundRect(pcb_w(), pcb_h(), pcb_edge_r(), center=true); + roundRect(PCB("pcb_sx"), PCB("pcb_sy"), PCB("pcb_edge_r"), center=true); - pcbScrewHoles() circle(d=M3()); + pcbScrewHoles() circle(d=PCB("M3")); - translate([co_x, co_y, 0]) square([co_w + $E, co_h], center=true); + translate([PCB("co_x"), PCB("co_y"), 0]) square([PCB("co_w") + $E, PCB("co_h")], center=true); } } -module pcb3D(pcb_t=pcb_t()) { +module pcb3D(pcb_t=PCB("pcb_t")) { FR4() - linear_extrude(pcb_t()) + linear_extrude(PCB("pcb_t")) pcbOutline(); if ($preview) { @@ -71,27 +85,27 @@ module pcb3D(pcb_t=pcb_t()) { pcbScrewHoles() Solder() difference() { - translate([0, 0, -$E]) cylinder(d=M3()*2, h=pcb_t()+2*$E); - translate([0, 0, -$E*2]) cylinder(d=M3()-$E, h=pcb_t()+4*$E); + translate([0, 0, -$E]) cylinder(d=PCB("M3")*2, h=PCB("pcb_t")+2*$E); + translate([0, 0, -$E*2]) cylinder(d=PCB("M3")-$E, h=PCB("pcb_t")+4*$E); } // Solder() -// translate([tpow_x(), tpow_y(), pcb_t() - $E]) +// translate([tpow_x(), tpow_y(), PCB("pcb_t") - $E]) // cube([tpow_sx(), tpow_sy(), tpow_sz()], center=true); -// translate([tpow_x(), tpow_y(), pcb_t() - $E]) +// translate([tpow_x(), tpow_y(), PCB("pcb_t") - $E]) // terminal2(); - translate([tpow_x(), tpow_y(), pcb_t()]) + translate([tpow_x(), tpow_y(), PCB("pcb_t")]) terminal2(); - for (ty=tled_y) - translate([tled_x(), ty, pcb_t()]) + for (ty=PCB("tled_y")) + translate([PCB("tled_x"), ty, PCB("pcb_t")]) rotate([0, 0, 180]) terminal3(); for (ty=[-aj_y(), aj_y()-aj_sy()]) - translate([aj_x(), ty, pcb_t()]) + translate([aj_x(), ty, PCB("pcb_t")]) audioJack(); } @@ -154,7 +168,7 @@ module terminal3() { // aj = audio jack function aj_x() = -12.25; -function aj_y() = pcb_h()/2; +function aj_y() = PCB("pcb_sy")/2; function aj_h() = 5.0; function aj_sx() = 12.4; function aj_sy() = 11.7; -- GitLab