EP 02 · THE SWITCH
This is a switch.
Your phone has about 20,000,000,000 of them.
Each one can flip billions of times a second.
None of them move.
So how do you build a switch… out of sand?
ACT 1
What is electricity?
A copper wire is already full of free electrons: tiny negative particles that can drift between the atoms. Connecting a battery doesn't send electrons racing from one end to the other. Each one just shoves its neighbour. Close the switch and watch.
A long copper wire, already packed with free electrons. One of them is marked.
Inside a battery, chemical reactions release electrons at its − end and use them up at its + end. (No electrons cross the battery itself: charged atoms, called ions, carry the charge through the paste inside.) So the − end has extra electrons and the + end is missing some. Charges push and pull on each other (like charges repel, opposite charges attract), so this imbalance creates an electric field: an invisible push that reaches into the wire and shoves every free electron along it, from the crowded − end toward the + end.
Left alone, the electrons would even out the imbalance, and the wire gives them a way to do exactly that. The chemistry keeps topping the imbalance back up, which is where the energy comes from. When the chemicals run out, it can't any more: the battery is flat.
Voltage is how much energy that push gives each bit of charge on its way around: 1 volt = 1 joule of energy per coulomb (a coulomb is about 6.24 billion billion electrons). In the bulb, the electrons crash into atoms and hand that energy over as heat and light.
- In the long wire, close the switch and watch the push race ahead of the marked electron.
- In the loop, turn the battery up. Watch the charge pile up at its ends, the push along the wire, and the bulb.
- Open the switch. What happens to the electrons on the far side?
- Swap the bottom piece for glass, then silicon.
The current meter counts how much charge flows past each second.
The push is fast, the electrons are slow. Each electron drifts slower than a snail, around a tenth of a millimetre per second. But the push spreads along the wire at a large fraction of the speed of light, trillions of times faster, so the bulb lights the moment you close the switch. Open the switch anywhere and the push is gone everywhere: every electron in the loop stops.
Copper has a sea of free electrons: a great conductor. Glass has none: every electron is locked to its atom, so it's an insulator. Silicon is in between: almost all its electrons are locked up, so barely anything flows. Remember that. It's the key to everything that follows.
In every circuit in this lesson, the moving cyan dots are electrons, drifting from − to +. (Engineers' diagrams often draw "current" the opposite way, from + to −. That convention was picked before anyone knew electrons existed.)
ACT 2
A switch can decide
ClickTap links to lay wire. Tap a placed switch to flip it on and off.
ACT 3
The relay
Wrap a wire around iron and send a current through it, and the iron becomes a magnet. Put a springy metal lever next to it, and the magnet can pull the lever shut. That's a relay: a switch flipped by electricity. Flip the switch in the left circuit.
The left circuit powers the magnet. The right circuit is switched by it.
Each relay's switch powers the next relay's magnet. One flip sets off the whole row.
ACT 4
The vacuum tube
Heat a metal wire until it glows, and electrons boil off it. Inside a glass tube with the air pumped out, they fly freely to a metal plate, and a current flows through empty space. The plate is strongly positive, so it pulls them hard. Between filament and plate sits a fine wire mesh: the grid. Switch the grid between negative and 0 V and watch.
Why doesn't the grid need to be hugely negative to fight a +100 V plate? It sits much closer to the filament, so its push dominates there. In a typical small tube, 1 volt on the grid counts as much as 20 to 100 volts on the plate, so a few volts negative shuts it off. That's also why tubes could amplify: a small signal on the grid controls a big current.
A computer flips switches in long chains, each one waiting for the one before. Race all three.
A vacuum tube is 10,000× faster than a relay. A modern transistor is another 100,000× faster than the tube: a billion times faster than the relay.
Surprise: the first transistor (Bell Labs, 1947) wasn't faster than a good vacuum tube. It won for other reasons:
- No heater. A tube's filament burns power just to stay hot, even when it isn't switching. A transistor sits cold until it's used.
- It doesn't wear out. Filaments burn out like light bulbs, and ENIAC lost a tube every couple of days. A transistor has nothing to burn.
- Tiny and tough. No glass and no vacuum: just a speck of solid crystal that you can drop.
- Instant on. No warming up.
- It can be printed by the billion. From 1958 to 1960 (Jack Kilby, then Robert Noyce), several parts, and soon many transistors, were made together on one chip: the integrated circuit. And every time they were made smaller, they also got faster, cheaper and less power-hungry. That's where the picoseconds came from.
ACT 5
Sand that conducts… sometimes
Zoom into silicon. A silicon atom has 14 electrons, but 10 sit in inner shells, held tight to the nucleus. Only its 4 outer electrons matter here, and each atom shares them with its 4 neighbours: those shared pairs are the bonds. Every electron is locked in a bond, so nothing is free to move, and silicon barely conducts. Unless you swap in a few different atoms.
no voltage
current = free charges × how hard the voltage pushes them
- Press APPLY VOLTAGE on the pure crystal. Does anything flow?
- Pick PHOSPHORUS and clicktap one silicon atom to swap it.
- Swap in more until the current passes the gold line.
Phosphorus has 5 outer electrons: 4 fit into bonds, and 1 is left over, free to roam. The voltage pushes the free ones along: a current. Silicon with phosphorus in it is called n-type (n for the negative electrons).
Boron has only 3, so one bond is missing an electron: a hole. A neighbouring electron can hop into it, which moves the hole the other way, like a bubble in water. Holes carry current too, as if they were positive charges. That's p-type.
One subtle thing: doped silicon is still electrically neutral. Think of each atom as a core (the nucleus plus its tightly held inner electrons) with outer electrons around it. The core's leftover charge always matches its number of outer electrons: +4 for silicon, +5 for phosphorus, +3 for boron. So phosphorus brings one extra outer electron and one extra unit of + charge in its core, and boron one fewer of each. Remember that for the next act.
Real chips swap only about one atom in a few thousand to one in tens of millions, yet the conductivity can rise by a factor of millions. This is called doping.
ACT 6
Build a transistor
Chip factories build transistors layer by layer. Follow the steps.
Turn the gate battery up slowly. Watch the space under the gate.
Some do. Right at each border, electrons wander across and fill holes. But each electron that leaves the n-type leaves its phosphorus atom behind with that extra + charge in its core and nothing to balance it: a fixed + charge. Each hole it fills gives a boron atom one electron more than its core can balance: a fixed − charge.
Those fixed charges can't move. Together they make an electric field across the border that pushes further electrons back. Almost instantly it balances, leaving a thin barrier with no free charges at all: the depletion zone. For silicon its push is worth a little under a volt. In the drawing it's the thin band around each island, with its fixed + and − charges.
The source and drain are n-type islands, full of free electrons. Between them is p-type silicon, fenced off by two barriers, so normally nothing gets across: off.
A positive voltage on the gate pulls electrons up against the glass (opposite charges attract) and pushes the holes away. Past the threshold, enough electrons gather to form a thin channel, a bridge of free electrons from source to drain: on. Take the voltage away and the bridge dissolves.
Why do the electrons go from source to drain? The battery decides. The source is wired to its − end, and the drain, through the bulb, to its + end. Electrons always drift toward +. "Source" just means where the electrons come from, and "drain" where they drain away. The transistor itself is symmetric: flip the battery and the two islands swap names.
Why are both islands n-type? So that once the channel forms, there's one unbroken road of free electrons: island, channel, island. Without a channel, the p-type in between puts two barriers back to back, so nothing gets through in either direction.
What is the gate, really? Just a piece of conductor sitting on the glass. Because the glass blocks current, the gate draws almost no current: it only needs a voltage on it, like pressing on one side of a wall to move what's on the other side.
Where does that voltage come from? Here, an adjustable battery. In a real chip, nobody turns a knob: each gate is connected by an ordinary wire to the output of another transistor. Switches flipping switches.
No moving parts: only the electrons move. Nearly every one of the billions of switches in your devices is one of these.
Flip every layer of the transistor you just built: an n-type body with p-type islands. Now the free charges in the islands are holes, and the gate has to pull holes up into a channel. Holes are pulled by a negative gate, so this one switches on when its gate is low.
"Low" compared to its source. In a chip, an n-type's source is wired to ground (0 V) and a p-type's source to the supply (+1 V). So a gate at 0 V is 1 V below the p-type's source, and turns it on. A gate at 1 V turns on the n-type instead.
A SWITCH THAT SAYS NOA relay makes a NOT easily: let the magnet pull a contact open. But a transistor only turns on when you push its gate. So how do you get an output that is 0 when the input is 1? The trick isn't a different switch. It's where you put it.
Inside a chip, an output is a wire's voltage: near the supply means 1, near ground means 0. So a switch can make a 0 by closing, as long as closing connects the output to ground.
ACT 7
How small is small?
Drag the slider to zoom from a relay down to a single atom.
A modern transistor is about 50 nm across, and its thinnest parts are only a few nanometres: a few dozen atoms.
Log scale. Roughly doubling every two years for half a century: Moore's law.
ACT 8
Switches flipping switches
In a chip, each transistor's output is wired to the gate of the next. Turn one on, and it turns on the next, and the next. It's the relay chain from Act 3, but with no clicks and no moving parts. Flip the first gate.
Where do all those batteries come from? They don't exist. The diagrams in this lesson each drew their own battery so you could see what drives that one circuit. A real chip has one power source, and two wires run everywhere: the supply rail, held at about 1 volt, and ground, at 0 V. Every one of its billions of transistors connects between those same two wires.
The power comes from one battery (a phone's, converted down from about 3.7 V) or a power supply plugged into the wall, and the wall is pushed by a power plant, solar panel or wind turbine. The transistors don't store any of it: each switch uses a tiny bit and turns it into heat. Billions of switches, billions of times a second, add up, which is why chips need fans and why a busy phone gets warm.
Wire them in clever patterns, a few at a time, and these chains start to decide things, like the AND and OR circuits you built in Act 2. Those patterns are called logic gates.
- Pushed electrons around a loop, and found out why glass and silicon resist.
- Built AND and OR circuits from two switches.
- Flipped a relay and a vacuum tube, the switches of the first computers.
- Doped silicon into n-type and p-type.
- Built a transistor from a bare wafer, and found its threshold.
- Set off a chain of transistors, each one switching the next.