Helps with the design of lego gear trains.
JavaScript Racket CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
racket
readme-pics
web
LICENSE
README.md
index.html

README.md

lego-gears

Helping you find the perfect Lego gear train for your project.

example usage

Let's say you have the following situation:

the-situation

Your gear train has to connect the two axle pins, and you need it to have a gear ratio of 2:-1. This means that when the gear on the left axle pin spins, the gear on the right axle pin will spin in the opposite direction at twice the speed. For your gear train to work, it has to span 5.5 units across and 2.6666 or 8/3 units up.

I'm assuming you have Racket installed. If not, you can get it here.

From your shell, move to the lego-gears directory.

Open up a Racket xrepl session:

steve@grizzles:~/Dropbox/Personal/programming/scheme/lego-gears/racket$ racket -il xrepl
Welcome to Racket v5.2.1.
->

Load in the lego-gears.rkt file:

-> ,en lego-gears.rkt
"lego-gears.rkt"> 

We're going to use the procedure called get-best-solutions. You call it like this:

(get-best-solutions list-of-objectives)

An objective is a list with following elements: up, across, ratio. We only have one objective, which would look like this: (note that it's best to use rational numbers instead of decimal numbers)

'(8/3 11/2 -1/2)

Our list-of-objectives is a list of just one objective, so it looks like this:

'((8/3 11/2 -1/2))

Now we can call our get-best-solutions procedure:

"lego-gears.rkt"> (get-best-solutions '((8/3 11/2 -1/2)))
'(((24 24 0 3) (24 20 7/3 1/2) (20 12 1/3 2))
  ((24 24 0 3) (24 16 4/3 2) (16 12 4/3 1/2))
  ((24 24 1/3 3) (24 20 7/3 1/2) (20 12 0 2))
  ((24 24 1/3 3) (24 12 4/3 3/2) (12 12 1 1))
  ((24 24 2/3 3) (24 12 1 2) (12 12 1 1/2))
  ((24 24 2/3 3) (24 12 5/3 1) (12 12 1/3 3/2))
  ((24 24 4/3 5/2) (24 16 0 5/2) (16 12 4/3 1/2))
  ((24 24 4/3 5/2) (24 12 4/3 3/2) (12 12 0 3/2))
  ((24 16 1/3 5/2) (16 20 4/3 3/2) (20 12 1 3/2))
  ((24 16 2/3 5/2) (16 20 5/3 1) (20 12 1/3 2))
  ((24 16 4/3 2) (16 20 4/3 3/2) (20 12 0 2))
  ((24 16 5/3 3/2) (16 20 1 2) (20 12 0 2)))

The procedure returns a list of solutions. Let's take a look at the first solution.

'((24 24 0 3) (24 20 7/3 1/2) (20 12 1/3 2))

The solution is a list of three combinations. A combination has the following elements: first-gear, second-gear, up, across. The first element on our list is '(24 24 0 3). That is a 24-tooth gear meshed with a 24-tooth gear, that are separated by three units across.

two-gears

The next element on our list is '(24 20 7/3 1/2). This means the last 24-tooth gear is meshed with a 20-tooth gear, which is separated by 7/3 units up and 1/2 units across.

three-gears

The last element on our list is '(20 12 1/3 2). This means the last 20-tooth gear is meshed with a 12-tooth gear, which is separated by 1/3 units up and 1/2 units across.

four-gears

That's the complete solution! You might have noticed that we only chose the first of many possible solutions.