This program interactively makes irregular two-dimensional shapes that function together as gears. Click in the gray square to start.

In June of 2013, I saw How To Make Organically-Shaped Gears, a 2010 video by Clayton Boyer, a totally awesome maker of elaborate wooden clocks, which shows a fairly general method for constructing a gear to mesh with another gear whose form is nearly arbitrary. Boyer uses two existing spur gears with the desired gear ratio (which probably needs to be fairly simple, like 1:1, 1:2, 2:3, or something like that, not 7:8 or 23:29), tapes a paper disc on top of one, and affixes the arbitrary shape to the other one. Then he rotates the two gears together, marking out the places where the arbitrary shape overlaps the paper disc; the remaining places, where it does not overlap, form the shape of the other gear.

That’s the basic thing this program does. You draw a red “draft” gear by clicking in the gray area, and it cuts away the gray where the red gear has to be able to move freely during its movement. If you click the “Exchange” button, the roles reverse: the old gray becomes the new red (which you can add to), a new gray field is established, and fairly quickly, the gray that would interfere with your gear gets cut away. If you wait long enough, it becomes fairly smooth. After a click of “Exchange”, the gears remain in contact with one another throughout their revolution, although not necessarily good contact.

You can also change the gear ratio you’re going for by clicking the buttons labeled with ratios such as “1:3”.

I used this program to 3-D print a couple of gears on a Prusa Mendel, and they seem to mesh pretty well when I try them by hand, although I haven’t mounted them to see if they really work. The process, which I clearly need to streamline because it took me like an hour in all, was as follows:

  1. Design the gears in this program, in Iceweasel (Firefox).
  2. Right-click on the canvas and “Save Image As” a PNG.
  3. Extract the gear shapes as raster PNGs:
    1. open the PNG in the GIMP,
    2. merge the existing layer down onto a new white background, convert it to Image → Mode → Grayscale,
    3. use Colors → Curves... to turn only the red gear black, and
    4. export it as a PNG.
    5. Undo the curves,
    6. bucket-fill the big gray background with white to eliminate it,
    7. turn only the gray gear black with curves,
    8. and export it as another PNG.
  4. Convert the two raster gear shapes to DXF polygons:
    1. open them in Inkscape,
    2. trace to vector image (Path → Trace Bitmap...) with the default settings,
    3. edit the node paths (F2) and add a whole shitload of nodes with ctrl-alt-leftclick in between the existing nodes,
    4. turn the polyline into a polygon by selecting all the segments of the path (^A) and using “Make selected segments lines”,
    5. resize the path to make it smaller (by 50% for one gear and 49% for the other, although I should have scaled down to 25% of the original size),
    6. move it so it’s centered on the lower left-hand corner of the page (the origin), and
    7. save as a “Desktop Cutting Plotter (Autocad DXF R14)” DXF file (right, left.)
  5. Extrude the polygons into a vertical prism STL file; for each gear:
    1. In a new file in OpenSCAD, put linear_extrude(height=3) import("foo.dxf"); , where foo.dxf is the name of the DXF file containing one of the polygons. Actually I think height=6 would have been a better idea. With my pipeline, the units are, by default, millimeters, so in theory that’s 3mm high, but it ends up being a little higher in practice. Because they’re about 100mm wide, that’s a 30:1 aspect ratio, which makes the gears kind of prone to flop apart if they’re not sitting on a flat surface.
    2. Hit F5 to see the shape to see if it’s okay.
    3. Do a CGAL render and then export an STL file (right, left.)
  6. Generate G-code from the STL file (right, left). I use “Quick slice” in Slic3r.
  7. Look at the G-code in Pronterface from Printrun to see if it looks good.
  8. Send it to the RepRap to fabricate.

Aside from the crudeness of the process above, this code could be greatly improved in its efficiency, among other things by using bounding boxes and strength reduction so that it doesn’t have to do ten million multiplications per second.