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 5 of 8. Click this box for table of contents.

5. Essential parts for robot builders

Righty-o. Now that we have the basics of machining, moldmaking, and resin casting covered to a good extent, it's useful to discuss more practical designs and part geometries of interest to robotics and other mechanical work. But before we dive into the inner workings of custom-designed gears and drivetrains, it's important to take a brief detour, and go over some of the prefabricated components that may come handy in your projects. Without a good source for tiny screws, springs, dowel pins, or cheap electronic sensors, you simply won't be able to get far.

Rest assured, this chapter will merely scratch the surface of it all. If you are looking for inspiration, get "Machine Devices and Components Illustrated Sourcebook" by Parmley, or "Mechanisms and Mechanical Devices Sourcebook" by Sclater and Chironis; and if you need a primer on electronics, my concise guide to electronics for geeks may come handy, too.

5.1. Mechanical components

5.1.1. Screws and threaded rods

Machine screws, also known as bolts, are one of the most important items to put on your shopping list: if you want to create durable, serviceable designs that can't be approximated with indiscriminate use of glue, suitable fasteners are simply a must. In tough plastics such as polyurethanes, the use of screws is particularly easy: simply machine a slightly undersized hole and drive the fastener into it, impressing its own thread onto the part. Much of the time, you don't need a nut!

If you want to shop for useful sizes and quantities of machine screws, skip your local hardware store. There are three particularly good online sources for miniature and subminiature fasteners in bulk: Micro Fasteners, Fast Metal Products, and Amazon Supply. Micro Fasteners is a good all-around source for low-cost screws in diameters over 1.5 mm or so; FMP offers decent pricing on fasteners smaller than that. Last but not least, Amazon Supply (formerly Small Parts) tends to be a tad more expensive - but Amazon Prime customers get free two-day shipping on every single nut and bolt, so especially for small orders, it's quite a good deal.

The exact selection of fasteners depends on the projects you intend to pursue, but I recommend starting with a good assortment of 0.8 mm, 1.5 mm, and 2 mm screws (000-120, 0-80, and 2-56 designations in ANSI UTS, respectively), 100 pieces each. You should grab the cheapest variety of steel or brass screws, aiming for lengths around 4, 6, 8, and 15 mm; drive type doesn't matter a lot - could be slotted, Phillips, or hex. Expect to pay around $2-$5 per 100 pieces for common diameters, and closer to $10-$15 for sizes under 1 mm. Getting some nuts and washers, especially for 2 mm screws, is not a bad plan - but as noted, you won't be routinely needing them.

You may also want to look into threaded rods, available from sources such as Amazon - the diameter around 2 mm probably being the most useful. Their more boring use is an extended-reach screw (with one nut at each end); a more interesting possibility is creating extremely compact and simple linear motion systems, like so:

Another possible arrangement is using a motor to directly rotate the shaft. In both cases, the transmission enjoys a very high ratio, because every turn of the motor moves the nut by a distance equal to the pitch of the shaft - often in the vicinity of 0.5 mm or so. The downside is poor efficiency - likely under 20% - due to significant friction under load.

Note: when it comes to online retailers, many hobbyists also love McMaster-Carr as a source for screws and other mechanical components. That said, they are almost always significantly more expensive than specialized distributors, and often more expensive than Amazon. They do have good deals on some otherwise hard-to-find stuff - say, miniature timing belts - but it's more of an exception than a rule.

5.1.2. Dowel pins, rods, and tubes

Traditional dowel pins are rather unassuming: they are just pieces of featureless, cylindrical steel, machined to tight tolerances. For their appearance, they find a truly surprising number of uses: as axles for spur gears and other rotating parts; as registration pins for molds and multi-part assemblies; as movement limiters and contact sensors; as serviceable torque couplers; and so on. You just need to have some - trust me on that.

Non-tapered, solid metal dowel pins are available from many sources, including Small Parts / Amazon Supply, and cost very little - usually in the vicinity of $4 to $8 per 100 pieces. I suggest stocking up on 2 mm diameter pins in several lengths ranging from 4 to 20 mm. For high-precision work, 1 and 1.5 mm diameters may come handy, too.

Dowel pins aside, it's also good to have some vanilla steel rods or tubes: they are very cheap (usually $1-$2 per meter), and can be cut to size with a hand saw to build anything from long-reaching axles (left) to fairly complex frames (right, also showing threaded rods used as linear motion systems):

Metal bars with rectangular, hexagonal, or L-, I-, or T-shaped cross-sections are particularly useful for torque transfer, because you can simply slide components onto them, and there is no risk of slippage under radial load; perfectly round profiles may require the application of glue or the use of a lock screw.

5.1.3. Springs and spring wire

