diff --git a/readme.md b/readme.md index 5fb7925..1e3132b 100644 --- a/readme.md +++ b/readme.md @@ -2465,12 +2465,17 @@ Pin headers and sockets, etc. | Function | Description | |:--- |:--- | | ```hdr_base_colour(type)``` | Header insulator colour | +| ```hdr_box_size(type)``` | Box header outside dimensions | +| ```hdr_box_wall(type)``` | Box header wall thickness | | ```hdr_pin_below(type)``` | Header pin length underneath | | ```hdr_pin_colour(type)``` | Header pin colour | | ```hdr_pin_length(type)``` | Header pin length | | ```hdr_pin_width(type)``` | Header pin size | | ```hdr_pitch(type)``` | Header pitch | +| ```hdr_ra_box_offset(type)``` | Offset between back of the box and the pins | +| ```hdr_ra_height(type)``` | Height of right angle connector | | ```hdr_socket_depth(type)``` | Socket depth for female housing | +| ```hdr_y_offset(type)``` | Y offset of pins from center of the box | ### Modules | Module | Description | diff --git a/tests/pin_headers.scad b/tests/pin_headers.scad index 6c12893..9639c08 100644 --- a/tests/pin_headers.scad +++ b/tests/pin_headers.scad @@ -64,11 +64,14 @@ module pin_headers() { pin_socket(pin_headers[$i], 3, 3, right_angle = true); } - translate([-20, 0]) - jst_xh_header(jst_xh_header, 5); + for(i = [0, 1], p = [5, 2][i], j = [0 , 1]) { + h = [jst_ph_header, jst_xh_header][j]; + translate([-20 * (i + 1), 0 + j * 40]) + jst_xh_header(h, p); - translate([-20, 20]) - jst_xh_header(jst_xh_header, 5, true); + translate([-20 * (i + 1), 20 + j * 40]) + jst_xh_header(h, p, true); + } } if($preview) diff --git a/tests/png/pcb.png b/tests/png/pcb.png index 484d917..65a42a7 100644 Binary files a/tests/png/pcb.png and b/tests/png/pcb.png differ diff --git a/tests/png/pcbs.png b/tests/png/pcbs.png index 7a1b6c1..afe2c26 100644 Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ diff --git a/tests/png/pin_headers.png b/tests/png/pin_headers.png index 1c9697f..ee44762 100644 Binary files a/tests/png/pin_headers.png and b/tests/png/pin_headers.png differ diff --git a/vitamins/panel_meters.scad b/vitamins/panel_meters.scad index a2b6d5a..37b951d 100644 --- a/vitamins/panel_meters.scad +++ b/vitamins/panel_meters.scad @@ -41,7 +41,7 @@ DSP5005 = ["DSP5005", "Ruideng DSP5005 Power supply module", [7 [[-25, 9, 0], [ 6.5, 4.5, 1], 0.5, "yellow"], ]]; -DSN_VC288PCB = ["", "", 41, 21, 1, 0, 0, 0, "green", false, [], [[ 5, -3, 0, "jst_xh", 3], ], []]; +DSN_VC288PCB = ["", "", 41, 21, 1, 0, 0, 0, "green", false, [], [[ 5, -3.525, 0, "jst_xh", 3], ], []]; DSN_VC288 = ["DSN_VC288","DSN-VC288 DC 100V 10A Voltmeter ammeter", [45.3, 26, 17.4], [47.8, 28.8, 2.5], 0, [1, 1.8], [36, 18, 2.5], [], 0, 2, [], 0, DSN_VC288PCB, 5, 0]; diff --git a/vitamins/pcbs.scad b/vitamins/pcbs.scad index 59a4123..fd9d2d2 100644 --- a/vitamins/pcbs.scad +++ b/vitamins/pcbs.scad @@ -348,7 +348,7 @@ PI_IO = ["PI_IO", "PI_IO V2", 35.56, 25.4, 1.6, 0, 0, 0, "green", tru ], []]; ZC_A0591 = ["ZC_A0591", "ZC-A0591 ULN2003 driver PCB", 35, 32, 1.6, 0, 2.5, 0, "green", false, [[2.25, 3.25], [-2.25, 3.25], [2.25, -3.25], [-2.25, -3.25] ], - [ [ 12.25, 8.3, -90, "jst_xh", 5], + [ [ 11.725, 8.3, -90, "jst_xh", 5], [ -6.5, 10, 0, "2p54header", 1, 4], [ 20.4, -4.5, 0, "2p54header", 4, 1], [ 20.4, 11, 180, "pdip", 16, "ULN2803AN", true], @@ -408,7 +408,7 @@ RAMPSEndstop = ["RAMPSEndstop", "RAMPS Endstop Switch", [2, 2, false], [2, 13.5, false], [17, 13.5], [36, 13.5] ], [ - [ 12, 8, -90, "jst_xh", 3, true, "white", "silver"], + [ 11.6, 8, -90, "jst_xh", 3, true, "white", "silver"], [ 26.5, 12.75, 0, "microswitch", small_microswitch], [ 27.5, 17.5, 15, "chip", 15, 0.5, 4.5, "silver"], ], diff --git a/vitamins/pin_header.scad b/vitamins/pin_header.scad index 08d6902..f12a383 100644 --- a/vitamins/pin_header.scad +++ b/vitamins/pin_header.scad @@ -29,13 +29,18 @@ function hdr_pin_width(type) = type[4]; //! Header pin size function hdr_pin_colour(type) = type[5]; //! Header pin colour function hdr_base_colour(type) = type[6]; //! Header insulator colour function hdr_socket_depth(type) = type[7]; //! Socket depth for female housing +function hdr_box_size(type) = type[8]; //! Box header outside dimensions +function hdr_box_wall(type) = type[9]; //! Box header wall thickness +function hdr_y_offset(type) = type[10]; //! Y offset of pins from center of the box +function hdr_ra_box_offset(type)= type[11]; //! Offset between back of the box and the pins +function hdr_ra_height(type) = type[12]; //! Height of right angle connector module pin(type, length = undef) { //! Draw a header pin w = hdr_pin_width(type); l = length == undef ? hdr_pin_length(type) : length; chamfer = w / 2; color(hdr_pin_colour(type)) - translate_z(l / 2 -hdr_pin_below(type)) + translate_z(l / 2 - hdr_pin_below(type)) hull() { cube([w, w, l - 2 * chamfer], center = true); @@ -108,9 +113,11 @@ module pin_header(type, cols = 1, rows = 1, smt = false, right_angle = false, cu module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! Draw box header pitch = hdr_pitch(type); + size = hdr_box_size(type); w = cols * pitch + 7.62; l = rows * pitch + 3.52; - h = 8.7; + h = size.z; + t = hdr_box_wall(type); base = h - 6.4; if(cutout) @@ -131,7 +138,7 @@ module box_header(type, cols = 1, rows = 1, smt = false, cutout = false) { //! D difference() { square([w, l], center = true); - square([w - 2.4, l - 2.4], center = true); + square([w - t, l - t], center = true); translate([0, -l / 2]) square([4.5, 4.5], center = true); @@ -225,65 +232,95 @@ module pin_socket(type, cols = 1, rows = 1, right_angle = false, height = 0, smt module jst_xh_header(type, pin_count, right_angle = false, colour = false, pin_colour = false) { //! Draw JST XH connector colour = colour ? colour : hdr_base_colour(type); pin_colour = pin_colour ? pin_colour : hdr_pin_colour(type); - sizeY = 5.75; pitch = hdr_pitch(type); + size = hdr_box_size(type) + [(pin_count - 1) * pitch, 0, 0]; + pinOffsetX = hdr_box_size(type).x / 2; // Offset from last pin to box edge + wallThickness = hdr_box_wall(type); + y_offset = hdr_y_offset(type); + ra_box_offset = hdr_ra_box_offset(type); + ra_h = hdr_ra_height(type); + ra_z = ra_h - size.y / 2; + ra_extra = ra_h - size.y; // thicker base for right angle version + pinWidth = hdr_pin_width(type); - module jst_xh_socket(type, pin_count) { - socketSizeZ = hdr_socket_depth(type); - pinOffsetX = 2.45; - sizeY = 5.75; - wallThickness = 0.8; - size = [pinOffsetX * 2 + (pin_count - 1) * pitch, sizeY, socketSizeZ]; - translate([-size[0] / 2, -size[1] / 2, 0]) { - // the base - cube([size[0], size[1], wallThickness]); - // the three full sides - translate([0, size[1] - wallThickness, 0]) - cube([size[0], wallThickness, size[2]]); - cube([wallThickness, size[1], size[2]]); - translate([size[0] - wallThickness, 0, 0]) - cube([wallThickness, size[1], size[2]]); - // the sides with cutouts - cube([size[0], wallThickness, 2]); - cutoutWidth = 1; - cutoutOffset = pinOffsetX - cutoutWidth / 2; - cube([cutoutOffset, wallThickness, size[2]]); - translate([size[0] - cutoutOffset, 0, 0]) - cube([cutoutOffset, wallThickness, size[2]]); - cube([cutoutOffset, wallThickness, size[2]]); - translate([size[0]-cutoutOffset, 0, 0]) - cube([cutoutOffset, wallThickness, size[2]]); - translate([cutoutOffset + cutoutWidth, 0, 0]) - cube([size[0] - 2 * (cutoutWidth + cutoutOffset), wallThickness, size[2]]); + module jst_xh_socket(type, pin_count, ra = false) { + module wall() { + difference() { + square([size.x, size.y], center = true); + + offset(-wallThickness) + square([size.x, size.y], center = true); + } + if(right_angle) + translate([0, size.y / 2 + ra_extra / 2]) + square([size.x, ra_extra], center = true); } - } // end module + module slots() { + cutoutWidth = 1.3; + cutoutOffset = pinOffsetX + cutoutWidth / 2 - hdr_pin_width(type) / 2; + for(side = [-1, 1]) + translate([side * (size.x / 2 - cutoutOffset), -size.y / 2 + wallThickness / 2]) + square([cutoutWidth, 2 * wallThickness], center = true); + } + + linear_extrude(wallThickness) + square([size.x, size.y], center = true); // the base + + linear_extrude(size.z / 2) // full walls up to the slots + wall(); + + linear_extrude(size.z) // slotted walls to the top + difference() { + wall(); + + if(type[0] == "jst_xh_header") { + if(pin_count > 2) + slots(); + else + hull() + slots(); + + translate([0, -size.y / 2 + 3 * wallThickness / 2]) + square([size.x + 1, wallThickness], center = true); + } + + if(type[0] == "jst_ph_header") { + translate([0, -size.y / 2 + wallThickness / 2]) + square([max((pin_count - 2) * pitch, 1), 2 * wallThickness], center = true); + + translate([0, -y_offset / 2 - pinWidth / 4]) + square([size.x + 1, y_offset + pinWidth / 2], center = true); + } + } + } // end module color(colour) if(right_angle) - translate([0, -1, sizeY / 2]) + translate([0, -ra_box_offset, ra_z]) rotate([-90, 0, 180]) - jst_xh_socket(type, pin_count); + jst_xh_socket(type, pin_count, true); else - jst_xh_socket(type, pin_count); + translate([0, y_offset]) + jst_xh_socket(type, pin_count); color(pin_colour) for(x = [0 : pin_count - 1]) { - pinWidth = hdr_pin_width(type); - verticalPinLength = right_angle ? hdr_pin_below(type) + sizeY / 2 : hdr_pin_length(type); - translate([pitch * (x - (pin_count - 1) / 2), 0, 0]) { + verticalPinLength = right_angle ? hdr_pin_below(type) + ra_z + y_offset : hdr_pin_length(type); + horizontalPinLength = hdr_pin_length(type) - hdr_pin_below(type) + ra_box_offset; + translate([pitch * (x - (pin_count - 1) / 2), 0]) { pin(type, verticalPinLength); if(right_angle) { - translate([0, -pinWidth / 2, sizeY / 2 - pinWidth / 2]) + translate([0, -pinWidth / 2, ra_z - pinWidth / 2 + y_offset]) rotate([0, -90, 0]) rotate_extrude(angle = 90, $fn = 32) translate([0, -pinWidth / 2]) square(pinWidth); - translate([0, -sizeY / 2 - 3 * pinWidth / 4, sizeY / 2]) - rotate([90,0,0]) - pin(type, hdr_pin_length(type) - hdr_pin_below(type)); + translate([0, -hdr_pin_below(type), ra_z + y_offset]) + rotate([90, 0, 0]) + pin(type, horizontalPinLength); } } } diff --git a/vitamins/pin_headers.scad b/vitamins/pin_headers.scad index 2ac37ff..97d2421 100644 --- a/vitamins/pin_headers.scad +++ b/vitamins/pin_headers.scad @@ -17,15 +17,16 @@ // If not, see . // -// p p b p p b Socket depth -// i i e i i a -// t n l n n s -// c o e -// h l w w c -// c -// -2p54header = ["2p54header", 2.54, 11.6, 3.2, 0.66, "gold", grey(20), 8.5]; -jst_xh_header = ["JST XH header",2.5, 10, 3.4, 0.64, "gold", grey(90), 7]; +// p p b p p b s b b p r r +// i i e i i a o o o i a a +// t n l n n s c x x n +// c o e k b h +// h l w w c s t y +// c h z o +// f +2p54header = ["2p54header", 2.54, 11.6, 3.2, 0.66, "gold", grey(20), 8.5, [0, 0, 8.7], 2.4, 0, 0, 0 ]; +jst_xh_header = ["jst_xh_header",2.5, 10, 3.4, 0.64, "gold", grey(90), 0, [4.9, 5.75, 7], 0.8, 0.525, 0.6, 6.1]; +jst_ph_header = ["jst_ph_header",2.0, 9, 3.4, 0.64, silver, grey(90), 0, [3.9, 4.5, 6], 0.6, 0.55, 0.25, 4.8]; pin_headers = [ 2p54header ];