1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-31 11:01:55 +02:00

Added SOT23 and SOT223 SMD packages.

smd_capacitors can now have a value.
Wire links can now have zero length to create a vertical wire.
This commit is contained in:
Chris Palmer
2022-02-09 21:50:10 +00:00
parent 00d6efc315
commit 055b4e7102
11 changed files with 108 additions and 24 deletions

View File

@@ -108,7 +108,7 @@ Axial components for PCBs.
| Module | Description | | Module | Description |
|:--- |:--- | |:--- |:--- |
| `ax_res(type, value, tol = 5, pitch = 0)` | Through hole axial resistor. If `pitch` is zero the minimum is used. If below the minimum the resistor is placed vertical. | | `ax_res(type, value, tol = 5, pitch = 0)` | Through hole axial resistor. If `pitch` is zero the minimum is used. If below the minimum the resistor is placed vertical. |
| `wire_link(d, l, h = 1, tail = 3)` | Draw a wire jumper link. | | `wire_link(d, l, h = 1, tail = 3)` | Draw a wire jumper link. If `l` is zero then a vertical wire is drawn. |
![axials](tests/png/axials.png) ![axials](tests/png/axials.png)
@@ -123,6 +123,7 @@ Axial components for PCBs.
| 1 | `ax_res(res1_2, 8200)` | Resistor 8200 Ohms 5% 0.5W | | 1 | `ax_res(res1_2, 8200)` | Resistor 8200 Ohms 5% 0.5W |
| 1 | `ax_res(res1_2, 8250, tol = 1)` | Resistor 8250 Ohms 1% 0.5W | | 1 | `ax_res(res1_2, 8250, tol = 1)` | Resistor 8250 Ohms 1% 0.5W |
| 1 | `wire_link(0.8, 10.16)` | Wire link 0.8mm x 0.4" | | 1 | `wire_link(0.8, 10.16)` | Wire link 0.8mm x 0.4" |
| 1 | `wire_link(0.8, 0, h = 5)` | Wire link 0.8mm x 8mm |
<a href="#top">Top</a> <a href="#top">Top</a>
@@ -2441,6 +2442,8 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| 1 | `smd_resistor(RES0603, 1K)` | SMD resistor 0603 1K 0.1W | | 1 | `smd_resistor(RES0603, 1K)` | SMD resistor 0603 1K 0.1W |
| 1 | `smd_resistor(RES0805, 1K)` | SMD resistor 0805 1K 0.125W | | 1 | `smd_resistor(RES0805, 1K)` | SMD resistor 0805 1K 0.125W |
| 1 | `smd_resistor(RES1206, 1K)` | SMD resistor 1206 1K 0.25W | | 1 | `smd_resistor(RES1206, 1K)` | SMD resistor 1206 1K 0.25W |
| 1 | `smd_sot(SOT223)` | SOT223 package LM117 |
| 1 | `smd_sot(SOT23)` | SOT23 package 2N7000 |
| 1 | `square_button(button_4p5mm)` | Square button 4.5mm | | 1 | `square_button(button_4p5mm)` | Square button 4.5mm |
| 1 | `square_button(button_6mm)` | Square button 6mm | | 1 | `square_button(button_6mm)` | Square button 6mm |
| 1 | `pcb(TMC2130)` | TMC2130 | | 1 | `pcb(TMC2130)` | TMC2130 |
@@ -2457,6 +2460,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o
| 2 | `vero_pin()` | Vero board pin | | 2 | `vero_pin()` | Vero board pin |
| 1 | `wire_link(0.8, 5.08, h = 10.16)` | Wire link 0.8mm x 0.2" | | 1 | `wire_link(0.8, 5.08, h = 10.16)` | Wire link 0.8mm x 0.2" |
| 1 | `wire_link(0.8, 10.16)` | Wire link 0.8mm x 0.4" | | 1 | `wire_link(0.8, 10.16)` | Wire link 0.8mm x 0.4" |
| 1 | `wire_link(0.8, 0, h = 5)` | Wire link 0.8mm x 8mm |
<a href="#top">Top</a> <a href="#top">Top</a>
@@ -3634,6 +3638,13 @@ Surface mount components for PCBs.
| `smd_res_end_cap(type)` | End cap width | | `smd_res_end_cap(type)` | End cap width |
| `smd_res_power(type)` | Power rating in Watts | | `smd_res_power(type)` | Power rating in Watts |
| `smd_res_size(type)` | Body length, width and height | | `smd_res_size(type)` | Body length, width and height |
| `smd_sot_lead_pitch(type)` | Lead pitch |
| `smd_sot_lead_size(type)` | Lead width, foot depth, lead thickness |
| `smd_sot_lead_span(type)` | Total span of leads |
| `smd_sot_lead_z(type)` | Top of lead frame from top |
| `smd_sot_size(type)` | Body length, width and height |
| `smd_sot_tab_width(type)` | The wide lead at the top |
| `smd_sot_z(type)` | Height above PCB surface |
### Functions ### Functions
| Function | Description | | Function | Description |
@@ -3645,9 +3656,10 @@ Surface mount components for PCBs.
### Modules ### Modules
| Module | Description | | Module | Description |
|:--- |:--- | |:--- |:--- |
| `smd_capacitor(type, height)` | Draw an SMD capacitor with specified height | | `smd_capacitor(type, height, value = undef)` | Draw an SMD capacitor with specified height |
| `smd_led(type, colour, cutout)` | Draw an SMD LED with specified `colour` | | `smd_led(type, colour, cutout)` | Draw an SMD LED with specified `colour` |
| `smd_resistor(type, value)` | Draw an SMD resistor with specified value | | `smd_resistor(type, value)` | Draw an SMD resistor with specified value |
| `smd_sot(type, value)` | Draw an SMD transistor |
![smds](tests/png/smds.png) ![smds](tests/png/smds.png)
@@ -3662,6 +3674,8 @@ Surface mount components for PCBs.
| 1 | `smd_resistor(RES0603, 1R0)` | SMD resistor 0603 1R0 0.1W | | 1 | `smd_resistor(RES0603, 1R0)` | SMD resistor 0603 1R0 0.1W |
| 1 | `smd_resistor(RES0805, 10M)` | SMD resistor 0805 10M 0.125W | | 1 | `smd_resistor(RES0805, 10M)` | SMD resistor 0805 10M 0.125W |
| 1 | `smd_resistor(RES1206, 100K)` | SMD resistor 1206 100K 0.25W | | 1 | `smd_resistor(RES1206, 100K)` | SMD resistor 1206 100K 0.25W |
| 1 | `smd_sot(SOT223)` | SOT223 package FZT851 |
| 1 | `smd_sot(SOT23)` | SOT23 package 2N7000 |
<a href="#top">Top</a> <a href="#top">Top</a>

