From 73909f3a0fb0ce0e5a99b59ab5f1077ce0343f6e Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 13:30:33 -0500 Subject: [PATCH 1/8] Updated gear module to correctly display error message when neither circular_pitch or diametral_pitch parameters are specified. Previous method of testing for false value did not work because circular_pitch is reassigned and becomes undef when diametral_pitch is false. --- involute_gears.scad | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/involute_gears.scad b/involute_gears.scad index fd80efe..5990e8a 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -310,7 +310,8 @@ module gear ( involute_facets=0, flat=false) { - if (circular_pitch==false && diametral_pitch==false) + // Check for undefined circular pitch (happens when neither circular_pitch or diametral_pitch are specified) + if (circular_pitch==undef) echo("MCAD ERROR: gear module needs either a diametral_pitch or circular_pitch"); //Convert diametrial pitch to our native circular pitch From a5fb4d884b35d58e95679a519afcf45f19dbc127 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 13:41:25 -0500 Subject: [PATCH 2/8] Updated gear module to correct calculations for circular_pitch and diametral_pitch. --- involute_gears.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index 5990e8a..c3afeba 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -315,10 +315,10 @@ module gear ( 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); + circular_pitch = (circular_pitch!=false?circular_pitch:pi/diametral_pitch); // Pitch diameter: Diameter of pitch circle. - pitch_diameter = number_of_teeth * circular_pitch / 180; + pitch_diameter = number_of_teeth * circular_pitch / pi; pitch_radius = pitch_diameter/2; echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); From f918e6d8c4dab3e54787308be3a9f187f276d2f4 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 13:45:14 -0500 Subject: [PATCH 3/8] Updated linear_extrude_flat_option to used children() instead of the depracated child() module. --- involute_gears.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index c3afeba..98ea26c 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -401,11 +401,11 @@ module linear_exturde_flat_option(flat =false, height = 10, center = false, conv { if(flat==false) { - linear_extrude(height = height, center = center, convexity = convexity, twist= twist) child(0); + linear_extrude(height = height, center = center, convexity = convexity, twist= twist) children(0); } else { - child(0); + children(0); } } From 68bde2d7d78e4824e6cfdbe1762310eec37695bd Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 14:09:32 -0500 Subject: [PATCH 4/8] Updated gear module to calculate the default clearance as .25/diametral_pitch (.25 * circular_pitch / PI). --- involute_gears.scad | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index 98ea26c..2a6eb19 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -297,7 +297,7 @@ module gear ( number_of_teeth=15, circular_pitch=false, diametral_pitch=false, pressure_angle=28, - clearance = 0.2, + clearance = false, gear_thickness=5, rim_thickness=8, rim_width=5, @@ -317,10 +317,13 @@ module gear ( //Convert diametrial pitch to our native circular pitch circular_pitch = (circular_pitch!=false?circular_pitch:pi/diametral_pitch); + // Calculate default clearance if not specified + clearance = (clearance!=false?clearance:0.25 * circular_pitch / pi); + // Pitch diameter: Diameter of pitch circle. pitch_diameter = number_of_teeth * circular_pitch / pi; pitch_radius = pitch_diameter/2; - echo ("Teeth:", number_of_teeth, " Pitch radius:", pitch_radius); + echo (str("Teeth: ", number_of_teeth, ", Pitch Radius: ", pitch_radius, ", Clearance: ", clearance)); // Base Circle base_radius = pitch_radius*cos(pressure_angle); From 526aa67e1c1e0b33385b4ee250397dac0a578a47 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 17:21:31 -0500 Subject: [PATCH 5/8] Renamed linear_exturde_flat_option module to linear_extrude_flat_option (corrected spelling of 'extrude'). --- involute_gears.scad | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index 2a6eb19..8be332f 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -364,7 +364,7 @@ module gear ( { difference () { - linear_exturde_flat_option(flat=flat, height=rim_thickness, convexity=10, twist=twist) + linear_extrude_flat_option(flat=flat, height=rim_thickness, convexity=10, twist=twist) gear_shape ( number_of_teeth, pitch_radius = pitch_radius, @@ -379,28 +379,28 @@ module gear ( cylinder (r=rim_radius,h=rim_thickness-gear_thickness+1); } if (gear_thickness > rim_thickness) - linear_exturde_flat_option(flat=flat, height=gear_thickness) + 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_exturde_flat_option(flat=flat, height=hub_thickness-gear_thickness) + linear_extrude_flat_option(flat=flat, height=hub_thickness-gear_thickness) circle (r=hub_diameter/2); } translate ([0,0,-1]) - linear_exturde_flat_option(flat =flat, height=2+max(rim_thickness,hub_thickness,gear_thickness)) + linear_extrude_flat_option(flat =flat, height=2+max(rim_thickness,hub_thickness,gear_thickness)) circle (r=bore_diameter/2); if (circles>0) { for(i=[0:circles-1]) rotate([0,0,i*360/circles]) translate([circle_orbit_diameter/2,0,-1]) - linear_exturde_flat_option(flat =flat, height=max(gear_thickness,rim_thickness)+3) + linear_extrude_flat_option(flat =flat, height=max(gear_thickness,rim_thickness)+3) circle(r=circle_diameter/2); } } } -module linear_exturde_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0) +module linear_extrude_flat_option(flat =false, height = 10, center = false, convexity = 2, twist = 0) { if(flat==false) { From 6474be3183b89a29c6b2402ce8b0a3fc07336350 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 17:53:29 -0500 Subject: [PATCH 6/8] Change gear module to use 'undef' as default value for circular_pitch and diametral_pitch parameters. This seems to make more sense than using 'false'. --- involute_gears.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index 8be332f..2b98168 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -295,7 +295,7 @@ module involute_bevel_gear_tooth ( module gear ( number_of_teeth=15, - circular_pitch=false, diametral_pitch=false, + circular_pitch=undef, diametral_pitch=undef, pressure_angle=28, clearance = false, gear_thickness=5, @@ -315,7 +315,7 @@ module gear ( 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:pi/diametral_pitch); + circular_pitch = (circular_pitch!=undef?circular_pitch:pi/diametral_pitch); // Calculate default clearance if not specified clearance = (clearance!=false?clearance:0.25 * circular_pitch / pi); From 2d1a97c307bda22ac5769303915826aac35ae308 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 17:57:25 -0500 Subject: [PATCH 7/8] In gear module, change default for clearance to 'undef'. --- involute_gears.scad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index 2b98168..b565b1b 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -297,7 +297,7 @@ module gear ( number_of_teeth=15, circular_pitch=undef, diametral_pitch=undef, pressure_angle=28, - clearance = false, + clearance = undef, gear_thickness=5, rim_thickness=8, rim_width=5, @@ -318,7 +318,7 @@ module gear ( circular_pitch = (circular_pitch!=undef?circular_pitch:pi/diametral_pitch); // Calculate default clearance if not specified - clearance = (clearance!=false?clearance:0.25 * circular_pitch / pi); + clearance = (clearance!=undef?clearance:0.25 * circular_pitch / pi); // Pitch diameter: Diameter of pitch circle. pitch_diameter = number_of_teeth * circular_pitch / pi; From 2a126e526a073ab8e095761d3bae031a1db42393 Mon Sep 17 00:00:00 2001 From: gizmoplex Date: Sat, 5 Dec 2015 18:57:18 -0500 Subject: [PATCH 8/8] In the gear module, set rim_thickness, rim_width, hub_thickness, hub_diameter, and bore_diameter default values to undef and then added code to calculate default values based on a percentage of the root circle radius. This helps generate a valid gear when the only parameter specified is the pitch (diametral or circular). --- involute_gears.scad | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/involute_gears.scad b/involute_gears.scad index b565b1b..9ae3dc3 100644 --- a/involute_gears.scad +++ b/involute_gears.scad @@ -299,11 +299,11 @@ module gear ( pressure_angle=28, clearance = undef, gear_thickness=5, - rim_thickness=8, - rim_width=5, - hub_thickness=10, - hub_diameter=15, - bore_diameter=5, + rim_thickness=undef, + rim_width=undef, + hub_thickness=undef, + hub_diameter=undef, + bore_diameter=undef, circles=0, backlash=0, twist=0, @@ -346,7 +346,16 @@ module gear ( half_thick_angle = (360 / number_of_teeth - backlash_angle) / 4; // Variables controlling the rim. + rim_thickness = (rim_thickness!=undef?(rim_thickness!=0?rim_thickness:gear_thickness):gear_thickness * 1.5); + rim_width = (rim_width!=undef?rim_width:root_radius * .1); rim_radius = root_radius - rim_width; + + // Variables controlling the hub_diameter + 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 bore + 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;