NopSCADlib/vitamins/jack.scad

308 lines
9.7 KiB
OpenSCAD
Raw Normal View History

2019-06-08 17:10:47 -04:00
//
// 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/>.
//
//
//! 4mm jack sockets and binding posts. Each has a colour for the BOM entry and an optional alternative colour for display.
//! E.g. a "brown" socket for mains live needs to be displayed as "sienna" to look realistic.
//
include <../core.scad>
include <spades.scad>
use <../utils/tube.scad>
use <../utils/rounded_cylinder.scad>
2020-03-04 12:42:03 -05:00
use <../utils/thread.scad>
2019-06-08 17:10:47 -04:00
use <ring_terminal.scad>
function jack_4mm_hole_radius() = 8/2; //! Panel hole radius for 4mm jack
module jack_4mm(colour, thickness, display_colour = false) { //! Draw a 4mm jack socket with nut positioned for specified panel thickness
vitamin(str("jack_4mm(\"", colour, "\", 3", arg(display_colour, false), "): 4mm jack socket ", colour));
flange_d = 10.6;
flange_t = 3;
flange_id = 4.6;
length = 28.5;
sleaved = 15;
sleaved_d = 6.4;
thread = 10.4;
thread_d = 8;
2020-03-04 12:42:03 -05:00
thread_p = 0.75;
2019-06-08 17:10:47 -04:00
nut_d = 9.8;
nut_t = 3;
barrel_d = 5.4;
barrel = 18.5;
spade = 7;
explode(length, offset = -length + flange_t) {
color(display_colour ? display_colour : colour) rotate_extrude() difference() {
union() {
square([flange_d / 2, flange_t]);
translate([0, -sleaved])
square([sleaved_d / 2, sleaved]);
}
square([flange_id, 100], center = true);
}
2020-03-04 12:42:03 -05:00
color(silver) rotate_extrude() difference() {
2019-06-08 17:10:47 -04:00
union() {
translate([0, -thread])
2020-03-04 12:42:03 -05:00
square([thread_d / 2 - (show_threads ? thread_p / 2 : 0), thread]);
2019-06-08 17:10:47 -04:00
translate([0, -barrel])
square([barrel_d / 2, barrel]);
}
square([4, 2 * (barrel - 1)], center = true);
}
2020-03-04 12:42:03 -05:00
if(show_threads)
translate_z(-thread)
male_metric_thread(thread_d, thread_p, thread, false, solid = false, colour = silver);
2019-06-08 17:10:47 -04:00
translate_z(-length + flange_t + spade)
vflip()
spade(spade4p8l, spade);
}
translate_z(-thickness)
explode(-length)
2020-03-04 12:42:03 -05:00
vflip() {
color(silver)
2019-06-08 17:10:47 -04:00
tube(ir = thread_d / 2, or = nut_d / 2, h = nut_t, center = false);
2020-03-04 12:42:03 -05:00
if(show_threads)
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
}
2019-06-08 17:10:47 -04:00
}
function jack_4mm_shielded_hole_radius() = 12/2; //! Panel hole radius for 4mm shielded jack
module jack_4mm_shielded(colour, thickness, display_colour = false) { //! Draw a 4mm shielded jack
vitamin(str("jack_4mm_shielded(\"", colour, "\", 3", arg(display_colour, false), "): 4mm shielded jack socket ", colour));
flange_d = 14.5;
flange_t = 2.5;
flange_id = 4.6;
sleaved = 21;
sleaved_d = 10.7;
thread = 14;
2020-03-04 12:42:03 -05:00
thread_d = 12;
thread_p = 0.75;
2019-06-08 17:10:47 -04:00
nut_d = 14.4;
nut_t = 5;
length = 32;
spade = 8.5;
2020-03-04 12:42:03 -05:00
actual_colour = display_colour ? display_colour : colour;
2019-06-08 17:10:47 -04:00
explode(length, offset = -length + flange_t) {
2020-03-04 12:42:03 -05:00
color(actual_colour) {
2019-06-08 17:10:47 -04:00
rounded_cylinder(r = flange_d / 2, h = flange_t, r2 = 1, ir = 4.5);
rotate_extrude() difference() {
union() {
translate([0, -sleaved])
square([sleaved_d / 2, sleaved + flange_t]);
2020-03-04 12:42:03 -05:00
if(!show_threads)
translate([0, -thread])
square([thread_d / 2, thread]);
2019-06-08 17:10:47 -04:00
}
square([flange_id, 100], center = true);
difference() {
square([9, 2 * sleaved - 1], center = true);
square([6, 2 * sleaved], center = true);
}
}
2020-03-04 12:42:03 -05:00
if(show_threads)
translate_z(-thread)
male_metric_thread(thread_d, thread_p, thread, false, solid = false);
2019-06-08 17:10:47 -04:00
}
2020-03-04 12:42:03 -05:00
color(silver)
2019-06-08 17:10:47 -04:00
translate_z(-length + flange_t + spade - 0.5)
cylinder(d = 4.8, h = 0.5);
translate_z(-length + flange_t + spade)
vflip()
spade(spade4p8ll, spade);
}
translate_z(-thickness)
explode(-length)
2020-03-04 12:42:03 -05:00
vflip() {
color(silver)
2019-06-08 17:10:47 -04:00
tube(ir = thread_d / 2, or = nut_d / 2, h = nut_t, center = false);
2020-03-04 12:42:03 -05:00
if(show_threads)
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
}
2019-06-08 17:10:47 -04:00
}
function post_4mm_diameter() = 13; //! Outer diameter of 4mm binding post
post_4mm_hole_radius = 7 / 2;
post_4mm_spigot_w = 1.1;
post_4mm_spigot_l = 1.2;
post_4mm_spigot_h = 2.5;
module post_4mm_hole(h = 100, poly = false) { //! Drill hole for 4mm binding post
extrude_if(h) union() {
r = cnc_bit_r + eps;
if(poly)
poly_circle(post_4mm_hole_radius);
else
drill(post_4mm_hole_radius, 0);
hull() {
translate([0, post_4mm_hole_radius + post_4mm_spigot_l - r])
drill(r, 0);
drill(r, 0);
}
}
}
module post_4mm(colour, thickness, display_colour = false) { //! Draw a 4mm binding post
vitamin(str("post_4mm(\"", colour, "\", 3", arg(display_colour, false), "): 4mm jack binding post ", colour));
actual_colour = display_colour ? display_colour : colour;
d = post_4mm_diameter();
base_h = 5;
collar_t = post_4mm_spigot_h;
post_od = 9.5;
post_metal = 0.2;
2020-03-04 12:42:03 -05:00
thread_d = 3.6;
thread_p = 0.66;
2019-06-08 17:10:47 -04:00
thread_l = 15;
post_d = 7;
post_h = 14;
ringterm = ["", 6.3, 3.8, 16.7, 3, 1.6, 0.3, M4_dome_screw];
2020-03-04 12:42:03 -05:00
module washer() color(silver) {
2019-06-08 17:10:47 -04:00
washer_t = 0.65;
tube(or = 7.6 / 2, ir = thread_d / 2, h = washer_t, center = false);
translate_z(washer_t)
children();
}
module nut() {
nut_t = 2.3;
2020-03-04 12:42:03 -05:00
color(silver)
linear_extrude(nut_t) difference() {
2020-03-04 12:42:03 -05:00
circle(d = 6.3 / cos(30), $fn = 6);
2019-06-08 17:10:47 -04:00
2020-03-04 12:42:03 -05:00
circle(d = thread_d);
}
if(show_threads)
female_metric_thread(thread_d, thread_p, nut_t, false, colour = silver);
2019-06-08 17:10:47 -04:00
translate_z(nut_t)
children();
}
module spigot()
hull()
for(end = [-1, 1])
translate([0, post_4mm_hole_radius + end * (post_4mm_spigot_l - post_4mm_spigot_w / 2)])
circle(d = post_4mm_spigot_w);
explode(20, offset = -thread_l) {
color(actual_colour) {
cylinder(d = d, h = base_h);
translate_z(-collar_t)
linear_extrude(base_h) {
2019-06-08 17:10:47 -04:00
circle(post_4mm_hole_radius - 0.1);
spigot();
}
translate_z(base_h + 1)
for(i = [0 : 7])
rotate(i * 360 / 8)
render() difference() {
rotate_extrude(angle = 360 / 8)
polygon([
2020-03-04 12:42:03 -05:00
[post_d / 2, 0],
2019-06-08 17:10:47 -04:00
[post_d / 2, 2],
[post_d / 2, 17.5],
[11 / 2, 17.5],
[12.5 / 2, 0]
]);
rotate(180 /8)
hull() {
translate([6.5, 0, 3])
sphere(d = 2.5);
translate([6, 0, 17.5])
cylinder(d = 2.5, h = eps);
}
}
}
2020-03-04 12:42:03 -05:00
color(silver) {
2019-06-08 17:10:47 -04:00
translate_z(post_metal)
cylinder(d = post_od, h = base_h);
translate_z(base_h + post_metal + 0.1)
cylinder(d = post_od, h = 2);
rotate_extrude() difference() {
square([post_d / 2, base_h + post_metal + post_h]);
translate([0, base_h + post_metal + 1])
square([2, post_h]);
}
2020-03-04 12:42:03 -05:00
if(!show_threads)
vflip()
cylinder(d = thread_d, h = thread_l);
2019-06-08 17:10:47 -04:00
}
2020-03-04 12:42:03 -05:00
if(show_threads)
vflip()
male_metric_thread(thread_d, thread_p, thread_l, false, colour = silver);
2019-06-08 17:10:47 -04:00
}
explode(-15)
color(actual_colour) {
translate_z(-thickness - base_h) {
linear_extrude(base_h)
2019-06-08 17:10:47 -04:00
difference() {
circle(d = d);
circle(post_4mm_hole_radius);
offset(0.1) spigot();
}
tube(or = d / 2, ir = thread_d / 2, h = collar_t, center = false);
}
}
translate_z(-thickness - base_h)
explode(-20, true)
2020-03-04 12:42:03 -05:00
vflip()
not_on_bom()
washer()
explode(5, true) nut()
explode(5, true) ring_terminal(ringterm)
explode(5, true) washer()
explode(5, true) nut();
2019-06-08 17:10:47 -04:00
}