From 1849bfd5ab58d1b1992f89a1be884e8f3009c22c Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Mon, 25 Jul 2016 18:50:36 +0200 Subject: [PATCH] New PlanetaryGear generator --- boxes/generators/planetary.py | 92 +++++++++++++++++++++++++++++++++++ scripts/boxesserver | 3 +- 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 boxes/generators/planetary.py diff --git a/boxes/generators/planetary.py b/boxes/generators/planetary.py new file mode 100644 index 0000000..942c6cb --- /dev/null +++ b/boxes/generators/planetary.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# Copyright (C) 2013-2016 Florian Festi +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from boxes import * +import math + +class Planetary(Boxes): + """Gearbox with multiple identical stages""" + def __init__(self): + Boxes.__init__(self) + self.argparser.add_argument( + "--sunteeth", action="store", type=int, default=8, + help="number of teeth on sun gear") + self.argparser.add_argument( + "--planetteeth", action="store", type=int, default=20, + help="number of teeth on planets") + self.argparser.add_argument( + "--modulus", action="store", type=float, default=3, + help="modulus of the theeth in mm") + self.argparser.add_argument( + "--shaft", action="store", type=float, default=6., + help="diameter of the shaft") + #self.argparser.add_argument( + # "--stages", action="store", type=int, default=4, + # help="number of stages in the gear reduction") + + def render(self): + # Initialize canvas + self.open() + + ringteeth = self.sunteeth+2*self.planetteeth + + pitch1, size1, xxx = self.gears.sizes(teeth=self.sunteeth, + dimension=self.modulus) + pitch2, size2, xxx = self.gears.sizes(teeth=self.planetteeth, + dimension=self.modulus) + pitch3, size3, xxx = self.gears.sizes( + teeth=ringteeth, internal_ring=True, spoke_width=10, + dimension=self.modulus) + + t = self.thickness + planets = int(math.pi//math.asin((self.planetteeth+2)/(self.planetteeth+self.sunteeth))) + + # Make sure the teeth mash + ta = self.sunteeth+ringteeth + # There are sunteeth+ringteeth mashing positions for the planets + if ta % planets: + planetpositions = [round(i*ta/planets)*360/ta for i in range(planets)] + else: + planetpositions = planets + + # XXX make configurable? + profile_shift = 20 + pressure_angle = 20 + spoke_width = 3*self.shaft + self.parts.disc(size3, lambda:self.hole(0,0,self.shaft/2), move="up") + self.gears(teeth=ringteeth, dimension=self.modulus, + angle=pressure_angle, internal_ring=True, + spoke_width=spoke_width, mount_hole=self.shaft, + profile_shift=profile_shift, move="up") + self.gears.gearCarrier(pitch1+pitch2, spoke_width, planetpositions, + 2*spoke_width, self.shaft/2, move="up") + self.gears(teeth=self.sunteeth, dimension=self.modulus, + angle=pressure_angle, + mount_hole=self.shaft, profile_shift=profile_shift, move="up") + for i in range(planets): + self.gears(teeth=self.planetteeth, dimension=self.modulus, + angle=pressure_angle, + mount_hole=self.shaft, profile_shift=profile_shift, move="up") + + self.close() + +def main(): + b = Box() + b.parseArgs() + b.render() + +if __name__ == '__main__': + main() diff --git a/scripts/boxesserver b/scripts/boxesserver index 499aa7c..c8ade43 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -28,7 +28,7 @@ except ImportError: from boxes.generators import box, box2, box3, drillbox from boxes.generators import flexbox, flexbox2, flexbox3, flexbox4, gearbox -from boxes.generators import flextest, flextest2, folder, pulley +from boxes.generators import flextest, flextest2, folder, planetary, pulley from boxes.generators import magazinefile, trayinsert, traylayout, typetray, silverwarebox @@ -91,6 +91,7 @@ class BServer: "GearBox" : gearbox.GearBox(), "MagazinFile" : magazinefile.Box(), "TrayInsert" : trayinsert.TrayInsert(), + "PlanetaryGear" : planetary.Planetary(), "Pulley" : pulley.Pulley(), "TypeTray" : typetray.TypeTray(), "SilverwareBox" : silverwarebox.Silverware(),