1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-02 20:02:46 +02:00

Added smd_250V_fuse() and rd_box_cap().

Fixed missing value parameters from a lot of the SMD component instantiation examples.
This commit is contained in:
Chris Palmer
2024-08-15 22:52:32 +01:00
parent a974e4fa9d
commit bc7f294f99
12 changed files with 226 additions and 56 deletions

View File

@@ -1169,6 +1169,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
if(show(comp, "rd_module")) rd_module(type = comp[4], value = comp[5]);
if(show(comp, "rd_transistor")) rd_transistor(type = comp[4], value = comp[5], lead_positions = param(6, undef), z = param(7, 5), kind = param(8,"Transistor"));
// type, value, lead positions, z, kind
if(show(comp, "rd_box_cap")) rd_box_cap(type = comp[4], kind = comp[5], value = comp[6]);
if(show(comp, "link")) wire_link(l = comp[4], h = param(5, 1), d = param(6, 0.8), tail = param(7, 3), sleeve = param(8, false));
if(show(comp, "D_plug")) translate_z(d_pcb_offset(comp[4])) d_plug(comp[4], pcb = true);
if(show(comp, "molex_hdr")) molex_254(comp[4], param(5, 0), param(6, undef));
@@ -1177,6 +1178,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
if(show(comp, "jst_zh")) jst_xh_header(jst_zh_header, comp[4], param(5, false), param(6, false), param(7, undef));
if(show(comp, "potentiometer")) let(pot = param(4, BTT_encoder)) translate_z(pot_size(pot).z) vflip() potentiometer(pot, shaft_length = param(5, undef));
if(show(comp, "buzzer")) buzzer(param(4, 9), param(5, 12), param(6, grey(20)));
if(show(comp, "smd_250V_fuse")) smd_250V_fuse(comp[4], comp[5]);
if(show(comp, "smd_res")) smd_resistor(comp[4], comp[5]);
if(show(comp, "smd_cap")) smd_capacitor(comp[4], comp[5], param(6, undef));
if(show(comp, "smd_tant")) smd_tant(comp[4], param(5, undef));

View File

@@ -158,6 +158,7 @@ module rd_module(type, value) { //! Draw a PCB mounted potted module, e.g. PSU o
r = rd_module_radius(type);
size = rd_module_size(type);
pin = rd_module_pin_size(type);
color(rd_module_colour(type))
rounded_top_rectangle(size, r, r);
@@ -393,3 +394,60 @@ module rd_electrolytic(type, value, pitch = undef, z = 0, tail = 3) { //! Draw a
cylinder(r = jacket_ir, h = eps);
}
}
function rd_boxc_size(type) = type[1]; //! Overall size and corner radius
function rd_boxc_z(type) = type[2]; //! Height of inner base above PCB.
function rd_boxc_skirt(type) = type[3]; //! Skirt slot, thickness, height
function rd_boxc_leads(type) = type[4]; //! Lead pitch, diameter and length
function rd_boxc_colours(type) = type[5]; //! Case colour and resin fill colour
module rd_box_cap(type, kind, value) { //! Draw radial boxed film capacitor
vitamin(str("rd_boxc(", type[0], ", \"", kind, "\", \"", value, "\" ): ", kind, " ", value));
size = rd_boxc_size(type);
r = size[3];
skirt = rd_boxc_skirt(type);
inset = skirt.y * 2;
leads = rd_boxc_leads(type);
c = rd_boxc_colours(type);
z = rd_boxc_z(type);
$fn = fn;
color(c[0]) {
translate_z(z)
rounded_top_rectangle([size.x, size.y, size.z - z], r, r);
for(i = [0, 1])
translate_z(i * skirt.z)
linear_extrude(z)
difference() {
rounded_square([size.x, size.y], r);
square([size.x - inset, size.y - inset], center = true);
if(!i)
square([skirt.x, size.y], center = true);
}
}
color(c[1])
translate_z(z)
cube([size.x - inset, size.y - inset, 2 * eps], center = true);
color(silver)
for(end = [-1, 1])
translate([end * leads.x / 2, 0]) {
translate_z(- leads.z)
cylinder(d = leads.y, h = leads.z + z);
solder(leads.y / 2);
}
color("black")
translate([0, -size.y / 2])
rotate([90, 0, 0])
linear_extrude(eps)
translate([-size.x * 0.45, size.z * 0.75])
resize([size.x * 0.9, size.z / 6])
text(value, halign = "left", valign = "top");
}

View File

