boxespy/boxes/generators/gearbox.py

108 lines
3.7 KiB
Python
Raw Normal View History

2016-07-16 15:32:06 +02:00
#!/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 <http://www.gnu.org/licenses/>.
from boxes import *
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
class GearBox(Boxes):
"""Gearbox with multiple identical stages"""
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
def __init__(self):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
2016-07-16 15:32:06 +02:00
self.argparser.add_argument(
2016-08-17 15:07:41 +02:00
"--teeth1", action="store", type=int, default=8,
2016-07-16 15:32:06 +02:00
help="number of teeth on ingoing shaft")
self.argparser.add_argument(
2016-08-17 15:07:41 +02:00
"--teeth2", action="store", type=int, default=20,
2016-07-16 15:32:06 +02:00
help="number of teeth on outgoing shaft")
self.argparser.add_argument(
2016-08-17 15:07:41 +02:00
"--modulus", action="store", type=float, default=3,
2016-07-22 00:18:32 +02:00
help="modulus of the theeth in mm")
2016-07-16 15:32:06 +02:00
self.argparser.add_argument(
2016-08-17 15:07:41 +02:00
"--shaft", action="store", type=float, default=6.,
2016-07-16 15:32:06 +02:00
help="diameter of the shaft")
self.argparser.add_argument(
2016-08-17 15:07:41 +02:00
"--stages", action="store", type=int, default=4,
2016-07-16 15:32:06 +02:00
help="number of stages in the gear reduction")
def render(self):
# Initialize canvas
self.open()
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
if self.teeth2 < self.teeth1:
self.teeth2, self.teeth1 = self.teeth1, self.teeth2
2016-08-17 15:07:41 +02:00
pitch1, size1, xxx = self.gears.sizes(teeth=self.teeth1, dimension=self.modulus)
pitch2, size2, xxx = self.gears.sizes(teeth=self.teeth2, dimension=self.modulus)
2016-07-16 15:32:06 +02:00
t = self.thickness
2016-08-17 15:07:41 +02:00
x = 1.1 * t * self.stages
if self.stages == 1:
y = size1 + size2
2016-08-17 15:07:41 +02:00
y1 = y / 2 - (pitch1 + pitch2) + pitch1
y2 = y / 2 + (pitch1 + pitch2) - pitch2
else:
y = 2 * size2
2016-08-17 15:07:41 +02:00
y1 = y / 2 - (pitch1 + pitch2) / 2
y2 = y / 2 + (pitch1 + pitch2) / 2
2016-07-16 15:32:06 +02:00
h = max(size1, size2) + t
b = "F"
2016-08-17 15:07:41 +02:00
t = "e" # prepare for close box
2016-07-16 15:32:06 +02:00
mh = self.shaft
def sideCB():
2016-08-17 15:07:41 +02:00
self.hole(y1, h / 2, mh / 2)
self.hole(y2, h / 2, mh / 2)
2016-07-16 15:32:06 +02:00
self.moveTo(self.thickness, self.thickness)
self.rectangularWall(y, h, [b, "f", t, "f"], callback=[sideCB], move="right")
self.rectangularWall(x, h, [b, "F", t, "F"], move="up")
self.rectangularWall(x, h, [b, "F", t, "F"])
self.rectangularWall(y, h, [b, "f", t, "f"], callback=[sideCB], move="left")
self.rectangularWall(x, h, [b, "F", t, "F"], move="up only")
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
self.rectangularWall(x, y, "ffff", move="up")
2016-07-17 17:24:40 +02:00
profile_shift = 20
pressure_angle = 20
2016-08-17 15:07:41 +02:00
for i in range(self.stages - 1):
self.gears(teeth=self.teeth2, dimension=self.modulus, angle=pressure_angle,
2016-07-17 17:24:40 +02:00
mount_hole=mh, profile_shift=profile_shift, move="up")
2016-08-17 15:07:41 +02:00
self.gears(teeth=self.teeth2, dimension=self.modulus, angle=pressure_angle,
2016-07-17 17:24:40 +02:00
mount_hole=mh, profile_shift=profile_shift, move="right")
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
for i in range(self.stages):
2016-08-17 15:07:41 +02:00
self.gears(teeth=self.teeth1, dimension=self.modulus, angle=pressure_angle,
2016-07-17 17:24:40 +02:00
mount_hole=mh, profile_shift=profile_shift, move="down")
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
self.close()
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
def main():
2016-08-17 15:07:41 +02:00
b = GearBox()
2016-07-16 15:32:06 +02:00
b.parseArgs()
b.render()
2016-08-17 15:07:41 +02:00
2016-07-16 15:32:06 +02:00
if __name__ == '__main__':
main()