1 Where Lab 5 Sits
So far you have controlled how fast and how bright. An LED had two states and a duty cycle; a DC motor had a speed that rose with duty cycle. In neither case did you ever know where anything was.
This week both motors are about position. A stepper moves in discrete, countable increments, so counting the steps tells you how far it has turned, as long as the rotor keeps up with every command. A servo contains its own feedback loop and holds whatever angle you command. They reach the same goal by opposite routes, and the contrast is the point of the lab.

A stepper is open loop: you command a sequence and trust that the motor followed it. A servo is closed loop: you command a position and the motor's internal electronics work to achieve it. Open loop is precise but silently fails when overloaded; closed loop corrects itself but only within its own range and resolution.
| Lab 5 task | What you do | Concept & section |
|---|---|---|
| 1 | Read the NEMA 17 and driver datasheets; identify driver pins and the four motor wires; draw a schematic | How a stepper is built and wired (§2, §6), the DRV8833 (§7) |
| 2 | Create full-step and half-step logic tables, clockwise and counter-clockwise | Coil states and the rotating field (§3) |
| 3 | Build and run; two full rotations each way, both sequences; report runtime, revolutions, period, frequency, angle per step, total steps | Step angle and RPM arithmetic (§4), a sample program (§5), reporting (§8) |
| 4 | Connect the MG996R servo; rotate to 30°; verify with a protractor | Servo pinout and pulse width (§9) |
| 5 | Extra credit: full range; duty-vs-angle table; fitting formula; accuracy; reject out-of-range input | Calibration and input validation (§10, §11) |
2 How a Stepper Motor Works
2.1 What turns, and what stays still
Every rotating motor in this lab has a stator, fixed to the case, and a rotor on the shaft, and in each of them the torque comes from coil currents pushing against a magnet’s field. (Induction and reluctance motors work differently, but you will not meet them here.) What differs between the motors in this lab is which part carries the coils and who switches their current.

That difference is the whole story of this lab. A DC motor switches its own coils, so all you can set is how hard it pushes, which is why Lab 4 controlled speed. A stepper has handed the switching to you: every coil change is an instruction, so you decide exactly how far it turns.
2.2 The simplest stepper
Put a bar magnet on the shaft and four coil poles round it. Energize the left and right poles so that one is a north pole and the other a south pole, and the magnet swings round to line up with them and holds there. Switch the current to the top and bottom poles and it swings 90° to line up with those instead.

Rotation is therefore not continuous. It is a series of jumps between stable alignments, and because the motor’s geometry fixes those alignments, every jump is the same size. That repeatability is what makes the motor useful: counting steps tells you how far the shaft has turned, as long as the rotor follows every command. To know the absolute angle you also need a known starting position.
A motor built this way, with a magnetized rotor, is a permanent-magnet (PM) stepper. Two coils (A and B) and two current directions give four states, and the magnet follows them round. But 90° per step is far too coarse for a printer or a telescope, and a real motor cannot fit enough separate poles round the rotor to make the steps small. The NEMA 17 solves that with teeth.
2.3 A 1.8° hybrid stepper: teeth and pole spacing
"NEMA 17" only names the size: a faceplate about 1.7 inches (42 mm) square, in a standard from the US National Electrical Manufacturers Association. The motor type is in the other word on its label, hybrid, and it means a mix of the two basic kinds of stepper:
- A permanent-magnet (PM) stepper is the motor of §2.2: coils pull a magnetized rotor round. The magnet gives good torque, but there is room for only a few poles, so the steps are large: 90° in the simplest one, typically 7.5° to 15° in real motors.
- A variable-reluctance (VR) stepper has no magnet at all. Its rotor is soft iron cut with teeth. Magnetic flux would much rather pass through iron than through air (iron has a far lower reluctance, the magnetic counterpart of resistance), so an energized pole pulls the nearest rotor teeth into line with its own teeth, closing the air gaps. Fine teeth give fine steps, but without a magnet the torque is weak, and the unpowered rotor turns freely.
- A hybrid stepper combines them: a permanent magnet for torque, iron teeth for small steps.
In the common 1.8° hybrid design illustrated here, the rotor is a cylindrical magnet, magnetized along the shaft, clamped between two soft-iron cups, each cut with 50 teeth. The magnet makes every tooth of one cup a north pole and every tooth of the other a south pole, and the two cups are turned half a tooth relative to each other. The stator has 8 poles, each with 6 teeth: 48 teeth in all.
The magnet's flux leaves through the north cup's teeth, crosses the air gap into the stator poles, runs round the stator iron, and comes back through the south cup's teeth. When coil current makes a stator pole a south pole, the pole's teeth attract the north cup's teeth and repel the south cup's teeth. Because the south cup is offset by half a tooth, its teeth sit exactly between the pole's teeth, so both forces turn the rotor the same way. The teeth decide where the rotor stops; the magnet makes it stop there firmly. The magnet also gives the small detent torque you feel as bumps when you turn an unpowered stepper's shaft by hand.

The rotor tooth pitch is 360°/50 = 7.2°. The eight stator poles are 45° apart, and 45° = 6 × 7.2° + 1.8°. So when one pole’s teeth line up with rotor teeth, the next pole’s teeth are a quarter of a tooth pitch, 1.8°, out of line. (The teeth on each pole follow roughly the rotor’s 7.2° pitch; the 48 stator teeth are not spread evenly round the circle, and the extra 1.8° comes from the gaps between poles.) That quarter-tooth offset, together with the order in which the coils are switched, sets the step angle. “NEMA 17” says nothing about tooth counts or step angle, so check your own motor.