@@ -54,4 +54,10 @@ ECAP8x11 = ["ECAP8x12", [8.2, 7.5, 12.5], 0.5, [2.4, 2.5], 0.5, inch(0.1), [grey
rd_electrolytics = [ECAP8x11];
// Boxed plastic film capacitors
BOXC18x5x11 = ["BOXC18x5x11", [18, 5, 11, 0.25], 1.2, [8, 0.6, 0.4], [15, 0.6, 4.4], [grey(40), "LightYellow"]];
BOXC18x10x16 = ["BOXC18x10x16", [18, 10, 16, 0.25], 1.7, [12, 0.8, 0.4], [15, 0.8, 4.4], [grey(40), "LightYellow"]];
rd_box_caps = [BOXC18x5x11, BOXC18x10x16];
use <radial.scad>

View File

@@ -55,7 +55,7 @@ function smd_size(size) = //! Convert size to 1/100" notation
module smd_led(type, colour, cutout) { //! Draw an SMD LED with specified `colour`
size = smd_led_size(type);
vitamin(str("smd_led(", type[0], ", ", colour, "): SMD LED ", smd_size(size), " ", colour));
vitamin(str("smd_led(", type[0], ", \"", colour, "\"): SMD LED ", smd_size(size), " ", colour));
lens = smd_led_lens(type);
r = size.y * 0.32;
@@ -137,7 +137,7 @@ function smd_cap_end_cap(type) = type[2]; //! End cap width
module smd_capacitor(type, height, value = undef) { //! Draw an SMD capacitor with specified height
size = smd_cap_size(type);
vitamin(str("smd_capacitor(", type[0], "): SMD capacitor ", smd_size(size), !is_undef(value) ? str(" ", value) : ""));
vitamin(str("smd_capacitor(", type[0], arg(value, undef, "value"), "): SMD capacitor ", smd_size(size), !is_undef(value) ? str(" ", value) : ""));
cap = smd_cap_end_cap(type);
@@ -161,7 +161,7 @@ function smd_sot_lead_size(type) = type[6]; //! Lead width, foot depth, lead
function smd_sot_tab_width(type) = type[7]; //! The wide lead at the top
module smd_sot(type, value) { //! Draw an SMD transistor
vitamin(str("smd_sot(", type[0], "): ", type[0], " package ", value));
vitamin(str("smd_sot(", type[0], ", \"", value, "\"): ", type[0], " package ", value));
size = smd_sot_size(type);
z0 = smd_sot_z(type);
@@ -197,7 +197,6 @@ module smd_sot(type, value) { //! Draw an SMD transistor
linear_extrude(eps)
resize([size.x - 4 * (z2 - z1) * tan(slant), size.y / 2])
text(value, halign = "center", valign = "center");
}
function smd_soic_size(type) = type[1]; //! Body length, width and height
@@ -208,7 +207,7 @@ function smd_soic_lead_span(type) = type[5]; //! Total span of leads
function smd_soic_lead_size(type) = type[6]; //! Lead width, foot depth, lead thickness
module smd_soic(type, value) { //! Draw an SMD SOIC
vitamin(str("smd_soic(", type[0], "): ", type[0], " package ", value));
vitamin(str("smd_soic(", type[0], ", \"", value, "\"): ", type[0], " package ", value));
size = smd_soic_size(type);
z0 = smd_soic_z(type);
@@ -261,7 +260,7 @@ function smd_diode_leads(type) = type[4]; //! Lead extent in x, width, thicknes
function smd_diode_colour(type) = type[5]; //! Body colour
module smd_diode(type, value) { //! Draw an SMD diode
vitamin(str("smd_diode(", type[0], "): ", type[0], " package ", value));
vitamin(str("smd_diode(", type[0], ", \"", value, "\"): ", type[0], " package ", value));
slant = 5; //! 5 degree body draft angle
size = smd_diode_size(type);
@@ -326,7 +325,7 @@ module smd_tant(type, value) { //! Draw an SMD tantalum capacitor
volts = is_undef(value) ? "" : let(c = value[3])
assert(in(codes, c), str("expected the 4th character of value to be a voltage code: ", codes, ", got ", c))
str(", ", voltages[search(c, codes)[0]], "V");
vitamin(str("smd_tant(", type[0], "): SMD Tantalum capacitor package ", type[0][len(type[0]) -1], uF, volts));
vitamin(str("smd_tant(", type[0], arg(value, undef, "value"), "): SMD Tantalum capacitor package ", type[0][len(type[0]) -1], uF, volts));
size = smd_tant_size(type);
slant = 5; //! 5 degree body draft angle
@@ -388,7 +387,7 @@ function smd_inductor_leads(type) = type[4]; //! Lead extent in x, width, thick
function smd_inductor_colour(type) = type[5]; //! Body colour
module smd_inductor(type, value) { //! Draw an SMD inductor
vitamin(str("smd_inductor(", type[0], "): ", type[0], " package ", value));
vitamin(str("smd_inductor(", type[0], " ,\"", value, "\"): ", type[0], " package ", value));
size = smd_inductor_size(type);
z0 = smd_inductor_z(type);
@@ -437,7 +436,7 @@ function smd_pot_cross(type) = type[4]; //! Cross head slot for screwdriver
function smd_pot_flat(type) = type[5]; //! Flat at the back of the wiper
module smd_pot(type, value) { //! Draw an SMD pot
vitamin(str("smd_pot(", type[0], "): ", type[0], " package ", value));
vitamin(str("smd_pot(", type[0], ", \"", value, "\"): ", type[0], " package ", value));
size = smd_pot_size(type);
contacts = smd_pot_contacts(type);
@@ -601,7 +600,7 @@ function smd_qfp_pin_size(type) = type[5]; //! Pins dimensions
function smd_qfp_gullwing(type) = type[6]; //! Gullwing S, L, R1, R2
module smd_qfp(type, value) { //! Draw and SMD QFP package
vitamin(str("smd_qfp(", type[0], "): SMD chip: ", value, ", package : ", type[0]));
vitamin(str("smd_qfp(", type[0], ", \"", value, "\"): SMD chip: ", value, ", package : ", type[0]));
size = smd_qfp_body_size(type);
offset = size.z / 2 * tan(smd_qfp_slant(type));
@@ -652,3 +651,66 @@ module smd_qfp(type, value) { //! Draw and SMD QFP package
circle(r = pin.y, $fn = fn);
}
}
function smd_250V_fuse_size(type) = type[1]; //! Bounding box of the body
function smd_250V_fuse_z(type) = type[2]; //! Height of body above the PCB surface
function smd_250V_fuse_step(type) = type[3]; //! End cutout length, width and height
function smd_250V_fuse_base(type) = type[4]; //! Base length
module gcube(s) translate_z(s.z / 2) cube(s, center = true);
module smd_250V_fuse(type, value) { //! Draw an SMD mains fuse
size = smd_250V_fuse_size(type);
step = smd_250V_fuse_step(type);
base = smd_250V_fuse_base(type);
z = smd_250V_fuse_z(type);
vitamin(str("smd_250V_fuse(", type[0], ", \"", value, "\"): SMD fuse: ", type[0], " ", value));
color("LightYellow")
translate_z(z) {
gcube(base);
translate_z(base.z)
gcube([size.x - step.x * 2, size.y, size.z - base.z]);
for(end = [-1, 1], side = [-1,1]) {
translate([end * (size.x / 2 - step.x / 2), side * (size.y / 2 - step.y / 2)])
gcube(step);
translate([end * (size.x / 2 - step.x / 2 - eps), 0])
gcube([step.x, size.y, base.z]);
}
}
color(silver) {
contact_h = step.z - 0.2;
fuse_d = size.y - 2 * step.y;
for(end = [-1, 1])
translate([end * (size.x / 2 - step.x), 0, contact_h / 2])
rotate([90, 0, 0])
linear_extrude(size.y - 2 * step.y, center = true)
difference() {
rounded_square([step.x * 2, contact_h], 0.2, $fn = fn);
translate([-step.x * end, 0])
square([step.x * 2, contact_h], center = true);
}
translate_z(step.z - fuse_d / 2)
rotate([0, 90, 0])
linear_extrude(size.x - (2 * step.x - eps), center = true)
scale([1, size.y / fuse_d - eps])
rotate(90)
semi_circle(fuse_d / 2);
}
color("black")
translate_z(z + size.z)
linear_extrude(eps)
resize([(size.x - 2 * step.x) * 0.9, size.y / 2])
text(value, halign = "center", valign = "center");
}

View File

@@ -87,4 +87,8 @@ QFP50P1200X1200X160_64N = ["QFP50P1200X1200X160_64N", [10, 10, 1.6], 12, 64, 0.5
smd_qfps = [ QFP50P1200X1200X160_64N ];
OMT250 = ["OMT250", [11, 4.6, 3.3], 0.15, [1.9,0.5, 2.7], [5.5, 4.6, 0.5]];
smd_250V_fuses = [OMT250];
use <smd.scad>