* Gears DLC (free) Using the involuteCircular fn to create a variety of cylindrical gearsets * Delete public/kcl-samples/gear directory * Update main.kcl fixing gear meshing * new samples Signed-off-by: Jess Frazelle <github@jessfraz.com> * add link Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com> Co-authored-by: Jess Frazelle <github@jessfraz.com>
		
			
				
	
	
		
			187 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			187 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
// Herringbone Planetary Gearset
 | 
						|
// A herringbone planetary gearset is a type of planetary gear system where the teeth of the sun gear, planet gears, and/or ring gear are herringbone rather than straight. This design allows for smoother, quieter operation, greater load-carrying capacity, and more flexible shaft alignment.
 | 
						|
 | 
						|
// Set units
 | 
						|
@settings(defaultLengthUnit = mm)
 | 
						|
 | 
						|
// Define a function to create a herringbone gear
 | 
						|
fn herringboneGear(nTeeth, module, pressureAngle, helixAngle, gearHeight) {
 | 
						|
  // Calculate gear parameters
 | 
						|
  pitchDiameter = module * nTeeth
 | 
						|
  addendum = module
 | 
						|
  deddendum = 1.25 * module
 | 
						|
  baseDiameter = pitchDiameter * cos(pressureAngle)
 | 
						|
  tipDiameter = pitchDiameter + 2 * module
 | 
						|
 | 
						|
  // Define a function to create a rotated gear sketch on an offset plane
 | 
						|
  fn herringboneGearSketch(offsetHeight) {
 | 
						|
    // Calculate the amount to rotate each planar sketch of the gear given the gear helix angle and total gear height
 | 
						|
    helixCalc = acos(offsetHeight * tan(helixAngle) / (tipDiameter / 2))
 | 
						|
 | 
						|
    // Using the gear parameters, sketch an involute tooth spanning from the base diameter to the tip diameter
 | 
						|
    herringboneGearSketch = startSketchOn(offsetPlane(XY, offset = offsetHeight))
 | 
						|
      |> startProfile(at = polar(angle = helixCalc, length = baseDiameter / 2))
 | 
						|
      |> involuteCircular(
 | 
						|
           startRadius = baseDiameter / 2,
 | 
						|
           endRadius = tipDiameter / 2,
 | 
						|
           angle = helixCalc,
 | 
						|
           tag = $seg01,
 | 
						|
         )
 | 
						|
      |> line(endAbsolute = polar(angle = 160 / nTeeth + helixCalc, length = tipDiameter / 2))
 | 
						|
      |> involuteCircular(
 | 
						|
           startRadius = baseDiameter / 2,
 | 
						|
           endRadius = tipDiameter / 2,
 | 
						|
           angle = -(4 * atan(segEndY(seg01) / segEndX(seg01)) - (3 * helixCalc)),
 | 
						|
           reverse = true,
 | 
						|
         )
 | 
						|
 | 
						|
      // Position the end line of the sketch at the start of the next tooth
 | 
						|
      |> line(endAbsolute = polar(angle = 360 / nTeeth + helixCalc, length = baseDiameter / 2))
 | 
						|
 | 
						|
      // Pattern the sketch about the center by the specified number of teeth, then close the sketch
 | 
						|
      |> patternCircular2d(
 | 
						|
           %,
 | 
						|
           instances = nTeeth,
 | 
						|
           center = [0, 0],
 | 
						|
           arcDegrees = 360,
 | 
						|
           rotateDuplicates = true,
 | 
						|
         )
 | 
						|
      |> close()
 | 
						|
      // Create a center hole with an 8mm diameter
 | 
						|
      |> subtract2d(tool = circle(center = [0, 0], radius = 4))
 | 
						|
    return herringboneGearSketch
 | 
						|
  }
 | 
						|
 | 
						|
  // Draw a gear sketch on the base plane
 | 
						|
  gearSketch001 = herringboneGearSketch(offsetHeight = 0)
 | 
						|
 | 
						|
  // Draw a gear sketch that has been rotated by the helix angle
 | 
						|
  gearSketch002 = herringboneGearSketch(offsetHeight = gearHeight / 2)
 | 
						|
 | 
						|
  // Draw a gear sketch at the total gear height that reverses the angle direction
 | 
						|
  gearSketch003 = clone(gearSketch001)
 | 
						|
    |> translate(z = gearHeight)
 | 
						|
 | 
						|
  // Loft each rotated gear sketch together to form a herringbone gear
 | 
						|
  herringboneGear = loft(
 | 
						|
    [
 | 
						|
      gearSketch001,
 | 
						|
      gearSketch002,
 | 
						|
      gearSketch003
 | 
						|
    ],
 | 
						|
    vDegree = 1,
 | 
						|
  )
 | 
						|
 | 
						|
  return herringboneGear
 | 
						|
}
 | 
						|
 | 
						|
// Define a function to create a ring gear
 | 
						|
