Created
February 16, 2018 18:08
-
-
Save ednisley/5ec9c82e6f37d774ce0418442adbe1e9 to your computer and use it in GitHub Desktop.
OpenSCAD source code: USB Camera ball mount for MPCNC
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
// MPCNC USB Camera Mount | |
// Ed Nisley KE4ZNU - 2018-02-16 | |
Layout = "Build"; // Build, Show, Mount | |
/* [Extrusion] */ | |
ThreadThick = 0.25; // [0.20, 0.25] | |
ThreadWidth = 0.40; // [0.40] | |
/* [Hidden] */ | |
Protrusion = 0.1; // [0.01, 0.1] | |
HoleWindage = 0.2; | |
inch = 25.4; | |
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit); | |
ID = 0; | |
OD = 1; | |
LENGTH = 2; | |
//- 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); | |
} | |
//- Dimensions | |
CameraStalk = [6.0 + 1.0,10.0 + HoleWindage,4.0]; // stalk OD, ball OD, stalk length | |
CameraAngle = -5; // stalk tilt, negative = downward | |
MountBlock = [24.0,20.0,CameraStalk[OD] + 7.0]; // cube to hold ball, stick to MPCNC frame | |
Insert = [3.0,4.4,4.5]; // brass insert | |
NumSides = 6*4; | |
//----- | |
// Define shapes | |
// Camera mount, enlongated for E-Z differencing | |
// Origin at center of ball, stalk along +X | |
module Camera() { | |
union() { | |
sphere(d=CameraStalk[OD] + HoleWindage,$fn=NumSides); | |
rotate([0,90 - CameraAngle,0]) | |
PolyCyl(CameraStalk[ID],3*CameraStalk[LENGTH],NumSides); | |
} | |
} | |
module Mount(Half="All") { | |
Rounding = 2.0; | |
ZShift = | |
(Half == "Upper") ? -MountBlock.z/2 : | |
(Half == "Lower") ? MountBlock.z/2 : | |
2*MountBlock.z; | |
difference() { | |
hull() | |
for (i=[-1,1], j=[-1,1], k=[-1,1]) | |
translate([i*(MountBlock.x - Rounding)/2,j*(MountBlock.y - Rounding)/2,k*(MountBlock.z - Rounding)/2]) | |
sphere(d=Rounding,$fn=3*4); | |
for (j=[-1,1]) | |
translate([-MountBlock.x/4,j*MountBlock.y/4,-(MountBlock.z/2 + Protrusion)]) { | |
PolyCyl(Insert[OD],Insert[LENGTH] + Protrusion,6); | |
PolyCyl(Insert[ID],2*MountBlock.z,6); | |
} | |
translate([MountBlock.x/2 - (CameraStalk[OD]/2 + CameraStalk[LENGTH]),0,0]) | |
Camera(); | |
translate([0,0,ZShift]) | |
cube([2*MountBlock.x,2*MountBlock.y,MountBlock.z],center=true); | |
} | |
} | |
//----- | |
// Build it | |
if (Layout == "Mount") | |
Mount(); | |
if (Layout == "Show") | |
Mount(); | |
if (Layout == "Build") { | |
translate([0,0.75*MountBlock.y,MountBlock.z/2]) | |
rotate([180,0,0]) | |
Mount("Upper"); | |
translate([0,-0.75*MountBlock.y,MountBlock.z/2]) | |
rotate([0,0,0]) | |
Mount("Lower");} |
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-7m7