Motor Mania!

Today we'll take a look at several types of motors, as well as their cousins, solenoids and relays. We'll talk about the contexts in which each is useful, and we'll hook each one up to a circuit/mechanism of some sort to see it in action. I'm not going to go into detail about the motors here; there's lots of info about motors on the web, so do some quick searches for more info.

We'll focus on inexpensive, readily available motors that you're likely to either remove from old equipment or purchase surplus. There are many different kinds of more exotic motors, but they tend to be very expensive and difficult to obtain.

AC Motor

There are various types of AC motors. Some of them are synced to the AC source (synchronous), others are variable speed (induction). In general, AC motors are good if you just need something to spin continuously at a fixed rate.

Although there are many variables, the ones you encounter will mostly share some of the following traits:

The good:
powerful; reliable; can run forever; plug-n-play; ubiquitous (fans, power tools, household appliances)

The bad:
control from electronics is possible, but less common; can be dangerous (wall current!); tend to be rather large/heavy

Hookup:
AC motors generally just plug into the wall. Often they have a "start" or "run" capacitor that needs to be hooked up to the AC cable. The motor will likely already have the capacitor installed or will come with installation instructions. The capacitor is used to give the motor extra torque at startup to overcome its initial inertia.

Identification:
Most AC motors will have two wires for power, and will have a label somewhere specifying the expected voltage and frequency.

Small, Simple DC Motor

Small, simple DC motors (a made up name) are the little can motors found in many consumer electonics products. Cell phone vibrators, mechanized toys, CD tray ejectors, etc. all contain little DC motors. To use them you simply hook up an appropriate DC voltage source (usually 3-12v) to the two terminals. They tend to spin very quickly, which maybe be good or bad, depending on your application. Their speed can be controlled (within a fairly small range) by varying the source voltage, but performance (torque) will suffer at lower voltages.

The good:
Ubiquitious; inexpensive; easy to use; safe.

The bad:
Not very powerful; stall easily; cheaply made; small, thin shaft can be difficult to work with; burn outo easily.

Hookup:
Just connect the +/- of your powersupply/battery to the terminals of the motor. Reversing polarity will reverse the direction of the motor.

Identification:
Generally a small steel can with two thin hookup wires and a thin shaft. May have voltage information or manufacturer data on the side of the can.

DC gear motor

A DC gear motor is like a bigger, more powerful version of the small, simple DC motor, but with a set of gears attached to the shaft and built into the motor housing. You can usually clearly see the two parts (motor, gear head) of the motor, the gearhead being the part where the shaft extends, the motor the part where the power is connected. The purpose of the gearhead is to reduce the speed and increase the torque of the raw DC motor.

DC gear motors are very often used in robotics and other control situations where you need a smallish motor with lots of power. The speed is generally controlled via PWM of the fixed input voltage. Input voltages range from 3-30v or so. Generally, motors with higher input voltages will give you more torque, although the specifics of the gearhead come into play as well. A DC gearhead motor will have an RPM specified, which is the final speed of the shaft after running through the geartrain. You don't generally know (or care about) the actual speed of the raw motor. The voltage specification of the motor doesn't tell you anything about the speed of the motor, since the final speed is determined by the details of the geartrain. Specified max speeds can range from < 1RPM to several hundred RPM. Using PWM you can vary the speed from 0RPM to the specified (max) RPM.

The good:
Powerful; available in many speed ranges; simple hookup; easily available via surplus; good power/size ratio; easy to control via PWM.

The bad:
Can be rather expensive, especially new; geartrain can be noisy; gears can go bad, especially in used/surplus (removed from equipment) motors;

Hookup:
Just connect the +/- of your powersupply/battery to the terminals of the motor. Reversing polarity will reverse the direction of the motor.

Identification:
Obvious two part body (motor and geartrain), two hookup wires. Sometimes a label with voltage/RPM info will be on the body.

Hobby Servo Motor

Hobby servo motors are commonly used in small remote control vehicles like RC planes, boats, etc. They can be very small and light and are reasonably powerful for their size. They come in a variety of sizes, from very tiny to 1/4 scale. A hobby servo is essentially a small DC gearhead motor with built-in control circuitry.

