diff --git a/libtest.png b/libtest.png index 3623517..1fc6784 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/readme.md b/readme.md index 1162057..d411974 100644 --- a/readme.md +++ b/readme.md @@ -24,23 +24,24 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa Belts LEDs Rod Carriers Fillet Polyholes Blowers Leadnuts SCS_bearing_blocks Corner_block Hanging_hole Rounded_rectangle Bulldogs Light_strips SK_brackets Door_hinge Layout Sphere - Buttons Linear_bearings SSRs Door_latch Maths Teardrops - Cable_strips Mains_sockets Screws Fan_guard Offset - Circlips Meter Sealing_strip Fixing_block Quadrant - Components Microswitches Sheets Flat_hinge Round - DIP Microview Spades Foot Rounded_cylinder - D_connectors Modules Spools Handle Rounded_polygon - Displays Nuts Springs PCB_mount Sector - Extrusion_brackets O_ring Stepper_motors PSU_shroud Sweep - Extrusions Opengrab Swiss_clips Printed_box Thread - Fans PCB Toggles Ribbon_clamp Tube - Fuseholder PCBs Transformers SSR_shroud - Geared_steppers PSUs Tubings Screw_knob - Green_terminals Pillars Variacs Socket_box - Hot_ends Pin_headers Veroboard Strap_handle - Hygrometer Pulleys Washers - IECs Wire - Inserts Zipties + Buttons Linear_bearings SMDs Door_latch Maths Teardrops + Cable_strips Mains_sockets SSRs Fan_guard Offset + Circlips Meter Screws Fixing_block Quadrant + Components Microswitches Sealing_strip Flat_hinge Round + DIP Microview Sheets Foot Rounded_cylinder + D_connectors Modules Spades Handle Rounded_polygon + Displays Nuts Spools PCB_mount Sector + Extrusion_brackets O_ring Springs PSU_shroud Sweep + Extrusions Opengrab Stepper_motors Printed_box Thread + Fans PCB Swiss_clips Ribbon_clamp Tube + Fuseholder PCBs Toggles SSR_shroud + Geared_steppers PSUs Transformers Screw_knob + Green_terminals Pillars Tubings Socket_box + Hot_ends Pin_headers Variacs Strap_handle + Hygrometer Pulleys Veroboard + IECs Washers + Inserts Wire + Zipties --- @@ -2053,6 +2054,7 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 1 | ```ax_res(res1_4, 10000)``` | Resistor 10000 Ohms 5% 0.25W | | 1 | ```ax_res(res1_2, 100000)``` | Resistor 100000 Ohms 5% 0.5W | | 1 | ```ax_res(res1_8, 1e+6, tol = 1)``` | Resistor 1e+6 Ohms 1% 0.125W | +| 1 | ```smd_led(LED0805, red)``` | SMD LED 0805 red | | 1 | ```square_button(button_6mm)``` | Square button 6mm | | 1 | ```pcb(TMC2130)``` | TMC2130 | | 1 | ```green_terminal(gt_5p08, 2)``` | Terminal block 2 way 0.2" | @@ -2987,6 +2989,46 @@ SK shaft support brackets | 6 | ```washer(M5_washer)``` | Washer M5 x 10mm x 1mm | +Top + +--- + +## SMDs +Surface mount components for PCBs. + + +[vitamins/smds.scad](vitamins/smds.scad) Object definitions. + +[vitamins/smd.scad](vitamins/smd.scad) Implementation. + +[tests/SMDs.scad](tests/SMDs.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| ```smd_led_lens(type)``` | Lens length width and height | +| ```smd_led_size(type)``` | Body length, width and height | + +### Functions +| Function | Description | +|:--- |:--- | +| ```smd_100th(x)``` | Convert dimesion to 1/100" notation | +| ```smd_led_height(type)``` | Total height | +| ```smd_size(size)``` | Convert size to 1/100" notation | + +### Modules +| Module | Description | +|:--- |:--- | +| ```smd_led(type, colour, cutout)``` | Draw an SMD LED with specified ```colour``` | + +![smds](tests/png/smds.png) + +### Vitamins +| Qty | Module call | BOM entry | +| ---:|:--- |:---| +| 1 | ```smd_led(LED0805, green)``` | SMD LED 0805 green | + + Top --- diff --git a/tests/PCB.scad b/tests/PCB.scad index a2e47a1..2a9dc63 100644 --- a/tests/PCB.scad +++ b/tests/PCB.scad @@ -21,6 +21,7 @@ include <../vitamins/microswitches.scad> include <../vitamins/d_connectors.scad> include <../vitamins/leds.scad> include <../vitamins/axials.scad> +include <../vitamins/smds.scad> use <../vitamins/pcb.scad> @@ -58,7 +59,7 @@ test_pcb = ["TestPCB", "Test PCB", [ [ 20, -5, 180, "trimpot10"], [ 20, -15, 0, "trimpot10", true], - + [ 10, 2, 0, "smd_led", LED0805, "red"], [ 10, 10, 0, "2p54header", 4, 1], [ 25, 10, 0, "2p54header", 5, 1, undef, "blue" ], [ 10, 20, 0, "2p54boxhdr", 4, 2], diff --git a/tests/SMDs.scad b/tests/SMDs.scad new file mode 100644 index 0000000..a999559 --- /dev/null +++ b/tests/SMDs.scad @@ -0,0 +1,29 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// 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 . +// +include <../utils/core/core.scad> +use <../utils/layout.scad> + +include <../vitamins/smds.scad> + +module smds() + layout([for(l = smd_leds) smd_led_size(l).x], 1) + smd_led(smd_leds[$i], ["green", "blue", "red"][$i % 3]); + +if($preview) + smds(); diff --git a/tests/png/pcb.png b/tests/png/pcb.png index 889c849..5610d28 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 5d451fe..064761d 100644 Binary files a/tests/png/pcbs.png and b/tests/png/pcbs.png differ diff --git a/tests/png/smds.png b/tests/png/smds.png new file mode 100644 index 0000000..fecae4f Binary files /dev/null and b/tests/png/smds.png differ diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index 17f5ae6..53020ec 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -36,6 +36,7 @@ use use use use +use function pcb_name(type) = type[1]; //! Description function pcb_length(type) = type[2]; //! Length @@ -910,6 +911,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon if(show(comp, "pdip")) pdip(comp[4], comp[5], param(6, false), param(7, inch(0.3))); if(show(comp, "ax_res")) ax_res(comp[4], comp[5], param(6, 5), param(7, 0)); if(show(comp, "molex_usb_Ax2")) molex_usb_Ax2(cutouts); + if(show(comp, "smd_led")) smd_led(comp[4], comp[5], cutouts); } } diff --git a/vitamins/pcbs.scad b/vitamins/pcbs.scad index 08b826b..c6c6d93 100644 --- a/vitamins/pcbs.scad +++ b/vitamins/pcbs.scad @@ -20,6 +20,7 @@ include include include include +include // // l w t r h l c b h @@ -348,6 +349,8 @@ MT3608 = ["MT3608", "MT3608 boost converter module", 37, 17, 1.2, 2, 1.5, TP4056 = ["TP4056", "TP4056 Li-lon Battery charger module", 26.2, 17.5, 1.0, 0, 1.0, [2.4, 2.4], "#2140BE", false, [[1.67, 1.8], [1.67, -1.8], [-1.67, 1.8], [-1.67, -1.8], [-1.67, -4.98], [-1.67, 4.98]], [ [ 2, 17.5 / 2, 180, "usb_uA"], + [ 7, -2 , 0, "smd_led", LED0805, "red"], + [ 11, -2 , 0, "smd_led", LED0805, "blue"], ]]; @@ -358,6 +361,8 @@ WD2002SJ = ["WD2002SJ", "WD2002SJ Buck Boost DC-DC converter", 78, 47, 1.6, 0, 3 [ -25.5, 3.1, 0, "trimpot10", true], [ 30.5, 3.1, 0, "trimpot10", true], [ 41.5, 3.1, 0, "trimpot10", true], + [ -10.5, 1.5, 0, "smd_led", LED0805, "blue"], + [ 16, 1.8, 0, "smd_led", LED0805, "red"], ], []]; diff --git a/vitamins/smd.scad b/vitamins/smd.scad new file mode 100644 index 0000000..4a7299c --- /dev/null +++ b/vitamins/smd.scad @@ -0,0 +1,80 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// 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 . +// + +// +//! Surface mount components for PCBs. +// +include <../utils/core/core.scad> + +use <../utils/tube.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 +function smd_led_height(type) = //! Total height + smd_led_size(type).z + smd_led_lens(type).z; + +function smd_100th(x) = //! Convert dimesion to 1/100" notation + let(s = str(round(x / inch(0.01)))) + len(s) < 2 ? str("0", s) : s; + +function smd_size(size) = //! Convert size to 1/100" notation + str(smd_100th(size.x), smd_100th(size.y)); + +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)); + + lens = smd_led_lens(type); + r = size.y * 0.32; + $fn = 32; + + if(cutout) + cylinder(d = 2.85, h = 100); // For lightguide made from transparent PLA filament + else { + color("white") + linear_extrude(size.z) + difference() { + square([size.x, size.y], center = true); + + for(end = [-1, 1]) + translate([end * size.x / 2, 0]) + circle(r); + } + + color(gold) + linear_extrude(size.z) + intersection() { + square([size.x, size.y], center = true); + + for(end = [-1, 1]) + translate([end * size.x / 2, 0]) + ring(or = r, ir = r / 2); + } + + color(colour, 0.9) + translate_z(size.z) + hull() { + cube([lens.x, lens.y, eps], center = true); + + slant = lens.z * tan(15); + translate_z(lens.z / 2) + cube([lens.x - slant, lens.y - slant, lens.z], center = true); + } + } +} diff --git a/vitamins/smds.scad b/vitamins/smds.scad new file mode 100644 index 0000000..e16082d --- /dev/null +++ b/vitamins/smds.scad @@ -0,0 +1,28 @@ +// +// NopSCADlib Copyright Chris Palmer 2020 +// 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 . +// + +// +//! Axial components +// + +LED0805 = ["LED0805", [2, 1.25, 0.46], [1.4, 1.25, 0.54]]; + +smd_leds = [LED0805]; + +use