Created
December 5, 2017 18:39
-
-
Save ednisley/8b71ec787c9a42970296d6d4836f9d9a to your computer and use it in GitHub Desktop.
OpenSCAD source code: TCRT5000 optical proximity sensor endstop mount for MPCNC Z Axis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TCRT5000 Z Axis Endstop Mount | |
// Ed Nisley KE4ZNU - 2017-12-04 | |
/* [Build Options] */ | |
Layout = "Show"; // [Build, Show, Block] | |
Section = true; // show internal details | |
/* [Extrusion] */ | |
ThreadThick = 0.25; // [0.20, 0.25] | |
ThreadWidth = 0.40; // [0.40] | |
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit); | |
/* [Hidden] */ | |
Protrusion = 0.01; // [0.01, 0.1] | |
HoleWindage = 0.2; | |
ID = 0; | |
OD = 1; | |
LENGTH = 2; | |
/* [Sizes] */ | |
RailOD = 23.5; // actual rail OD | |
OptoPCB = [32.5,14.2,1.6]; // prox sensor PCB | |
ComponentHeight = 5.0; // max component height above PCB | |
OptoSensor = [5.8,10.2,10.5]; // sensor head below PCB | |
OptoOffset = 3.0; // sensor head center from PCB edge | |
OptoRange = 2.0; // sensor to rail distance | |
TapeThick = 1.0; // foam mounting tape | |
WallThick = 4.0; // basic wall thickness | |
Block = [WallThick + OptoRange + RailOD/2 + (OptoPCB[0] - OptoOffset), | |
RailOD/2 + OptoRange + OptoSensor[2] - TapeThick, | |
IntegerMultiple(OptoPCB[1] + 2*WallThick,2.0)]; // basic block shape | |
echo(str("Block: ",Block)); | |
NumSides = 6*4; | |
//- Adjust hole diameter to make the size come out right | |
module PolyCyl(Dia,Height,ForceSides=0) { // based on nophead's polyholes | |
Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2); | |
FixDia = Dia / cos(180/Sides); | |
cylinder(r=(FixDia + HoleWindage)/2,h=Height,$fn=Sides); | |
} | |
//- Shapes | |
// Main block constructed with PCB along X, opto sensor at Y=0 | |
module PCBBlock() { | |
difference() { | |
translate([-(WallThick + OptoRange + RailOD/2), | |
(-Block[1] + RailOD/2 + OptoRange), | |
-Block[2]/2]) | |
cube(Block,center=false); | |
for (i=[-(RailOD/2 + OptoRange + WallThick), | |
(OptoPCB[0] - OptoOffset)]) | |
translate([i,0,0]) | |
rotate([90,0,0]) rotate(45) | |
cube([2*ThreadWidth,2*ThreadWidth,2*Block[2]],center=true); | |
translate([0,(RailOD/2 + OptoRange),0]) | |
cylinder(d=(RailOD + 2*OptoRange), | |
h=(Block[2] + 2*Protrusion), | |
$fn=NumSides,center=true); | |
rotate([90,0,0]) | |
cube(OptoSensor + [0,0,Block[1]],center=true); | |
} | |
} | |
//- Build things | |
if (Layout == "Block") | |
PCBBlock(); | |
if (Layout == "Show") { | |
translate([0,-(RailOD/2 + OptoRange),0]) | |
PCBBlock(); | |
color("Yellow",0.5) | |
cylinder(d=RailOD,h=2*Block[2],$fn=NumSides,center=true); | |
} | |
if (Layout == "Build") | |
translate([0,0,OptoSensor[2] - TapeThick]) | |
rotate([90,0,0]) | |
PCBBlock(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More details on my blog at https://wp.me/poZKh-7cC