Skip to content

Instantly share code, notes, and snippets.

@SharpCoder
Last active January 6, 2020 07:29
Show Gist options
  • Select an option

  • Save SharpCoder/5dc086c54bffc7decb334f1f60193420 to your computer and use it in GitHub Desktop.

Select an option

Save SharpCoder/5dc086c54bffc7decb334f1f60193420 to your computer and use it in GitHub Desktop.
include <openfusion.scad>
// Personal Constants
in_to_mm = 25.4;
tol = .2;
/* Bore */ bore = 45 + tol; // mm
/* Height */ h = 5; // mm
/* Number of teeth */ N = 32;
/* Diametrical pitch */ P = 12;
/* Pressure angle */ pa = 14.5;
/* *********************
Calculated Values (distances)
*********************/
/* Whole depth */ ht = (in_to_mm) * (2.157 / P); // in_to_mm * ((2.2 / P) + 0.002);
/* Addendum */ a = (1 / P) * in_to_mm;
/* Dedendum */ b = ht - a;
/* Pitch Circle (diameter) */ D = (N / P) * in_to_mm;
/* Base Circle (diameter) */ Db = D * cos(pa);
/* Root Circle (diameter) */ Dr = D - (2 * b);
echo("Final size ~");
echo(D + a);
/* *********************
Calculated Values (other)
*********************/
/* Circular pitch */ p = (3.1416 / P) * in_to_mm;
/* Tooth thickness */ t = (1.5708 / P) * in_to_mm;
/* Clearance */ c = ht - 2 * a;
module base_circle() {
// NOTE:
// The additional .2 is for tolerances
// and might need to be changed
circle(d=Dr + tol, $fn=100);
}
module tooth_mesh() {
x = cos(90-pa) * a;
xop = cos(90+pa) * a;
polygon(
points=[
[-t,0],
[-t + x, a],
[xop, a],
[0,0]
]
);
}
module tooth() {
rotate(90)
translate([-t/2,Dr/2,0])
union() {
square([t,b]);
translate([t,b]) tooth_mesh();
}
}
module teeth() {
circular_mirror(d=0, steps=N)
tooth();
}
module gear() {
teeth();
base_circle();
}
module final() {
difference() {
gear();
circle(d=bore, $fn=100);
}
//circle(d=D, $fn=100);
}
linear_extrude(height=h)
final();
/**
Maths
**/
function rad(degree) = (degree / 180) * 3.14;
function deg(rad) = (rad * 180) / 3.14;
/**
Modules
**/
module circular_mirror(x=0, y=0, d, steps) {
aps = 360 / steps;
for (step=[0:steps]) {
current_angle = step * aps;
unit_x = cos(current_angle);
unit_y = sin(current_angle);
translate([x, y, 0]) {
translate([unit_x * d, unit_y * d, 0]) {
rotate(current_angle) children();
}
}
}
}
// This is a hexagon, but radius is the distance
// from the center point to the middle of a side.
// (rather than to a pointy end) which mimics fusion.
module hexagon(r) {
rotate(90) circle($fn=6, r=r * 1.125);
}
// Mirror in 4 directions
module quadruple_mirror() {
children();
mirror([-1, 0, 0]) children();
mirror([0, -1, 0]) children();
mirror([-1, 0, 0]) mirror([0, -1, 0]) children();
}
// Splat children elements equidistance "count" times along
// a particular vector (x, y, and/or z) over some distance (d)
module splat(d, count, x=false, y=false, z=false) {
step_distance=d / (count - 1);
for (step=[0:count - 1]) {
move = step * step_distance;
translate([x ? move : 0, y ? move : 0, z ? move : 0])
children();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment