1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-06 15:36:30 +02:00

Added $show_plugs to show crude reprentations of housings on pin_headers and Molex KK headers.

This commit is contained in:
Chris Palmer
2021-09-27 16:36:47 +01:00
parent c37373c920
commit 50958b064d
4 changed files with 54 additions and 10 deletions

View File

@@ -2351,7 +2351,8 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| `flex(cutout = false)` | Draw flexistrip connector |
| `hdmi(type, cutout = false)` | Draw HDMI socket |
| `jack(cutout = false)` | Draw 3.5mm jack |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254_housing(ways)` | Draw a Molex KK housing |
| `molex_usb_Ax1(cutout)` | Draw Molex USB A connector suitable for perf board |
| `molex_usb_Ax2(cutout)` | Draw Molex dual USB A connector suitable for perf board |
| `pcb(type)` | Draw specified PCB |
@@ -2495,7 +2496,8 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| `flex(cutout = false)` | Draw flexistrip connector |
| `hdmi(type, cutout = false)` | Draw HDMI socket |
| `jack(cutout = false)` | Draw 3.5mm jack |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254(ways, right_angle = 0, skip = undef)` | Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version. |
| `molex_254_housing(ways)` | Draw a Molex KK housing |
| `molex_usb_Ax1(cutout)` | Draw Molex USB A connector suitable for perf board |
| `molex_usb_Ax2(cutout)` | Draw Molex dual USB A connector suitable for perf board |
| `pcb(type)` | Draw specified PCB |

View File

@@ -859,7 +859,28 @@ module terminal_35(ways, colour = "blue") { //! Draw 3.5mm terminal block
single();
}
module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version.
module molex_254_housing(ways) { //! Draw a Molex KK housing
vitamin(str("molex_254_housing(", ways, "): Molex KK housing ", ways, " way"));
pitch = 2.54;
width = ways * pitch + 0.6;
depth = 4.9;
height = 12.8;
header_depth = 6.35;
tab = [1.73, 0.96, 2.15];
color("white")
translate([(header_depth - depth) / 2, 0]) {
linear_extrude(height)
square([depth, width], center = true);
for(side = [-1, 1])
translate([-depth / 2 - tab.x / 2, side * (pitch / 2 - tab.y / 4) * ways, tab.z / 2])
cube(tab, center = true);
}
}
module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex KK header, set `right_angle` to 1 for normal right angle version or -1 for inverted right angle version.
vitamin(str("molex_254(", ways, "): Molex KK header ", ways, " way"));
pitch = 2.54;
width = ways * pitch - 0.1;
@@ -872,10 +893,11 @@ module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, s
pin_w = 0.64;
r = 1;
a = right_angle ? width / 2 - r - pin_w / 2 : above;
ra_offset = 2.72;
ra_offset = 2.2;
color("white")
translate(right_angle ? [-ra_offset, 0, depth / 2] : [ 0, 0, 0])
rotate(right_angle ? right_angle > 0 ? [180, 90, 0] : [0, -90, 0] : [ 0, 0, 0])
rotate(right_angle ? right_angle > 0 ? [180, 90, 0] : [0, -90, 0] : [ 0, 0, 0]) {
union() {
translate([ -depth / 2, -width / 2,])
cube([depth, width, base]);
@@ -885,6 +907,11 @@ module molex_254(ways, right_angle = 0, skip = undef) { //! Draw molex header, s
cube([back, w, height]);
}
if(show_plugs)
translate_z(base + 0.1)
molex_254_housing(ways);
}
color("silver")
for(i = [0 : ways -1])
if(is_undef(skip) || !in(skip, i))
@@ -1007,9 +1034,11 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
function param(n, default = 0) = len(comp) > n ? comp[n] : default;
rotate(comp.z) {
// Components that have a cutout parameter go in this section
if(show(comp, "2p54header")) pin_header(2p54header, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54header")) let($show_plugs = show_plugs && param(9, true))
pin_header(2p54header, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54joiner")) pin_header(2p54joiner, comp[4], comp[5], param(6, false), param(8, false), cutouts, colour = param(7, undef));
if(show(comp, "2p54boxhdr")) box_header(2p54header, comp[4], comp[5], param(6, false), cutouts);
if(show(comp, "2p54boxhdr")) let($show_plugs = show_plugs && param(7, true))
box_header(2p54header, comp[4], comp[5], param(6, false), cutouts);
if(show(comp, "2p54socket")) pin_socket(2p54header, comp[4], comp[5], param(6, false), param(7, 0), param(8, false), cutouts, param(9, undef));
if(show(comp, "chip")) chip(comp[4], comp[5], comp[6], param(7, grey(30)), cutouts);
if(show(comp, "rj45")) rj45(cutouts);

View File

@@ -856,7 +856,7 @@ ArduinoNano = let(l = 43.18, w = 17.78, pitch = inch(0.6), pins = 15, poffset =
[ // components
[l / 2 + poffset, w / 2 - pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset, w / 2 + pitch / 2, 0, "-2p54joiner", pins, 1],
[l / 2 + poffset + inch(0.75), w / 2, 0, "2p54header", 2, 3],
[l / 2 + poffset + inch(0.75), w / 2, 0, "2p54header", 2, 3, false, undef, false, false],
[1.75, w / 2, 180, "usb_uA" ],
[l / 2 - inch(0.25), w / 2, 45, "chip", 7, 7, 1.3],
[l / 2 + poffset + inch(0.15), w / 2, 0, "chip", 3.5, 6, 1.8, silver ], // mock button

View File

@@ -21,6 +21,8 @@ include <../utils/core/core.scad>
use <../utils/dogbones.scad>
panel_clearance = 0.2;
housing_height = 14.12; // measured height of a Dupont connector.
housing_colour = grey(25);
function hdr_pitch(type) = type[1]; //! Header pitch
function hdr_pin_length(type) = type[2]; //! Header pin length
@@ -96,7 +98,7 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
}
// Insulator
translate([0, right_angle ? -ra_offset - (rows - 1) * pitch / 2 : 0, right_angle ? width / 2 : 0])
rotate([right_angle ? 90 : 0, 0, 0])
rotate([right_angle ? 90 : 0, 0, 0]) {
color(base_colour)
linear_extrude(h)
for(x = [0 : cols - 1], y = [0 : rows - 1])
@@ -107,12 +109,18 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu
square([pitch - chamfer, pitch + eps], center = true);
}
if(show_plugs && hdr_pin_length(type) > 7)
color(housing_colour)
translate_z(h + eps)
linear_extrude(housing_height)
square([cols * pitch , rows * pitch], center = true);
}
}
}
}
module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! Draw box header
pitch = hdr_pitch(type);
pitch = hdr_pitch(type);
size = hdr_box_size(type);
w = cols * pitch + 7.62;
l = rows * pitch + 3.52;
@@ -144,6 +152,11 @@ module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! D
square([4.5, 4.5], center = true);
}
}
if(show_plugs)
color(housing_colour)
translate_z(base)
linear_extrude(housing_height)
square([cols * pitch, rows * pitch], center = true);
}
}
}