diff --git a/readme.md b/readme.md index c4a5088..80016ae 100644 --- a/readme.md +++ b/readme.md @@ -2126,7 +2126,11 @@ 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(LED0603, orange)``` | SMD LED 0603 orange | | 1 | ```smd_led(LED0805, red)``` | SMD LED 0805 red | +| 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 | ```square_button(button_6mm)``` | Square button 6mm | | 1 | ```pcb(TMC2130)``` | TMC2130 | | 1 | ```green_terminal(gt_5p08, 2)``` | Terminal block 2 way 0.2" | @@ -3081,11 +3085,14 @@ Surface mount components for PCBs. |:--- |:--- | | ```smd_led_lens(type)``` | Lens length width and height | | ```smd_led_size(type)``` | Body length, width and height | +| ```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 | ### Functions | Function | Description | |:--- |:--- | -| ```smd_100th(x)``` | Convert dimesion to 1/100" notation | +| ```smd_100th(x)``` | Convert dimension to 1/100" notation | | ```smd_led_height(type)``` | Total height | | ```smd_size(size)``` | Convert size to 1/100" notation | @@ -3093,13 +3100,18 @@ Surface mount components for PCBs. | Module | Description | |:--- |:--- | | ```smd_led(type, colour, cutout)``` | Draw an SMD LED with specified ```colour``` | +| ```smd_resistor(type, value)``` | Draw an SMD resistor with specified value | ![smds](tests/png/smds.png) ### Vitamins | Qty | Module call | BOM entry | | ---:|:--- |:---| -| 1 | ```smd_led(LED0805, green)``` | SMD LED 0805 green | +| 1 | ```smd_led(LED0603, green)``` | SMD LED 0603 green | +| 1 | ```smd_led(LED0805, blue)``` | SMD LED 0805 blue | +| 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 | Top diff --git a/tests/PCB.scad b/tests/PCB.scad index ac2d8f3..9c66844 100644 --- a/tests/PCB.scad +++ b/tests/PCB.scad @@ -58,8 +58,12 @@ test_pcb = ["TestPCB", "Test PCB", // components [ [ 20, -5, 180, "trimpot10"], - [ 20, -15, 0, "trimpot10", true], - [ 10, 2, 0, "smd_led", LED0805, "red"], + [ 20, -15, 90, "trimpot10", true], + [ 10, 2, 90, "smd_led", LED0805, "red"], + [ 13, 2, 90, "smd_led", LED0603, "orange"], + [ 16, 2, 90, "smd_res", RES1206, "1K"], + [ 19, 2, 90, "smd_res", RES0805, "1K"], + [ 22, 2, 90, "smd_res", RES0603, "1K"], [ 10, 10, 0, "2p54header", 4, 1], [ 25, 10, 0, "2p54header", 5, 1, false, "blue" ], [ 10, 20, 0, "2p54boxhdr", 4, 2], diff --git a/tests/SMDs.scad b/tests/SMDs.scad index a999559..3c4f083 100644 --- a/tests/SMDs.scad +++ b/tests/SMDs.scad @@ -21,9 +21,14 @@ 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]); +module smds() { + layout([for(r = smd_resistors) smd_res_size(r).x], 1) + smd_resistor(smd_resistors[$i], ["1R0", "10M", "100K"][$i % 3]); + + translate([0, 3]) + 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 5610d28..12c24f9 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 fecae4f..b6a3f1a 100644 Binary files a/tests/png/smds.png and b/tests/png/smds.png differ diff --git a/vitamins/pcb.scad b/vitamins/pcb.scad index e3ba72a..e41b14d 100644 --- a/vitamins/pcb.scad +++ b/vitamins/pcb.scad @@ -924,6 +924,7 @@ module pcb_component(comp, cutouts = false, angle = undef) { //! Draw pcb compon if(show(comp, "jst_xh")) jst_xh_header(jst_xh_header, comp[4], param(5, false), param(6, "white"), param(7, undef)); if(show(comp, "potentiometer")) potentiometer(param(4, 5), param(5, 9)); 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]); } } } diff --git a/vitamins/smd.scad b/vitamins/smd.scad index 3a73ae7..ace1649 100644 --- a/vitamins/smd.scad +++ b/vitamins/smd.scad @@ -29,7 +29,7 @@ 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 +function smd_100th(x) = //! Convert dimension to 1/100" notation let(s = str(round(x / inch(0.01)))) len(s) < 2 ? str("0", s) : s; @@ -78,3 +78,33 @@ module smd_led(type, colour, cutout) { //! Draw an SMD LED with specified ```col } } } + +function smd_res_size(type) = type[1]; //! Body length, width and height +function smd_res_end_cap(type) = type[2]; //! End cap width +function smd_res_power(type) = type[3]; //! Power rating in Watts + +module smd_resistor(type, value) { //! Draw an SMD resistor with specified value + size = smd_res_size(type); + vitamin(str("smd_resistor(", type[0], ", ", value, "): SMD resistor ", smd_size(size), " ", value, " ", smd_res_power(type), "W")); + + t = 0.04; + cap = smd_res_end_cap(type); + color("white") + translate_z(size.z / 2) + cube([size.x - 2 * t, size.y, size.z - 2 * t], center = true); + + color(grey(20)) + translate_z(size.z - t) + cube([size.x - 2 * cap, size.y, eps], center = true); + + color(silver) + for(end = [-1, 1]) + translate([end * (size.x / 2 - cap / 2), 0, size.z / 2]) + cube([cap, size.y - 2 * eps, size.z], center = true); + + color("white") + translate([0, 0, size.z]) + linear_extrude(eps) + resize([(size.x - 2 * cap) * 0.75, size.y / 2]) + text(value, halign = "center", valign = "center"); +} diff --git a/vitamins/smds.scad b/vitamins/smds.scad index e16082d..1af2327 100644 --- a/vitamins/smds.scad +++ b/vitamins/smds.scad @@ -18,11 +18,18 @@ // // -//! Axial components +//! SMD components // -LED0805 = ["LED0805", [2, 1.25, 0.46], [1.4, 1.25, 0.54]]; +LED0603 = ["LED0603", [1.6, 0.8, 0.18], [1.0, 0.8, 0.42]]; +LED0805 = ["LED0805", [2.0, 1.25, 0.46], [1.4, 1.25, 0.54]]; -smd_leds = [LED0805]; +smd_leds = [LED0603, LED0805]; + +RES0603 = ["RES0603", [1.6, 0.8, 0.45], 0.3, 1/10]; +RES0805 = ["RES0805", [2.0, 1.2, 0.45], 0.4, 1/8]; +RES1206 = ["RES1206", [3.1, 1.6, 0.6], 0.5, 1/4]; + +smd_resistors = [RES0603, RES0805, RES1206]; use