Why exactly one step, and why the rotor stays there
Most of the torque you control comes from the energized poles; the magnet adds the small detent torque. In any one coil state the rotor feels a torque that depends on how far its teeth are from lining up with the energized poles' teeth. The pattern repeats every rotor tooth, 7.2°, and to a good approximation it is a sine curve:
Here θ0 is the rest point for that state and TH is the holding torque, the largest torque the energized coils can exert; it is on the motor's datasheet. Three things follow, and Figure 6 shows all of them.
- At the rest point the torque is zero, and it pushes back if you move away. Turn the shaft a little forward and the torque becomes negative; turn it back and it becomes positive. Either way the rotor is pushed back, like a mass on a spring. A steady load shifts the rotor a little off the rest point, to where the motor’s torque balances it, and the motor can hold the load only if it needs less than TH. This is why a powered stepper resists your fingers, and why it gets warm while standing still: holding costs current.
- A new state moves the rest point, not the rotor. Switching from one state to the next moves the "spring's anchor" a quarter tooth, 1.8°, along. The rotor, still at the old rest point, is now 1.8° from the new one. That is a quarter of the 7.2° period, 90° into the sine, so the torque on it is the largest there is. The rotor accelerates toward the new rest point. Once past it the torque reverses and pulls it back, so it overshoots a little, rings and settles there until the next state. That is the usual outcome, not a guarantee: a rotor moving fast enough, or carrying a heavy load, can be carried right past the new rest point.
- It takes the short way. For a rotor at rest with little load, the torque always points toward the nearest rest point within half a tooth, ±3.6°. The nearest aligned position ahead is 1.8° away; the one behind is 7.2° − 1.8° = 5.4° away, outside that range, so the rotor steps forward. (This is the picture for a rotor at rest; one that is already moving may not behave so neatly.) It is also why the states must be applied in order. Skip one state (a 3.6° jump, exactly half a tooth) and the rotor sits on the boundary between two rest points, so which way it goes is chance. Skip two (5.4°) and it steps 1.8° backwards.

If the load needs more than TH, or the next state arrives before the rotor has caught up, the rotor ends up outside the capture range, settles at a different rest point, and the software's count and the shaft disagree from then on: missed steps (§4.4).
So one change of which coil is energized moves the rotor only a quarter of a tooth. One tooth pitch of the rotor is
and the four coil states of one electrical cycle (A+, B+, A−, B−, in §3) move the rotor through one tooth pitch. So one state change moves it a quarter of that:
Half stepping inserts a state between each pair (§3.4), giving 0.9° and 400 states per revolution. The electrical angle of the field and the mechanical angle of the shaft are different things: the field turns 360° while the shaft turns 7.2°, a ratio of 50.

2.4 Eight poles, two coils, four wires
Eight poles do not need sixteen wires. The four poles at 0°, 90°, 180° and 270° are wound with one continuous wire, coil A, and the four in between with another, coil B. Alternate poles in each set are wound in the opposite sense (A and Ā, B and B̄), so a single current in coil A makes two opposite north poles and two opposite south poles at once. Two coils with two ends each: four wires.

3 Full Step and Half Step
3.1 From driver inputs to coil current
The DRV8833 (§7) has one pair of inputs per coil. For coil A, inputs AIN1 and AIN2 decide the voltages on AOUT1 and AOUT2; BIN1 and BIN2 do the same for coil B. Three of the four input combinations are all a stepper needs:
| xIN1 xIN2 | xOUT1 xOUT2 | Coil current | Label |
|---|---|---|---|
| 1 0 | H L | xOUT1 → xOUT2 | A+ (or B+) |
| 0 1 | L H | xOUT2 → xOUT1 | A− (or B−) |
| 0 0 | Z Z | current decays after switching off (coast) | coil off |
| 1 1 | L L | coil shorted (brake) | not used for stepping |
We write a state as the four bits AIN1 AIN2 BIN1 BIN2. So 1 0 1 0 means A+ and B+ together; 0 0 1 0 means B+ alone.
3.2 The field is a vector sum
Put coil A's field along the horizontal axis and coil B's along the vertical. The field inside the motor is the vector sum of the two:
- Energizing one coil alone points the field along that coil's axis.
- Energizing both coils together points the field along the diagonal, midway between the two axes, and with a larger magnitude: the vector sum of two equal perpendicular contributions is √2 times either one.
- Reversing a coil's polarity flips its contribution through 180°.

3.3 The full-step table
Full step uses one kind of state throughout. The two-coil version keeps both coils on and walks the field around the four diagonals:
| State | AIN1 | AIN2 | BIN1 | BIN2 | Coils | Field |
|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | A+ B+ | 45° |
| 1 | 0 | 1 | 1 | 0 | A− B+ | 135° |
| 2 | 0 | 1 | 0 | 1 | A− B− | 225° |
| 3 | 1 | 0 | 0 | 1 | A+ B− | 315° |

There is also a one-coil full step ("wave drive"): A+, B+, A−, B−, which is 1 0 0 0, 0 0 1 0, 0 1 0 0, 0 0 0 1. It puts the rotor on the axes instead of the diagonals, draws half the current, and gives about 1/√2 of the torque. Either is a valid full step; say which you used.
3.4 The half-step table
Half step alternates the two kinds of state, so the field lands on the axes and the diagonals in turn: eight states per electrical cycle, 45° of field and 0.9° of shaft per state.
| State | AIN1 | AIN2 | BIN1 | BIN2 | Coils | Field |
|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 0 | A+ | 0° |
| 1 | 1 | 0 | 1 | 0 | A+ B+ | 45° |
| 2 | 0 | 0 | 1 | 0 | B+ | 90° |
| 3 | 0 | 1 | 1 | 0 | A− B+ | 135° |
| 4 | 0 | 1 | 0 | 0 | A− | 180° |
| 5 | 0 | 1 | 0 | 1 | A− B− | 225° |
| 6 | 0 | 0 | 0 | 1 | B− | 270° |
| 7 | 1 | 0 | 0 | 1 | A+ B− | 315° |

The odd rows of this table are exactly the full-step table of §3.3. That is a useful check on both tables, and it is why the half-step torque alternates: the two-coil rows have √2 more field than the one-coil rows.
3.5 Direction, and the coils in quadrature
Direction is simply the order in which you walk the table. Walk it with the state index counting up for one direction and counting down for the other; after the last row, wrap to the first. You do not need a second table.
Which way "up" turns the shaft depends on how the coils are wound and connected, so establish it on the bench: mark the shaft, step up, and look along the shaft from the front. If it turns the opposite way to the direction you want to call clockwise, either count the other way or swap the two leads of one coil.