fn ringGear(nTeeth, module, pressureAngle, helixAngle, gearHeight) {
 | 
						|
  // Calculate gear parameters
 | 
						|
  pitchDiameter = module * nTeeth
 | 
						|
  addendum = module
 | 
						|
  deddendum = 1.25 * module
 | 
						|
  baseDiameter = pitchDiameter * cos(pressureAngle)
 | 
						|
  tipDiameter = pitchDiameter + 2 * module
 | 
						|
 | 
						|
  // Define a function to create a rotated gear sketch on an offset plane
 | 
						|
  fn ringGearSketch(offsetHeight) {
 | 
						|
    // Calculate the amount to rotate each planar sketch of the gear given the gear helix angle and total gear height
 | 
						|
    helixCalc = acos(offsetHeight * tan(helixAngle) / (tipDiameter / 2))
 | 
						|
 | 
						|
    // Using the gear parameters, sketch an involute tooth spanning from the base diameter to the tip diameter
 | 
						|
    ringTeeth = startSketchOn(offsetPlane(XY, offset = offsetHeight))
 | 
						|
      |> startProfile(at = polar(angle = helixCalc, length = baseDiameter / 2))
 | 
						|
      |> involuteCircular(
 | 
						|
           startRadius = baseDiameter / 2,
 | 
						|
           endRadius = tipDiameter / 2,
 | 
						|
           angle = helixCalc,
 | 
						|
           tag = $seg01,
 | 
						|
         )
 | 
						|
      |> line(endAbsolute = polar(angle = 220 / nTeeth + helixCalc, length = tipDiameter / 2))
 | 
						|
      |> involuteCircular(
 | 
						|
           startRadius = baseDiameter / 2,
 | 
						|
           endRadius = tipDiameter / 2,
 | 
						|
           angle = -(4 * atan(segEndY(seg01) / segEndX(seg01)) - (3 * helixCalc)),
 | 
						|
           reverse = true,
 | 
						|
         )
 | 
						|
 | 
						|
      // Position the end line of the sketch at the start of the next tooth
 | 
						|
      |> line(endAbsolute = polar(angle = 360 / nTeeth + helixCalc, length = baseDiameter / 2))
 | 
						|
 | 
						|
      // Pattern the sketch about the center by the specified number of teeth, then close the sketch
 | 
						|
      |> patternCircular2d(
 | 
						|
           %,
 | 
						|
           instances = nTeeth,
 | 
						|
           center = [0, 0],
 | 
						|
           arcDegrees = 360,
 | 
						|
           rotateDuplicates = true,
 | 
						|
         )
 | 
						|
      |> close()
 | 
						|
 | 
						|
    // Create a circular body that is larger than the tip diameter of the gear, then subtract the gear profile from the body
 | 
						|
    ringGearSketch = startSketchOn(offsetPlane(XY, offset = offsetHeight))
 | 
						|
      |> circle(center = [0, 0], radius = tipDiameter / 1.8)
 | 
						|
      |> subtract2d(tool = ringTeeth)
 | 
						|
    return ringGearSketch
 | 
						|
  }
 | 
						|
 | 
						|
  // Draw a gear sketch on the base plane
 | 
						|
  gearSketch001 = ringGearSketch(offsetHeight = 0)
 | 
						|
 | 
						|
  // Draw a rotated gear sketch on a middle interstitial plane
 | 
						|
  gearSketch002 = ringGearSketch(offsetHeight = gearHeight / 2)
 | 
						|
 | 
						|
  // Draw a gear sketch at the total gear height that reverses the angle direction
 | 
						|
  gearSketch003 = clone(gearSketch001)
 | 
						|
    |> translate(z = gearHeight)
 | 
						|
 | 
						|
  // Loft each rotated gear sketch together to form a ring gear
 | 
						|
  ringGear = loft(
 | 
						|
    [
 | 
						|
      gearSketch001,
 | 
						|
      gearSketch002,
 | 
						|
      gearSketch003
 | 
						|
    ],
 | 
						|
    vDegree = 1,
 | 
						|
  )
 | 
						|
 | 
						|
  return ringGear
 | 
						|
}
 | 
						|
 | 
						|
// Create the outer ring gear for the planetary gearset
 | 
						|
ringGear(
 | 
						|
  nTeeth = 58,
 | 
						|
  module = 1.5,
 | 
						|
  pressureAngle = 14,
 | 
						|
  helixAngle = -35,
 | 
						|
  gearHeight = 8,
 | 
						|
)
 | 
						|
 | 
						|
// Create a central sun gear using a small herringbone gear
 | 
						|
herringboneGear(
 | 
						|
  nTeeth = 18,
 | 
						|
  module = 1.5,
 | 
						|
  pressureAngle = 14,
 | 
						|
  helixAngle = 35,
 | 
						|
  gearHeight = 8,
 | 
						|
)
 | 
						|
 | 
						|
// Create the herringbone planet gears
 | 
						|
numPlanetGears = 4
 | 
						|
herringboneGear(
 | 
						|
       nTeeth = 18,
 | 
						|
       module = 1.5,
 | 
						|
       pressureAngle = 14,
 | 
						|
       helixAngle = -35,
 | 
						|
       gearHeight = 8,
 | 
						|
     )
 | 
						|
  |> translate(y = 18 * 1.5 + 1.95)
 | 
						|
  |> patternCircular3d(
 | 
						|
       instances = numPlanetGears,
 | 
						|
       axis = [0, 0, 1],
 | 
						|
       center = [0, 0, 0],
 | 
						|
       arcDegrees = 360,
 | 
						|
       rotateDuplicates = false,
 | 
						|
     )
 |