Similarly to dowel pins, springs have quite a few uses; many of them are obvious (wheel suspension and other pre-tensioned mechanisms, energy storage, etc), but some aren't. For example, springs are indispensable for transfering rotary motion at an angle - a process that otherwise requires complex bevel gears or universal joints.

Perhaps the most common sort is a compression spring: it has generous spacing between its coils, and is meant to contract under load. You can find them inside many types of pens, spray bottles, and so on. The other popular type is an extension spring: it is tightly wound, and offers little or no compressive action - but stretches very well.

It's difficult to recommend a particular selection of compression and extension springs up front, but it's definitely a good idea to have a robust variety always available in your workshop, simply to prototype stuff easily. Possibly the best and least expensive assortment I have seen so far is this set - 200 reasonably sized springs for less than $9; comparable kits are also available on Amazon. A great selection of individual springs with specific diameter, pitch, and length, can be also found on Amazon, usually in packs of 10.

Traditional springs aside, you should also grab some spring wire (also known as music wire). It comes handy for making contact sensors (especially whiskers!), for creating simple tensioners, and for designing other devices where you want to use a straight piece of elastic material to deflect effortlessly, and then spring back to its original shape. There are many low-cost assortments you can find on the Internet - and as usual, Amazon isn't bad.

5.1.4. Ball bearings

There are many situations where it is desirable to constrain rotary movement to a particular axis of rotation, and support it so that the part doesn't wiggle back and forth, or snap under load. Sleeve bearings are the simplest solution: you can route the rotating part through a round, slightly oversized opening, and perhaps use a bit of grease to minimize friction.

Alas, this approach has its limits: if the part is rotating very quickly, or if it's subject to significant radial forces, sleeve bearings will result in significant power losses or excessive wear. In particular, sleeve bearings for propellers and wheels may have a very limited lifespan.

Because of this, you should get a decent assortment of ball bearings, and use them when appropriate. There are many sources of bearings on the Internet, but most of them tend to be pricey; is a notable exception to this rule. They ship internationally and have an amazing selection of 10-, 20-, 30-, or even 100-packs at sensible prices - often hovering around $1 to $1.50 per piece. Some comparably good or even better deals can be found in the $0.99 discount bin or the 10-pack-section of Boca Bearings, too - although their "regular" prices are higher than VXB.

Some of my favorite bearing sizes (ID x OD x H) are: 3x6x2 mm (link, $1 a piece, only for miniature projects); 6x10x3 mm (link, $1.50); 8x12x3.5 mm (link, $1.50); and 8x16x5 mm (link, $1). For larger projects, 8x22x7 mm bearings are a bargain, too - trading for about 50 cents a piece or less (link).

If you don't have any specific designs in mind, but plan to work on small to medium-scale projects, grabbing a set of 6x10x3 mm or 8x12x3.5 mm bearings is not a waste of money.

5.1.5. Gears and timing belts

When building precision mechanical assemblies, it is usually much more convenient (and a lot cheaper) to make your own gears than to source them online. Part of the reason for this is that most of the time, you will want to use compound gears with very specific diameters, heights, tooth counts and ratios, axle bore sizes, and so on. Chances are, you won't be able to find just the right ready-made options online, at least not on the cheap.

Timing belts are a different story, in part because they are tend to be simpler. Whether you need timing belts is a good question; they do offer an alternative form of gearing in applications where other solutions are inconvenient to use because of size constraints or the distances involved. For example, they may offer a space-saving way to couple a motor to a wheel without reducing ground clearance. Another popular use is in linear motion systems, where they can acutate any assembly clamped to the belt (and mounted on some sort of a rigid slide to keep it from flopping around).

Historically, timing belts used to be fairly expensive and difficult to source in miniature sizes, but this has changed over the past few years. One of the best sources for small timing belts, many for around $1.50 a piece, is McMaster-Carr; check out the MXL series for some very good picks. Some of their smallest ones are just about 10 mm long and 3 mm wide.

Timing belts run quiet and have very little backlash, but they are less durable and less rigid than plastic gears; they may be somewhat less efficient, too.

5.2. Robot-related electronics

5.2.1. Motors

The selection of motors at your disposal is definitely the single most important factor affecting the ability to bring your electromechanical designs to life. It's also something very easy to get wrong - or get right, but grossly overspend on.

It is probably safe to assume that you are interested primarily in small, low-voltage DC motors; if so, the choice is roughly as follows:

As you can see, there is no perfect solution. I personally prefer sticking to vanilla brushed motors and creating my own gearboxes, but if your patience can wear thin, servos or geared motors may be a better choice. For any of these motors, you should definitely look at the following characteristics when shopping around:

Possibly the best source to find a great assortment of low-cost brushed motors (both vanilla and geared) is Kysan Electronics; they have a $100 minimum on all online orders, but seem to be willing to make exceptions if necessary. Good deals can be also sometimes found at various surplus outlets, including All Electronics, Electronic Goldmine, Surplus Shed, BG Micro, or HSC Supply - but their inventory can change rapidly, so your mileage may vary. Last but not least, for servos and brushless motors, Hobby King is hard to beat - they ship from Hong Kong, but do so promptly and cheaply; on orders under $200 or so, you are unlikely to run into import duties.

Whatever you do, I'd recommend avoiding robotics-oriented sources such as Solarbotics, Robotics Connection, Pololu, Acroname, and many more. They are good people, but they usually sell exactly the same low-cost motors, and simply charge you more for the privilege of shopping with them. Case in point: this motor costs $23 when bought from Robot Marketplace, or $16 when you go to Solarbotics - but Kysan Electronics carries it for $8 a piece... or just $3 on orders over 1,000 (which is probably the price that the first two shops have paid).

In any case, it makes sense to find 2-4 models that are best suited for your needs, and then buy 10-20 pieces of each; having a steady supply of well-performing motors beats having one or two of every mediocre product available on the market. My personal recommendations are:

If you need inspiration, here's a video of Mabuchi FF-N20PN powering a miniature planetary gearbox:

5.2.2. Useful sensors

Sensors are essential in almost any electromechanical design, helping interact with the outside world, and providing internal feedback about the state of mechanical assemblies. This section covers some of the most useful, low-cost choices to consider in your work:

5.2.3. IC glue and MCUs

If you have a favorite brand of microcontrollers, there is probably no need to revisit this topic; but if you are looking for advice, it's pretty hard to go wrong with AVR chips such as ATmega1284P ($8). This particular 8-bit MCU, for example, operates at speeds up to 20 MHz (internal oscillator is provided), has 128 kB of Flash memory for program storage, 16 kB of data memory (SRAM), and 4 kB of non-volatile EEPROM. It's essentially a complete computer-on-chip, complete with 32 bidirectional I/O lines, 8-channel 10-bit ADC, hardware PWM channels - all that supporting a wide range of supply voltages, from 1.8 to 5.5 V; there are precious few external components required to operate it in most real-world applications. ATmega chips have a mature GCC-based toolchain with tons of useful libraries, a nice emulator, and a pretty good IDE - and unless you are doing complex image processing or working on something else data-intensive, they will serve you well. (In more demanding tasks, you may need to spend quite a bit more on 32-bit ARM or AT32 chips; I also like Intel Edison.)

For ATmega, the only other gadget you need is a simple USB ISP dongle (e.g., AVRISP mkII), costing somewhere between $15 and $30 - and even that can be avoided if you opt for a chip with a built-in USB controller.

Note: some people love AVR-based development platforms such as Arduino or Teensy. I am personally wary of these boards, because I find them to offer very few real benefits over the AVR chip itself; you are essentially charged a 1000% markup in exchange for someone soldering the chip to a PCB, and then adding several components that are completely unnecessary in many uses, but make it look sophisticated (e.g., voltage regulators, external crystals).

Especially when developing more complex software, you may find it useful to add a way for the MCU to communicate essential information in an easily readable way. Tethering it to a computer is one option, but you may also consider getting an LCD module based on a well-known HD44780 chip; for example, NHD-0216K1Z-NSB-FBW-L ($11) is a very user-friendly device with ample display space. It can be controlled with as few as 6 data lines, and is pretty trivial to interface with - its dedicated controller maintains its own display memory, and even stores editable font data and track of the cursor for you, so you just have to send ASCII data to the appropriate port.

In addition to the MCU itself, you should also have a good assortment of standard "glue" chips that are useful for example in multiplexing and demultiplexing applications, and will allow you to extend the I/O capabilities of your chip almost arbitrarily. Probably the best IC family to stick to is 74HC - they are widely available and fairly cheap ($0.10 - $0.35 per chip), and offer respectable speeds and good load driving capabilities. You may want to grab basic logic gates (74HC00, 02, 04, 08, 32, 86 - NAND, NOR, NOT, AND, OR, and XOR respectively); line drivers (74HC240, 241, or 244); multiplexers, demultiplexers (74HC164, 165); line selectors (74HC137, 42, 151); and flip-flops / latches (74HC175, 75, 259). Some projects may also have uses for counters, timers (e.g., 7555), external oscillators, assorted op-amps, etc.

