diff --git a/readme.md b/readme.md index f203b23..27dc975 100644 --- a/readme.md +++ b/readme.md @@ -108,7 +108,7 @@ Axial components for PCBs. | 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. | -| `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) @@ -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, 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, 0, h = 5)` | Wire link 0.8mm x 8mm | Top @@ -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(RES0805, 1K)` | SMD resistor 0805 1K 0.125W | | 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_6mm)` | Square button 6mm | | 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 | | 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, 0, h = 5)` | Wire link 0.8mm x 8mm | Top @@ -3634,6 +3638,13 @@ Surface mount components for PCBs. | `smd_res_end_cap(type)` | End cap width | | `smd_res_power(type)` | Power rating in Watts | | `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 | Function | Description | @@ -3645,9 +3656,10 @@ Surface mount components for PCBs. ### Modules | 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_resistor(type, value)` | Draw an SMD resistor with specified value | +| `smd_sot(type, value)` | Draw an SMD transistor | ![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(RES0805, 10M)` | SMD resistor 0805 10M 0.125W | | 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 | Top diff --git a/tests/PCB.scad b/tests/PCB.scad index 9906c78..6334234 100644 --- a/tests/PCB.scad +++ b/tests/PCB.scad @@ -59,7 +59,7 @@ test_pcb = ["test_pcb", "Test PCB", [ [3, 3], [3, -3], [-3, 3], [-3, -3] ], // components [ - [ 20, -5, 180, "trimpot10"], + [ 20, -5, 180, "trimpot10"], [ 20, -15, 90, "trimpot10", true], [ 10, 2, 90, "smd_led", LED0805, "red"], [ 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], [ 28, 2, 90, "smd_cap", CAP0805, 1.0], [ 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], [ 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], [ 55, 22, 0, "vero_pin"], [ 55, 17, 0, "vero_pin", true], + [ 55, 9, 0, "link", 0, 5], [ 80, 9, 0, "link", inch(0.2), inch(0.4)], [ 80, 12, 0, "ax_res", res1_8, 1000000, 1, inch(0.1)], diff --git a/tests/SMDs.scad b/tests/SMDs.scad index e2b5e21..4932f4f 100644 --- a/tests/SMDs.scad +++ b/tests/SMDs.scad @@ -33,6 +33,11 @@ module smds() { layout([for(c = smd_capacitors) smd_cap_size(c).x], 1) let(c = smd_capacitors[$i]) 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) diff --git a/tests/axials.scad b/tests/axials.scad index ea3d430..1c3bc5f 100644 --- a/tests/axials.scad +++ b/tests/axials.scad @@ -28,6 +28,9 @@ module axials() { rotate(90) 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]) { pcb_grid(pcb, 2 * i + 2, 1 + [0, 0.5, 1.5][i]) rotate(90) diff --git a/tests/png/axials.png b/tests/png/axials.png index e9a4cef..a1422d5 100644 Binary files a/tests/png/axials.png and b/tests/png/axials.png differ diff --git a/tests/png/pcb.png b/tests/png/pcb.png index 7429831..6c393e0 100644 Binary files a/tests/png/pcb.png and b/tests/png/pcb.png differ diff --git a/tests/png/smds.png b/tests/png/smds.png index 4a904e3..fc6f55c 100644 Binary files a/tests/png/smds.png and b/tests/png/smds.png differ diff --git a/vitamins/axial.scad b/vitamins/axial.scad index 95b1734..9e4b106 100644 --- a/vitamins/axial.scad +++ b/vitamins/axial.scad @@ -23,27 +23,31 @@ include <../utils/core/core.scad> include <../utils/round.scad> -module wire_link(d, l, h = 1, tail = 3) { //! Draw a wire jumper link. - vitamin(str("wire_link(", d, ", ", l, arg(h, 1, "h"), arg(tail, 3, "tail"), "): Wire link ", d, "mm x ", l / inch(1), "\"")); +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 ? str(l / inch(1), "\"") : str(h + tail,"mm"))); r = d; $fn = 32; - color("silver") { - for(side = [-1, 1]) { - translate([side * l / 2, 0, -tail]) - cylinder(d = d, h = tail + h - r); + color("silver") + if(l) { + for(side = [-1, 1]) { + translate([side * l / 2, 0, -tail]) + cylinder(d = d, h = tail + h - r); - translate([side * (l / 2 - r), 0, h - r]) - rotate([90, 0, side * 90 - 90]) - rotate_extrude(angle = 90) - translate([r, 0]) - circle(d = d); + translate([side * (l / 2 - r), 0, h - r]) + rotate([90, 0, side * 90 - 90]) + rotate_extrude(angle = 90) + translate([r, 0]) + circle(d = d); + } + + translate_z(h) + rotate([0, 90, 0]) + cylinder(d = d, h = l - 2 * r, center = true); } - - translate_z(h) - rotate([0, 90, 0]) - cylinder(d = d, h = l - 2 * r, center = true); - } + else + translate_z(-tail) + cylinder(d = d, h = tail + h); } function ax_res_wattage(type) = type[1]; //! Power rating diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 5aad53d..ca5457c 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -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 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) { // Components that have a cutout parameter go in this section 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, "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_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, "terminal")) terminal_block(comp[5], comp[4]); } diff --git a/vitamins/smd.scad b/vitamins/smd.scad index b010347..671ec26 100644 --- a/vitamins/smd.scad +++ b/vitamins/smd.scad @@ -23,6 +23,7 @@ include <../utils/core/core.scad> use <../utils/tube.scad> +use <../utils/sweep.scad> function smd_led_size(type) = type[1]; //! Body 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); color("white") - translate([0, 0, size.z]) + translate_z(size.z) linear_extrude(eps) resize([(size.x - 2 * cap) * 0.75, size.y / 2]) 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_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); - 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); @@ -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]) 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"); + +} diff --git a/vitamins/smds.scad b/vitamins/smds.scad index 19950b3..c21a720 100644 --- a/vitamins/smds.scad +++ b/vitamins/smds.scad @@ -38,4 +38,9 @@ CAP1206 = ["CAP1206", [3.1, 1.6], 0.5]; 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