How the dimmer works
A small NPN transistor turns a P-channel switch on and off, and the switch sits between the 12 V and the display. Why that arrangement keeps the digit in memory, and what each of the two resistors is for.
This page is about the newer board, the one with the PWM pad. The earlier version has no dimmer, and its 12 V reaches the display's anode directly.
A switch on the 12 V side
On this board the 12 V does not go straight to the display. It goes through Q2, an AO3407A, a P-channel MOSFET: its source is the 12 V and its drain is the display's common anode. Q2 conducts when its gate is pulled well below its source. Its gate is held up at 12 V by R9, a 5.1 k resistor, so Q2 is off unless something pulls the gate down.
That something is Q1, an S8050 NPN transistor, with its emitter on GND and its collector on Q2's gate. When Q1 conducts it pulls the gate toward ground, and Q2 turns on.
Q1's base is fed from the PWM pad through R11 (220 ohm) and D1, a Schottky diode in series with it. R12 (10 k) ties the base to GND. The files do not show which way round D1 is fitted, so this page does not say what it is there for beyond being in that path.
Run it. The pad goes high, a little current runs into Q1's base, Q1 pulls Q2's gate down, Q2 conducts and the anode is at 12 V. Then the pad goes low and the same chain runs back: R12 lets Q1's base fall to ground, Q1 stops, and R9 pulls the gate back up to 12 V on its own. The shift register's byte is drawn unchanged from first to last.
Why the switch is on the 12 V side
The switch removes the segments' supply and nothing else. The shift register runs from the logic rail and never loses power, so it keeps its byte while the digit is dark. When the switch closes again the same digit is back at once, without a byte being sent. That is why PWM does not disturb what you latched.
A switch that cut the shift register's own supply instead would lose the byte, and the display would come back showing whatever the register woke up holding.
Why there are two resistors
R9 makes the default off. Q2's gate sits at 12 V unless Q1 acts, so a module with no signal, a loose wire or a crashed program has a dark digit and not a stuck-on one. It also does the turn-off: when Q1 lets go, R9 is the only thing pulling the gate up. The gate has an input capacitance of about 520 pF (the datasheet's typical figure), and 5.1 k times 520 pF is about 2.7 microseconds. The PWM periods the sketches in this book make are 1 to 2 milliseconds, around a thousand times longer, so the switch is far faster than the signal driving it.
R12 makes a floating pad off. With nothing wired to the PWM pad the pin is not at any voltage, and a transistor base left floating can pick up enough to turn on. R12 ties the base to ground so the open pad reads as a clean low. That is the dark module you get from the bag, and it is deliberate.
What it costs
- The switch's own resistance is at most 78 milliohm at a gate voltage of -4.5 V, and with Q1 on the gate is pulled much further than that, so Q2 adds almost nothing to what the segments see. Its gate rating is plus or minus 20 V, so the full 12 V on the gate is within it.
- A 3.3 V high on the pad has to get through R11, D1 and Q1's base. Take about 0.7 V for the base and a few tenths for the Schottky diode and about 2 V is left across 220 ohm, which is of the order of 10 mA. Q1 only has to pull R9 down from 12 V, which is about 2.4 mA at most. We did not measure it, but the margin is plain on paper.
- The dimmer is all or nothing across the digit. Individual segments cannot be dimmed separately.
- The PWM pad floating, or a wire that never leaves 0 V, gives a dark digit. So does a 12 V supply that is not there. It is worth checking all three before suspecting the code.
When it does not work
The dimmer switch is off. Either the PWM pin is floating with the pad open, or the signal on it never goes high. Put a meter on the PWM pin: a pin that reads 0 V all the time is the cause, whatever the sketch thinks it is doing.
A bridged pad ties PWM to the logic rail, so Q1 should be on. Check the rail itself: with 0 V on 3V3/5V the shift register is off and so is the dimmer. Then check the 12 V, because Q2 passes only what it is given.
Toggling PWM does not touch the shift register, so the byte is the one you last latched. If it is wrong, it was wrong before the dimmer was involved: look at the bit order and the latch.
No. The switch is between the supply and the display's common anode, so every segment shares it. The module does not bring out a separate control for a single segment.
It should. The pad's 3.3 V has to push current through R11 (220 ohm), the diode D1 and Q1's base, and the arithmetic on this page leaves a current of the order of milliamps. We have not measured it.
A sketch that fades a digit in and out with analogWrite, and what the duty cycle and the frequency each do.
Dim it with PWM →Edit this page — content/books/seg4/how-the-dimmer-works.mdx
Questions about this product
See what other owners have asked, and read their solutions.
4″ 7-Segment LED Display with 74HC595
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.