View File

@@ -59,7 +59,7 @@ test_pcb = ["test_pcb", "Test PCB",
[ [3, 3], [3, -3], [-3, 3], [-3, -3] ], [ [3, 3], [3, -3], [-3, 3], [-3, -3] ],
// components // components
[ [
[ 20, -5, 180, "trimpot10"], [ 20, -5, 180, "trimpot10"],
[ 20, -15, 90, "trimpot10", true], [ 20, -15, 90, "trimpot10", true],
[ 10, 2, 90, "smd_led", LED0805, "red"], [ 10, 2, 90, "smd_led", LED0805, "red"],
[ 13, 2, 90, "smd_led", LED0603, "orange"], [ 13, 2, 90, "smd_led", LED0603, "orange"],
@@ -69,6 +69,8 @@ test_pcb = ["test_pcb", "Test PCB",
[ 25, 2, 90, "smd_cap", CAP1206, 1.5], [ 25, 2, 90, "smd_cap", CAP1206, 1.5],
[ 28, 2, 90, "smd_cap", CAP0805, 1.0], [ 28, 2, 90, "smd_cap", CAP0805, 1.0],
[ 31, 2, 90, "smd_cap", CAP0603, 0.7], [ 31, 2, 90, "smd_cap", CAP0603, 0.7],
[ 16, 6, -90, "smd_sot", SOT23, "2N7000"],
[ 28, 20, -90, "smd_sot", SOT223, "LM117"],
[ 10, 10, 0, "2p54header", 4, 1], [ 10, 10, 0, "2p54header", 4, 1],
[ 25, 10, 0, "2p54header", 5, 1, false, "blue" ], [ 25, 10, 0, "2p54header", 5, 1, false, "blue" ],
@@ -99,6 +101,7 @@ test_pcb = ["test_pcb", "Test PCB",
[ 65, 22, 0, "ax_res", res1_2, 100000], [ 65, 22, 0, "ax_res", res1_2, 100000],
[ 55, 22, 0, "vero_pin"], [ 55, 22, 0, "vero_pin"],
[ 55, 17, 0, "vero_pin", true], [ 55, 17, 0, "vero_pin", true],
[ 55, 9, 0, "link", 0, 5],
[ 80, 9, 0, "link", inch(0.2), inch(0.4)], [ 80, 9, 0, "link", inch(0.2), inch(0.4)],
[ 80, 12, 0, "ax_res", res1_8, 1000000, 1, inch(0.1)], [ 80, 12, 0, "ax_res", res1_8, 1000000, 1, inch(0.1)],

View File

@@ -33,6 +33,11 @@ module smds() {
layout([for(c = smd_capacitors) smd_cap_size(c).x], 1) layout([for(c = smd_capacitors) smd_cap_size(c).x], 1)
let(c = smd_capacitors[$i]) let(c = smd_capacitors[$i])
smd_capacitor(c, smd_cap_size(c).y * 0.8); smd_capacitor(c, smd_cap_size(c).y * 0.8);
translate([0, 12])
layout([for(s = smd_sots) smd_sot_size(s).x], 1)
let(s = smd_sots[$i])
smd_sot(s, ["2N7000", "FZT851"][$i]);
} }
if($preview) if($preview)

View File

@@ -28,6 +28,9 @@ module axials() {
rotate(90) rotate(90)
wire_link(0.8, inch(0.4)); wire_link(0.8, inch(0.4));
pcb_grid(pcb, 0, 7)
wire_link(0.8, 0, 5);
for(i = [0 : len(ax_resistors) - 1]) { for(i = [0 : len(ax_resistors) - 1]) {
pcb_grid(pcb, 2 * i + 2, 1 + [0, 0.5, 1.5][i]) pcb_grid(pcb, 2 * i + 2, 1 + [0, 0.5, 1.5][i])
rotate(90) rotate(90)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View File

@@ -23,27 +23,31 @@
include <../utils/core/core.scad> include <../utils/core/core.scad>
include <../utils/round.scad> include <../utils/round.scad>
module wire_link(d, l, h = 1, tail = 3) { //! Draw a wire jumper link. module wire_link(d, l, h = 1, tail = 3) { //! Draw a wire jumper link. If `l` is zero then a vertical wire is drawn.
vitamin(str("wire_link(", d, ", ", l, arg(h, 1, "h"), arg(tail, 3, "tail"), "): Wire link ", d, "mm x ", l / inch(1), "\"")); vitamin(str("wire_link(", d, ", ", l, arg(h, 1, "h"), arg(tail, 3, "tail"), "): Wire link ", d, "mm x ", l ? str(l / inch(1), "\"") : str(h + tail,"mm")));
r = d; r = d;
$fn = 32; $fn = 32;
color("silver") { color("silver")
for(side = [-1, 1]) { if(l) {
translate([side * l / 2, 0, -tail]) for(side = [-1, 1]) {
cylinder(d = d, h = tail + h - r); translate([side * l / 2, 0, -tail])
cylinder(d = d, h = tail + h - r);
translate([side * (l / 2 - r), 0, h - r]) translate([side * (l / 2 - r), 0, h - r])
rotate([90, 0, side * 90 - 90]) rotate([90, 0, side * 90 - 90])
rotate_extrude(angle = 90) rotate_extrude(angle = 90)
translate([r, 0]) translate([r, 0])
circle(d = d); circle(d = d);
}
translate_z(h)
rotate([0, 90, 0])
cylinder(d = d, h = l - 2 * r, center = true);
} }
else
translate_z(h) translate_z(-tail)
rotate([0, 90, 0]) cylinder(d = d, h = tail + h);
cylinder(d = d, h = l - 2 * r, center = true);
}
} }
function ax_res_wattage(type) = type[1]; //! Power rating function ax_res_wattage(type) = type[1]; //! Power rating

View File

@@ -1032,7 +1032,7 @@ module block(size, colour, makes_cutout, cutouts) //! Draw a coloured cube to re
module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb component from description module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb component from description
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 && !is_undef(comp[n]) ? comp[n] : default;
rotate(comp.z) { rotate(comp.z) {
// Components that have a cutout parameter go in this section // Components that have a cutout parameter go in this section
if(show(comp, "2p54header")) let($show_plugs = show_plugs && param(9, true)) if(show(comp, "2p54header")) let($show_plugs = show_plugs && param(9, true))
@@ -1087,7 +1087,8 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon
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, "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, "buzzer")) buzzer(param(4, 9), param(5, 12), param(6, grey(20)));
if(show(comp, "smd_res")) smd_resistor(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]); if(show(comp, "smd_cap")) smd_capacitor(comp[4], comp[5], param(6, undef));
if(show(comp, "smd_sot")) smd_sot(comp[4], comp[5]);
if(show(comp, "vero_pin")) vero_pin(param(4, false)); if(show(comp, "vero_pin")) vero_pin(param(4, false));
if(show(comp, "terminal")) terminal_block(comp[5], comp[4]); if(show(comp, "terminal")) terminal_block(comp[5], comp[4]);
} }

View File

@@ -23,6 +23,7 @@
include <../utils/core/core.scad> include <../utils/core/core.scad>
use <../utils/tube.scad> use <../utils/tube.scad>
use <../utils/sweep.scad>
function smd_led_size(type) = type[1]; //! Body length, width and height function smd_led_size(type) = type[1]; //! Body length, width and height
function smd_led_lens(type) = type[2]; //! Lens length width and height function smd_led_lens(type) = type[2]; //! Lens length width and height
@@ -104,7 +105,7 @@ module smd_resistor(type, value) { //! Draw an SMD resistor with specified value
cube([cap, size.y - 2 * eps, size.z], center = true); cube([cap, size.y - 2 * eps, size.z], center = true);
color("white") color("white")
translate([0, 0, size.z]) translate_z(size.z)
linear_extrude(eps) linear_extrude(eps)
resize([(size.x - 2 * cap) * 0.75, size.y / 2]) resize([(size.x - 2 * cap) * 0.75, size.y / 2])
text(value, halign = "center", valign = "center"); text(value, halign = "center", valign = "center");
@@ -113,9 +114,9 @@ module smd_resistor(type, value) { //! Draw an SMD resistor with specified value
function smd_cap_size(type) = type[1]; //! Body length, width function smd_cap_size(type) = type[1]; //! Body length, width
function smd_cap_end_cap(type) = type[2]; //! End cap width function smd_cap_end_cap(type) = type[2]; //! End cap width
module smd_capacitor(type, height) { //! Draw an SMD capacitor with specified height module smd_capacitor(type, height, value = undef) { //! Draw an SMD capacitor with specified height
size = smd_cap_size(type); size = smd_cap_size(type);
vitamin(str("smd_capacitor(", type[0], "): SMD capacitor ", smd_size(size))); vitamin(str("smd_capacitor(", type[0], "): SMD capacitor ", smd_size(size), !is_undef(value) ? str(" ", value) : ""));
cap = smd_cap_end_cap(type); cap = smd_cap_end_cap(type);
@@ -129,3 +130,51 @@ module smd_capacitor(type, height) { //! Draw an SMD capacitor with specified he
translate([end * (size.x / 2 - cap / 2), 0, height / 2]) translate([end * (size.x / 2 - cap / 2), 0, height / 2])
cube([cap, size.y - 2 * eps, height], center = true); cube([cap, size.y - 2 * eps, height], center = true);
} }
function smd_sot_size(type) = type[1]; //! Body length, width and height
function smd_sot_z(type) = type[2]; //! Height above PCB surface
function smd_sot_lead_z(type) = type[3]; //! Top of lead frame from top
function smd_sot_lead_pitch(type) = type[4]; //! Lead pitch
function smd_sot_lead_span(type) = type[5]; //! Total span of leads
function smd_sot_lead_size(type) = type[6]; //! Lead width, foot depth, lead thickness
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));
size = smd_sot_size(type);
z0 = smd_sot_z(type);
z2 = z0 + size.z;
z1 = z2 - smd_sot_lead_z(type);
slant = 7; //! 7 degree body draft angle
pitch = smd_sot_lead_pitch(type);
span = smd_sot_lead_span(type);
leads = floor(size.x / pitch) + 1;
ls = smd_sot_lead_size(type);
r = ls.z;
gullwing = rounded_path([[0, 0, ls.z / 2], [0, ls.y - ls.z, ls.z / 2], r, [0, ls.y -ls.z + z1 - ls.z, z1 - ls.z / 2], r, [0, span / 2, z1 - ls.z / 2]]);
color(grey(20))
hull()
for(z = [z0, z1, z2], inset = abs(z - z1) * tan(slant))
translate_z(z)
cube([size.x - 2 * inset, size.y - 2 * inset, eps], center = true);
color(silver) {
for(i = [0 : leads - 1])
translate([i * pitch - size.x / 2 + (size.x - (leads - 1) * pitch) / 2, -span / 2])
sweep(gullwing, rectangle_points(ls.x, ls.z));
rotate(180)
translate([0, -span / 2])
sweep(gullwing, rectangle_points(smd_sot_tab_width(type), ls.z));
}
color("white")
translate_z(z0 + size.z)
linear_extrude(eps)
resize([size.x - 4 * (z2 - z1) * tan(slant), size.y / 2])
text(value, halign = "center", valign = "center");
}

View File

@@ -38,4 +38,9 @@ CAP1206 = ["CAP1206", [3.1, 1.6], 0.5];
smd_capacitors = [CAP0603, CAP0805, CAP1206]; smd_capacitors = [CAP0603, CAP0805, CAP1206];
SOT23 = ["SOT23", [3, 1.4, 1.0], 0.05, 0.66, 1.9, 2.6, [0.4, 0.45, 0.15], 0.4];
SOT223 = ["SOT223", [6.5, 3.5, 1.6], 0.05, 0.89, 2.3, 7.0, [0.7, 0.95, 0.25], 3];
smd_sots = [SOT23, SOT223];
use <smd.scad> use <smd.scad>