In their original form they're used to move a shaft to a particular position in order to move a flap on a plane's wing, change a rudder position, etc. When used in this way they can not rotate 360 degrees; they tend to have a range of 180-270 degrees. The position of the shaft is set via a PWM signal; the position of the shaft changes with the width of the PWM signal. The PWM control signal is separate from the power supply, which is held constant, and is usually around 6v.

Hobby servos are often modified for 360 degree rotation by modifying their internal electronics. The process is simple and is described on innumerable robotics resources. When modified in this manner the motor can no longer be set to a particular position. Instead the same PWM control signal is used to cause the motor to go forwards or backwards at different speeds. This is often useful for small robotics platforms, although often a DC gearhead motor makes more sense. The benefit of using a modified servo is that you don't need an additional driver circuit; you just connect power to the motor and then feed it a PWM control signal directly from your microcontroller.

Hobby servos are usually purchased new, unless you have acess to lots of broken RC toys. They can be rather expensive, especially for high quality servos. "High quality" usually means they have stronger (metal) gears rather than cheapo plastic ones.

The good:
Can be very small; easy to control directly from a microcontroller; easy to position fairly precisely; come with a variety of shaft couplers for simple mechanical hookup; standardized sizes/body configurations, making mounting easier.

The bad:
Relatively expensive; gears often wear down under constant usage; make a loud whirring noise as they move; PWM to position relationship not consistent from motor to motor (especially between brands/sizes).

The hookup:
Hobby servos have three wires: +, ground, control. The position/color of the wires is not standardized, so you need to have info specific to the servo you're using before hooking it up. The + wire goes to your motor power supply (probably 6v), the ground to ground, and the control wire goes to the PWM signal coming from your microcontroller. Most hobby servos come with a three position socket attached, making it easy to plug/unplug the motor from a standard 3 pin SIP header.

Identification:
Almost always a boxy shape with three hookup wires ending in a 3pin socket.

N.B.: Don't confuse the hobby servo with an industrial servo motor. Outside of hobbyland, a "servo motor" is a generic term for a motor with a built-in feedback system of one sort or another. The motors described above are almost always specifically referred to as "hobby servos" to differentiate them from industrial servo motors. If you're on a surplus site and they're selling "servo motors", they're probably _not_ talking about hobby servos.

some servo movies:
http://www.youtube.com/watch?v=UcFFRLeMGhw
http://www.youtube.com/watch?v=tZOzHz6EaFE
http://www.youtube.com/watch?v=NW7G_mqVWnA

Stepper Motor

Unlike most other motors, a stepper motor's shaft doesn't rotate continuously; instead, it turns in small increments (steps). The stepping action makes it easy to rotate the shaft by a precise and repeatable amount, something that can be difficult with other types of motors. Many consumer electronics/computer products, like printers, scanners, and fax machines have stepper motors in them. In those products the stepper motor is generally used to precisely position a print/scan head or to move a sheet of paper into position. In robotics stepper motors are often used to precisely orient parts of the mechanism.

Controlling a stepper motor is more complex than controlling a regular DC motor. Instead of just giving power to the motor to make it spin you have to give power to different parts of the motor in a specific sequence. The specifics of the sequence determine the stepping behavior (forwards, backwards, 1/2 step at a time, etc.) The trade off for the increased control complexity is more precise control of the shaft's position. Note however, that stepper motors aren't infallible; if you tell the motor to take 20 steps clockwise but it is underpowered or it runs into a physical obstacle, it may not sucessfully complete all of the steps. So often you still need some sort of feedback system (usually an optical encoder with a disk on the motor shaft) to keep track of exactly how many steps have actually been taken. A stepper motor doesn't inherently know anything about its position and has no built-in feedback loop.

The good:
Ubiquitious; many sizes to choose from; precisely controllable; reliable.

The bad:
Require more resources to control than other motors (code + hardware); non-standardized interface can make hookup difficult; not a ton of torque.

