| 1 | // OpenSCAD Herringbone Wade's Gears Script |
| 2 | // (c) 2011, Christopher "ScribbleJ" Jansen |
| 3 | // |
| 4 | // Thanks to Greg Frost for his great "Involute Gears" script. |
| 5 | // |
| 6 | // Licensed under the BSD license. |
| 7 | // |
| 8 | // Adapted for Reprap Wilson by Martin Rice |
| 9 | // |
| 10 | |
| 11 | include <MCAD/involute_gears.scad> |
| 12 | |
| 13 | |
| 14 | // WHAT TO GENERATE? |
| 15 | generate = 0; // GENERATE BOTH GEARS FOR VIEWING |
| 16 | generate = 1; // GENERATE STEPPER GEAR FOR PRINTING |
| 17 | // generate = 2; // GENERATE DRIVE GEAR FOR PRINTING |
| 18 | |
| 19 | // OPTIONS COMMON TO BOTH GEARS: |
| 20 | distance_between_axels = 42; |
| 21 | gear_h = 10; |
| 22 | |
| 23 | // for big |
| 24 | //gear_shaft_h = 5; |
| 25 | |
| 26 | // for small |
| 27 | gear_shaft_h = 10; |
| 28 | |
| 29 | |
| 30 | // GEAR1 (SMALLER GEAR, STEPPER GEAR) OPTIONS: |
| 31 | // It's helpful to choose prime numbers for the gear teeth. |
| 32 | gear1_teeth = 13; |
| 33 | gear1_shaft_d = 5.6; // diameter of motor shaft |
| 34 | gear1_shaft_r = gear1_shaft_d/2; |
| 35 | // gear1 shaft assumed to fill entire gear. |
| 36 | // gear1 attaches by means of a captive nut and bolt (or actual setscrew) |
| 37 | gear1_setscrew_offset = 5; // Distance from motor on motor shaft. |
| 38 | gear1_setscrew_d = 3.5; |
| 39 | gear1_setscrew_r = gear1_setscrew_d/2; |
| 40 | gear1_captive_nut_d = 6; |
| 41 | gear1_captive_nut_r = gear1_captive_nut_d/2; |
| 42 | gear1_captive_nut_h = 2.5; |
| 43 | |
| 44 | |
| 45 | // GEAR2 (LARGER GEAR, DRIVE SHAFT GEAR) OPTIONS: |
| 46 | gear2_teeth = 37; |
| 47 | gear2_shaft_d = 8.6; |
| 48 | gear2_shaft_r = gear2_shaft_d/2; |
| 49 | // gear2 has settable outer shaft diameter. |
| 50 | gear2_shaft_outer_d = 16; |
| 51 | gear2_shaft_outer_r = gear2_shaft_outer_d/2; |
| 52 | |
| 53 | // gear2 has a hex bolt set in it, is either a hobbed bolt or has the nifty hobbed gear from MBI on it. |
| 54 | gear2_bolt_hex_d = 15.2; |
| 55 | gear2_bolt_hex_r = gear2_bolt_hex_d/2; |
| 56 | // gear2_bolt_sink: How far down the gear shaft the bolt head sits; measured as distance from drive end of gear. |
| 57 | gear2_bolt_sink = 5; |
| 58 | // gear2's shaft is a bridge above the hex bolt shaft; this creates 1/3bridge_helper_h sized steps at top of shaft to help bridging. (so bridge_helper_h/3 should be > layer height to have any effect) |
| 59 | bridge_helper_h=1; |
| 60 | |
| 61 | gear2_rim_margin = 3; |
| 62 | gear2_cut_circles = 5; |
| 63 | |
| 64 | // gear2 setscrew option; not likely needed. |
| 65 | gear2_setscrew_offset = 0; |
| 66 | gear2_setscrew_d = 0; |
| 67 | gear2_setscrew_r = gear2_setscrew_d/2; |
| 68 | // captive nut for the setscrew |
| 69 | gear2_captive_nut_d = 0; |
| 70 | gear2_captive_nut_r = gear2_captive_nut_d/2; |
| 71 | gear2_captive_nut_h = 0; |
| 72 | |
| 73 | |
| 74 | // Tolerances for geometry connections. |
| 75 | AT=0.02; |
| 76 | ST=AT*2; |
| 77 | TT=AT/2; |
| 78 | |
| 79 | |
| 80 | module bridge_helper() |
| 81 | { |
| 82 | difference() |
| 83 | { |
| 84 | translate([0,0,-bridge_helper_h/2]) |
| 85 | cylinder(r=gear2_bolt_hex_r+TT, h=bridge_helper_h+TT,$fn=6,center=true); |
| 86 | #translate([0,0,-bridge_helper_h/2]) |
| 87 | cube([gear2_bolt_hex_d+ST, gear2_shaft_d, bridge_helper_h+AT], center=true); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | |
| 92 | |
| 93 | module gearsbyteethanddistance(t1=13,t2=51, d=60, teethtwist=1, which=1) |
| 94 | { |
| 95 | cp = 360*d/(t1+t2); |
| 96 | |
| 97 | g1twist = 360 * teethtwist / t1 / 2; |
| 98 | g2twist = 360 * teethtwist / t2 / 2; |
| 99 | |
| 100 | g1p_d = t1 * cp / 180; |
| 101 | g2p_d = t2 * cp / 180; |
| 102 | g1p_r = g1p_d/2; |
| 103 | g2p_r = g2p_d/2; |
| 104 | |
| 105 | echo(str("Your small ", t1, "-toothed gear will be ", g1p_d, "mm across (plus 1 gear tooth size) (PR=", g1p_r,")")); |
| 106 | echo(str("Your large ", t2, "-toothed gear will be ", g2p_d, "mm across (plus 1 gear tooth size) (PR=", g2p_r,")")); |
| 107 | echo(str("Your minimum drive bolt length (to end of gear) is: ", gear2_bolt_sink+bridge_helper_h, "mm and your max is: ", gear_h+gear_shaft_h, "mm.")); |
| 108 | echo(str("Your gear mount axles should be ", d,"mm (", g1p_r+g2p_r,"mm calculated) from each other.")); |
| 109 | if(which == 1) |
| 110 | { |
| 111 | // GEAR 1 |
| 112 | difference() |
| 113 | { |
| 114 | union() |
| 115 | { |
| 116 | translate([0,0,(gear_h/2) - TT]) |
| 117 | gear( twist = g1twist, |
| 118 | number_of_teeth=t1, |
| 119 | circular_pitch=cp, |
| 120 | gear_thickness = gear_shaft_h + (gear_h/2)+AT, |
| 121 | rim_thickness = (gear_h/2)+AT, |
| 122 | rim_width = 0, |
| 123 | hub_thickness = (gear_h/2)+AT, |
| 124 | hub_width = 0, |
| 125 | bore_diameter=0); |
| 126 | |
| 127 | translate([0,0,(gear_h/2) + AT]) |
| 128 | rotate([180,0,0]) |
| 129 | gear( twist = -g1twist, |
| 130 | number_of_teeth=t1, |
| 131 | circular_pitch=cp, |
| 132 | gear_thickness = (gear_h/2)+AT, |
| 133 | rim_thickness = (gear_h/2)+AT, |
| 134 | hub_thickness = (gear_h/2)+AT, |
| 135 | bore_diameter=0); |
| 136 | } |
| 137 | //DIFFERENCE: |
| 138 | //shafthole |
| 139 | translate([0,0,-TT]) |
| 140 | cylinder(r=gear1_shaft_r, h=gear_h+gear_shaft_h+ST); |
| 141 | |
| 142 | //setscrew shaft |
| 143 | translate([0,0,gear_h+gear_shaft_h-gear1_setscrew_offset]) |
| 144 | rotate([0,90,0]) |
| 145 | cylinder(r=gear1_setscrew_r, h=g1p_r); |
| 146 | |
| 147 | //setscrew captive nut |
| 148 | translate([(g1p_r)/2, 0, gear_h+gear_shaft_h-gear1_captive_nut_r-gear1_setscrew_offset]) |
| 149 | translate([0,0,(gear1_captive_nut_r+gear1_setscrew_offset)/2]) |
| 150 | #cube([gear1_captive_nut_h, gear1_captive_nut_d, gear1_captive_nut_r+gear1_setscrew_offset+ST],center=true); |
| 151 | |
| 152 | |
| 153 | } |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | // GEAR 2 |
| 158 | difference() |
| 159 | { |
| 160 | union() |
| 161 | { |
| 162 | // cylinder(h=gear_h+gear_shaft_h , r=gear2_shaft_outer_r); |
| 163 | |
| 164 | translate([0,0,(gear_h/2) - TT]) |
| 165 | gear( twist = -g2twist, |
| 166 | number_of_teeth=t2, |
| 167 | circular_pitch=cp, |
| 168 | gear_thickness = gear_shaft_h + (gear_h/2)+AT, |
| 169 | rim_thickness = (gear_h/2)+AT, |
| 170 | rim_width = gear2_rim_margin, |
| 171 | hub_diameter = gear2_shaft_outer_d, |
| 172 | hub_thickness = (gear_h/2)+AT, |
| 173 | bore_diameter=0, |
| 174 | circles = gear2_cut_circles); |
| 175 | |
| 176 | translate([0,0,(gear_h/2) + AT]) |
| 177 | rotate([180,0,0]) |
| 178 | gear( twist = g2twist, |
| 179 | number_of_teeth=t2, |
| 180 | circular_pitch=cp, |
| 181 | gear_thickness = (gear_h/2)+AT, |
| 182 | rim_thickness = (gear_h/2)+AT, |
| 183 | rim_width = gear2_rim_margin, |
| 184 | hub_diameter = gear2_shaft_outer_d, |
| 185 | hub_thickness = (gear_h/2)+AT, |
| 186 | bore_diameter=0, |
| 187 | circles = gear2_cut_circles); |
| 188 | } |
| 189 | |
| 190 | //DIFFERENCE: |
| 191 | //shafthole |
| 192 | translate([0,0,-TT]) |
| 193 | cylinder(r=gear2_shaft_r, h=gear_h+gear_shaft_h+ST); |
| 194 | |
| 195 | //setscrew shaft |
| 196 | if(0) { |
| 197 | translate([0,0,gear_h+gear_shaft_h-gear2_setscrew_offset]) |
| 198 | rotate([0,90,0]) |
| 199 | cylinder(r=gear2_setscrew_r, h=gear2_shaft_outer_d); |
| 200 | |
| 201 | //setscrew captive nut |
| 202 | translate([(gear2_shaft_outer_d)/2, 0, gear_h+gear_shaft_h-gear2_captive_nut_r-gear2_setscrew_offset]) |
| 203 | translate([0,0,(gear2_captive_nut_r+gear2_setscrew_offset)/2]) |
| 204 | #cube([gear2_captive_nut_h, gear2_captive_nut_d, gear2_captive_nut_r+gear2_setscrew_offset+ST],center=true); |
| 205 | } |
| 206 | |
| 207 | //trim shaft |
| 208 | difference() |
| 209 | { |
| 210 | translate([0,0,gear_h+AT]) cylinder(h=gear_shaft_h+ST, r=g2p_r); |
| 211 | #translate([0,0,gear_h]) cylinder(h=gear_shaft_h , r=gear2_shaft_outer_r); |
| 212 | } |
| 213 | |
| 214 | //hex bolt shaft |
| 215 | translate([0,0,-TT]) cylinder(r=gear2_bolt_hex_r, h=gear2_bolt_sink+AT,$fn=6); |
| 216 | |
| 217 | } |
| 218 | |
| 219 | if(1) translate([0,0,1]) { |
| 220 | // hex bolt shaft bridge aid. |
| 221 | #translate([0,0,gear2_bolt_sink]) //gear_h+gear_shaft_h-gear2_bolt_sink]) |
| 222 | bridge_helper(); |
| 223 | #translate([0,0,gear2_bolt_sink-bridge_helper_h/3]) //gear_h+gear_shaft_h-gear2_bolt_sink+bridge_helper_h/3]) |
| 224 | rotate([0,0,60]) bridge_helper(); |
| 225 | #translate([0,0,gear2_bolt_sink-(bridge_helper_h/3*2)]) //gear_h+gear_shaft_h-gear2_bolt_sink+((bridge_helper_h/3)*2)]) |
| 226 | rotate([0,0,-60]) bridge_helper(); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | } |
| 231 | |
| 232 | |
| 233 | t1 = gear1_teeth; |
| 234 | t2 = gear2_teeth; |
| 235 | cp = 360*distance_between_axels/(t1+t2); |
| 236 | g1p_d = t1 * cp / 180; |
| 237 | g2p_d = t2 * cp / 180; |
| 238 | g1p_r = g1p_d/2; |
| 239 | g2p_r = g2p_d/2; |
| 240 | |
| 241 | if(generate == 1) |
| 242 | { |
| 243 | gearsbyteethanddistance(t1 = gear1_teeth, t2=gear2_teeth, d=distance_between_axels, which=1); |
| 244 | } |
| 245 | else if(generate == 2) |
| 246 | { |
| 247 | gearsbyteethanddistance(t1 = gear1_teeth, t2=gear2_teeth, d=distance_between_axels, which=2); |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | |
| 252 | translate([-g1p_r,0,0]) rotate([0,0,($t*360/gear1_teeth)]) gearsbyteethanddistance(t1 = gear1_teeth, t2=gear2_teeth, d=distance_between_axels, which=1); |
| 253 | translate([g2p_r,0,0]) rotate([0,0,($t*360/gear2_teeth)*-1]) gearsbyteethanddistance(t1 = gear1_teeth, t2=gear2_teeth, d=distance_between_axels, which=2); |
| 254 | } |
| 255 | |