fixed rack, fixed test_gears, and added spoked gears

This commit is contained in:
skeptonomicon 2021-07-19 08:48:24 -04:00
parent 4b4caeb5da
commit 28fbdac168

View file

@ -303,6 +303,11 @@ module gear (
rim_width=undef,
hub_thickness=undef,
hub_diameter=undef,
spokes=0,
spoke_width=undef,
spoke_thickness=undef,
spoke_square=false,
z_symmetry=false,
bore_diameter=undef,
circles=0,
backlash=0,
@ -354,10 +359,23 @@ module gear (
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);
// 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);
// Variables controlling the circular holes in the gear.
circles = spokes==0?circles:0;
circle_orbit_diameter=hub_diameter/2+rim_radius;
circle_orbit_curcumference=pi*circle_orbit_diameter;
@ -373,6 +391,7 @@ module gear (
{
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 +402,52 @@ module gear (
half_thick_angle = half_thick_angle,
involute_facets=involute_facets);
if (flat == false && gear_thickness < rim_thickness)
//if we have a spoked gear, then the gear body must be removed.
if (spokes>0)
translate ([0,0,-1])
cylinder (r=rim_radius,h=rim_thickness+2);
//if the rim is thicker than the gear, carve out the gear body
else if (rim_thickness>gear_thickness)
translate ([0,0,gear_thickness])
cylinder (r=rim_radius,h=rim_thickness-gear_thickness+1);
cylinder (r=rim_radius,h=rim_thickness);
}
if (gear_thickness > rim_thickness)
//extend the gear body if gear_thickness > rim_thickness unless spoked,
if (spokes==0 && gear_thickness > rim_thickness)
{
linear_extrude_flat_option(flat=flat, height=gear_thickness)
//if rim is thicker than body, body protrudes into rim
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);
}
//add the hub
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=1,d=1);
}
}
}
//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 +473,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 +616,25 @@ 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,
circular_pitch=500*pi/180,
circles=8);
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 +642,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,21 +656,23 @@ module test_gears()
translate ([-61.1111111,0,0])
{
gear (number_of_teeth=27,
circular_pitch=500,
circles=5,
circular_pitch=500*pi/180,
//circles=5,
spokes=6,
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,
clearance = 0.2,
gear_thickness = 10,
@ -629,14 +683,15 @@ module test_gears()
translate ([13.8888888,0,1])
gear (
number_of_teeth=11,
circular_pitch=200,
circular_pitch=200*pi/180,
pressure_angle=5,
clearance = 0.2,
gear_thickness = 10,
rim_thickness = 10,
rim_width = 15,
hub_thickness = 20,
hub_diameter=2*7.222222,
//hub_diameter=2*7.222222,
hub_diameter=8,
bore_diameter=5,
circles=0);
}
@ -645,7 +700,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 +711,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);
@ -749,3 +804,4 @@ module test_backlash ()
translate([0,0,-5])
cylinder ($fn=20,r=backlash / 4,h=25);
}