Lesson 2. The idle meter
The bottleneck is the machine that never stands: there is always a queue in front of it. All the others wait from time to time. So to find the bottleneck, we must measure how long each machine stands idle. In this lesson we build such an instrument: button S moves a «probe» from machine to machine, and display I shows how many seconds the chosen machine stood without work.
The circuit is big, so we take it step by step: who is chosen → is it busy → count the seconds.
2.1. Step 1: who is chosen — the CD4017
We need five signals «machine 1 chosen», …, «machine 5 chosen», of which exactly one is lit at any moment. The CD4017 does this: it has ten outputs O0…O9, and every rising edge of CLOCK moves the «one» to the next output.
CLOCK= button S (SEL): press — the probe moves to the next machine;O0…O4— labelsP1…P5; they also light the probe lamps above the machines;- we need only five positions, so
O5(P6) resets the counter at once: as soon as the one reaches O5, theRESETleg sends it back to O0. The probe goes round 1 → 2 → 3 → 4 → 5 → 1; - button R must also send the probe back to machine 1:
SRST = P6 OR R— the first OR gate of a CD4071.
2.2. Step 2: is the chosen one busy — a multiplexer of AND and OR
Each machine has a BUSY leg: B1…B5. We need one signal — the BUSY of the machine under the probe. This is called a multiplexer: of five inputs, the chosen one passes to the output.
We build it from gates:
A1 = P1 AND B1, …,A5 = P5 AND B5— five AND gates (CD4081: four in the first chip, the fifth in the second). Only the chosen machine hasPk = 1, so only itsAkcan be 1 — and it equals its BUSY;SB = A1 OR A2 OR A3 OR A4 OR A5— a CD4072, two 4-input OR gates: the first gathers A1…A4 intoT4, the second —T4andA5.
SB = 1 — the chosen machine works, SB = 0 — it stands.
2.3. Step 3: counting idle seconds — a CD4029 with enable
The display is again two CD4029, as in FL-01. They are clocked by CKR — the 1 Hz clock while START is on (it already exists in FL-01: CKR = CK AND RUN). But we must count not every second, only while the machine stands. For that the CD4029 has an enable leg CI: counting happens only if CI = 0. We feed SB to it:
- the machine works (
SB = 1) — theCKRedge is skipped, the number stays; - the machine stands (
SB = 0) — theCKRedge adds a second.
So the display counts exactly on the clock edges, without extra pulses at the moments a machine frees up in the middle of a second.
2.4. Step 4: clearing the meter
Display I must be cleared in two cases: on R (a new shift) and when the probe moves to another machine — otherwise the seconds of one machine add to the seconds of another. So the counters' load input PE is MRST = R OR S, the second OR gate of the same CD4071.
2.5. Assembly
- Import the kit's chips: the file
flow-chips.json. It holds everything from FL-01 plus CD4017, CD4071, CD4072, CD4013, CD4019. If the editor asks about identical chips — they are the same, you can keep yours. - Insert the lesson with
Cmd+Ion top of FL-01 with Herbie (the text is at the end of the lesson). You get:- on the base — button S, five probe lamps above the machines, display I «idle, s»;
- outside — a CD4017, a CD4071, two CD4081, a CD4072 and two CD4029.
2.6. Check
- Power off and on → R → START. The probe above machine 1 lights, display I grows.
- Press S — the probe moves to the next machine, display I starts from 0.
- Stay on each machine for about 20 seconds.
| Probe on machine | Display I after 20 seconds |
|---|---|
| 1, 2 | about 10: they stand until Herbie takes a part |
| 3 — Herbie | 0: works without a break |
| 4, 5 | about 10: waiting for a part from Herbie |
The bottleneck is the machine with zero idle time. The instrument found it, not the eye.
Lesson 2 insert (Cmd+I)
# Lesson 2 — the idle meter. Insert on top of the finished FL-01 «The Dice Game» (needs the chip file flow-chips.json).# Button S steps the probe from machine to machine (CD4017: one lit output O0…O4; O5 jumps back to O0; R also resets).# The probe lamps P1…P5 show which machine is measured. SB = the probed machine is busy: Pk · Bk for each machine, then OR.# The meter counts seconds while the probed machine stands: clock CKR (= CK · RUN of FL-01), enable CI = SB (counts at SB = 0).# MRST = R OR S: pressing S also clears the meter — it starts from 0 on the newly probed machine.button sel{label="S"}(SEL)at(sel, B, 760, 290)led p1(P1)at(p1, B, 150, 60)led p2(P2)at(p2, B, 270, 60)led p3(P3)at(p3, B, 390, 60)led p4(P4)at(p4, B, 510, 60)led p5(P5)at(p5, B, 630, 60)display shI{busSource=I}at(shI, B, 620, 290)"TI CD4071B"(A=P6, B=RST, J=SRST, C=SEL, D=RST, K=MRST, E=GND, F=GND, G=GND, H=GND)"TI CD4017B"(CLOCK=SEL, INH=GND, RESET=SRST, O0=P1, O1=P2, O2=P3, O3=P4, O4=P5, O5=P6)"TI CD4081B"(A=P1, B=B1, J=A1, C=P2, D=B2, K=A2, E=P3, F=B3, L=A3, G=P4, H=B4, M=A4)"TI CD4081B"(A=P5, B=B5, J=A5, C=GND, D=GND, E=GND, F=GND, G=GND, H=GND)"TI CD4072B"(A=A1, B=A2, C=A3, D=A4, J=T4, E=T4, F=A5, G=GND, H=GND, K=SB)"TI CD4029B"(CLOCK=CKR, UD=VCC, BD=VCC, PE=MRST, CI=SB, J1=GND, J2=GND, J3=GND, J4=GND, Q1=I0, Q2=I1, Q3=I2, Q4=I3, CO=COI)"TI CD4029B"(CLOCK=CKR, UD=VCC, BD=VCC, PE=MRST, CI=COI, J1=GND, J2=GND, J3=GND, J4=GND, Q1=I4, Q2=I5, Q3=I6, Q4=I7)¿No te sale? Algo no funciona →