About the only thing you can't do with all these parts is driving any power-hungry loads, such as motors: the tiny transistors inside most MCUs and 7400 series chips can output at best around 20-40 mA per line - enough for a LED or two, but not much more. It is possible to use discrete power MOSFETs (e.g., BUK7510) to control high-current devices, but doing so is not always space- and cost-efficient - so you may want to look into IC-based motor drivers. FAN8082 is probably the cheapest ($0.40) full H bridge (i.e., bidirectional) driver capable of delivering up to 1.5A at 18V to brushed motors and bipolar steppers; it even comes with rudimentary speed control. The disadvantages of this chip are its reltively high voltage drop (almost 2V), and the fact that it doesn't support "freewheeling" (high impedance) mode. Somewhat more expensive TA7291P ($0.90, 2A peak at 20V) supports all four output states: forward, reverse, brake, and freewheel; TLE52052 chip ($3.50, 6A peak at 40V) can drive even larger motors with ease. Several dozen similar products exist - shop around, and grab at least around 10 pieces or so.

For driving unipolar steppers, solenoids, and other power equipment where you don't need to change polarity, you can also save some money by going with simpler devices: ULN2003 ($0.30) can drive up to 6 devices at 500 mA and 50V (or one device at 3A); while ULN2065 ($2) has four outputs capable of delivering 1.5A at 35V, adding up to 6A total.

5.2.4. Power sources, watchdogs, regulators

About the last major set of electronic components that you need to think about are the power sources you will be using in your work. To make the right call, you need to consider several factors:

Today, the best all-around option for robotics are rechargeable lithium-polymer cells, simply because of an excellent balance between capacity, weight, and cost. My favorite source is Hobby King. They have good products, and although they are in Hong Kong, they ship cheaply, quickly, and with no hassle whatsoever. If you browse their site, you can find a 7.4V 5 Ah cell, weighing around 300 g, for about $25; a smaller 1.6 Ah cell fetches $10 and tips the scales at 90 gram; while a tiny 800 mAh one weighs barely 50 g and costs $5.

Of course, nothing comes free: lithium batteries have two drawbacks that you should know about. First of all, if they are charged improperly or badly damaged, they can overheat and catch fire - so you need to store and handle them with some care. The other issue is that they shouldn't be discharged past a certain minimum voltage to avoid altering their chemistry; using a voltage cut-off IC, such as MAX8211 or MAX8212, is a very good idea.

Of course, there are many alternatives to Li-poly; a typical AA battery is nothing to sneeze at, and delivers up to 3 Ah, with peak current as high as 10A; your usual 9V battery is closer to 500 mAh and can't source more than 1A. If weight is not an issue, you can also go with lead-acid batteries, of course: they are cheap, but weight a ton ($20 will get you 15 Ah at 6V, but be prepared to haul around 2 kg). Ultracapacitors are also of some interest in recent years - but right now, they tend to be fairly expensive, especially if you are interested in supply voltages over 2.5V or so. Last but not least, solar cells deserve a honorable mention - although similarly to ultracapacitors, they are not that practical in everyday uses. Because of their lamentable power capabilities in function of their size, they are useful mostly as a way to conveniently recharge a chemical battery or a capacitor, and not as a continuous primary supply.

Oh, one more thing: for prototyping, I recommend grabbing an adjustable benchtop power supply, such as Mastech GPS-3030D ($90); convenience of being able to quickly adjust voltage aside, their huge benefit is that you can limit the current to a safe value, so that an accidental short-circuit will not destroy everything in its path. The same can't be said about most batteries.

Tip: the reason why you should match the supply voltage with the most power-hungry components in your circuit is that high-current DC voltage adjustments can be pretty tricky. It's easy to lower the voltage supplied to a low-current device, such as a microcontroller or a couple of LEDs: just grab a linear regulator such as LM317T ($0.25) or L7805 ($0.50) and be done with it. For efficient regulation of higher currents, or for stepping the voltage up, you generally need switched regulators, however.

Such regulators are fairly complicated to build on your own, and get expensive if you want a plug-and-play solution. For example, ICL7660 - a chip that can handle up to 20 mA - goes for $2; Murata OKR-T3-W12-C - a hybrid device that can deliver up to 3A - retails for $7; and a 6A variant of the same Murata product will fetch $14.

5.2.5. Other components

Well, it goes without saying that you will also need an assortment of generic electronic components to get anywhere: make sure that you have a bunch of resistors and capacitors, a handful of PCB mount potentiometers, some medium-power MOSFET transistors (n- and p-channel), a good selection of terminal blocks and ribbon connectors, a solderless breadboard or two for prototyping, perforated boards in various sizes, and so on. In fact, if you need any help with selecting the right components and using them in a circuit, check out my short primer on electronics in your spare time.

What else? If you want to make your own PCBs for finished projects, you can of course print and etch them - although keep in mind that it's also quick and easy - and often more precise - to machine them on your CNC mill: you can simply selectively remove copper plating from a blank board with a cutter - and drill mounting holes at the same time.

And of course, don't forget about installing a conveniently located and obvious self-destruct switch!

Click to proceed to chapter 6...