From fecc93746ab80ad1fc74f0fe3465de92ffee7b36 Mon Sep 17 00:00:00 2001 From: Dirkjan Krijnders Date: Wed, 8 Mar 2023 09:20:14 +0100 Subject: [PATCH 1/2] Added vitamins for photo interrupters --- lib.scad | 2 + vitamins/photo_interrupter.scad | 87 ++++++++++++++++++++++++++++++++ vitamins/photo_interrupters.scad | 1 + 3 files changed, 90 insertions(+) create mode 100644 vitamins/photo_interrupter.scad create mode 100644 vitamins/photo_interrupters.scad diff --git a/lib.scad b/lib.scad index b83a24a..969c741 100644 --- a/lib.scad +++ b/lib.scad @@ -48,6 +48,7 @@ include include include include +include include include include @@ -99,3 +100,4 @@ use use use use +use \ No newline at end of file diff --git a/vitamins/photo_interrupter.scad b/vitamins/photo_interrupter.scad new file mode 100644 index 0000000..6838698 --- /dev/null +++ b/vitamins/photo_interrupter.scad @@ -0,0 +1,87 @@ +include <../utils/core/core.scad> + +function pi_name(type) = type[0]; +function pi_base_height(type) = type[3]; +function pi_base_length(type) = type[2]; +function pi_base_width(type) = type[1]; +function pi_gap_height(type) = type[4]; +function pi_gap_width(type) = type[6]; +function pi_stem_width(type) = type[5]; +function pi_hole_diameter(type) = type[7]; +function pi_color(type) = type[8]; +function pi_pcb(type) = type[9]; + +module pi_hole_locations(type) { + translate([0, -(pi_base_length(type) - pi_base_width(type)) / 2, 0]) + children(); + translate([0, (pi_base_length(type) - pi_base_width(type)) / 2, 0]) + children(); +} + +module pi_pcb_hole_locations(pcb) { + for (xy = pcb[7]) { + translate([xy[0], xy[1], 0]) + children(); + } +} + +module pi_pcb(type) { + pcb = pi_pcb(type); + color(pcb[6]) { + difference() { + union() { + translate([0, 0, -pcb[2]]){ + if (pcb[4]) { + hull() { + pi_hole_locations(type) + cylinder(h=pcb[2], d=pi_base_width(type)); + } + } + } + translate([pcb[4], 0, -pcb[2]/2]) { + cube([pcb[0], pcb[1], pcb[2]], center = true); + } + } + translate([0, 0, -pcb[2]]) { + pi_pcb_hole_locations(pcb) + cylinder(h=pcb[2]+0.1, d = pcb[8]); + pi_hole_locations(type) + cylinder(h=pcb[2]+0.1, d=pi_hole_diameter(type)); + } + } + } +} + +module photo_interrupter(type) { + vitamin(pi_name(type)); + color(pi_color(type)) + difference() { + union() { + hull() { + 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]) + cube([pi_base_width(type), pi_stem_width(type), pi_gap_height(type) + pi_base_height(type)]); + translate([-pi_base_width(type)/2, pi_gap_width(type)/2, 0]) + cube([pi_base_width(type), pi_stem_width(type), pi_gap_height(type) + pi_base_height(type)]); + } + pi_hole_locations(type) + cylinder(h = pi_base_height(type), d = pi_hole_diameter(type)); + } + pi_pcb(type); +} + +module pi_cutout(type) { + hull() { + 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]) + cube([pi_base_width(type), pi_stem_width(type), pi_gap_height(type) + pi_base_height(type)]); + translate([-pi_base_width(type)/2, pi_gap_width(type)/2, 0]) + cube([pi_base_width(type), pi_stem_width(type), pi_gap_height(type) + pi_base_height(type)]); +}; + +PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "black", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; +photo_interrupter(PH1); diff --git a/vitamins/photo_interrupters.scad b/vitamins/photo_interrupters.scad new file mode 100644 index 0000000..6bb8015 --- /dev/null +++ b/vitamins/photo_interrupters.scad @@ -0,0 +1 @@ +PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "black", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; \ No newline at end of file From c5fab08a454383b295be2b151fd715ee79b85db3 Mon Sep 17 00:00:00 2001 From: Dirkjan Krijnders Date: Wed, 8 Mar 2023 16:51:08 +0100 Subject: [PATCH 2/2] Added photo_interrupter to the test --- tests/photo_interrupters.scad | 28 ++++++++++++++++++++++++++++ vitamins/photo_interrupter.scad | 3 --- vitamins/photo_interrupters.scad | 6 +++++- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/photo_interrupters.scad diff --git a/tests/photo_interrupters.scad b/tests/photo_interrupters.scad new file mode 100644 index 0000000..ee64fd6 --- /dev/null +++ b/tests/photo_interrupters.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 . +// +include <../utils/core/core.scad> +include <../vitamins/photo_interrupters.scad> + +use <../utils/layout.scad> + +module photo_interrupters() + layout([for(l = photo_interrupters) pi_base_length(l)], 5) + photo_interrupter(photo_interrupters[$i]); + +photo_interrupters(); diff --git a/vitamins/photo_interrupter.scad b/vitamins/photo_interrupter.scad index 6838698..f7c7697 100644 --- a/vitamins/photo_interrupter.scad +++ b/vitamins/photo_interrupter.scad @@ -82,6 +82,3 @@ module pi_cutout(type) { translate([-pi_base_width(type)/2, pi_gap_width(type)/2, 0]) cube([pi_base_width(type), pi_stem_width(type), pi_gap_height(type) + pi_base_height(type)]); }; - -PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "black", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; -photo_interrupter(PH1); diff --git a/vitamins/photo_interrupters.scad b/vitamins/photo_interrupters.scad index 6bb8015..6c92215 100644 --- a/vitamins/photo_interrupters.scad +++ b/vitamins/photo_interrupters.scad @@ -1 +1,5 @@ -PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "black", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; \ No newline at end of file +PH1 = ["PH1: Photo interrupter", 6.4, 25.9 , 3.5, 8.6, 4.1, 5.9, 3, "black", [22, 20, 1.6, true, 11-3.2, 0, "blue",[[8.3, -7.5], [8.3, 7.5]], 3]]; + +photo_interrupters = [PH1]; + +use