13.2 Working at the bench
A circuit that is wired up in one go and switched on to see what happens usually does nothing, and then nobody knows why.
There may be one fault or five, in the wiring, the parts, the supply or the code, and every one of them hides the others. Instead we build the circuit in small steps, predict what each step should do, measure that it does it, and write the result down. When something fails, only the last small step can be to blame, and we can always go back to the previous state that worked.
The first chapters embed videos from Ben Eater’s playlist Digital electronics, which builds the same circuits on camera with a lab supply, a breadboard and a multimeter. Watch each video first, then do the experiment with our parts.
The breadboard
A breadboard holds parts and wires without soldering. Under each column of five holes lies a metal spring clip, so the five holes are connected to each other and to nothing else (Figure 13.2.1). Two parts are connected when one leg of each is in the same group of five.
Along the edges run the power rails, long strips marked + (red) and − (blue) where the supply and ground are distributed.
The long boards that carry the ESP32 later in this part have each rail cut in the middle. The red and blue lines along the rail break at the cut, and the left and right halves are separate rails until a short jumper joins them (Figure 13.2.2). Put four jumpers across the cut, one per rail, before the first circuit goes on a long board. On a board with no break in its lines, the continuity test of the meter shows whether the rail is cut all the same.
Three mistakes account for most breadboard faults. A part with both legs in the same group of five is short-circuited and does nothing. A leg that went into the hole next to the intended one is connected to the wrong node (Figure 13.2.3). A leg that is too short, or a stranded wire that is not twisted, is loose and makes contact only sometimes. Push every leg in until it stops, and look at the board from straight above before switching on.
The bench power supply
Every new circuit in this book is powered first from an adjustable bench power supply with a current limit, never straight from a battery. It has two knobs that a battery lacks. The voltage knob lets one supply stand in for every source the circuit will meet (Table 13.2.1), without waiting for a battery to run down. The current knob sets the highest current the supply will deliver, so a wiring mistake shows up as a lamp on the front panel and not as smoke.
| Source | Voltage |
|---|---|
| USB charger | 5 V |
| 9 V battery | 9 V |
| Car battery, nearly empty | 11.8 V |
| Car battery, full | 12.6 V |
If you buy a supply for your own bench, buy one with both knobs; a fixed-voltage adapter or a supply without a current limit gives up these two advantages.
Set to 5.00 V and 30 mA, the two knobs make the supply a promise: at most 5.00 V and at most 30 mA. We draw this promise with the current \(I\) along the horizontal axis and the voltage \(U\) up the vertical one (Figure 13.2.4). The supply can only be at a point on the two thick lines. On the blue line the voltage is 5.00 V and the current anything up to 30 mA; on the red line the current is 30 mA and the voltage anything up to 5.00 V.
Where on these lines the circuit sits is decided by the load. A resistor obeys Ohm’s law, \(U = RI\): the voltage across it is its resistance times the current through it. In the same plot this is a straight line through the origin, steep for a large \(R\) and flat for a small one. The circuit sits where this line crosses the supply’s lines, the one point where the supply and the resistor agree on both \(U\) and \(I\). A 1 kΩ resistor at 5.00 V draws 5.0 mA, well under the limit, so the supply holds 5.00 V and the C.V. (constant voltage) lamp is lit.
A 100 Ω resistor at 5.00 V would draw 50 mA, more than the promise allows. The supply then lowers its voltage until the current is 30 mA, which for 100 Ω happens at \(U = 100\ \Omega \cdot 30\ \text{mA} = 3.00\) V, and the C.C. (constant current) lamp lights instead. The change happens at the corner, where \(R = 5.00\ \text{V} / 30\ \text{mA} = 167\ \Omega\), and every smaller resistance lands on the red line. Even a short circuit, \(R = 0\), only moves the circuit to the bottom of that line, 30 mA at 0 V, which harms neither the supply nor the wire. The C.C. lamp is a warning: either the limit is too low for this circuit, or the circuit has a fault such as a short circuit.
The lab has two supplies. Set each one up the same way every time.
The VOLTAGE knobs (COARSE for large steps, FINE for the last tenths) set the voltage the supply tries to hold at its output. The CURRENT knob sets the current limit. The yellow terminal is connected to the mains earth; we leave it unused and take our ground from the black − terminal.
- Press OUTPUT so that the output is off, and disconnect the circuit. Turn the CURRENT knob to minimum.
- Switch on with POWER and set the voltage with COARSE and FINE while reading the green display. Set it to zero if we will raise it slowly.
- Set the current limit. Connect the red and black leads to each other with a short wire, switch the output on, and turn CURRENT until the red display shows the limit we want; the C.C. lamp is lit, since the short asks for more. Switch the output off and remove the wire.
- Connect the circuit, red lead to +, black lead to −, and switch the output on.
- Look at the lamps and the displays. C.V. and the expected current: carry on. C.C.: switch the output off and find out why.
The PS 613 has one VOLTAGE knob, one CURRENT knob, and neither an OUTPUT button nor a C.V. lamp. Its CURRENT LIMITED lamp does the job of the C.C. lamp: dark while the supply holds the voltage, lit when the circuit asks for more than the limit. The fixed 12 V and 5 V outputs beside the adjustable one have no current knob, so we leave them alone until a circuit works.
- Disconnect the circuit and turn the CURRENT knob to minimum. The supply delivers current as soon as POWER is on, so the circuit stays disconnected until step 4.
- Switch on with POWER and set the voltage with VOLTAGE while reading the left display.
- Set the current limit. Connect the + and − sockets to each other with a short wire and turn CURRENT until the right display shows the limit we want; the CURRENT LIMITED lamp is lit, since the short asks for more. Remove the wire.
- Connect the circuit, red lead to +, black lead to −. Connecting it switches it on.
- Look at the lamp and the displays. CURRENT LIMITED dark and the expected current: carry on. CURRENT LIMITED lit: disconnect the circuit and find out why.
Some supplies show the current limit only while a button marked LIMIT or I-SET is held, and need no short circuit in step 3.
Both supplies show the current with a resolution of 0.01 A, so the 14 mA of an LED circuit appears as 0.01 and a few milliamperes as 0.00. Ben meets the same limit in his second video (“this isn’t the greatest ammeter”). The display is good enough to tell 10 mA from 100 mA and to catch a short circuit; when we need the milliamperes, we measure them with the multimeter, either in series (Measuring DC current) or as the voltage across a known resistor (the voltage budget).
A sensible current limit is a little above the current we predicted, e.g. 30 mA for an LED circuit that should draw 15 mA. If anything is wrong, the supply holds the current at the limit before a part is damaged. Batteries and USB chargers have no such knob, so a circuit moves to them only after it works on the bench supply.
The multimeter
The supply shows roughly what the circuit draws in total. The multimeter measures at each part of it: the voltage between two points, the current in a wire, the resistance of a part. The lab’s meter is the UNI-T UT131D of Figure 13.2.7.
COM, the red lead in VmAµA, and the dial is on the 20 range of DC volts (V⎓). Clockwise from OFF at the top come DC volts, AC volts (V~), the non-contact voltage tester (NCV), DC current (A⎓), the diode and continuity test, and resistance (Ω).
The black lead always goes in COM, and the red lead in VmAµA for nearly everything: voltage, resistance, the diode and continuity tests, and currents up to 200 mA. The 10A MAX jack is only for larger currents, such as a motor, and for at most 10 s at a time.
The dial picks the quantity and the range. Each number on the dial is the largest value that position can show: at 20 on V⎓ the meter reads up to 19.99 V. We choose the smallest range above the value we expect, 20 for a 9 V battery and 2000m for the 1.9 V of an LED. When we cannot predict the value, we start at the highest range and step down; above the range the display shows an overload sign.
Because one jack serves both volts and milliamperes, the dial alone decides what the meter is. On A⎓ it is close to a short circuit, and touching its probes across a battery blows its fuse. After every current measurement, turn the dial back to V⎓ or OFF. How to make each measurement, and why these rules hold, is in The multimeter.
The loop
Every step at the bench runs through the same five moves (Figure 13.2.8).
- Predict. Before switching on, write down what should happen: the LED lights, the current is about 14 mA, the voltage at this point is about 1.9 V. A prediction can be rough. Without one, we cannot tell a working circuit from a broken one.
- Change one thing. Add one part, move one wire, change one value in the code. Never two at a time.
- Measure. Use the multimeter, not the eye. An LED that “looks fine” may be carrying three times its rated current.
- Compare. Does the measurement agree with the prediction? A difference of a few percent is normal; parts have tolerances. A factor of two, or a sign the wrong way, means that the prediction or the circuit is wrong, and we find out which before going on.
- Record. Write the values in the lab log, and when a step is complete, mark it as a checkpoint.
The log is a notebook, paper or a file, with one entry per step. A table is enough:
| Step | Change | Predicted | Measured | OK? |
|---|---|---|---|---|
| 1 | LED on supply at 1.80 V | dim, a few mA | 2 mA, dim | yes |
| 2 | supply to 1.90 V | brighter, about 15 mA | 16 mA | yes |
| 3 | 220 Ω added, supply 5.00 V | 14 mA | 13.6 mA | yes, checkpoint |
Each entry takes a minute. It pays off the first time a circuit that worked yesterday does not work today, because it tells us exactly what worked means. The loop feels slow the first time, but no method we know reaches a working circuit sooner, because almost no time goes into hunting for faults.
Checkpoints and rolling back
A checkpoint is a state of the circuit that we have measured and know to work. Each chapter in this part marks its checkpoints in a box like this one, here step 3 of Table 13.2.2:
At a checkpoint we record what we need to rebuild that state: a photo of the breadboard from straight above (Figure 13.2.9), the measured values, and for code the Git commit (or a copy of the project folder).
When a later step fails and we cannot see why within a few minutes, we go back. We undo the last change, or rebuild from the photo, and check that the checkpoint values return. The fault is then in the last change, and that change is small; we take it again, smaller.
When it does not work
Faults are found by measuring, not by staring at the wiring.
Four techniques cover nearly every fault in this book. We try them in this order, since each takes longer than the one before.
- Roll back to the last checkpoint, as above.
- Walk with the voltmeter from the supply towards ground, as in the voltmeter walk.
- Compare with a known-good copy. Build a second, identical circuit that works, or keep the one from the last checkpoint, and measure the same point in both, as in A signal is not a power supply.
- Swap one part. If the circuits differ, exchange one part (the LED, the resistor, a jumper wire) between the good and the bad circuit. If the fault moves with the part, the part is faulty. If it stays, the part is fine.
The datasheet
Every part we use has a datasheet, a document from its manufacturer that states what the part does and what it tolerates. Search for the part number (printed on the part, the bag or the shop page) followed by the word datasheet, and prefer the PDF from the manufacturer’s own website. How to read one is shown on the LED in Read the datasheet. A development board such as the ESP32 comes with a pinout as well, which we keep open whenever we wire to the board.
Before switching on
Read this list before every new circuit is powered for the first time.
- The supply is set (voltage and current limit) before it is connected.
- Every LED has a resistor in series, or the supply’s current limit is at or below the LED’s rated current. Its long leg points towards +.
- No part has both legs in the same group of five holes.
- Red goes to +, black to −, and every ground is connected to every other ground.
- The meter’s dial is on V⎓ or OFF, not on a current range, unless we are about to measure current.
- We know what the circuit should do, and we have written the prediction down.
Further reading
Ben Eater’s series on building an 8-bit computer on breadboards shows the step-by-step method at a scale of hundreds of wires.