Given a list of gear in term of the gear teeth number, find the rpm of the last cog, the driven gear will rotate at 1 rpm in the clockwise direction.

Before we start this example, I would like to give credit to the below articles that help me to solve this problem.

  1. How to Determine Gear Ratio.
  2. Python Math: Convert a float to ratio.

The steps we need to solve this problem (not in order) are as follows:-

  1. Find out the rpm of the last cog with this formula : rpm of first cog x teeth number of first cog = rpm of last cog x teeth number of last cog.
  2. If the list has even number of cog teeth, then the last gear will turn counter clock wise, or else that gear will turn clockwise.
  3. Use the Fraction python module to return the answer as fraction instead of float value.
from fractions import Fraction
def cog_RPM(cogs):

    # determine whether the last gear will spin clockwise or counter clockwise
    length_cog = len(cogs) 
    sign = 1 # cw
    if (length_cog % 2) == 0:
        sign = -1 #ccw

    # the number of teeth of the first gear and the last cog
    driven_gear = cogs.pop(0)
    drive_gear = cogs.pop(len(cogs)-1)

    # find the rpm of the last gear, use Fraction module to return the rpm in fraction value
    rpm = sign * (Fraction(driven_gear/drive_gear).limit_denominator())
    return rpm

The cog calculation is part of the mechanical engineering knowledge, do feel free to read one of the article above on how to determine gear ratio to learn more about this subject.

As usual, leave your comment below if you have a better idea to solve this problem.

Click to rate this post!
[Total: 0 Average: 0]
Please follow and like us:
error0

Leave a Reply

Your email address will not be published. Required fields are marked *