The hookup:
Ha! There are two main types of stepper motors: unipolar and bipolar. Unipolar have five or six wires, bipolar have four. There's no standard for which wire is which, so you'll have to do some experimenting to hook the motor up correctly. Luckily there's lots of info on the WWW on hooking up stepper motors. But be prepared for some frustration, especially when using info-less motors removed from equipment. It's not worth it for me to go into detail on hooking up steppers here; a quick search will bring up lots of info.

Identification:
Steppers can have from four to eight wires. They're usually squatter than other types of motors. If you remove a motor from a piece of equipment and it has more than three wires then it's probably a stepper. Try to rotate the shaft; if you feel a distinct step as you move it then it's proabably as stepper.

Some stepper movies:
http://www.youtube.com/watch?v=dY71z739jbQ (more rock less talk!)
http://www.youtube.com/watch?v=mnImyMhmUU0
http://www.youtube.com/watch?v=c2vEijM-AMA
http://www.youtube.com/watch?v=bAgV2vtI468

Solenoids

A solenoid is an electromagnet-based device that pushes or pulls a shaft. Sort of like a motor that moves in and out instead of spinning. Solenoids are often used as momentary actuators in things like automatic door locks, player pianos, clutches and release mechanisms, etc. Solenoids come in a range of voltages, usually from about 12v-48v DC to 120V AC. It's possible to use sophisticated control techniques to vary the force of a solenoid, but in general they're binary devices, either off or on. Some solenoids are "continuous duty", meaning you can turn them on and leave them on. Others are "intermittent" and will have a duty cycle and maximum on-time specified; ignore at your peril! Some solenoids are "pull type" meaning when you activate them they pull the shaft in. Others are "push type" meaning when you activate them they push the shaft out. A few are "push/pull" meaning that you can reverse the polarity to get the opposite action; these are rare. Pull type solenoids are the most common. When you remove the power from a solenoid the shaft doesn't return to its original position on its own own (there's no force to make it move!), so usually you need something like gravity or a spring that will return the shaft when the power is removed. Most solenoids take a lot of current for full-power operation! Measure the coil resistance and then use Ohm's Law to figure out how much current it will need given the source voltage. Make sure your power supply can handle that much current.

The good:
Linear motion; many sizes and types to choose from; easy to use; reliable.

The bad:
Take a lot of current; will burn out if mistreated; not as strong as you think they are; shaft travel distance tends to be small.

The hookup:
Solenoids have just two wires. For most common solenoids there is no polarity, so it doesn't matter which wire goes to + and which goes to ground. Apply the appropriate voltage across the terminals and the solenoid's plunger will move in or out, depending on the type. Remove the voltage and the solenoid will stop pushing or pulling.

Identification:
Most solenoids are simply a wire coil mounted in a metal enclosure of some sort with a hole in the middle for the shaft. They have only two wires. Sometimes there is voltage/duty cycle and/or coil resistance information printed on the body. If there is no info then assume it's a DC solenoid. Try with 12v, if that doesn't move the shaft, or it seems very weak, move up to 24v. Assume that an unmarked solenoid is intermittent duty!

Relays

A relay is the lovechild of a solenoid and a switch. It uses a solenoid action to activate a switch. They come in many types, including all varieties of switches, latching, etc.

The good:
Ubiquitous; easy to use; come in many sizes, ratings, and switch configurations.

The bad:
Same as for solenoids; mounting can be awkward, especially for large ones;

The hookup:
Depends on the type. Some simply have four pins, two for the solenoid and two for the switch. Others have many pins for different solenoid directions, and multi-pole, multi-throw switches. Usually there's a legend of some sort printed on the shell. Look for two pins that have a loopy coil symbol across them -- that tells you which pins activate the internal solenoid. The other pins will be connected to various parts of the internal switch.

Identification:
Usually a plastic box of some sort, solid or transparent. Usually there is some info about activation voltage and switch ratings printed on the shell. Older industrial relays take a variety of strange shapes (circuilar, irregular). Contemporary ones tend to be boxy.