3.6 What each choice costs
| Mode | Step angle | Steps per revolution | Trade-off |
|---|---|---|---|
| Full step | θfull | S | Higher torque per step, simpler table, coarser resolution. Can be noisier, and is more prone to resonance at particular step rates. |
| Half step | θfull/2 | 2S | Twice the resolution and noticeably smoother, but torque alternates between the one-coil and two-coil values, and the step rate must double for the same speed. |
Both modes are required in Task 3, and running the same physical rotation in each is the cleanest way to demonstrate the difference. Listen to the motor as well as watching it. Half stepping is audibly smoother, and that observation belongs in the report.
4 Step Angle, RPM and Timing
4.1 The arithmetic
Everything Task 3 asks you to report follows from two numbers: the step angle and the step rate.
where S is the number of steps in one full revolution in the mode you are using. If a delay td separates consecutive steps, then
Equation (4) counts only the delays. Every step also costs software overhead (the same effect analyzed in §6 of the Lecture 03 notes), so a real revolution takes slightly longer than S × td (§4.3).
A 1.8° full step gives 360°/1.8° = 200 full steps per revolution, so half-step mode has S = 400. With td = 5 ms:
These are delay-only figures, before overhead. For the same shaft speed in full-step mode, S halves to 200, so td doubles to 10 ms and the state-update rate halves to 100 Hz. The 1.8° angle is an example: take your motor’s figure from its datasheet and verify it, as below.
Get the full-step angle from the NEMA 17 datasheet, then verify it by measurement: mark the shaft, command a known number of steps, and see whether it ends up where the arithmetic says it should. Command exactly one revolution's worth and check that the mark returns to its starting position.
A gearbox multiplies the steps per output revolution by the gear ratio, so check whether your motor has one. The DRV8833 has no microstepping setting: whether you full-step or half-step is decided entirely by the table your program walks, so S is 200 or 400 for a bare 1.8° motor. A dedicated step/direction driver with mode pins would be different, and a driver silently set to 1/8 microstepping makes every angle wrong by a factor of eight while staying perfectly self-consistent.
Task 3 explicitly asks you to compare the reported values with your observations. This is why.
4.2 RPM control: choosing the delay
Turn Equation (4) around to get the delay for a target speed. Since one revolution takes S states,
Full step, S = 200: . Half step, S = 400: . The shaft speed is the same; the half-step program simply updates the coils twice as often.
Two turns in half step is 2 × 400 = 800 states, which at 2.5 ms takes 2.0 s before overhead.

To change speed smoothly, change td gradually rather than jumping straight to a short delay. A motor started at full speed from rest often stalls, because the rotor and its load must be accelerated; a ramp lets it keep up. For example, start at twice the final delay and shorten it over the first few dozen states.
4.3 Loop overhead
Each pass through the stepping loop does more than sleep. It works out the next row, calls GPIO.output() four times, and returns to the scheduler, all of which take time toh. The real step period is td + toh.

The two-turn half-step run of §4.2 is predicted to take 2.0 s. Suppose time.perf_counter() shows 2.08 s. Then each state really took 2.08 s / 800 = 2.6 ms, so
A first correction is to sleep 2.5 − 0.1 = 2.4 ms and measure again. This uses the average overhead per state, so it matters more as td shrinks: 0.1 ms is 4% of a 2.5 ms delay but 10% of a 1 ms delay. Measure it on your own Pi; it varies from run to run.
4.4 Speed is limited by physics, not by code
You cannot step arbitrarily fast. Three effects set the ceiling:
- Torque falls with step rate. Each coil is an inductor: after a state change its current rises toward V/R with time constant . With the example motor's 2.8 mH and 1.5 Ω plus the DRV8833's 0.36 Ω of switch resistance, . If a coil only stays in one state for about 1 ms, its current reaches about half its final value; after 5 ms it is within 4%. Less current means less field and less torque.
- Missed steps. If the rotor cannot reach the next alignment before the field moves again, it slips. The motor buzzes, stalls, or turns erratically, and the software has no idea. Your step count says one thing, the shaft says another. This is the characteristic failure of open-loop control, and demonstrating it deliberately makes an excellent report figure.
- Resonance. At particular step rates the rotor's oscillation about each new position couples with the stepping rate and the motor loses torque badly. It is usually a narrow band, and stepping through it quickly avoids it.



If the motor misbehaves, increase td first. Most “the stepper does not work” problems are simply stepping too fast.
(a) A motor has a 0.9° full step. How many full steps make one revolution? How many half steps?
(b) Using that motor in full-step mode with td = 4 ms, find the step frequency, the time for one revolution, and the RPM.
(c) How many half steps are needed for two complete revolutions of the same motor, and how long will that take with td = 2.5 ms?
(d) You command 400 half steps on a motor whose datasheet full-step angle predicts two revolutions, but the shaft turns exactly one. Give two possible explanations and a test that distinguishes them.
(e) A 1.8° motor must turn at 90 RPM in half-step mode. What delay does Equation (5) give? If your loop overhead is 0.15 ms, what delay should the program actually sleep?
(f) A motor has 4.0 mH coils of 2.0 Ω, driven through 0.36 Ω of switch resistance. Find τ, and the fraction of final current reached 2 ms after a state change.
5 A Sample Stepper Program
This program puts §3 and §4 together. It walks the full-step table of §3.3 forward or backward for a chosen number of turns at a chosen speed, and reports how long that took. It is written the long way on purpose: every pin has its own name, every row of the table has its own if branch, and every decision is a plain if. The GPIO numbers are the ones used in the course's example wiring; use your own.
import time
import RPi.GPIO as GPIO
# DRV8833 input pins (BCM numbers).
# Example wiring: change to match yours.
AIN1 = 19
AIN2 = 26
BIN1 = 20
BIN2 = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(AIN1, GPIO.OUT, initial=0)
GPIO.setup(AIN2, GPIO.OUT, initial=0)
GPIO.setup(BIN1, GPIO.OUT, initial=0)
GPIO.setup(BIN2, GPIO.OUT, initial=0)
# Send one row of the table to the driver.
def set_coils(a1, a2, b1, b2):
GPIO.output(AIN1, a1)
GPIO.output(AIN2, a2)
GPIO.output(BIN1, b1)
GPIO.output(BIN2, b2)
# Settings
steps_per_rev = 200 # 1.8° full steps
turns = 2 # turns to make
rpm = 30 # target speed
direction = 1 # 1 forward, -1 back
# Delay per step in seconds, Eq. (5)
delay = 60 / (steps_per_rev * rpm)
total_steps = turns * steps_per_rev
# Align first; this initial movement is not a counted step.
state = 0
try:
set_coils(1, 0, 1, 0)
time.sleep(0.2) # allow alignment at this starting state
start = time.perf_counter()
for step in range(total_steps):
state = (state + direction) % 4
if state == 0:
set_coils(1, 0, 1, 0) # A+ B+
elif state == 1:
set_coils(0, 1, 1, 0) # A- B+
elif state == 2:
set_coils(0, 1, 0, 1) # A- B-
else:
set_coils(1, 0, 0, 1) # A+ B-
time.sleep(delay)
elapsed = time.perf_counter() - start
print(f"Time: {elapsed:.2f} s")
print(f"Average RPM: {turns * 60 / elapsed:.1f}")
finally:
set_coils(0, 0, 0, 0) # release coils even after Ctrl-C
GPIO.cleanup()Example only. Do not copy this code as it is: read it, learn from it, then write your own.
How it works, piece by piece:
- The pins.
AIN1,AIN2,BIN1andBIN2are just names for four GPIO numbers, so the rest of the program reads like the DRV8833 pinout. Each is set up as an output. set_coilswrites one row of the table: four numbers in the order AIN1 AIN2 BIN1 BIN2, exactly as the table columns are written. The four writes happen sequentially. They briefly apply intermediate states; their timing depends on the GPIO implementation and operating system.- The settings.
steps_per_revis 200 for a 1.8° motor in full step.delayis Equation (5), andtotal_stepsis Equation (3) turned around. - The
if/elifblock is the full-step table of §3.3, one branch per row. The comment on each branch names the coils that are on, so you can check it against the table and Figure 10. time.sleep(delay)holds each row for td, giving the rotor time to move to the new position.- The next row. After initial alignment,
state = (state + direction) % 4advances or reverses one row and wraps at either end. Each counted iteration is now one transition between known states. The first alignment establishes a relative origin, not an absolute home position. - The timing uses
time.perf_counter(), a high-resolution clock, read before and after the loop, so the measured time includes the overhead of §4.3. The printed average RPM uses the commanded turn count; it is not a measurement of shaft speed if steps are missed. In theprintlines, thefbefore the quotes lets you put a value inside{ }, and:.2fshows it with two decimal places (:.1fwith one). - Switching off. The
finallyblock puts both coils in coast and releases the GPIO pins on normal completion, Ctrl-C or a Python exception. A process kill or power failure cannot run cleanup; switch off the motor supply before leaving the bench.
Two turns at 30 RPM should take 4.0 s by Equation (5); the program reports what it really took. For Lab 5 you will add half step: a second if/elif block with eight branches, one per row of the §3.4 table, with the wrap at 8 instead of 4 and steps_per_rev doubled to 400. You will also run both directions and report every quantity Task 3 asks for (§8).
6 The Lab Motor: Pinout and Datasheet
With the stepping sequence and the program in hand, the remaining question is which wire is which. This section identifies the lab motor’s four leads and reads the numbers on its datasheet; §7 then connects them to the driver.
6.1 The lab motor's pinout
A bipolar stepper has four leads, two per coil (§2.4). The lab motor's color code is not in either datasheet you were given, so here it is.

