Comparators & Mixed-Signal Building Blocks

a relay

A relay is an electrically operated switch — a small electromagnet that physically pulls a set of metal contacts together or apart. A tiny current through the coil makes a magnet; the magnet yanks a lever; the lever closes (or opens) heavy contacts that can carry a completely separate, much larger current. It is the original way to let a weak signal control a powerful circuit, and because the control coil and the switched contacts are mechanically separate pieces of metal, the relay also isolates the two sides from each other.

Energise the coil — often 5 V or 12 V at a few tens of milliamps — and the magnetic field pulls an armature that snaps the contacts over. The contacts themselves are just springy metal that can switch mains voltage and several amps, far more than the coil circuit ever sees. Relays are described by their contact arrangement: normally-open (open until energised), normally-closed (closed until energised), or changeover (a common terminal that flips between two). Because the coil is an inductor, switching it off collapses its magnetic field into a high-voltage spike, so a flyback diode across the coil is essential when a transistor drives it. A relay needs a transistor driver because a logic pin cannot supply the coil current.

Relays still rule where you need genuine galvanic isolation, very low contact resistance, the ability to switch AC or DC of either polarity, or simple high-current switching — appliances, automotive, industrial control. The honest tradeoffs versus a transistor or solid-state switch: relays are slow (milliseconds, not microseconds), they wear out (contacts arc and erode over hundreds of thousands of operations), they click audibly, and they can bounce on closing just like a mechanical switch. A solid-state relay (an optocoupler driving a triac or MOSFET) trades the moving parts for silent, fast, bounce-free switching, at the cost of a small on-state voltage drop and some leakage.

A 12 V relay coil drawing 40 mA, switched by an NPN transistor with a flyback diode, lets a 3.3 V microcontroller turn a 230 V, 5 A water pump on and off. The pump's mains circuit never touches the controller — the contacts are a separate piece of metal.

An electromagnet closes heavy contacts; the two sides stay isolated.

Always put a flyback diode across a relay coil driven by a transistor — the coil's collapse spikes hundreds of volts. And remember relay contacts bounce and wear, so they are not ideal for fast or high-cycle switching.

Also called
electromechanical relayEMR電驛