diff --git a/lib.scad b/lib.scad index 05f6efc..50f8c39 100644 --- a/lib.scad +++ b/lib.scad @@ -60,6 +60,7 @@ include include include include +include use use diff --git a/libtest.png b/libtest.png index 0c69201..ddbeec6 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index 3af711a..5605e20 100644 --- a/libtest.scad +++ b/libtest.scad @@ -40,6 +40,7 @@ use use use use +use use use use @@ -252,6 +253,9 @@ components_y = toggles_y + 40; translate([x2, leds_y]) leds(); +translate([x2 + 40, leds_y]) + ldrs(); + translate([x2 + 8, carriers_y]) carriers(); diff --git a/readme.md b/readme.md index d122006..04b9c23 100644 --- a/readme.md +++ b/readme.md @@ -35,16 +35,17 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa Iecs Spades Screw_knob Tube Inserts Spools Socket_box Jack Springs Ssr_shroud - Leadnuts Ssrs Strap_handle - Leds Stepper_motors - Light_strips Toggles - Linear_bearings Transformers - Mains_sockets Tubings - Meter Variacs - Microswitches Veroboard - Microview Washers - Modules Wire - Nuts Zipties + Ldrs Ssrs Strap_handle + Leadnuts Stepper_motors + Leds Toggles + Light_strips Transformers + Linear_bearings Tubings + Mains_sockets Variacs + Meter Veroboard + Microswitches Washers + Microview Wire + Modules Zipties + Nuts --- @@ -951,6 +952,47 @@ E.g. a "brown" socket for mains live needs to be displayed as "sienna" to look r | 1 | ```jack_4mm_shielded("brown", 3, "sienna")``` | 4mm shielded jack socket brown | +Top + +--- + +## Ldrs +Light dependent resistors. + +Larger ones seem to have both a higher dark resistance and a lower bright light resistance. + + +[vitamins/ldrs.scad](vitamins/ldrs.scad) Object definitions. + +[vitamins/ldr.scad](vitamins/ldr.scad) Implementation. + +[tests/ldrs.scad](tests/ldrs.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| ```ldr_active(type)``` | The active width | +| ```ldr_description(type)``` | Description | +| ```ldr_diameter(type)``` | The diameter of the round bit | +| ```ldr_lead_d(type)``` | The lead diameter | +| ```ldr_pitch(type)``` | Pitch between the leads | +| ```ldr_thickness(type)``` | Thickness | +| ```ldr_width(type)``` | Across the flats | + +### Modules +| Module | Description | +|:--- |:--- | +| ```LDR(type, lead_length = 3)``` | Draw an LDR, can specify the lead length | + +![ldrs](tests/png/ldrs.png) + +### Vitamins +| Qty | Module call | BOM entry | +| ---:|:--- |:---| +| 1 | ```ldr(large_ldr)``` | Light dependent resistor | +| 1 | ```ldr(small_ldr)``` | Light dependent resistor | + + Top --- diff --git a/tests/ldrs.scad b/tests/ldrs.scad new file mode 100644 index 0000000..a3139ed --- /dev/null +++ b/tests/ldrs.scad @@ -0,0 +1,27 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// 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 <../vitamins/ldrs.scad> + +use <../utils/layout.scad> + +module ldrs() + layout([for(l = ldrs) ldr_diameter(l)], 5) + LDR(ldrs[$i]); + +ldrs(); diff --git a/vitamins/insert.scad b/vitamins/insert.scad index 5cdd014..e9388c1 100644 --- a/vitamins/insert.scad +++ b/vitamins/insert.scad @@ -108,7 +108,7 @@ module insert_boss(type, z, wall = 2 * extrusion_width) { //! Make a boss to tak } } -module insert_lug(insert, wall, side, counter_bore = 0) { +module insert_lug(insert, wall, side, counter_bore = 0) { //! Make a flying insert lug, see [ssr_shroud](#Ssr_shroud) boss_r = insert_boss_radius(insert, wall); boss_h = insert_hole_length(insert); boss_h2 = boss_h + counter_bore; diff --git a/vitamins/ldr.scad b/vitamins/ldr.scad new file mode 100644 index 0000000..5bd20ec --- /dev/null +++ b/vitamins/ldr.scad @@ -0,0 +1,105 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// 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 . +// + +// +//! Light dependent resistors. +//! +//! Larger ones seem to have both a higher dark resistance and a lower bright light resistance. +// +include <../core.scad> + +function ldr_description(type) = type[1]; //! Description +function ldr_diameter(type) = type[2]; //! The diameter of the round bit +function ldr_width(type) = type[3]; //! Across the flats +function ldr_thickness(type) = type[4]; //! Thickness +function ldr_pitch(type) = type[5]; //! Pitch between the leads +function ldr_active(type) = type[6]; //! The active width +function ldr_lead_d(type) = type[7]; //! The lead diameter + +module LDR(type, lead_length = 3) { //! Draw an LDR, can specify the lead length + vitamin(str("ldr(", type[0], "): Light dependent resistor: ", ldr_description(type))); + + module shape() + intersection() { + circle(d = ldr_diameter(type)); + + square([100, ldr_width(type)], center = true); + } + + function serpentine_t() = let(w = ldr_width(type), n = floor(w / 0.5) + 0.5) w / (n * 2); + + module serpentine() { + w = ldr_width(type); + + t = serpentine_t(); + pitch = 2 * t; + l = ldr_active(type); + lines = ceil(w / pitch); + + for(i = [0 : lines - 1]) + translate([0, i * pitch - w / 2 + t / 2]) { + square([l - 3 * t, t], center = true); + + end = i % 2 ? 1 : -1; + $fn = 16; + translate([end * (l / 2 - 1.5 * t), t]) + rotate(-end * 90) + difference() { + semi_circle(1.5 * t); + + semi_circle(t / 2); + } + } + } + + t = ldr_thickness(type); + + color("white") + linear_extrude(height = t - 0.4) + shape(); + + color("orange") + translate_z(t - 0.4) + linear_extrude(height = 0.1) + shape(); + + color([0.9, 0.9, 0.9]) + translate_z(t - 0.3) + linear_extrude(height = 0.1) + difference() { + offset(-serpentine_t()) + shape(); + + serpentine(); + } + + color("silver") + for(side = [-1, 1]) + translate([side * ldr_pitch(type) / 2, 0]) { + translate_z(-lead_length) + cylinder(d = ldr_lead_d(type), h = lead_length, $fn = 16); + + translate_z(t - 0.3) + cylinder(d = 1.5 * ldr_lead_d(type), h = 0.2, $fn = 16); + } + color([1, 1, 1, 0.25]) + translate_z(t - 0.3 + eps) + linear_extrude(height = 0.3) + shape(); +} diff --git a/vitamins/ldrs.scad b/vitamins/ldrs.scad new file mode 100644 index 0000000..bdca70a --- /dev/null +++ b/vitamins/ldrs.scad @@ -0,0 +1,28 @@ +// +// NopSCADlib Copyright Chris Palmer 2018 +// 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 . +// + +// +// Light dependent resistors. +// +small_ldr = ["small_ldr", "small", 5, 4.2, 1.8, 3.2, 2.5, 0.4]; +large_ldr = ["large_ldr", "large", 9.2, 7.9, 1.8, 6.8, 4.5, 0.5]; + +ldrs = [small_ldr, large_ldr]; + +use