I've got part of a circuit diagram for an 8x8x8 RGB LED cube from http://www.kevindarrah.com. See the entire schematic. I'm having trouble working out how it does what it does.

I know that a high voltage coming to CNTRL_L0 will illuminate the LED attached to ANODE_LEVEL_0 but I'm not sure why all of this is necessary?

The 2N3904 is an NPN transistor, so when the CNTRL_0 is high the transistor is active and allows current through so that would mean the circuit connects from the first (on the left) +5V to the first GND and you effectively get a low going into the IRF9Z34N (the pMOSFET). That means the pMOSFET does not conduct, but so what? No matter what happens the ANODE_LEVEL_0 is connected to GND, wouldn't it always be illuminated? And if all that is needed to get this to work is that the 2nd +5V is cut off from the ANODE_LEVEL_0 then wouldn't a single PNP transistor joining CNTRL_L0, 5V and ANODE/GND do the same thing?

enter image description here

  • 1
    \$\begingroup\$ You have a good answer below, I just wanted to clarify that a PMOS transistor conducts current when its gate is at a lower voltage than its source, so when CNTRL_LO is high the PMOS does indeed conduct. Also, an LED illuminates when its anode is at a higher voltage than the cathode, so the LED is not illuminated when the anode is at GND. \$\endgroup\$
    – Joe Hass
    Jul 20, 2013 at 13:03
  • \$\begingroup\$ The extra BJT is probably used because it provides a low switching voltage, and one that is consistent from part to part. The BJT stage also provides gain. It takes just one 2 mA of current through R3 to generate 2V. The gain makes for a rapid transition between on and off. \$\endgroup\$
    – Kaz
    Jul 20, 2013 at 13:53

1 Answer 1


T1 is a simple common emitter inverter. CNTRL_L0 is the input, and the node between T1 and Q2 is the output. If the input is high, the output is low. If the input is low, the output is high.

Q2 is just another inverter, but it uses a MOSFET instead of a BJT, and because this is a P-channel device, everything is upside-down. In this circuit, as is conventional, the P-channel MOSFET is drawn with the source at the top, and the drain at the bottom. It's on when the gate is at a lower voltage than the source. So in this circuit, connecting the gate to GND turns Q2 on. Connecting the gate to +5V turns Q2 off.

IRF9Z34 is a power MOSFET device, so we can infer that it's intended to pass large currents. I don't see where the schematic shows how the LEDs are connected, but it's a safe bet that these large currents are due to the potentially many LEDs connected to this node. A P-channel device is needed because each LED has a separate switch already on the low side, so this circuit must switch the high side. Effectively:


simulate this circuit – Schematic created using CircuitLab

C8 is simply a decoupling capacitor, to reduce power supply impedance and filter switching noise generated by this circuit.

The net effect of these two inverters is no inversion. When CNTRL_L0 is high, T1 is saturated, pulling the gate of Q2 to GND, turning it on. When Q2 is on, ANODE_LEVEL_0 is effectively connected to +5V, providing voltage to illuminate the LEDs (if their individual low-side transistors, Q1, Q4, Q3 are also on).

When CNTRL_L0 is low, T1 is off. The gate of Q2 is pulled high by R3, switching it off. ANODE_LEVEL_0 is then connected to GND through R4. In this condition, both ends of the LEDs will be connected to GND, so can be no voltage across them, so they will not be illuminated.

It would have been possible to connect CNTRL_L0 directly to the gate of Q2. This would invert the logic, but the controller programming could take that into account. However, power MOSFETs have significant gate capacitance, at it takes significant current to switch them. It's likely that the shift registers selected did not have enough current drive capability to switch the power MOSFETs sufficiently fast.

  • \$\begingroup\$ Thank you for the very thorough explanation. My initial confusing was from a temporary brain-freeze over connecting the anode to the ground would make it illuminated. It was late and I was tired. With that sorted I can see how it works and with your full walk through I can see why these components were chose. You are right in concluding the high current is a factor. Each level of the anodes connects to 64 RGB LEDs, so potentially 3.84 amps if all colours are on max. \$\endgroup\$
    – Craig
    Jul 20, 2013 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.