Vendor datasheets use their own colors. The Handson 17HS4401S sheet puts one coil on black–green and the other on red–blue; the PBC Linear sheet uses blue, red, green and black. Colors tell you nothing until you have checked which leads share a coil.

With the motor disconnected, measure resistance between pairs of leads. Two leads from the same coil show a low resistance, typically a few ohms. Two leads from different coils show an open circuit. That single test partitions the four wires into two pairs unambiguously. For the lab motor you should find red–yellow and green–gray; record the two resistances, because §7.5 uses them.
A second, satisfying check: short two leads together and turn the shaft by hand. It becomes noticeably harder to turn, because you have completed a circuit and the motor is now generating current into a short. If that happens, those two leads are one coil.
Which lead of a pair is which end only sets the direction of rotation. If the motor turns the wrong way, swap one pair.
6.2 Reading the stepper datasheet
Five numbers on a stepper datasheet matter for this lab: the step angle, the rated phase current, the winding resistance and inductance, and the holding torque.

The resistance sets the steady current for a given drive voltage, . The inductance sets how quickly that current can build after each state change, which in turn limits speed (§4.4). The lab motor's figures may differ from this example; measure its resistance, and use the numbers here to practice the arithmetic.
7 The DRV8833 Driver
7.1 Why a driver chip
A stepper coil draws far more current than a GPIO pin can supply, and it is inductive, so it needs the same treatment a DC motor did in Lab 4, except that each of the two coils must be driven in both polarities. Reversing current through a coil takes four switches arranged as an H-bridge: two connect the coil ends to the supply, two to ground, and closing a diagonal pair sets the current direction. A bipolar stepper needs two H-bridges, one per coil. The Texas Instruments DRV8833 is exactly that, in one chip.
How an H-bridge works. Draw the coil as the crossbar of a letter H. Each upright is two switches in series between the supply VM and ground: a high-side switch from VM down to one end of the coil, and a low-side switch from that end down to ground. Call them HS1 and LS1 on the OUT1 side and HS2 and LS2 on the OUT2 side. The Lab 4 circuit was one low-side switch, which could only turn the current on and off in one direction; the H-bridge adds the second side and the high-side switches, so it can also choose the direction.
| xIN1 | xIN2 | HS1 | LS1 | HS2 | LS2 | OUT1 | OUT2 | Coil |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | on | off | off | on | VM | 0 | current OUT1 → OUT2 |
| 0 | 1 | off | on | on | off | 0 | VM | current OUT2 → OUT1 |
| 0 | 0 | off | off | off | off | open | open | off (coast) |
| 1 | 1 | off | on | off | on | 0 | 0 | shorted (brake) |
- One diagonal on: current one way. HS1 and LS2 put VM on OUT1 and ground on OUT2, so current flows through the coil from OUT1 to OUT2.
- The other diagonal on: current reversed. HS2 and LS1 swap the two ends, and the same coil's current, and so every one of its poles, reverses. That is the + and − of §3.1, from one supply.
- Never both switches of one upright. HS1 and LS1 on together connect VM straight to ground through two small resistances. This shoot-through is a short circuit that can destroy a bridge in microseconds. No input combination asks for it, and the chip adds a short dead time at every change (§7.2) so the switch that is turning off is fully off before its partner turns on.
- Opening switches does not stop the current at once. The coil is an inductor, so when a switch opens, its current must go somewhere. Each MOSFET has a built-in body diode that gives it a path, back to the supply or round the bridge; §7.4 shows both paths and why they matter.
A GPIO output is like one small bridge leg, switching between 3.3 V and ground, but it is built for logic, not for driving a motor (Lecture 03 §4.7). The DRV8833 gives each coil a full bridge of four much larger switches, handling up to 1.5 A from VM, and a GPIO pin only has to tell each bridge which state to be in.

