Guerrilla guide to CNC machining, mold making, and resin casting
Copyright (C) 2013, 2014, 2015, 2016 by Michal Zalewski (
Follow the author on Twitter: @lcamtuf
You are viewing chapter 6 of 8. Click this box for table of contents.

6. Practical part geometries

To wrap up the discussion of technical topics, let's go over a collection of practical approaches that should help you create useful and reliable mechanical designs for small- to medium-sized projects - no matter if you are using CNC machining, 3D printing, or still carving stuff in stone. The failure to get even the most rudimentary understanding of these topics is one of the cardinal sins of hobbyist makers - so don't let this happen to you.

6.1. Basic part design tips

The mathematics of material engineering are fairly obtuse, and the finite element modeling software that can be used to model the dynamic behavior of real-world part geometries is prohibitively expensive. Nevertheless, if you are designing small- to medium-scale components and can afford to learn from mistakes every now and then, there is a couple of simple rules of thumb you can follow to get great results without resorting to any of that.

(You can also find quite a few good engineering tips on this page.)

6.1.1. Rigidity management

Perhaps the most profound cognitive dissonance you can experience during your first adventures in DIY manufacturing is making the first part that happens to be long, thin, and flat. Let's say you grabbed IE-3075 and cast a piece that is 2 mm thick, 1 cm wide, and 15 cm long; you will be probably impressed by how difficult it is to break this sample - but also shocked by how easily it deflects. It just doesn't seem to make any sense: the datasheet says that the material is ought to be 50% more rigid than the plastic used to make Lego bricks, and several times less flexible than the commodity plastics used in everything from toaster ovens to computer cases. But your toaster doesn't flex nearly as much, right?

To understand what's going on, consider what would happen if you applied the same bending force to the side of the part, rather than the top:

If you do that, you won't be able to flex the part even the slightest bit. The cross-section of the material is still the same - 2 x 10 mm - but all of sudden, it is a lot more willing to resist your efforts.

That's because flexing the material amounts to stretching the polymer chains farther apart on one side of the part, and squeezing them close together on the other end. If the material is thin, the effect is relatively modest, and you don't need to invest a lot of energy to make it happen. For thicker segments, the displacement is a lot more dramatic, however:

The effect is pretty significant. Simplifying slightly, the rigidity of the part is proportional to the width of the sample - but to the cube of its thickness.

This behavior brings us to the manufacturing trick that is being used in almost every item made out of plastic or sheet metal - including toasters and Lego bricks. In essence, you can greatly improve rigidity by increasing the maximum span of the part in the direction subjected to bending loads - without adding any significant bulk. The most common approach is the addition of a couple properly oriented ribs:

The average thickness of the part - and thus its weight or the amount of plastic used - hasn't changed significantly. But because each of these ribs contributes to rigidity in proportion to the cube of their height, their impact is more significant than it may seem.

The following picture is a good example of the use of ribs to control the rigidity of a thin-walled chassis of a medium-size robot. Note how the ribs are routed around any locations where additional clearance is required, and not interfere with the mechanical design. In fact, they probably improve the overall aesthetics:

It is also possible to achieve the same effect without having to introduce any "standalone" ribs; for example, if the part uses curved surfaces or happens to have outer walls, this can provide a comparable degree of reinforcement:

Properly reinforced thin-walled parts weigh less, cost less, provide more clearance for other components, exhibit much less shrinkage - and often simply look better. Because of this, try to learn and use these approaches as often as possible. Stick to 1 to 1.5 mm as a baseline wall thickness for all the larger parts - especially for chassis components, covers, etc - and just sprinkle them liberally with ribs, gussets, and other features of this sort. A handful of ribs extending 2-4 mm from the surface of the part is usually all you need to make it work.

6.1.2. Stress distribution

So far, we've talked about the need to reinforce thin, long, planar surfaces; but there is one more situation where a small amount of extra plastic routinely saves the day.

From the discussion of casting resins earlier in this guide, you may recall that the resistance of these materials to non-uniform loads (e.g., tearing) is dramatically lower than the ability to withstand uniformly distributed stress. For this reason, you should pay close attention to sharp corners, jagged edges, holes, and similar features in locations subjected to significant loads - and incorporate simple reinforcements to ensure that the stress isn't concentrated in any single spot.

For example, when designing a coupling for an axle that may be subject to strong radial forces and shock, adding a fillet or a couple of load-bearing gussets can save the day; all other things being equal, the "vanilla" approach shown on the left is much more likely to fail:

Given the negligible cost of these features, it typically makes no sense to spend too much time trying to figure out in which exact spots they happen to be absolutely necessary. Whenever it is clear that a localized stress may occur, throwing in a rib, a gusset, or a fillet is simply a good plan.

6.1.3. Fitting tolerances

Another problem that a novice designed may bump into is the question of fitting tolerances: when one part needs to mate with another, what should their respective dimensions be to form the desired type of fit?

The correct answer depends on a number of factors, including the accuracy of your CNC mill, or the operating conditions of the assembly (temperature, risk of contamination, running speed). Nevertheless, when working with a reasonably accurate milling machine and dealing with normal circumstances, the following rules of thumb tend to work pretty well for rigid plastics:

When in doubt, be quick to experiment: it takes just a couple minutes to machine a rectangular or cylindrical test piece and play with it. Save yourself the time and frustration of having to debug issues in more complex parts.

6.2. Creating spur gears

Gears are an extremely versatile tool that will come handy in all sorts of mechanical assemblies. Depending on your needs, they can reduce or increase the speed of movement, adjust torque, or change the direction, axis, and type of motion - all that with high precision, excellent efficiency (95%+), and great load-bearing capabilities. Alas, unfortunately for hobbyists, much of the freely available information about the geometry of common types of gears is misleading or incomplete - and even the articles posted on Wikipedia are littered with inaccurate images or animations such as this.

The key property of a well-designed set of gears is that they transfer motion almost exclusively through a rolling action, with very little sliding (and thus friction) involved; and that they maintain constant velocity and a constant angle of contact through the process. If you violate these principles, your gears will become inefficient, noisy, and prone to vibration. The optimal design is exemplified by the ubiquituos involute spur gear:

The blue lines shown on this picture are the theoretical pitch circles of the gears; if you replaced the gears with idealized rubber rollers of these diameters, the behavior of the transmission would not change. The linear speed of any mating gears is the same when measured along the pitch circle, and the ratio of angular speeds depends on the ratio of their pitch diameters. For example, if one of the gears has a pitch circle with a diameter of 10 cm, and it's turning another gear with a pitch diameter of 4 cm, one turn of the former will rotate the latter by 10 / 4 = 2.5 turns.

Before getting any real work done, you need to make up your mind about several key parameters that will define the gears used in a particular project; except for tooth count, these values should be the same for any two gears that are supposed to mesh with each other.

6.2.1. Tooth count

This parameter depends chiefly on the transmission ratios you are hoping to achieve. The only constrain here is that with very low tooth counts, you will see a behavior known as undercutting: the two meshing gears will collide, necessitating the introduction of some additional clearance - and thus weakening the part:

This is not a big deal if the undercut is small; but when it begins to extend significantly into the area where power transfer takes place - that is, the region above the so-called base line, the gray circle shown in the earlier animation - the performance of the gear may be compromised. To avoid having to heavily compensate for this issue, unless exceptional circumstances apply, try to keep tooth counts over 8-9 or so.

Note: most of the gear generators you can find online can't deal with undercuts at all: quite simply, if you try to specify fewer than a certain number of teeth, they will reject your input or generate an incorrect result. Avoid these like a plague - and scroll down for better alternatives.

As for the maximum number of teeth - there is no real limit to how far you can go, but to keep your models simple and the cutting process rapid, it's preferable to keep the count under 100 or so.

6.2.2. Tooth width

This parameter is measured at the pitch circle. The tooth must be wide enough to allow the mating region to be machined with the tools you happen to have at your disposal; in fact, it's advisable to use tooth width at least 30% greater than the diameter of the smallest end mill in your collection.

In precision applications that do not involve extreme torques, the value will typically range from 0.3 to 1 mm - and 0.6 mm is a good starting point. You may want to increase the width when working with larger models, to keep the number of teeth sane.

6.2.3. Pressure angle

When you look back at the animation shown earlier in this section, you will notice a slanted line that goes through the center. This is the path along which the gears come into contact, and the actual torque transfer takes place. The slant of this slope can be selected to suit your needs, but it needs to be reflected in the geometry of the resulting teeth:

In general, low pressure angles result in quiet-running, precise gears that are easy to machine due to generous clearances - but will be weaker, and have more pronounced undercuts. High pressure angles result in thicker tooth profiles which need to be machined with smaller tools, and can be more noisy and prone to backlash and slippage - but also survive a lot more abuse.

Sensible values for this parameter range from 12° to 25° or so - and my personal favorite for miniature assemblies is 17.5°.

6.2.4. Addendum

The addendum is the distance by which every tooth sticks out above the pitch (contact) circle. The recommended value that ensures continuous and smooth torque transfer is tooth_width * 2 / π, with some wiggle room if you are pressed for space or are running into other constraints. Going below 70% of the recommended distance should be done at your own risk.

To minimize undercuts when dealing with low pressure angles and low tooth counts, you can use a larger addendum on the smaller of the two meshing gears, and a smaller addendum on the other one. This technique, known as profile shift, is particularly useful for gears with fewer than 12 teeth, where it can significantly reduce undercuts without compromising machinability (right):

Of course, profile-shifted gears will not mesh correctly with regular ones - the mating gear always needs to have exactly the opposite shift. This is seldom a problem, but you need to keep this constraint in mind.

6.2.5. Putting it all together

All right! Equipped with all this knowledge, you can compute the profile for your first set of involute gears. There are many different approaches to this task, but my favorite method is unique in that it comes without the limitations that plague simpler techniques - and if you are so inclined, it can be easily generalized to deal with a variety of unusual gear shapes and tooth profiles later on.

The process begins with calculating the circumference of the pitch circle for your gear: cpitch = tooth_width * 2 * tooth_count. From this, you can trivially calculate its diameter of the circle you need to draw (c / π). Once you have it on your screen, you need to add a straight line tangent to the pitch circle; this will be used to build a hypothetical mating gear with an infinite diameter. If we can mesh with this, we will be also able to mesh with any smaller gears encountered in real life.

On this "pitch line" of our infinite gear, we can draw two lines perpendicular to it, precisely tooth_width apart - and rotate them around the point where they intersect the infinite gear by an amount corresponding to the pressure angle we want to maintain (18° in this example). To turn this into a proper tooth, we need to add a horizontal line that is normally placed addendum = tooth_width * 2 / π below; in fact, draw the line about 5% farther down to create some clearance for any dirt or grease caught in between gears. When done, trim off the excess - and voila:

The next step is to simply perform a simulation of how this tooth would engage and then disengage with the actual gear we are trying to create. Recall the mention of rubber rollers: for any two meshing gears, the linear velocity at the pitch circle should be the same - so if the infinite gear (aka rack) moves by n millimeters, the other gear will rotate by 360° / cpitch * n.

The rest should be fairly obvious; this is the pattern you will see if you keep creating copies of the tooth at successive offsets along the rack, and then rotating them back by a matching angle around the center of the pitch circle of our gear:

The process can be automated easily in almost every CAD tool, although for the initial try, it makes sense to do it by hand; in any case, once you have this pattern generated, you simply need to trace a curve around it, replicate this curve using the polar array tool to create the preselected number of teeth, and offset the pitch circle by the addendum distance to trim off the unnecessary bits:

Try to do this exercise on your own. With rare exceptions where backlash is completely unacceptable, you should draw the outline about 0.05 mm apart from the trace left behind by the simulation; without this small amount of play, the teeth will engage on both sides simultaneously, producing unnecessary friction.

6.2.6. Bonus tricks

The beauty of the simulation-based method of constructing gears is that it's WYSIWYG, and that it takes most of the usual constraints out of the equation: for example, you can produce gears with any number of teeth, because the possibilty of undercuts is automatically accounted for. On top of that, it can be modified in several fairly intuitive ways. You can:

Sounds more fun than it should be? You bet it does!

Tip: of course, there is no need to repeat all these steps by hand. The most flexible option is this web-based generator developed by Rainer Hessmer. The tool is very user-friendly: simply enter several parameters and get a DXF file in return. The tool properly handles undercuts, internal gears, profile shifts, and so on - so take it for a spin!

If you're using Rhino, you may also enjoy my experimental Grasshopper module, which provides a comparable degree of flexibility, but is much faster, with instant feedback right within the CAD environment. It comes with fairly detailed instructions and features important for machineability, too. To run the add-on, you will need to install the Grasshopper plugin itself, open the plugin with the namesake command, and then load the file into the app. Note that the internal gear functionality is not fully operational yet: undercuts are not properly compensated for if the diameter of the meshing gear is close to that of the internal one.

Last but not least, some Rhino users may want to grab a copy of my earlier semi-automatic script. Its main advantage is that it can handle arbitrary tooth profiles and very accurately handle internal gears. It is activated by entering Hob4 in the command prompt and answering some simple questions about the gear you want to generate. It will then draw the appropriate circles and - if instructed to do - a standard trapezoidal tooth profile. You can modify the profile or simply select the one produced by the script, and run Hob4 again to finish the job.

As noted, the script also allows you to generate internal gears; to do that, you must provide a mating pitch circle and tooth profile extracted from a previously generated external gear. This circle needs to inside, and must be touching the top of the pitch circle for the internal gear.

6.3. Other types of gears

Involute spur gears are remarkably versatile, easy to model, and easy to manufacture - but they are certainly not the only type of a gear you can use. Let's go over some of the more exotic but still useful options that may come handy in your work.

6.3.1. Bevel gears

In comparison to planar spur gears, bevel gears have a very important property: they mesh at an angle, and therefore, can be used to change the axis of rotation. Although this goal can be achieved by other means - for example, with simplified crown gears or with worm drive, bevel gears do so with remarkable precision and efficiency.

The process of constructing a set of meshing bevel gears is considerably more complicated than what we discussed before, and involves a brush with non-Euclidean spaces; nevertheless, if you follow these instructions closely, you should be able to pull it off.

As with spur gears, the first step is to choose tooth counts, width, height, and pressure angles; you should also think about the exact gear ratio you want to achieve, as one pair of gears will be not interoperable with any other differently configured set.

Next, draw the appropriate pitch circles for both of the gears you want to create, placing them on the X-Y plane; when done, add two lines perpendicular to this plane and going through the center of each circle. Finally, rotate one of the circles (and the associated perpendicular line) in the Y-Z plane, pivoting the operation around the point where touches the other one. In our example, we will use 90° between the mating gears, but any other angle is a possibility:

With this out of the way, draw a line that starts where the two perpendicular lines meet each other, and ends where the two circles touch each other (Q). Next, using the Y-Z drawing plane, add a line perpendicular to this newly created one. This final line is denoted as l:

To minimize clutter, we'll focus on constructing the gear profile for circle a, and hide the other circle for time being; the steps needed to construct a suitable gear profile for the second gear will be analogous to what we are doing past this point, so you should have no difficulty figuring it out.

The next task is to mark two locations on the line l that are in equal distance from point Q; these newly created locations are denoted as C and D. The distance must be a bit greater than the addendum for your gears, but beyond that, the exact value doesn't matter. With these two points in place, draw a circle in the X-Y plane that has the same center as circle a, and passes through point C; a similar circle should be drawn for D. Lastly, use the loft operator after selecting the newly created circles c and d to build a conical surface:

The next challenge is to check the manual for your CAD application, and identify an operator that allows you to "unroll" this surface to a construction plane; in Rhino, UnrollSrf is what you need. Select the surface and the original circle a, and apply this transformation; you should get an object resembling the one on the left:

Extract the two "broken" edges of the surface as straight curves, and draw a circle that has the same center and diameter as the arc produced by unrolling the curve we selected alongside with the cone. This will be your virtual pitch circle, on which you will have to construct a regular tooth profile using the approach outlined earlier on.

You can start by simulating the appropriate tooth profile (center, above), and then by making a planar array to complete the gear (right). The only difference is that before making the array, you need to rotate the profile by 90° to touch one of the extracted edges; and then make a radial array consisting of tooth_count copies that fill an angle of 360° / length_of_virtual_pitch_circle * length_of_circle_a, rather than the usual 360°. When done, truncate the parts that stick outside the edges, and you should be all set.

To wrap up this process, you need to position the created gear profile over the unrolled surface again, making sure that it is aligned correctly. Next, use an operator that will map the curve back onto the original conical surface, using the unrolled geometry as a reference. In Rhino, this is accomplished with FlowAlongSrf. Just make sure that you select matching locations on the reference and destination surface, and if you did it right, you should be able to get something of this sort:

You can delete the cone and all the helper surfaces at this point, and repeat the same procedure to generate the other gear. In the end, you should be seeing a result that resembles this:

Neat, eh? You can now create a scaled copy of each outline along the appropriate axis, using a 3D scaling operator with the origin set at the point where the axes intersect; be careful with this step, as using an incorrect origin will result in gears that would not mesh. With this step out of the way, the scaled copy and the original can be then lofted together, and each of them can be individually extruded toward any point behind the gear to create a cap surface. A few extra moves to trim and cap everything neatly, and you should have a final result in front of you:


6.3.2. Worm gears

Worm gears are an interesting animal. On one hand, they offer extremely high reduction ratios, which makes them quite attractive for robotics: every turn of the input shaft advances the output gear just by a single tooth. On the other hand, they generally boast very poor efficiency due to significant friction - 30-40% being the norm.

From the design standpoint, these gears are fairly unremarkable; the output gear is generated the same way you would make any other spur gear, while the input gear - or more accurately, the input screw - is essentially a rack tooth that is wrapped around a spiral path, with a tooth_width * 2 pitch between the turns:

Depending on the thickness of the output gear and the diameter of the input screw, the profile used to generate the output gear may need to be corrected slightly, based on a 2D projection of the trimmed, meshing section of the screw. You should be able to create all this with no help by now; operators such as Sweep1 and Silhouette in Rino are about everything you need. The only complication for CNC machining is that as opposed to spur and bevel gears, the input screw needs a two-part mold.

6.3.3. Helical gears

Helical gears are essentialy spur gears - but (literally!) with a twist. Instead of having their teeth extruded along the axis of rotation, the top and bottom profiles are rotated in relation to each other, and then lofted to form a twisted gear. The twisting may be done in a straight line (left) or in a curved fashion (center):

The point of this modification is that each gear will now engage more gradually, thus reducing the amount of noise and vibration produced under load, this matters particularly in automotive applications and other situations where steel gears transfer high torques at high speeds. On the flip side, this geometry means that the gears act like a wedge, and exert substantial axial forces on the assembly they are coupled to; a double helical layout, also known as herringbone (above, right) works around that to a large extent.

Helical gears are relatively difficult to make using simple, CNC-machined molds; for optimal results, the mold would need to be split into four to six parts. It is easier to machine them directly using a rotary axis - but in any case, the benefits of using this class of gears are negligible in small-scale robotics work.

6.3.4. Pulleys for timing belts

Gears that mesh with timing belts are constructed in a manner fairly similar to a normal gear meshing with a rack, but their shape is not entirely symmetrical. MXL timing belts use 40° teeth with a pitch of 2.03 mm. Addendum of the timing belt is approximately 0.5 mm; the dedendum is zero. The width of base of the tooth (at the pitch circle / line of the belt) is around 1.2 mm, leaving just around 0.8 mm in between the teeth. The solid section above the gears is usually around 0.7 mm thick.

Of course, the belts are made of rubber and will easily conform to pulleys even if the dimensions are slightly off - so you don't need to obsess over it as much as you'd have to with rigid gears.

6.4. Getting started with gearboxes

It is possible to adjust the speed or torque of a motor by employing just a single pair of gears, but doing so is often impractical: for example, if you have a motor that nominally runs at 10,000 RPM, and want to get down to 100 RPM - a reduction of 100:1 - you would need to mesh an input gear with about 10 teeth to an output gear with no fewer than 1,000. Assuming that the width of a single tooth is 0.6 mm, the diameter of the latter gear would be almost 50 cm - oops!

To solve this problem, it is common to build gearboxes that employ multiple stages; each stage reduces the speed by a more reasonable factor - usually between 2:1 and 5:1 - and then powers the next stage that performs the same trick again. The gains are exponential: if one stage gives us 4:1, then two will offer a 16:1 reduction; three will yield 64:1; and four would get us down to 256:1.

The most rudimentary type of a gearbox is the offset-gear arrangement shown on the left; you can check out a practical example of this design here. This approach works well, but tends to take up space; a simple modification, shown on the right, is to stack the gears alternating between two shared axles, instead (example):

Offset gear transmissions of this sort are simple and adequate for most needs; for instance, Tinybot mk III uses them exclusively. Having said that, every now and then, you may wish for something more compact and self-contained. If you are pressed for space, it makes sense to consider a planetary gearbox. There are several possible ways to design such a mechanism, but the most practical arrangement relies on a small, centrally placed sun gear coupled with the input shaft; that gear is surrounded by several planets, and these planet gears in turn roll inside a stationary internal gear known as annulus or ring:

Of course, this design makes little or no sense if the planets just run freely; the output stage is created by creating a carriage that slides onto the planet gears, often using a sleeve bearing. The transmission ratio of such a mechanism will be tooth_cntsun / tooth_cntannulus - and that's quite a good result in such a small envelope. Just as importantly, additional stages of a planetary gearbox can be packed tightly on top of each other, resulting in a form factor that is pretty hard to beat.

To better illustrate the practical aspects of making a planetary gearbox, you may want to check out this rendering of the design I have been using in my projects for quite a little while:

Of course, planetary gearboxes are no silver bullet; they are about 2-3 times more compact than offset gears, and outperform them in some ways, but it's possible to run into situations where an even higher ratio would be desirable - but where the poor efficiency of worm gears and other types of screw-based actuators is hard to swallow.

Of all the more exotic transmission systems, the most promising one is probably the cycloidal drive. This device easily attains ratios of 100:1 or more in a single stage by brilliantly exploiting eccentric motion of a large gear in a comparably-sized "cage":

I have a separate page describing this particular design in more detail, so I won't repeat all the information here. Rest assured, cycloidal drive systems have some substantial downsides - for example, they tend to introduce vibration, and require subminiature ball bearings to isolate the input shaft from the eccentric gear. Nevertheless, when out of mainstream options, they are worth a try.

6.5. Overview of drive systems

By now, you should be well-equipped to get ahead with almost any electromechanical project you can think of; the only question is where to start. In the world of robotics, the single most important choice is probably the mode of locomotion; everything else - from the selection of sensors, to power sources, to data processing capabilities - follows from that. In the last section of this chapter, it makes sense to quickly run through the options you have.

In all likelihood, your initial projects should probably be wheeled. It is tempting to try something bolder, but until you are familiar with the dynamic properties of plastics, and have several precision robots under your belt, it's really the best choice. Some of the common approaches to wheeled robots include:

Wheeled robots aside, legged creatures have some undeniable appeal. These robot designs tend to pose a range of challenges related to space management, torque requirements, obstacle sensing, and the creation of practical movement algorithms. Sure - it is relatively easy to bolt a bunch of expensive servos on top of a simple frame - but going beyond that point is usually fraught with peril. Still, if you want to give it a try, your basic choices are:

These movement modes aside, there is a long tail of exotic inventions that are worth at least reading about. We have hopping pogo stick robots; several well-publicized ball-balancing units; a bunch of levitating designs that leverage air cushions, magnetic fields, or vibration; insanely cool crawling robots; and a large selection of flying and sailing ones. And hey - why not add something of your own to that list?

Click to proceed to chapter 7...