class: center, middle, inverse, title-slide .title[ # The 4017 — Turning Ticks into Steps ] .subtitle[ ## Programmable Electronics — Unit 2 ] .date[ ### Class 18 ] --- # Learning Targets .lt-box[ - Explain what a decade counter does — one clock edge advances a single HIGH across its outputs in turn. - Explain why that requires the chip to remember something, and why you therefore cannot write a truth table for it. - Drive a 4017 from a 555 clock and read the walking output. - Use the reset pin to shorten the sequence to a chosen number of steps. ] .eu-label[Essential Understanding:] A clock on its own only says *now*. Every machine that does things in order also has to know *where in the order it is* — and that means a chip that remembers. Today you meet the first one in this course. Identical ticks go in; a sequence of distinct, named steps comes out. That is the entire distance between a blinking LED and a traffic light. --- # Agenda .agenda-box[ 1. What your clock can't do 2. Meet the 4017 3. What it actually does 4. The chip that remembers 5. Reset: counting to *N* 6. Quick check 7. **Build 1:** a light that walks 8. **Build 2:** make it count to four 9. **Build 3:** put the speed dial back 10. Homework — and it's the milestone design ] --- # What your clock can't do Back in Class 12 you built a 555 astable and made it blink at any rate you liked. It's a good clock. But a clock has **no memory at all**. Tick 3 and tick 400 are identical events. Ask it "which tick is this?" and it has nothing to say. .pull-left.w48[ A traffic light needs more than a tick. It needs: *"we are on step 4 of 6, so green is on"* ] .pull-right.w48[ Which means something has to **count the ticks** and remember the answer between them. That part is in your kit now. ] --- class: small-font # Meet the 4017 .pull-left.w40[ <img src="assets/schematics/counter-4017-pinout.svg" alt="4017 decade counter as a 16-pin DIP: pin 1 Q5, 2 Q1, 3 Q0, 4 Q2, 5 Q6, 6 Q7, 7 Q3, 8 GND, 9 Q8, 10 Q4, 11 Q9, 12 CO, 13 INH, 14 CLK, 15 MR, 16 Vdd" style="width:100%;max-height:330px;"/> ] .pull-right.w56[ A **decade counter**: a 16-pin DIP with **ten outputs**, Q0 through Q9. - Exactly **one output is HIGH at any moment**. The other nine are LOW. Engineers call this **one-hot**. - Every **rising edge** on **CLK (14)** moves the HIGH one step along: Q0 → Q1 → Q2 → … → Q9 → back to Q0. - **MR (15)** — master reset. Take it HIGH and the count jumps straight back to Q0. - **INH (13)** — clock inhibit. Take it HIGH and the chip ignores the clock. We tie it to **ground**. - **CO (12)** — carry out, one pulse per ten clocks, for chaining a second counter. Not used today. .font-small[ **Look at the pin order.** Q0 is pin 3, Q1 is pin 2, Q5 is pin 1. They are *not* in order around the package — which is exactly why you read a pinout instead of assuming one. ] ] --- class: small-font # What it actually does Feed it a clock and watch the outputs. Each row is one rising edge later: | clock edge | Q0 | Q1 | Q2 | Q3 | Q4 | … | |---|---|---|---|---|---|---| | power-up | **1** | 0 | 0 | 0 | 0 | | | 1st | 0 | **1** | 0 | 0 | 0 | | | 2nd | 0 | 0 | **1** | 0 | 0 | | | 3rd | 0 | 0 | 0 | **1** | 0 | | | 4th | 0 | 0 | 0 | 0 | **1** | | | … | | | | | | | | 10th | **1** | 0 | 0 | 0 | 0 | *(wrapped)* | Ten LEDs on the ten outputs would give you a light **walking** down the row, one step per tick, over and over. --- # The chip that remembers Stop and notice what just changed. - **Classes 16 and 15:** a 74HC gate's output depends *only* on its inputs **right now**. Put the same inputs in, get the same output out, every time, forever. That's **combinational** logic — the half adder had a truth table because nothing else mattered. - **The 4017:** feed it a rising edge. What comes out? **It depends on what happened before.** The same input produces a different output depending on where the count already was. You cannot write a truth table for this chip. There is no row for "CLK goes high" — the answer is *"one further along than last time."* .emphasis[ This is called **sequential** logic, and the difference is memory. A gate computes. A counter *remembers, and then* computes. ] That is the real dividing line in digital electronics, and you just crossed it. --- # Reset: counting to *N* Ten steps is rarely the number you want. A traffic light doesn't have ten phases. .pull-left.w52[ **The trick:** wire an output back to **MR**. The instant the count reaches **Q4**, that output goes HIGH, which resets the chip, which snaps the count back to **Q0**. So Q4 is HIGH for only a few billionths of a second — far too brief to light an LED or to see — and the circuit behaves as a **four-step counter**: Q0, Q1, Q2, Q3, Q0, Q1, … ] .pull-right.w44[ .center[ **Q4 → MR gives 4 steps** **Q6 → MR gives 6 steps** **Q_N → MR gives *N* steps** ] ] Pick your step count, wire that output to MR, done. You will use this next class, and the number you pick will be a design decision you have to defend. --- class: small-font # Quick check 1. A 4017 is clocked at 2 Hz with **nothing** wired to MR. How long until the same LED lights again? 2. You need a **six**-step sequence. Which output goes to MR? How many LEDs will you actually see light up? 3. Your clock's duty cycle is very lopsided — it sits HIGH much longer than LOW. Does that change how long each **step** lasts? Why or why not? 4. Someone's 4017 does nothing at all. Their CLK wire is correct and the chip is powered. They left **INH floating**. What's happening, and which rule from Class 16 did they break? 5. Why can you write a truth table for a 74HC08 but not for a 4017? --- class: small-font # What you're building .pull-left.w52[ <img src="assets/schematics/counter-4017-walk.svg" alt="A 4017 clocked from a 555, with LEDs and 1 kilohm resistors on Q0 through Q3, INH tied to ground, and Q4 fed back to the master reset pin" style="width:100%;max-height:340px;"/> ] .pull-right.w44[ - The **clock arrives on one wire** from the 555 — the schematic doesn't redraw the timer, because by now it's a block you already trust. - **INH to ground**, so every rising edge counts. - Four LEDs, four resistors, on **Q0–Q3**. - The **blue feedback wire from Q4 to MR** is Build 2. Wire everything else first, with MR grounded, and add that wire last. - Only the pins in use are drawn. That's normal on a schematic — the full package is on the pinout slide. ] --- class: center, middle # Build: a light that walks Three builds, each one wire different from the last. --- class: small-font # Build 1 (20 min): the walking light You need your clock back. Rebuild the **Class 12 astable** — `\(R_A\)` = 10 kΩ, `\(R_B\)` = 100 kΩ, `\(C\)` = 10 µF, TRG tied to THR, RST to +6 V — on one end of the board. Then add the **4017**, four LEDs, four **1 kΩ** resistors, and a second **0.1 µF** decoupling cap. 1. **Power off.** Seat the 4017 across the trench, **pin 1 at the notch**. **Vdd (16) to +6 V, GND (8) to ground**, 0.1 µF decoupling straight across those two pins. 2. **INH (13) to ground.** **MR (15) to ground** for now. *Both must be wired — a floating CMOS input is not a low input.* 3. Wire the 555's **OUT (3)** to the 4017's **CLK (14)**. That is the entire connection between the two chips: **one wire.** 4. LEDs with **1 kΩ** resistors on **Q0 (pin 3), Q1 (pin 2), Q2 (pin 4), Q3 (pin 7)**. Read those pin numbers off the pinout — they are not in order. 5. Power up. The light should **walk** Q0 → Q1 → Q2 → Q3 … then **pause for six ticks** with nothing lit while the count runs through Q4–Q9, then start again. 6. **That pause is correct.** Don't fix it. Work out with your partner exactly how many ticks it lasts and why. .font-small[ **Nothing moves?** Check the clock still blinks on its own first — put an LED on OUT (3). Boundary between two blocks; halve the problem. ] --- class: small-font # Build 2 (8 min): make it count to four One wire. 1. **Power off.** Take MR's wire **off ground** — remove it, don't just add another. 2. Connect **Q4 (pin 10) → MR (pin 15)**. 3. Power up. The walk should now snap back to Q0 straight after Q3. **Four steps, no gap.** 4. **You will never see Q4 light**, even though it's the output doing the work. With your partner, explain why not — in terms of how long Q4 is high. 5. **Predict, then measure:** at your clock rate, how many seconds is one full four-step lap? Time it. # Build 3 (8 min): put the speed dial back 1. Swap the clock's `\(R_B\)` (100 kΩ) for the **100 kΩ pot + 1 kΩ floor** from Class 12. 2. Now you can **turn the speed of the whole sequence up and down** with a knob, while it runs. 3. Turn it slowly enough to call out the steps, and fast enough that it stops looking like steps at all. .font-small[ **Stretch:** wire all ten outputs to ten LEDs and watch a full decade. Or put the photoresistor back in and make the sequence run at the speed of the room's light. ] --- class: center, middle # Homework .hw-box[ - **Design the milestone sequencer.** A traffic light needs **six** steps. Which 4017 output goes to MR? Sketch it. - Decide how long one step should last, then give the `\(R_A\)`, `\(R_B\)`, and `\(C\)` for a 555 astable that produces it. Use values from the kit and **show the arithmetic** — you are going to build this next class. - Red should stay on longer than yellow. But the 4017 only ever lights **one** output at a time. In a sentence or two: how could three steps' worth of outputs turn on **one** red lamp? *(You already own the part that does it — you've had it since Class 16.)* - One sentence: the half adder had a truth table and the 4017 doesn't. Why not? ]