The numbers that matter for Lab 5, from the TI DRV8833 datasheet's recommended operating conditions and electrical characteristics (at VM = 5 V and 25 °C unless noted):
| Quantity | Value | What it means for you |
|---|---|---|
| Motor supply VM | 2.7–10.8 V (abs. max 11.8 V) | The coil voltage comes from here, not from the Pi |
| Output current per bridge | Up to 1.5 A RMS in PWP/RTY; 0.5 A RMS in PW; 2 A peak | Depends on the chip package, board cooling and temperature; your breakout may manage less |
| Switch resistance, high + low side | 200 + 160 mΩ = 0.36 Ω | Adds to the coil resistance; dissipates I²×0.36 Ω per bridge |
| Logic high, xIN | ≥ 2 V | A 3.3 V GPIO pin drives it directly |
| Input current at 3.3 V | 16.5 µA typ. | Negligible load on a GPIO pin |
| Input pulldowns | 150 kΩ (xIN), 500 kΩ (nSLEEP) | An unconnected input reads 0; an unconnected nSLEEP sleeps |
| Logic high, nSLEEP | ≥ 2.5 V | 3.3 V is enough |
| Wake-up time | ≤ 1 ms | Wait after raising nSLEEP before stepping |
| Overcurrent trip | 2 A min, 3.3 A typ. | Bridge shuts off, retries every 1.35 ms |
| Thermal shutdown | 150 °C min | Recovers when the die cools |
7.2 Inside the chip

All four switches in each bridge are N-channel MOSFETs, the devices of Lecture 04. The high-side ones need a gate voltage above VM to turn fully on, which is what the charge pump provides. The chip also inserts about 450 ns of dead time whenever a bridge changes state, so the high and low switches on one side are never on together; you do not need to add any delay for that yourself.

7.3 The breakout board
The lab uses the chip on a small breakout board with the supporting capacitors already fitted.


| Pin | Connects to | Notes |
|---|---|---|
| AIN1, AIN2 | two GPIO outputs | Control coil A (§3.1) |
| BIN1, BIN2 | two GPIO outputs | Control coil B |
| SLP | 3.3 V (a 3.3 V pin, or a GPIO set high) | nSLEEP, active low: 0 V sleeps, 3.3 V runs. Low, or floating on a bare chip, puts both bridges to sleep: a quiet, complete failure. Measure it with the DMM while the circuit is powered. |
| FLT | optional GPIO input with pull-up to 3.3 V | nFAULT, active low, open-drain: pulled to 0 V on overcurrent or overtemperature. Needs a pull-up, such as the Pi's internal one, to read. |
| GND | Pi GND and supply − | One common ground for all three |
| VM | motor supply + | Also on the VMotor screw terminal |
| AOUT1, AOUT2 | red, yellow (coil A) | Never unplug while powered |
| BOUT2, BOUT1 | green, gray (coil B) | Note the order: B2 before B1 |
| AS, BS | normally nothing | Sense nodes, for measuring coil current |
Logic levels and active-low controls. The chip's pin names follow a convention worth learning: a leading n, as in nSLEEP and nFAULT, means the signal is active low: the thing it names happens when the pin is at 0 V. The breakout shortens the names to SLP and FLT and drops the n, but the pins behave exactly as the chip's do:
- AIN1, AIN2, BIN1 and BIN2 are plain logic inputs, one pair per coil. A GPIO pin at 3.3 V is a 1 (the threshold is 2 V) and 0 V is a 0. An unconnected input reads 0 through its internal 150 kΩ pulldown, so the bridge sits in coast.
- SLP (nSLEEP) is active low: 0 V means sleep, 3.3 V means run. Low switches all eight bridge transistors off, so the outputs float, and resets the chip's logic; high wakes it within 1 ms. The pin has an internal 500 kΩ pulldown, so on a bare chip an unconnected SLP means sleep. Connect SLP to 3.3 V: a 3.3 V header pin, or a GPIO pin set high if you want your program to be able to put the driver to sleep. 3.3 V is above the 2.5 V the pin needs and well below the 6.5 V at which it clamps. (The datasheet also allows tying it to VM, but only through a 20–75 kΩ resistor.) Some breakouts pull SLP up on the board; either way, check with the DMM that it reads above 2.5 V while the circuit is powered.
- FLT (nFAULT) is an active-low output. It goes to 0 V when the chip shuts a bridge down for overcurrent or overtemperature, and returns high when it recovers. It is open-drain: the chip can pull it to ground but never drives it high, so it needs a pull-up resistor to read high when all is well. It is optional. To watch it, connect it to a GPIO input and use the Pi's internal pull-up,
GPIO.setup(FLT, GPIO.IN, pull_up_down=GPIO.PUD_UP); thenGPIO.input(FLT) == 0means a fault.
7.4 One bridge, four states

Coast and brake differ in what happens to current already flowing in the coil. The coil's inductance insists that its current keep flowing for a moment, so it must have somewhere to go. In coast (0 0) it flows back to the supply through the MOSFETs' body diodes and dies away quickly: fast decay. In brake (1 1) it circulates round the shorted coil and the two low-side switches and dies away slowly: slow decay. The datasheet draws both paths:

For stepping, use 0 0 for "coil off". A shorted coil (1 1) acts as a generator into a short, the same effect as the shaft-turning test of §6.1, and drags on the rotor. The same four states also give PWM speed control of a DC motor, which is the datasheet's Table 2; you met the idea in Lab 4.

7.5 Current limit and protection
Each bridge can limit its own current. Its low-side switches return to ground through the xISEN pin; with a small resistor from xISEN to ground, the voltage across it measures the coil current. When that voltage reaches 200 mV, the chip stops driving and recirculates current in slow decay until the next PWM cycle (50 kHz typical):

