Last active
December 5, 2024 15:15
-
-
Save SharpCoder/b1cab020d2d8d7626d8556bdac7069cd to your computer and use it in GitHub Desktop.
Revisions
-
SharpCoder renamed this gist
Jan 28, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
SharpCoder revised this gist
Jan 28, 2020 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ # gears.scad In order to use this code, you will need to copy gears.scad to your Libraries folder. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries @@ -31,4 +29,7 @@ Which takes the following parameters: - N2 = Tooth count of the second gear - P = Diametral Pitch The output of this function will be the mm distance you must space both gears for them to mesh perfectly.  -
SharpCoder revised this gist
Jan 28, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # gears.scad  In order to use this code, you will need to copy gears.scad to your Libraries folder. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries -
SharpCoder renamed this gist
Jan 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
SharpCoder renamed this gist
Jan 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
SharpCoder renamed this gist
Jan 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
SharpCoder revised this gist
Jan 25, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ include <gears.scad> Teeth = 18; Pitch = 12; linear_extrude(6) -
SharpCoder revised this gist
Jan 25, 2020 . 1 changed file with 25 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,28 @@ https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries And then you can run *Untitled.scad* as any other normal scad project file. If you don't want to mess around with the library, just combine the two code files together into one. ## Library Functions This code will provide a function **spur_gear()** Which takes the following parameters: - N = Number of teeth - P = Diametral Pitch (defaults to 12) - pa = Pressure Angle (defaults to 14.5) The output of this method will be a 2D gear (converted to mm) which you simply need to *linear_extrude* in order to print on a 3D printer. The library also includes a number of other mathematical functions including: **calc_center_distance()** Which takes the following parameters: - N1 = Tooth count of the first gear - N2 = Tooth count of the second gear - P = Diametral Pitch The output of this function will be the mm distance you must space both gears for them to mesh perfectly. -
SharpCoder revised this gist
Jan 25, 2020 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # gears.scad In order to use this code, you will need to copy gears.scad to your Libraries folder. https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries And then you can run *Untitled.scad* as any other normal scad project file. If you don't want to mess around with the library, just combine the two code files together into one. -
SharpCoder revised this gist
Jan 25, 2020 . 2 changed files with 29 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,14 +3,16 @@ include <gears.scad> Teeth = 20; Pitch = 12; linear_extrude(6) difference() { spur_gear(N=Teeth, P=Pitch); circle(d=19.1); } // Change this variable to calculate how far // this gear and another gear need to be spaced // in order to mesh properly. // (output will display in the console in units mm) OtherGearTeeth = 37; echo("***"); echo("center distance (mm)", calc_center_distance(Teeth, OtherGearTeeth, Pitch)); echo("***"); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ function calc_circular_pitch(P) = (PI / P) * in_to_mm; function calc_thickness(P) = (1.5708 / P) * in_to_mm; function calc_alpha(dp, db, pa) = ((sqrt(pow(dp,2) - pow(db,2))/db) * rad_to_deg - pa); function calc_clearance(P) = calc_dedendum(P) - calc_addendum(P); function calc_center_distance(N1, N2, P) = in_to_mm * (N1 + N2) /(2 * P); /** Modules @@ -44,6 +44,7 @@ module spur_gear(N, P = 12, pa = 14.5) { db = calc_db(N, P, pa); dr = calc_dr(N, P); a = calc_addendum(P); b = calc_dedendum(P); c = calc_clearance(P); p = calc_circular_pitch(P); @@ -57,30 +58,36 @@ module spur_gear(N, P = 12, pa = 14.5) { beta = ((360 / (4*N)) - alpha) * 2; module involute_tooth() { x = function(t) (r * (cos(t*rad_to_deg) + t * sin(t*rad_to_deg))); y = function(t) (r * (sin(t * rad_to_deg) - t * cos(t * rad_to_deg))); x2 = function(t) r * (cos(-t*rad_to_deg - beta) - t * sin(-t * rad_to_deg - beta)); y2 = function(t) r * (sin(-t*rad_to_deg - beta) + t * cos(-t * rad_to_deg - beta)); involute_1_points = parametric_points(fx=x, fy=y, t1=.68); involute_2_points = parametric_points(fx=x2, fy=y2, t1=.68); difference() { union() { polygon( concat( [[ 0, 0 ]], involute_1_points, reverse(involute_2_points), [[ 0, 0]] ) ); } // Use subtraction to extend the invlute curve towards the base // circle and then stop it at that point. This will // add some square-shaped space at the base of the tooth // NOTE: usage of undercut might be overkill. circle(d=(dp - 2*b)); } } difference() { circle(d=(dp + 2*a)); circular_mirror(d=0, steps=N) involute_tooth(); } } @@ -100,4 +107,4 @@ module circular_mirror(x=0, y=0, d, steps) { } } } } -
SharpCoder revised this gist
Jan 25, 2020 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,16 @@ include <gears.scad> Teeth = 20; Pitch = 12; linear_extrude(5) difference() { spur_gear(N=Teeth, P=Pitch); circle(d=19.1); } // Calculate distance between another gear (may need to add 1mm tolerance) OtherGearTeeth = 34; echo("***"); echo("center distance (mm)", calc_center_distance(Teeth, OtherGearTeeth, Pitch)); echo("***"); -
SharpCoder created this gist
Jan 25, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ include <gears.scad> linear_extrude(5) difference() { // Generate spur gear with 20 teeth spur_gear(N=20); // Add the bore for a shaft. circle(d=19.1); } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,103 @@ /** Constants **/ in_to_mm = 25.4; rad_to_deg = 180 / PI; deg_to_rad = PI / 180; /** Functions **/ function parametric_points(fx, fy, t0=0, t1=10, delta=0.01) = [for(i = [t0:delta:t1]) [fx(i), fy(i)]]; function reverse(vector) = [for(i = [1:len(vector)]) vector[len(vector) - i]]; /** Maths **/ function calc_module(P) = in_to_mm / P; function calc_addendum(P) = (1/P) * in_to_mm; function calc_dedendum(P) = (1.25/P) * in_to_mm; function calc_dp(N, P) = (N/P) * in_to_mm; function calc_db(N, P, pa) = calc_dp(N,P) * cos(pa); function calc_dr(N, P) = calc_dp(N,P) - 2 * calc_dedendum(P); function calc_circular_pitch(P) = (PI / P) * in_to_mm; function calc_thickness(P) = (1.5708 / P) * in_to_mm; function calc_alpha(dp, db, pa) = ((sqrt(pow(dp,2) - pow(db,2))/db) * rad_to_deg - pa); function calc_clearance(P) = calc_dedendum(P) - calc_addendum(P); function calc_center_distance(N1, N2, P) = in_to_mm * (N1 + N2) / (2 * P); /** Modules **/ /** Given some parameters, this method will generate a spur gear with an involute curve. Accepted paramters include: - N = How many teeth - P = Diametral pitch (all gears should have the same P) - pa = pressure angle (recommended to remain at 14.5) **/ module spur_gear(N, P = 12, pa = 14.5) { dp = calc_dp(N, P); db = calc_db(N, P, pa); dr = calc_dr(N, P); a = calc_addendum(P); c = calc_clearance(P); p = calc_circular_pitch(P); // Undercut adjustment // NOTE: this might not be great? IDK undercut = 1 * c; // Calculate radius to begin the involute calculations r = (db - undercut) * .5; alpha = calc_alpha(dp, db, pa); beta = ((360 / (4*N)) - alpha) * 2; module involute_tooth() { x = function(t) (r * cos(t*rad_to_deg)) + (r * t * sin(t*rad_to_deg)); y = function(t) (r * sin(t*rad_to_deg)) - (r * t * cos(t*rad_to_deg)); x2 = function(t) r * (cos(-t*rad_to_deg - beta) - t * sin(-t * rad_to_deg - beta)); y2 = function(t) r * (sin(-t*rad_to_deg - beta) + t * cos(-t * rad_to_deg - beta)); involute_1_points = parametric_points(fx=x, fy=y, t1=1); involute_2_points = parametric_points(fx=x2, fy=y2, t1=1); union() { polygon( concat( involute_1_points, reverse(involute_2_points) ) ); } } difference() { circle(d=(dp + 2*a)); rotate(-p) // This rotate doesn't really matter circular_mirror(d=0, steps=N) involute_tooth(); } } /** Helper 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(); } } } }