Merge pull request #91 from skeptonomicon/master

fixed rack, fixed test_gears, and added spoked gears
This commit is contained in:
Chow Loong Jin 2021-07-24 12:41:01 +08:00 committed by GitHub
commit 9d88138aed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -303,8 +303,15 @@ module gear (
rim_width=undef,
hub_thickness=undef,
hub_diameter=undef,
spokes=0,
spoke_width=undef,
spoke_thickness=undef,
spoke_square=false,
centered_gear=false,
centered_hub=false,
bore_diameter=undef,
circles=0,
circle_diameter=undef,
backlash=0,
twist=0,
involute_facets=0,
@ -350,29 +357,43 @@ module gear (
rim_width = (rim_width!=undef?rim_width:root_radius * .1);
rim_radius = root_radius - rim_width;
// Variables controlling the hub_diameter
// Variables controlling the hub
hub_thickness = (hub_thickness!=undef?(hub_thickness!=0?hub_thickness:gear_thickness):gear_thickness * 2);
hub_diameter = (hub_diameter!=undef?hub_diameter:root_radius * .3);
hub_base = (centered_hub == false)? 0 : rim_thickness/2 - hub_thickness/2;
// Variables controlling the spokes
spokes = spokes == undef? 0 : spokes;
spoke_thickness = (spoke_thickness == undef)? rim_thickness : spoke_thickness;
spoke_width = (spokes==0)? 1 : (spoke_width == undef)? 0.75 * pi * hub_diameter / spokes : spoke_width;
//spoke_depth is depth spoke must penetrate into hub to ensure complete penetration
spoke_depth = ((hub_diameter/2)^2-(spoke_width/2)^2)^0.5 +.01;
//spoke length is length of spoke including the depth sunk into the hub
spoke_length = spoke_depth+rim_radius-(hub_diameter/2.0);
//spoke raius is the distance from gear center to base of the spoke(inside the hub)
spoke_radius = (hub_diameter/2.0)-spoke_depth;
//echo (str("spoke_width: ",spoke_width,", hub_diameter: ",hub_diameter, ", spoke_depth: ",spoke_depth));
// Variables controlling the bore
bore_diameter = (bore_diameter!=undef?bore_diameter:root_radius * .1);
bore_diameter = bore_diameter!=undef?bore_diameter:root_radius * .1;
// Variables controlling the circular holes in the gear.
circle_orbit_diameter=hub_diameter/2+rim_radius;
circle_orbit_curcumference=pi*circle_orbit_diameter;
// Limit the circle size to 90% of the gear face.
circle_diameter=
min (
circle_default_diameter = min (
0.70*circle_orbit_curcumference/circles,
(rim_radius-hub_diameter/2)*0.9);
(rim_radius+hub_diameter/2)*0.9);
circle_diameter=(circle_diameter != undef)? circle_diameter : circle_default_diameter;
echo(str("cir_orb_dia: ", circle_orbit_diameter, ", cir_orb_circumf: ", circle_orbit_curcumference, ", default cir dia: ",circle_default_diameter, ", cir_dia:",circle_diameter));
difference()
{
union ()
{
difference ()
{
//start with a plane toothed disk gear
linear_extrude_flat_option(flat=flat, height=rim_thickness, convexity=10, twist=twist)
gear_shape (
number_of_teeth,
@ -383,21 +404,78 @@ module gear (
half_thick_angle = half_thick_angle,
involute_facets=involute_facets);
if (flat == false && gear_thickness < rim_thickness)
//if we have a 0 hub thickness, then hub must be removed
if (hub_thickness == 0)
translate ([0,0,-1])
cylinder (r=rim_radius,h=rim_thickness+2);
//if the rim is thicker than the gear, carve out gear body
else if (rim_thickness>gear_thickness){
//if not centered, carve out only the top
if (centered_gear == false){
translate ([0,0,gear_thickness])
cylinder (r=rim_radius,h=rim_thickness-gear_thickness+1);
cylinder (r=rim_radius,h=rim_thickness);
}
else
//carve out half from top and half from bottom
union ()
{
translate ([0,0,(gear_thickness + rim_thickness)/2])
cylinder (r=rim_radius,h=rim_thickness+1);
translate ([0,0,-1 -(gear_thickness + rim_thickness)/2])
cylinder (r=rim_radius,h=rim_thickness+1);
}
}
}
//extend the gear body if gear_thickness > rim_thickness unless spoked,
if (gear_thickness > rim_thickness)
{
if (centered_gear == false)
{
linear_extrude_flat_option(flat=flat, height=gear_thickness)
circle (r=rim_radius);
if (flat == false && hub_thickness > gear_thickness)
translate ([0,0,gear_thickness])
linear_extrude_flat_option(flat=flat, height=hub_thickness-gear_thickness)
circle (r=hub_diameter/2);
}
else
{
translate ([0,0,-(gear_thickness - rim_thickness)/2])
linear_extrude_flat_option(flat=flat, height=gear_thickness)
circle (r=rim_radius);
}
//if rim is thicker than body, body protrudes into rim
}
//add the hub
translate ([0,0,hub_base])
linear_extrude_flat_option(flat=flat, height=hub_thickness)
circle (r=hub_diameter/2);
//add in spokes
if (spokes>0)
{
for(i=[0:spokes-1])
translate([0,0,rim_thickness/2])
rotate([90,0,i*360/spokes])
translate([0,0,spoke_radius])
{
if (spoke_square==true){
resize([spoke_width,spoke_thickness,spoke_length])
translate([0,0,.5])
cube(1,center=true);
}
if (spoke_square==false){
resize([spoke_width,spoke_thickness,spoke_length])
cylinder(h=10,d=10);
}
}
}
}
//remove the center bore
translate ([0,0,-1])
linear_extrude_flat_option(flat =flat, height=2+max(rim_thickness,hub_thickness,gear_thickness))
circle (r=bore_diameter/2);
//remove circles from gear body
if (circles>0)
{
for(i=[0:circles-1])
@ -423,10 +501,10 @@ module rack(
echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch");
//Convert diametrial pitch to our native circular pitch
circular_pitch = (circular_pitch!=false?circular_pitch:180/diametral_pitch);
pitch = circular_pitch / 180 * PI;
circular_pitch = (circular_pitch!=false?circular_pitch:pi/diametral_pitch);
pitch = circular_pitch;
addendum = circular_pitch / 180;
addendum = circular_pitch / pi;
dedendum = addendum + clearance;
pitch_slope = tan(pressure_angle);
@ -566,23 +644,31 @@ function involute (base_radius, involute_angle) =
module test_gears()
{
$fs = 0.2;
$fa =1;
translate([17,-15])
{
gear (number_of_teeth=17,
circular_pitch=500,
circles=8);
circular_pitch=500*pi/180,
spokes=6,
spoke_thickness=4,
gear_thickness=0,
rim_thickness=5,
hub_thickness=5,
hub_diameter=10,
circles=0);
rotate ([0,0,360*4/17])
translate ([39.088888,0,0])
{
gear (number_of_teeth=11,
circular_pitch=500,
circular_pitch=500*pi/180,
hub_diameter=0,
rim_width=65);
translate ([0,0,8])
{
gear (number_of_teeth=6,
circular_pitch=300,
circular_pitch=300*pi/180,
hub_diameter=0,
rim_width=5,
rim_thickness=6,
@ -590,7 +676,7 @@ module test_gears()
rotate ([0,0,360*5/6])
translate ([22.5,0,1])
gear (number_of_teeth=21,
circular_pitch=300,
circular_pitch=300*pi/180,
bore_diameter=2,
hub_diameter=4,
rim_width=1,
@ -604,22 +690,29 @@ module test_gears()
translate ([-61.1111111,0,0])
{
gear (number_of_teeth=27,
circular_pitch=500,
circles=5,
circular_pitch=500*pi/180,
circles=6,
circle_diameter=12,
spokes=6,
gear_thickness=2,
hub_thickness=10,
centered_gear=true,
spoke_thickness=3,
hub_diameter=2*8.88888889);
translate ([-37.5,0,0])
rotate ([0,0,-90])
rack (
circular_pitch=500
circular_pitch=500*pi/180
);
translate ([0,0,10])
{
gear (
number_of_teeth=14,
circular_pitch=200,
circular_pitch=200*pi/180,
pressure_angle=5,
twist=30,
clearance = 0.2,
gear_thickness = 10,
rim_thickness = 10,
@ -628,16 +721,18 @@ module test_gears()
circles=0);
translate ([13.8888888,0,1])
gear (
number_of_teeth=11,
circular_pitch=200,
number_of_teeth=10,
circular_pitch=200*pi/180,
pressure_angle=5,
clearance = 0.2,
gear_thickness = 10,
rim_thickness = 10,
rim_thickness = 8,
twist=-30*8/10,
rim_width = 15,
hub_thickness = 20,
hub_diameter=2*7.222222,
bore_diameter=5,
hub_thickness = 10,
centered_hub=true,
hub_diameter=7,
bore_diameter=4,
circles=0);
}
}
@ -645,7 +740,7 @@ module test_gears()
rotate ([0,0,360*-5/17])
translate ([44.444444444,0,0])
gear (number_of_teeth=15,
circular_pitch=500,
circular_pitch=500*pi/180,
hub_diameter=10,
rim_width=5,
rim_thickness=5,
@ -656,7 +751,7 @@ module test_gears()
rotate ([0,0,360*-1/17])
translate ([30.5555555,0,-1])
gear (number_of_teeth=5,
circular_pitch=500,
circular_pitch=500*pi/180,
hub_diameter=0,
rim_width=5,
rim_thickness=10);
@ -683,7 +778,7 @@ module test_double_helix_gear (
pressure_angle=30;
gear (number_of_teeth=teeth,
circular_pitch=700,
circular_pitch=700*pi/180,
pressure_angle=pressure_angle,
clearance = 0.2,
gear_thickness = height/2*0.5,
@ -696,7 +791,7 @@ module test_double_helix_gear (
twist=twist/teeth);
mirror([0,0,1])
gear (number_of_teeth=teeth,
circular_pitch=700,
circular_pitch=700*pi/180,
pressure_angle=pressure_angle,
clearance = 0.2,
gear_thickness = height/2,
@ -721,7 +816,7 @@ module test_backlash ()
rotate ([0,0,-360/teeth/4])
gear (
number_of_teeth = teeth,
circular_pitch=700,
circular_pitch=700*pi/180,
gear_thickness = 12,
rim_thickness = 15,
rim_width = 5,
@ -734,7 +829,7 @@ module test_backlash ()
rotate ([0,0,360/teeth/4])
gear (
number_of_teeth = teeth,
circular_pitch=700,
circular_pitch=700*pi/180,
gear_thickness = 12,
rim_thickness = 15,
rim_width = 5,
@ -745,7 +840,8 @@ module test_backlash ()
circles=8);
}
color([0,0,128,0.5])
color([0,0,1,0.5])
translate([0,0,-5])
cylinder ($fn=20,r=backlash / 4,h=25);
}