The breakout's two resistors are marked R20, which is the surface-mount code for 0.20 Ω. Equation (6) then gives 0.2 V / 0.20 Ω = 1.0 A per coil (0.8–1.2 A across the reference's 160–240 mV tolerance). Check the marking on your own board.
Without current limiting, the coil current is set by the supply and the total resistance in the path. For a 1.5 Ω motor at VM = 5 V:
That is more than the 1.5 A rating. Do not count on the overcurrent protection to save you. It will not trip below 2 A, it typically trips near 3.3 A, the datasheet gives no upper limit, and in any case it is a last resort, not a way to set the current. The current limit of §7.5 is the right tool: with 0.20 Ω sense resistors it chops at about 1.0 A. Even then, check that 1.0 A suits your motor’s rating and your board’s cooling. A motor with a higher coil resistance may never reach the chop level at all, so estimate VM/(R + Rsense + 0.36 Ω) with your measured R before you connect it. (The 2.7 A above is the worst case, with no sense resistor and the rotor stopped; a turning motor’s back-EMF lowers the current.)
At 1.0 A the switches in one bridge dissipate about 1.0² × 0.36 = 0.36 W, and with both coils on in full step the chip dissipates about 0.7 W. That is why it gets warm while holding.
The chip protects itself in three ways: overcurrent (a short to supply, to ground or across the coil disables that bridge, pulls FLT low, and retries after 1.35 ms), thermal shutdown (above about 150 °C both bridges switch off until the die cools), and undervoltage lockout (below about 2.6 V on VM everything stops). None of these protects the motor from a current limit set too high, or the chip from a coil being unplugged mid-current.
7.6 Putting it together

Your schematic must show, and your report must list:
- Which driver pins are logic inputs from the Pi (AIN1, AIN2, BIN1, BIN2), with the GPIO numbers you chose, and which are coil outputs to the motor, with the lead colors.
- The motor supply and its voltage, within 2.7–10.8 V, and your estimate of the coil current from §7.5.
- How SLP is held high, since the bridges are off without it.
- The current limit: the sense resistor value and the chopping current it gives.
- The ground: the Pi's ground and the motor supply's ground tied together, as in Lab 4.
- The supply bypass capacitor the datasheet recommends: 10 µF from VM to GND, close to the chip (check whether your board already has it).
Breaking a coil circuit while current is flowing is exactly the inductive interruption of Lecture 04’s Equation (7), and it can damage the driver. Power down before changing any motor connection. The coils also draw current whenever they are energized, even when the motor stands still, so the driver and motor get warm in normal use. That is expected. To judge whether it is too warm, measure the current and compare it with the motor and board ratings; a fingertip is not a thermometer.
8 Reporting the Stepper Numbers
Task 3 asks your program to report runtime, number of revolutions, step period, step frequency, revolution period, rotation angle per step, and total number of steps, and then to compare those with what you actually observe. The comparison is the graded part, so make it easy on yourself:
| Quantity | Where it comes from | How to check it |
|---|---|---|
| Total steps | Counted by your program | Compare with Equation (3) for the revolutions you intended |
| Angle per step | Datasheet: 1.8° full, 0.9° half | Mark the shaft; command a known number of steps; measure with a protractor |
| Revolutions | Steps divided by S | Count turns of the shaft mark by eye |
| Runtime | time.perf_counter() around the loop | Time it with a stopwatch: a crude check, but it catches gross errors |
| Period and frequency | Equation (4), and the measured runtime divided by the number of states | Put the scope on one input pin. It does not repeat every step: in full step each input repeats once every four steps, in half step once every eight (Figure 12), so divide its period accordingly. |
S × td is a lower bound. Every loop iteration also spends time on the GPIO.output() call, index arithmetic and the scheduler (§4.3). Measured runtime will therefore come out longer than predicted, by an amount that grows in relative terms as td shrinks.
Quantifying that gap, and attributing it correctly, is a much better answer than reporting the two numbers and calling them equal.
9 How a Hobby Servo Works
9.1 Four parts in one box
An MG996R contains a DC motor, a reduction gearbox, a position sensor (a potentiometer on the output shaft) and a small control circuit. The circuit continuously compares the commanded position with the potentiometer's reading and drives the motor to null the difference. That is a complete feedback loop, sealed inside the case, and it is why the servo holds its angle against a load while a stepper simply holds its last commanded step.


9.2 The circuit inside the case
A good way to picture the servo’s electronics is an error amplifier driving an H-bridge. The MG996R actually does the job with a small digital controller, so the diagram shows how the feedback works, not the exact circuit. The incoming pulse width is converted to a target voltage. The potentiometer, connected between V+ and ground with its wiper turned by the output shaft, gives an actual voltage proportional to the shaft angle. An error amplifier subtracts one from the other, and the difference drives a small H-bridge (the same four-switch circuit as §7.4) that turns the motor in whichever direction shrinks the error.

Two consequences follow. A servo pushed off its angle by a load pushes back, because the potentiometer reports the error and the loop corrects it; that is the holding behavior you will feel in Task 4. And the servo can only reach angles the potentiometer can report, which is why its travel is a limited arc rather than continuous rotation.
9.3 Not a stepper at all
A servo has no coil table, no step count and no step angle. Inside, it is the DC motor of Lab 4, whose own brushes switch its coil; the servo adds gears, a position sensor and control electronics. Figure 1 puts the two side by side: the stepper chain is open, the servo's is closed through the potentiometer. A stepper that is overloaded loses steps and never knows; a servo that is overloaded knows exactly how far off it is and keeps pushing.
9.4 DC motor, stepper or servo?
| DC motor (Lab 4) | Stepper (Lab 5) | Servo (Lab 5) | |
|---|---|---|---|
| You control | speed, through duty cycle | position, by counting states | angle, through pulse width |
| Motion | continuous and fast | any number of turns, moderate speed | a limited arc |
| Feedback | none | none | potentiometer, built in |
| Holding | none when off | holds while energized | holds and corrects against loads |
| Drive electronics | one transistor, or an H-bridge to reverse | two H-bridges and a sequence | built in; one logic pulse |
| Typical uses | fans, wheels, pumps | 3D printers, stages, syringe pumps | robot joints, flaps, pointers |
Choose a DC motor when speed matters and position does not; a stepper when you need a known position over many turns and the load is predictable; a servo when you need a known angle within an arc and the load may push back.
9.5 The command is a pulse width, not a duty cycle
A servo reads the width of the pulse, not the fraction of the period it occupies. The frame is conventionally repeated at 50 Hz (a 20 ms period), and within each frame a pulse of roughly 1–2 ms encodes the angle, with the usable range on many servos extending somewhat wider.
Because GPIO.PWM() is commanded in duty cycle, you must convert. At a fixed 50 Hz:
This only holds at 50 Hz. Change the PWM frequency and every duty-cycle number changes meaning, because the same duty cycle now corresponds to a different pulse width. If your servo behaves strangely, check the frequency before anything else.



