diff --git a/libtest.png b/libtest.png index 697d905..d169c11 100644 Binary files a/libtest.png and b/libtest.png differ diff --git a/libtest.scad b/libtest.scad index a635445..4a12c49 100644 --- a/libtest.scad +++ b/libtest.scad @@ -85,6 +85,7 @@ use use use use +use use use use @@ -428,6 +429,9 @@ translate([x3 + 60, modules_y]) translate([x3 + 90, modules_y]) modules(); +translate([x3 + 150, modules_y]) + photo_interrupters(); + translate([x3, ssrs_y]) { ssrs(); diff --git a/readme.md b/readme.md index 404b212..23bcd24 100644 --- a/readme.md +++ b/readme.md @@ -42,12 +42,12 @@ A list of changes classified as breaking, additions or fixes is maintained in [C Extrusion_brackets PCBs Terminals PSU_shroud Sweep Extrusions PSUs Toggles Pocket_handle Thread Fans Panel_meters Transformers Press_fit Tube - Fastons Pillars Tubings Printed_box - Fuseholder Pillow_blocks Variacs Printed_pulleys - Geared_steppers Pin_headers Veroboard Ribbon_clamp - Green_terminals Potentiometers Washers SSR_shroud - Hot_ends Pulleys Wire Screw_knob - Hygrometer Zipties Socket_box + Fastons Photo_interrupters Tubings Printed_box + Fuseholder Pillars Variacs Printed_pulleys + Geared_steppers Pillow_blocks Veroboard Ribbon_clamp + Green_terminals Pin_headers Washers SSR_shroud + Hot_ends Potentiometers Wire Screw_knob + Hygrometer Pulleys Zipties Socket_box Strap_handle @@ -2754,6 +2754,49 @@ PCBs and perfboard with optional components. The shape can be a rectangle with o | 4 | pcb_spacer4090.stl | +Top + +--- + +## Photo_interrupters +Photo interrupter modules popular in robot kits and from China. + +[vitamins/photo_interrupters.scad](vitamins/photo_interrupters.scad) Object definitions. + +[vitamins/photo_interrupter.scad](vitamins/photo_interrupter.scad) Implementation. + +[tests/photo_interrupters.scad](tests/photo_interrupters.scad) Code for this example. + +### Properties +| Function | Description | +|:--- |:--- | +| `pi_base_height(type)` | Height of the base | +| `pi_base_length(type)` | Length of the base | +| `pi_base_width(type)` | Width of the base | +| `pi_color(type)` | Color of photo interrupter | +| `pi_gap_height(type)` | Height of the gap where the light can be interrupted | +| `pi_gap_width(type)` | Width of the gap | +| `pi_hole_diameter(type)` | Diameter of the mounting holes | +| `pi_pcb(type)` | Parameter for the support PCB, created with pi_pcb | +| `pi_stem_width(type)` | Width of the stems | + +### Modules +| Module | Description | +|:--- |:--- | +| `photo_interrupter(type)` | Draw the photo interrupter, with PCB | +| `pi_cutout(type)` | Shape to subtract for fitting a photo interrupter | +| `pi_hole_locations(type)` | Locations of photo interrupter mounting holes | +| `pi_pcb(type)` | Draw the support PCB | +| `pi_pcb_hole_locations(pcb)` | Locations of the PCB holes | + +![photo_interrupters](tests/png/photo_interrupters.png) + +### Vitamins +| Qty | Module call | BOM entry | +| ---:|:--- |:---| +| 1 | `photo_interrupter(PH1)` | PH1 Photo interrupter | + + Top --- diff --git a/tests/photo_interrupters.scad b/tests/photo_interrupters.scad index ee64fd6..3468cee 100644 --- a/tests/photo_interrupters.scad +++ b/tests/photo_interrupters.scad @@ -1,5 +1,5 @@ // -// NopSCADlib Copyright Chris Palmer 2018 +// NopSCADlib Copyright Chris Palmer 2023 // nop.head@gmail.com // hydraraptor.blogspot.com // @@ -22,7 +22,7 @@ include <../vitamins/photo_interrupters.scad> use <../utils/layout.scad> module photo_interrupters() - layout([for(l = photo_interrupters) pi_base_length(l)], 5) + layout([for(l = photo_interrupters) pi_base_length(l)], 5, true) photo_interrupter(photo_interrupters[$i]); photo_interrupters(); diff --git a/tests/png/photo_interrupters.png b/tests/png/photo_interrupters.png new file mode 100644 index 0000000..5fd35f5 Binary files /dev/null and b/tests/png/photo_interrupters.png differ diff --git a/vitamins/photo_interrupter.scad b/vitamins/photo_interrupter.scad index 0cec772..c9f4bfb 100644 --- a/vitamins/photo_interrupter.scad +++ b/vitamins/photo_interrupter.scad @@ -1,11 +1,33 @@ +// +// NopSCADlib Copyright Chris Palmer 2023 +// 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 . +// + +// +//! Photo interrupter modules popular in robot kits and from China. +// include <../utils/core/core.scad> include <../utils/rounded_polygon.scad> function pi_base_width(type) = type[1]; //! Width of the base function pi_base_length(type) = type[2]; //! Length of the base function pi_base_height(type) = type[3]; //! Height of the base -function pi_gap_height(type) = type[4]; //! Heigth of the gap where the light can be interrupted -function pi_gap_width(type) = type[6]; //! Width of the gap +function pi_gap_height(type) = type[4]; //! Height of the gap where the light can be interrupted +function pi_gap_width(type) = type[6]; //! Width of the gap function pi_stem_width(type) = type[5]; //! Width of the stems function pi_hole_diameter(type) = type[7]; //! Diameter of the mounting holes function pi_color(type) = type[8]; //! Color of photo interrupter @@ -42,23 +64,23 @@ module pi_pcb(type) { //! Draw the support PCB circle(d = pcb[8]); pi_hole_locations(type) circle(d=pi_hole_diameter(type)); - } + } } } } } module photo_interrupter(type) { //! Draw the photo interrupter, with PCB - vitamin(type[0]); + vitamin(str("photo_interrupter(", type[0], "): ", type[0], " Photo interrupter")); color(pi_color(type)) { linear_extrude(pi_base_height(type)) { difference() { hull() { - pi_hole_locations(type) + pi_hole_locations(type) circle(d = pi_base_width(type)); } - pi_hole_locations(type) - circle(d = pi_hole_diameter(type)); + pi_hole_locations(type) + circle(d = pi_hole_diameter(type)); } } translate([-pi_base_width(type)/2, -(pi_gap_width(type)/2 + pi_stem_width(type)), 0]) @@ -69,9 +91,9 @@ module photo_interrupter(type) { //! Draw the photo interrupter, with PCB pi_pcb(type); } -module pi_cutout(type) { //! Shape to substract for fitting a photo interrupter +module pi_cutout(type) { //! Shape to subtract for fitting a photo interrupter hull() { - pi_hole_locations(type) + pi_hole_locations(type) cylinder(h = pi_base_height(type), d = pi_base_width(type)); } translate([-pi_base_width(type)/2, -(pi_gap_width(type)/2 + pi_stem_width(type)), 0]) diff --git a/vitamins/photo_interrupters.scad b/vitamins/photo_interrupters.scad index f458f6f..83bc38f 100644 --- a/vitamins/photo_interrupters.scad +++ b/vitamins/photo_interrupters.scad @@ -1,4 +1,22 @@ -PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "grey", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; +// +// NopSCADlib Copyright Chris Palmer 2023 +// 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 . +// +PH1 = ["PH1", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, grey(20), [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; photo_interrupters = [PH1];