mirror of
https://github.com/DJSundog/NopSCADlib.git
synced 2024-11-23 15:23:51 -05:00
Merge branch 'pcb_additions' of https://github.com/martinbudden/NopSCADlib into martinbudden-pcb_additions
This commit is contained in:
commit
171c9a6a34
110
tests/pcb.scad
Normal file
110
tests/pcb.scad
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
//
|
||||||
|
// NopSCADlib Copyright Chris Palmer 2018
|
||||||
|
// nop.head@gmail.com
|
||||||
|
// hydraraptor.blogspot.com
|
||||||
|
//
|
||||||
|
// This file is part of NopSCADlib.
|
||||||
|
//
|
||||||
|
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
// GNU General Public License as published by the Free Software Foundation, either version 3 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
// See the GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with NopSCADlib.
|
||||||
|
// If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
include <../core.scad>
|
||||||
|
|
||||||
|
use <../vitamins/pcb.scad>
|
||||||
|
include <../vitamins/microswitches.scad>
|
||||||
|
include <../vitamins/d_connectors.scad>
|
||||||
|
|
||||||
|
gt_5x17 = ["gt_5x17", 5, 10, 17, 5, 11, 0.4, 9, 2,1.5, 1, 3, 6, 0, 0, 0];
|
||||||
|
gt_5x11 = ["gt_5x11", 5, 8, 11, 5, 7, 0.4, 7, 1.5,1.5, 1,2.5, 6, 0, 0, 0];
|
||||||
|
|
||||||
|
TMC2130HeatSinkColor = "DeepSkyBlue";
|
||||||
|
TMC2130 = ["TMC2130", "TMC2130",
|
||||||
|
20, 14, 1.6, 0, 3, 0, "white", false, [],
|
||||||
|
[
|
||||||
|
[ 10, 1, 0, "-2p54header", 8, 1 ,undef, "blue" ],
|
||||||
|
[ 10, 13, 0, "-2p54header", 8, 1],
|
||||||
|
[ 12, 7, 0, "-chip", 6, 4, 1, grey20 ],
|
||||||
|
// mock up a heat sink
|
||||||
|
[ 10, 7, 0, "block", 9, 9, 2, TMC2130HeatSinkColor ],
|
||||||
|
[ 10, 11, 0, "block", 9, 1, 11, TMC2130HeatSinkColor ],
|
||||||
|
[ 10, 9, 0, "block", 9, 1, 11, TMC2130HeatSinkColor ],
|
||||||
|
[ 10, 7, 0, "block", 9, 1, 11, TMC2130HeatSinkColor ],
|
||||||
|
[ 10, 5, 0, "block", 9, 1, 11, TMC2130HeatSinkColor ],
|
||||||
|
[ 10, 3, 0, "block", 9, 1, 11, TMC2130HeatSinkColor ],
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
];
|
||||||
|
|
||||||
|
test_pcb = ["TestPCB", "Test PCB",
|
||||||
|
50, 500, 1.6, // length, width, thickness
|
||||||
|
3, // Corner radius
|
||||||
|
2.75, // Mounting hole diameter
|
||||||
|
6, // Pad around mounting hole
|
||||||
|
"green",// Color
|
||||||
|
false, // True if the parts should be separate BOM items
|
||||||
|
// hole offsets
|
||||||
|
[ [3, 3], [3, -3], [-3, 3], [-3, -3] ],
|
||||||
|
// components
|
||||||
|
[
|
||||||
|
[ 10, 10, 0, "2p54header", 4, 1],
|
||||||
|
[ 25, 10, 0, "2p54header", 5, 1, undef, "blue" ],
|
||||||
|
[ 10, 20, 0, "2p54boxhdr", 4, 2],
|
||||||
|
[ 10, 30, 0, "2p54socket", 6, 1],
|
||||||
|
[ 25, 30, 0, "2p54socket", 4, 1, undef, undef, undef, "red" ],
|
||||||
|
[ 10, 40, 0, "chip", 10, 5, 1, grey20],
|
||||||
|
[ 10, 60, 180, "rj45"],
|
||||||
|
[ 8, 80, 180, "usb_A"],
|
||||||
|
[ 8, 100, 180, "usb_Ax2"],
|
||||||
|
[ 3, 120, 180, "usb_uA"],
|
||||||
|
[ 8, 140, 180, "usb_B"],
|
||||||
|
[ 10, 160, 0, "buzzer"],
|
||||||
|
[ 25, 160, 0, "buzzer", 4.5, 8.5],
|
||||||
|
[ 10, 175, 0, "potentiometer"],
|
||||||
|
[ 30, 175, 0, "potentiometer", 7, 8],
|
||||||
|
[ 8, 190, 180, "jack"],
|
||||||
|
[ 6, 200, 180, "barrel_jack"],
|
||||||
|
[ 5, 220, 180, "hdmi"],
|
||||||
|
[ 3, 240, 180, "mini_hdmi"],
|
||||||
|
[ 10, 250, 0, "flex"],
|
||||||
|
[ 10, 265, 0, "flat_flex"],
|
||||||
|
[ 10, 280, 0, "D_plug", DCONN9],
|
||||||
|
[ 10, 300, 0, "molex_hdr", 2],
|
||||||
|
[ 10, 310, 0, "jst_xh", 2],
|
||||||
|
[ 10, 320, 180, "term254", 3],
|
||||||
|
[ 20, 320, 180, "term254", 3, undef, grey20],
|
||||||
|
[ 10, 340, 180, "gterm35", 4, [1,2]],
|
||||||
|
[ 20, 340, 180, "gterm35", 4, [1,2], "red"],
|
||||||
|
[ 30, 340, 180, "gterm", gt_5x11, 3],
|
||||||
|
[ 10, 360, 180, "gterm635", 2],
|
||||||
|
[ 25, 360, 180, "gterm635", 2, undef, "blue"],
|
||||||
|
[ 40, 360, 180, "gterm", gt_5x17, 2, undef, grey20],
|
||||||
|
[ 40, 340, 180, "gterm", gt_5x17, 3, [1], "red"],
|
||||||
|
[ 10, 380, 180, "term35", 4],
|
||||||
|
[ 20, 380, 180, "term35", 3, "lime"],
|
||||||
|
[ 10, 400, 0, "transition", 5],
|
||||||
|
[ 10, 410, 0, "block", 10, 5, 8, "orange"],
|
||||||
|
[ 10, 420, 0, "button_6mm"],
|
||||||
|
[ 10, 435, 0, "microswitch", small_microswitch],
|
||||||
|
[ 12, 450, 0, "pcb", 11, TMC2130 ],
|
||||||
|
[ 12, 456, 0, "2p54socket", 8, 1 ],
|
||||||
|
[ 12, 444, 0, "2p54socket", 8, 1, undef, undef, undef, "red" ],
|
||||||
|
[ 10, 470, 0, "standoff", 5, 4.5, 12.5, 2.54],
|
||||||
|
[ 6, 480, 180, "uSD", [12, 11.5, 1.4]],
|
||||||
|
],
|
||||||
|
// accessories
|
||||||
|
[]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
if($preview)
|
||||||
|
let($show_threads = true)
|
||||||
|
pcb(test_pcb);
|
||||||
|
|
@ -31,6 +31,7 @@ include <microswitches.scad>
|
|||||||
|
|
||||||
use <../utils/rounded_cylinder.scad>
|
use <../utils/rounded_cylinder.scad>
|
||||||
use <../utils/dogbones.scad>
|
use <../utils/dogbones.scad>
|
||||||
|
use <../utils/thread.scad>
|
||||||
use <../utils/tube.scad>
|
use <../utils/tube.scad>
|
||||||
use <d_connector.scad>
|
use <d_connector.scad>
|
||||||
|
|
||||||
@ -79,16 +80,21 @@ module chip(length, width, thickness, colour, cutout = false) //! Draw a coloure
|
|||||||
color(colour)
|
color(colour)
|
||||||
translate_z(thickness / 2) cube([length, width, thickness], center = true);
|
translate_z(thickness / 2) cube([length, width, thickness], center = true);
|
||||||
|
|
||||||
|
module usb_Ax1(cutout = false) { //! Draw USB type A single socket
|
||||||
|
usb_A(h = 6.5, v_flange_l = 4.5, bar = 0, cutout = cutout);
|
||||||
|
}
|
||||||
|
|
||||||
module usb_Ax2(cutout = false) { //! Draw USB type A dual socket
|
module usb_Ax2(cutout = false) { //! Draw USB type A dual socket
|
||||||
|
usb_A(h = 15.6, v_flange_l = 12.15, bar = 3.4, cutout = cutout);
|
||||||
|
}
|
||||||
|
|
||||||
|
module usb_A(h, v_flange_l, bar, cutout) {
|
||||||
l = 17;
|
l = 17;
|
||||||
w = 13.25;
|
w = 13.25;
|
||||||
h = 15.6;
|
|
||||||
flange_t = 0.4;
|
flange_t = 0.4;
|
||||||
h_flange_h = 0.8;
|
h_flange_h = 0.8;
|
||||||
h_flange_l = 11;
|
h_flange_l = 11;
|
||||||
v_flange_h = 1;
|
v_flange_h = 1;
|
||||||
v_flange_l = 12.15;
|
|
||||||
bar = 3.4;
|
|
||||||
socket_h = (h - 2 * flange_t - bar) / 2;
|
socket_h = (h - 2 * flange_t - bar) / 2;
|
||||||
|
|
||||||
translate_z(h / 2)
|
translate_z(h / 2)
|
||||||
@ -203,11 +209,32 @@ module jack(cutout = false) { //! Draw 3.5mm jack
|
|||||||
|
|
||||||
module buzzer(height, diameter, colour) { //! Draw PCB buzzer with specified height, diameter and color
|
module buzzer(height, diameter, colour) { //! Draw PCB buzzer with specified height, diameter and color
|
||||||
color (colour)
|
color (colour)
|
||||||
tube(or = diameter / 2, ir = height > 5 ? 1 : 0.75, h = height);
|
tube(or = diameter / 2, ir = height > 5 ? 1 : 0.75, h = height, center = false);
|
||||||
color("white")
|
color("white")
|
||||||
cylinder(d = 2, h = max(height - 3 , 0.5));
|
cylinder(d = 2, h = max(height - 3 , 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module potentiometer(h1, h2) {
|
||||||
|
color("silver") {
|
||||||
|
baseSize = [12, 11, 6];
|
||||||
|
translate_z(baseSize.z / 2)
|
||||||
|
cube(baseSize, center = true);
|
||||||
|
translate_z(baseSize.z) {
|
||||||
|
cylinder(d = 5, h = h1 - 0.5);
|
||||||
|
if (show_threads)
|
||||||
|
male_metric_thread(6, metric_coarse_pitch(5), length = h1 - 0.5, center = false);
|
||||||
|
}
|
||||||
|
translate_z(baseSize.z + h1 - 0.5)
|
||||||
|
cylinder(d = 3, h = 0.5);
|
||||||
|
translate_z(baseSize.z + h1)
|
||||||
|
linear_extrude(h2)
|
||||||
|
difference() {
|
||||||
|
circle(d=5);
|
||||||
|
square([0.75,5], center = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hdmi_depth(type) = type[2]; //! Front to back depth
|
function hdmi_depth(type) = type[2]; //! Front to back depth
|
||||||
function hdmi_width1(type) = type[3]; //! Inside width at the top
|
function hdmi_width1(type) = type[3]; //! Inside width at the top
|
||||||
function hdmi_width2(type) = type[4]; //! Inside width at the bottom
|
function hdmi_width2(type) = type[4]; //! Inside width at the bottom
|
||||||
@ -574,7 +601,7 @@ module flat_flex(cutout = false) { //! Draw flat flexistrip connector as used on
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module terminal_35(ways) { //! Draw 3.5mm terminal block
|
module terminal_35(ways, colour = "blue") { //! Draw 3.5mm terminal block
|
||||||
vitamin(str("terminal_35(", ways, "): Terminal block ", ways, " way 3.5mm"));
|
vitamin(str("terminal_35(", ways, "): Terminal block ", ways, " way 3.5mm"));
|
||||||
pitch = 3.5;
|
pitch = 3.5;
|
||||||
width = ways * pitch;
|
width = ways * pitch;
|
||||||
@ -592,7 +619,7 @@ module terminal_35(ways) { //! Draw 3.5mm terminal block
|
|||||||
|
|
||||||
module single() {
|
module single() {
|
||||||
screw_r = 1;
|
screw_r = 1;
|
||||||
color("blue") {
|
color(colour) {
|
||||||
rotate([90, 0, 0])
|
rotate([90, 0, 0])
|
||||||
linear_extrude(height = pitch, center = true)
|
linear_extrude(height = pitch, center = true)
|
||||||
polygon(points = [
|
polygon(points = [
|
||||||
@ -710,15 +737,17 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
|
|||||||
function show(comp, part) = (comp[3] == part || comp[3] == str("-",part)) && (!cutouts || angle == undef || angle == comp.z);
|
function show(comp, part) = (comp[3] == part || comp[3] == str("-",part)) && (!cutouts || angle == undef || angle == comp.z);
|
||||||
function param(n, default = 0) = len(comp) > n ? comp[n] : default;
|
function param(n, default = 0) = len(comp) > n ? comp[n] : default;
|
||||||
rotate(comp.z) {
|
rotate(comp.z) {
|
||||||
if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6), cutouts);
|
if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6), cutouts, colour = param(7, undef));
|
||||||
if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6), cutouts);
|
if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6), cutouts);
|
||||||
if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7), param(8, false), cutouts);
|
if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7), param(8, false), cutouts, param(9, undef));
|
||||||
if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey30), cutouts);
|
if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey30), cutouts);
|
||||||
if(show(comp, "rj45")) rj45(cutouts);
|
if(show(comp, "rj45")) rj45(cutouts);
|
||||||
|
if(show(comp, "usb_A")) usb_Ax1(cutouts);
|
||||||
if(show(comp, "usb_Ax2")) usb_Ax2(cutouts);
|
if(show(comp, "usb_Ax2")) usb_Ax2(cutouts);
|
||||||
if(show(comp, "usb_uA")) usb_uA(cutouts);
|
if(show(comp, "usb_uA")) usb_uA(cutouts);
|
||||||
if(show(comp, "usb_B")) usb_B(cutouts);
|
if(show(comp, "usb_B")) usb_B(cutouts);
|
||||||
if(show(comp, "buzzer")) buzzer(param(4, 9), param(5, 12), param(6, grey20));
|
if(show(comp, "buzzer")) buzzer(param(4, 9), param(5, 12), param(6, grey20));
|
||||||
|
if(show(comp, "potentiometer")) potentiometer(param(4, 5), param(5, 9));
|
||||||
if(show(comp, "jack")) jack(cutouts);
|
if(show(comp, "jack")) jack(cutouts);
|
||||||
if(show(comp, "barrel_jack")) barrel_jack(cutouts);
|
if(show(comp, "barrel_jack")) barrel_jack(cutouts);
|
||||||
if(show(comp, "hdmi")) hdmi(hdmi_full, cutouts);
|
if(show(comp, "hdmi")) hdmi(hdmi_full, cutouts);
|
||||||
@ -728,10 +757,11 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
|
|||||||
if(show(comp, "D_plug")) if(!cutouts) translate_z(d_pcb_offset(comp[4])) d_plug(comp[4], pcb = true);
|
if(show(comp, "D_plug")) if(!cutouts) translate_z(d_pcb_offset(comp[4])) d_plug(comp[4], pcb = true);
|
||||||
if(show(comp, "molex_hdr")) if(!cutouts) molex_254(comp[4]);
|
if(show(comp, "molex_hdr")) if(!cutouts) molex_254(comp[4]);
|
||||||
if(show(comp, "jst_xh")) if(!cutouts) jst_xh_header(jst_xh_header, comp[4], param(5, false), param(6, "white"), param(7, undef));
|
if(show(comp, "jst_xh")) if(!cutouts) jst_xh_header(jst_xh_header, comp[4], param(5, false), param(6, "white"), param(7, undef));
|
||||||
if(show(comp, "term254")) if(!cutouts) green_terminal(gt_2p54,comp[4], comp[5]);
|
if(show(comp, "term254")) if(!cutouts) green_terminal(gt_2p54,comp[4], comp[5], param(6,"lime"));
|
||||||
if(show(comp, "gterm35")) if(!cutouts) green_terminal(gt_3p5, comp[4], comp[5]);
|
if(show(comp, "gterm")) if(!cutouts) green_terminal(comp[4], comp[5], comp[6], param(7,"lime"));
|
||||||
if(show(comp, "gterm635")) if(!cutouts) green_terminal(gt_6p35, comp[4], comp[5]);
|
if(show(comp, "gterm35")) if(!cutouts) green_terminal(gt_3p5, comp[4], comp[5], param(6,"lime"));
|
||||||
if(show(comp, "term35")) if(!cutouts) terminal_35(comp[4]);
|
if(show(comp, "gterm635")) if(!cutouts) green_terminal(gt_6p35, comp[4], comp[5], param(6,"lime"));
|
||||||
|
if(show(comp, "term35")) if(!cutouts) terminal_35(comp[4], param(5,"blue"));
|
||||||
if(show(comp, "transition")) if(!cutouts) idc_transition(2p54header, comp[4], comp[5]);
|
if(show(comp, "transition")) if(!cutouts) idc_transition(2p54header, comp[4], comp[5]);
|
||||||
if(show(comp, "block"))
|
if(show(comp, "block"))
|
||||||
color(comp[7]) if(!cutouts) translate_z(comp[6] / 2) cube([comp[4], comp[5], comp[6]], center = true);
|
color(comp[7]) if(!cutouts) translate_z(comp[6] / 2) cube([comp[4], comp[5], comp[6]], center = true);
|
||||||
|
@ -43,8 +43,9 @@ module pin(type, length = undef) { //! Draw a header pin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cutout = false) { //! Draw pin header
|
module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cutout = false, colour) { //! Draw pin header
|
||||||
pitch = hdr_pitch(type);
|
pitch = hdr_pitch(type);
|
||||||
|
base_colour = colour ? colour : hdr_base_colour(type);
|
||||||
h = pitch;
|
h = pitch;
|
||||||
ra_offset = 2.4;
|
ra_offset = 2.4;
|
||||||
width = pitch * rows;
|
width = pitch * rows;
|
||||||
@ -79,7 +80,7 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
|
|||||||
}
|
}
|
||||||
translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0])
|
translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0])
|
||||||
rotate([right_angle ? 90 : 0, 0, 0])
|
rotate([right_angle ? 90 : 0, 0, 0])
|
||||||
color(hdr_base_colour(type))
|
color(base_colour)
|
||||||
linear_extrude(height = h)
|
linear_extrude(height = h)
|
||||||
for(x = [0 : cols - 1], y = [0 : rows - 1])
|
for(x = [0 : cols - 1], y = [0 : rows - 1])
|
||||||
translate([pitch * (x - (cols - 1) / 2), pitch * (y - (rows - 1) / 2), pitch / 2])
|
translate([pitch * (x - (cols - 1) / 2), pitch * (y - (rows - 1) / 2), pitch / 2])
|
||||||
@ -160,18 +161,19 @@ module idc_transition(type, cols = 5, skip = [], cutout = false) { //! Draw IDC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module pin_socket(type, cols = 1, rows = 1, right_angle = false, height = 0, smt = false, cutout = false) { //! Draw pin socket
|
module pin_socket(type, cols = 1, rows = 1, right_angle = false, height = 0, smt = false, cutout = false, colour) { //! Draw pin socket
|
||||||
pitch = hdr_pitch(type);
|
pitch = hdr_pitch(type);
|
||||||
length = pitch * cols + 0.5;
|
length = pitch * cols + 0.5;
|
||||||
width = pitch * rows - 0.08;
|
width = pitch * rows - 0.08;
|
||||||
depth = height ? height : hdr_socket_depth(type);
|
depth = height ? height : hdr_socket_depth(type);
|
||||||
|
base_colour = colour ? colour : hdr_base_colour(type);
|
||||||
ra_offset = 1.5;
|
ra_offset = 1.5;
|
||||||
if(cutout)
|
if(cutout)
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
vitamin(str("pin_socket(", type[0], ", ", cols, ", ", rows, arg(right_angle, false, "right_angle"), arg(height, 0, "height"), arg(smt, false, "smt"),
|
vitamin(str("pin_socket(", type[0], ", ", cols, ", ", rows, arg(right_angle, false, "right_angle"), arg(height, 0, "height"), arg(smt, false, "smt"),
|
||||||
"): Pin socket ", cols, " x ", rows, right_angle ? " right_angle" : ""));
|
"): Pin socket ", cols, " x ", rows, right_angle ? " right_angle" : ""));
|
||||||
color(hdr_base_colour(type))
|
color(base_colour)
|
||||||
translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0])
|
translate([0, right_angle ? -ra_offset - pitch / 2 : 0, right_angle ? width / 2 : 0])
|
||||||
rotate([right_angle ? 90 : 0, 0, 0])
|
rotate([right_angle ? 90 : 0, 0, 0])
|
||||||
translate_z(depth / 2)
|
translate_z(depth / 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user