At 50 Hz the period is 20 ms. A duty cycle of 5% is a pulse of 0.05 × 20 ms = 1.0 ms; 10% is 2.0 ms; 7.5% is 1.5 ms, the traditional center. So the classical 1–2 ms servo range corresponds to only 5–10% duty cycle. That narrow window is why small duty-cycle errors produce visible angle errors.
Change the frequency to 100 Hz and the same 7.5% duty gives 0.075 × 10 ms = 0.75 ms. That is a different command, so the servo moves even though the duty cycle did not change.
The supplied reference sheet's 5 µs dead band is 5 µs / 20 ms = 0.025% of the frame, or a change of 0.025 percentage points in duty. Treat that as a rough guide to how small a change the servo notices, not as a guaranteed angular resolution.
The reference code used in this course sweeps a somewhat wider range to reach the MG996R's full travel. Verify on the oscilloscope what pulse widths your own duty cycles actually produce before you trust them.
The only calls you need are the ones from Lecture 03's PWM section: GPIO.PWM(pin, 50) creates a 50 Hz channel, .start(duty) starts it, .ChangeDutyCycle(duty) moves the servo, and .stop() ends the pulse train.
9.6 The MG996R pinout and datasheet


| Datasheet quantity | Value | Consequence |
|---|---|---|
| Bench supply | Regulated 5–6 V | Give the servo its own supply, within your servo’s rating |
| Running current (6 V) | 0.5–0.9 A | More than the Pi's 5 V pin should be asked for |
| Stall current (6 V) | 2.5 A | What it draws against an end stop (§10.1) |
| Stall torque | 9.4 kgf·cm (4.8 V), 11 kgf·cm (6 V) | Strong enough to pinch fingers and snap probe leads |
| Speed | 0.17 s per 60° (4.8 V), 0.14 s per 60° (6 V) | A 120° move takes about 0.3 s: wait before reading the angle |
| Dead band in the supplied reference sheet | 5 µs | Other versions may differ; measure your own |
| Rotation | about 120° (60° each way) | A claim to test in Task 5, not a limit to trust |

The reference sheet you were given and the manufacturer’s MG996R page do not agree on voltage, speed, current or dead band. The manufacturer lists 4.8–6.6 V, so do not trust the older sheet’s 7.2 V limit. A regulated 5–6 V bench supply is safe either way. Treat the table’s current and speed figures as typical values from the reference sheet, not a promise for every MG996R, and record the travel and current you actually measure.
9.7 A first servo program
A minimal program that uses the calls above. It centers the servo, moves it to one side and back, and stops:
import time
import RPi.GPIO as GPIO
SERVO = 18 # BCM pin for the orange wire (example)
GPIO.setmode(GPIO.BCM)
GPIO.setup(SERVO, GPIO.OUT)
pwm = GPIO.PWM(SERVO, 50) # 50 Hz: one frame every 20 ms
try:
pwm.start(7.5) # 7.5 % of 20 ms = 1.5 ms: center
time.sleep(1) # give the horn time to get there
pwm.ChangeDutyCycle(6.5) # 1.3 ms: somewhere to one side
time.sleep(1)
pwm.ChangeDutyCycle(7.5) # back to the center
time.sleep(1)
finally:
pwm.stop()
GPIO.cleanup()Example only. Do not copy this code as it is: read it, learn from it, then write your own.
GPIO.PWM(SERVO, 50)fixes the frame at 20 ms, so Equation (7) turns each duty cycle into a pulse width.pwm.start(7.5)begins at the traditional center, 1.5 ms. Starting at the center, rather than near an end stop, is the safe habit of §10.1.time.sleep(1)waits for the move. A 60° move takes 0.14–0.17 s by the datasheet, so a second is generous; without a wait the program moves on before the horn arrives.- 6.5 % is just "somewhere to one side". Which way it turns and how far is not known until you measure it.
pwm.stop()ends the pulse train. With no pulses the servo has no target, and many servos stop driving and go limp; do not rely on it to hold a load.
This program deliberately answers none of the lab's questions. Which duty cycle gives 30° (Task 4), how far the servo really turns, the table and fitting formula that link duty cycle to angle, and the check that rejects an impossible angle (Task 5) all come from your own measurements (§10, §11).
10 Calibrating the Servo
Task 4 asks for 30° verified with a protractor; Task 5 asks for the full range, a duty-versus-angle table, a fitting formula, and an assessment of its accuracy. The fit is yours to derive, but here is how to gather data worth fitting.
10.1 Approach the limits carefully
Commanding a pulse width outside the servo's mechanical range drives it against its internal end stop, where it stalls, draws heavy current (2.5 A at 6 V, by the datasheet), buzzes audibly and strips its gears if held there. Never simply command the extremes to “see what happens.”
Instead, approach each end in small increments and stop as soon as the horn stops moving or the servo begins to buzz. The buzzing is the warning: back off immediately. Record the last duty cycle that produced clean motion; that is your usable limit, and it is the number to quote.
Lab 5 also warns not to force the horn by hand. To change its orientation, remove it and reinstall it. Forcing it drives the gear train backwards and can destroy it.
10.2 Taking the data
- Mount the servo so it cannot move, and fix a protractor with the horn's pivot over its center. A servo that shifts between readings ruins the dataset in a way that is invisible afterwards.
- Step the duty cycle in small, even increments across the usable range, allowing time at each setting for the horn to settle before reading the angle.
- Record commanded duty cycle, measured pulse width from the scope, and measured angle. Including the measured pulse width is what lets you separate a software error from a servo characteristic.
- Sweep in both directions. A difference between increasing and decreasing sweeps is hysteresis. Gear backlash, friction, controller dead band and reading error can all contribute; the sweep alone cannot separate them.
10.3 Fitting and judging the fit
The relationship is designed to be linear, so a straight line in angle against duty cycle is the natural model. Report the slope in degrees per percent duty (or per millisecond, which is the more portable unit) and the intercept, both with units.

