Spinning is easy. Stopping in the right place is hard.
A motor turns electricity into spinning. Almost every robot has several. But a robot does not only need to spin. It needs to turn exactly 40 degrees, then stop and hold still. Different motors solve that in different ways.
Pick a motor below to see how it works and what it is good at. We will look at three: the DC motor, the servo, and the stepper.
DC motor: the plain spinner
- How it works
- Connect power and the shaft spins. Flip the wires and it spins the other way. More power means faster.
- Good at
- Wheels, fans, and drills. Anything that just needs to keep turning.
- The catch
- It does not know where its shaft is. You cannot ask it to stop at exactly 40 degrees without adding a sensor.
Servo: go to this angle
- How it works
- A small motor, gears, a sensor, and a tiny circuit board are packed in one box. You send an angle command and the servo turns there and holds.
- Good at
- Robot arms, grippers, steering, and moving a camera. Most hobby servos turn about half a circle (around 180 degrees).
- The catch
- Limited range. Hobby servos are not made for many full spins, and small ones are not very strong.
Stepper: count the steps
- How it works
- It turns in tiny, equal steps. A common kind has 200 steps for one full turn, so each step is 1.8 degrees. Send 50 steps and it turns 90 degrees.
- Good at
- 3D printers, plotters, and camera sliders. Anything that needs repeatable positions and can turn any number of times.
- The catch
- A basic stepper setup never checks its own position. If it is overloaded, it can skip steps without telling anyone.
| Motor | You command | Knows its position? | Typical use |
|---|---|---|---|
| DC motor | How much power | No | Wheels, fans |
| Servo | A target angle | Yes, it measures it | Robot arms, grippers |
| Stepper | A number of steps | No, it counts | 3D printers, plotters |
How a pulse becomes an angle
A hobby servo has three wires: power, ground, and one signal wire. All the commands travel on that single signal wire. The trick is a pulse whose width carries the message.
The controller sends a pulse about 50 times every second. One round is a frame, about 20 milliseconds long (a millisecond, written ms, is one thousandth of a second). In each frame the signal turns on for a short time, then turns off. How long it stays on is the pulse width. This way of sending numbers as on-time is called PWM, short for pulse-width modulation.
For many hobby servos, a pulse of about 1.0 ms means one end of the range, 1.5 ms means the middle, and 2.0 ms means the other end. These numbers are approximate. Different servo models use slightly different ranges, so always check the datasheet.
- Horn angle
- 90°
- Pulse width
- 1.50 ms
- On-time
- 7.5% of frame
- Frame
- 20 ms
Rule of thumb: angle = (pulse − 1.0 ms) × 180°
Try it: hit the target
Target: point the horn at 135°.
Set the pulse width so the horn lines up with the target.
What is inside the little box?
A servo can find its own angle because it has a feedback loop built in. Click each part to see what it does.
Pick a part. Follow the arrows from left to right, then follow the dashed feedback line back.
A motor that counts in steps
A stepper motor does not spin smoothly. Inside, a ring of electromagnets switches on in a pattern, one after another. Each switch pulls the shaft to the next position. That is one step.
The size of one step is the step angle. A full turn is 360 degrees, so step angle = 360° ÷ steps per turn. A very common stepper has 200 steps per turn, so each step is 360 ÷ 200 = 1.8°. To turn 90 degrees, send 90 ÷ 1.8 = 50 steps.
Because the controller just counts steps, it assumes the shaft went where it was told. Try the lab. Then switch on the heavy load and see what happens.
- Controller counted
- 0 steps
- Shaft angle
- 0.0°
- Steps lost
- 0
- Retries
- 0
Try 50 steps with the load off. The shaft should end at exactly 90 degrees.
Why do steps get lost? A stepper has limited turning force, and that force gets weaker as it spins faster. If the load is heavy or the speed is too high, the magnets cannot pull the shaft to the next spot. The controller still sent the step, so its count is now wrong. This lab is a simple toy model. Real skip behavior depends on the motor, the voltage, and how smoothly the speed ramps up.
Check your understanding
How many steps?
A stepper has 200 steps per turn. You want the shaft to turn exactly half a turn. How many steps do you send, and what is that angle?
Half a turn is 180 degrees. Each step is 1.8 degrees, so 180 ÷ 1.8 = 100 steps. You can also think of it as half of 200.
Open loop or closed loop?
Imagine walking across a room with your eyes closed, taking 10 steps and trusting you are at the door. That is open loop. Now open your eyes and adjust as you go. That is closed loop.
An open-loop controller sends a command and hopes it worked. A closed-loop controller uses a sensor to measure what really happened, compares it to what it wanted, and fixes the difference. The measured value sent back is called feedback.
A hobby servo is closed loop: its sensor reports the shaft angle to its control circuit many times a second. A basic stepper is open loop. That is why the stepper lab could drift, and why turning on the encoder fixed it.
Open loop: the controller sends the command and never checks. It is simple and cheap, but any mistake goes unnoticed.
Is open loop bad? Not at all. When the load is light and the speed is gentle, a stepper never skips, and open loop is simple and cheap. Closed loop costs more (a sensor and extra code) but is safer when mistakes matter.
Gears trade speed for turning force
Small motors spin fast but push weakly. Gears fix that. Two gears with different numbers of teeth turn at different speeds, and the slower one pushes harder.
The gear on the motor is the driver. The gear it turns is the driven gear. The gear ratio compares their teeth. If the driver has 10 teeth and the driven gear has 30, the driver must turn 30 ÷ 10 = 3 times for the driven gear to turn once. So the output is 3 times slower, with about 3 times more torque (turning force). Gears move energy around. They do not add any. Real gears also lose a little to friction, often somewhere around 5 to 20 percent.
Set the tooth counts. Watch the speed and torque balance. Then try to lift the loads.
Ratio 3.00 : 1 (gear down)
Challenge: the motor makes 10 torque units. Lift the load.
Pick a load to test your gears.
That is why servos have gears inside. A tiny motor spins very fast with very little torque. The built-in gear train slows it down and multiplies the torque so the output horn can actually move a robot arm.
Drive a 2-joint robot arm
A robot arm is just servos in a row. Each joint is one servo. Here, the shoulder servo swings the whole arm, and the elbow servo bends the forearm. Your job: put the gripper on the target.
You will notice something: moving one joint moves everything after it. That is why robot programmers must think about the whole chain. Use the sliders, or click a slider and press the arrow keys for fine steps.
Move the sliders until the black gripper sits inside the dashed ring.
Elbow at 90° means the forearm is straight. Smaller bends it one way, larger the other.
Words to remember
- Servo
- A motor package with gears and a sensor that turns to a commanded angle and holds it.
- Stepper motor
- A motor that turns in equal, fixed steps.
- DC motor
- A plain motor that spins when you apply power.
- PWM
- Pulse-width modulation. Sending a value by changing how long a signal stays on.
- Pulse width
- How long the signal stays on in one frame, about 1 to 2 ms for a hobby servo.
- Step angle
- How far the shaft turns in one step. 360° ÷ steps per turn.
- Gear ratio
- The tooth counts of two meshing gears compared. It sets the speed and torque trade.
- Torque
- Turning force. More torque means the motor can move a heavier load.
- Feedback
- A measurement sent back to the controller so it can correct errors.
- Open loop
- Sending commands with no check on the result.
- Closed loop
- Measuring the result and correcting it.
- Encoder
- A sensor that measures how far a shaft has turned.
Quick answers
What is the difference between a servo and a stepper motor?
A hobby servo has a motor, gears, and a position sensor inside it. You send it a pulse and it turns to a matching angle and holds there, usually within a half-turn range. A stepper motor moves in fixed small steps, such as 200 steps for one full turn, and it keeps turning as long as you send steps. A servo checks its own position. A basic stepper does not.
How does PWM control a servo?
The controller sends a short pulse about 50 times every second, so one frame lasts about 20 milliseconds. The width of the pulse is the command. For many hobby servos, about 1 millisecond means one end of the range, about 1.5 milliseconds means the middle, and about 2 milliseconds means the other end. The exact numbers differ from one servo model to another.
Why do stepper motors skip steps?
A stepper motor can only turn one step if its magnets can pull the shaft with enough force. If the load is too heavy, or the controller asks for steps too fast, the shaft can fail to move even though the controller sent the step. Most simple stepper systems are open loop, so the controller never finds out that a step was lost.
What does a gear ratio do?
A gear ratio compares the number of teeth on two gears that mesh. If a small gear drives a gear with three times as many teeth, the output turns three times slower but can deliver about three times more torque, ignoring friction. Gears trade speed for turning force. They do not create extra energy.
What is the difference between open loop and closed loop control?
An open-loop system sends a command and trusts that it worked, with no sensor to check. A closed-loop system measures the result and corrects errors. A hobby servo is closed loop because it has a position sensor inside. A basic stepper setup is open loop.
Quick quiz
1. A hobby servo gets a pulse of about 1.5 ms every 20 ms. Where does the horn point?
2. A stepper has 200 steps per turn. A heavy load makes it skip 10 steps. What does the controller think?
3. A small gear with 10 teeth drives a big gear with 40 teeth. What happens to the output?
Keep building motion
You can now explain how servos, steppers, and gears make robots move. Next, see how a whole robot fits together, or learn how a controller board sends these signals.
Related: What Is CAD? and Binary Explorer