Then judge it honestly, which is what Task 5 means by evaluating accuracy:
- Plot the residuals, not just the line through the points. Systematic curvature means the servo is not quite linear; scatter means your protractor reading, or the servo's repeatability, is the limit.
- Compare the measured angular range with the datasheet's roughly 120°, as Task 5 asks, and comment on any difference.
- State the smallest angle change you could reliably command and observe. That is the practical resolution. This is usually set by the duty-cycle granularity of your software or the servo's dead band, not by the fit.
- Estimate repeatability by returning to the same setting several times, and compare the spread with how precisely you can read the protractor. Small residuals on their own do not prove the servo is accurate.
(a) At 50 Hz, what pulse width does a 6.5% duty cycle produce? What duty cycle gives a 1.75 ms pulse?
(b) A servo moves 180° as the pulse goes from 0.6 ms to 2.4 ms. How many degrees per millisecond? Per percent duty cycle at 50 Hz?
(c) Your software sets duty cycle only in steps of 0.1%. Using (b), what angular resolution does that impose? Is that step larger or smaller than the MG996R's 5 µs dead band?
(d) A student runs their servo code at 100 Hz instead of 50 Hz and the servo jitters and will not hold position. Explain why, in terms of Equation (7).
11 Validating the Input
The last part of Task 5 asks for a program that accepts an angle and rejects values outside the permitted range. This is a small piece of software engineering, and it is graded, so treat it as a design problem rather than an afterthought.
Three distinct categories, and all three deserve a sensible response:
- Out of range. A number outside your measured limits from §10.1. Reject it, say what the valid range is, and do not move the servo.
- Input that is not a usable number. Empty input or ordinary text makes the conversion to a number fail, so catch that. Watch for
nanandinftoo: Python happily turns them into numbers, but they are not angles, so reject them explicitly. - Valid. Convert the angle to a duty cycle with your own fitted formula from §10.3 (this is where the calibration work pays off), and command it.
The range you enforce should be the range you measured, not a textbook 0–180°. Enforcing limits your own servo cannot reach is how the gears get stripped, and quoting your measured limits shows the calibration actually informed the design.
One further habit worth adopting: stop sending pulses, or release the pin, when the program ends. A servo left with a live pulse train continues to hold torque, drawing current and getting warm on a bench nobody is watching.
12 Common Mistakes and Bench Safety
12.1 Things that destroy hardware
- Unplugging a stepper with the driver powered. Inductive interruption; kills driver chips.
- Exceeding 10.8 V on VM. The DRV8833's absolute maximum is 11.8 V; a 12 V supply is too much.
- Forcing the servo horn by hand. Drives the gear train backwards. Remove and reinstall instead.
- Holding a servo against its end stop. Stalled current, stripped gears. Back off at the first buzz.
- Powering motors from the Pi. Both motors need their own supply, exactly as in Lab 4.
- Missing common ground between the Pi, the driver and the motor supply.
- Coil current higher than the motor's rating. The motor and driver run hot. Compute it from §7.5 before you power up.
12.2 Things that waste your afternoon
- Mis-paired coil wires: the motor buzzes, vibrates, or turns erratically instead of stepping. Do the DMM test in §6.1 first.
- Coil B's leads in the wrong order on the header: the lab motor's order is B2 then B1 (green, gray).
- Stepping too fast, so steps are silently missed (§4.4). Increase the delay before suspecting anything else.
- SLP left low or floating. Quiet, complete, and easy to overlook.
- A table row typed wrong: sketch the field arrow for each row (Figures 10 and 11); consecutive rows must advance by a constant angle in one direction.
- Running the servo at a PWM frequency other than 50 Hz, which silently changes what every duty cycle means.
- A servo or protractor that shifts between readings, quietly corrupting the whole calibration table.
12.3 Mechanical safety
Secure both motors to the bench. A stepper with anything attached to its shaft has real torque and will drag loose wiring around; a servo horn sweeps through its arc quickly enough to pinch fingers and catch probe leads. Keep hands clear while either is energized, and power down before adjusting anything mechanical.
13 Self-Check
- Explain why counting steps tells you the angle, and state the one assumption that makes it true.
- Explain how a 7.2° rotor tooth pitch and 45° stator pole spacing give a 1.8° alignment offset, and why eight poles need only four wires.
- Give the DMM procedure for identifying which stepper wires belong to the same coil, and the expected readings for the lab motor.
- What is the physical difference between a full step and a half step, in terms of the field direction?
- Write the DRV8833 inputs for B− alone, and for A+ with B−.
- How do you obtain counter-clockwise rotation from a table written for clockwise?
- A motor has a 1.8° full step. How many half steps in two complete revolutions?
- What step delay gives 45 RPM in full-step mode on that motor? What does loop overhead do to the speed you actually get?
- What do coast and brake do to the current already in a coil? Which do you use for "coil off" when stepping, and why?
- The breakout's sense resistors are 0.20 Ω. What chopping current does that set?
- What happens, mechanically and in software, when a stepper misses steps? Why is this the characteristic weakness of open-loop control?
- At 50 Hz, what duty cycle produces a 1.5 ms pulse? What happens to that pulse width if the frequency is changed to 100 Hz at the same duty cycle?
- Name the three input categories a robust servo angle routine must handle, and the correct response to each.
A stepper gives you position by construction: energize the coils in the right order and count. But it fails silently when pushed past its torque. The DRV8833 turns four logic lines into two reversible coil currents and limits them for you. A servo gives you position by feedback: send a pulse width and it corrects itself, but only inside a range you must measure, not assume. Both need their own power supply, a shared ground, and a calibration you performed rather than inherited.
14 Practical Engineering Connections
- Steppers in machines. 3D printers, CNC mills, laser cutters and plotters position their axes by counting steps, which is why a printer that misses steps produces a layer-shifted part: the machine never knew.
- Steppers in instruments. Telescope drives, syringe pumps, filter wheels, monochromators and optical stages all rely on repeatable open-loop positioning.
- Microstepping. Driving the coils with graded currents rather than full on/off subdivides each step further, smoothing motion and reducing resonance. It is the direct extension of §3.2’s vector argument. Dedicated step/direction drivers do it with the same current-chopping idea as §7.5.
- H-bridges. The same four-switch topology reverses DC motors, drives audio in class-D amplifiers, and forms the output stage of inverters.
- Hobby servos. Robot arms, camera gimbals, radio-controlled vehicles and animatronics use exactly the pulse-width protocol you calibrated here.
- Industrial servos. The same closed-loop principle scaled up, with encoders instead of potentiometers and a tuned controller, moves robot arms and machine-tool axes.
- Open versus closed loop. The central trade-off of control engineering: open loop is cheap and precise until something unexpected happens; closed loop costs a sensor and buys the ability to notice and correct.
- Calibration as method. Measuring your own duty-to-angle relation rather than trusting a datasheet is what instrument scientists do with every new device, and it is the habit this course is really trying to build.