4
\$\begingroup\$

I'm driving 3 tricolor LEDs from 3 PWM pins. They can't source enough current to drive them directly so I have them switching on some 2n7000s. Works great when each PWM corresponds to one color but...

I wanted to have each pin drive a different LED colors (e.g. PWM1 drives Led1.Red, Led2.Green, Led3.Blue, etc.), so they'd always be different colors. The drivers are staggered as shown enter image description here(https://imgur.com/a/hi1f6qa). It didn't work at first or had apparently strange behavior. Eventually I realized, of course, the B/G LEDs have a Vf of around 2.8 and the R LEDs are about 2.3. So if I had the Red channel turned on, the Blue and Green were either extremely dim or just off entirely. I was trying to create 2 voltages simultaneously at the drain of the FET.

Is this design fundamentally incorrect, or is there some small change I could add to compensate?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I would use P-channel MOSFETs between the supply and the current-limiting resistors. More energy-efficient too. \$\endgroup\$
    – vir
    Dec 23, 2020 at 19:10
  • 1
    \$\begingroup\$ Yes it is fundamentally incorrect. I would put the NMOS on the low side. Also, if VCC is not 5V, then use a BSS138 instead of a 2n7000. This changes the logic because high at the FET gate means LED is on. \$\endgroup\$
    – mkeith
    Dec 23, 2020 at 19:41
  • 1
    \$\begingroup\$ @brenzo Are those 4 pin LEDs with common cathode, or do all individual LEDs have separate supply pins? \$\endgroup\$
    – Justme
    Dec 23, 2020 at 20:41
  • \$\begingroup\$ @Justme common cathode. They all have separate supply pins. \$\endgroup\$
    – brenzo
    Dec 24, 2020 at 0:56
  • \$\begingroup\$ @vir That seems like a solid idea. Then I can high-side switch and still stagger them, right? The design I made was hoping to save space (this is going in a very small enclosure). \$\endgroup\$
    – brenzo
    Dec 24, 2020 at 0:56

5 Answers 5

9
\$\begingroup\$

That is a pretty weird way of "driving" LEDs.

OP's schematic:

enter image description here

A few issues:

  • essentially you have an "equivalent" resistor, shared by the LEDs (if the LEDs have any imbalance - which they have - the current draw will be uneven)
  • power draw - when the LEDs are "off", the FET will be drawing the current (even more than the amount drawn by the LED since there will be no V_LED)

The "regular" way of doing it would be (for each of the tricolor LEDs, then you can tie the GPIOX to whatever color combination you need):

(Assuming you dont need level shifting. Gate/Pull-up resistors omitted.)

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
6
\$\begingroup\$

Yes, it requires modifications.

First of all, the LEDs of different colors are in parallel, so only LED with smallest Vf will light up.

And connected like that, the resistors get paralleled too, so you have much more (3x what you intended?) current flowing via the LED that does light up.

Even more, the LEDs are turned off by shunting current by turning FET on.

If the LED is in one package, and is common cathode, you should change to a P channel FET and drive the high side so that each LED can have a separate resistor.

\$\endgroup\$
6
\$\begingroup\$

This is one way to do it. This inverts the logic compared to what you have now. What I mean is, in your current circuit, driving the gate high turns OFF the relevant LED. But in my circuit below, driving the gate high turns ON the relevant LED.

When the LED's are off, the drain of the MOSFET's are basically at VCC. When the LED's are on, the drain is basically at GND. So this eliminates the problem you have in your circuit that forces the LED's to have the same forward voltage.

NOTE: if VCC is less than 5V (for example, 3.3V) then don't use 2n7002 or 2n7000. Use the BSS138. The 2N700x does not always turn on fully with 3.3V VCC.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • \$\begingroup\$ In my experience, the R, G and B will probably need different pullup resistor values. The ones I have shown here are kind of random guesses. But the main point is that they may need to be different because of differing Vf and different photonic efficiency and different sensitivity of the human eye. \$\endgroup\$
    – mkeith
    Dec 23, 2020 at 20:24
  • \$\begingroup\$ I believe that they are common cathode tri-color LEDs, this answer assumes that they are independent. \$\endgroup\$
    – Mattman944
    Dec 23, 2020 at 23:05
  • \$\begingroup\$ @Mattman944 if they are common cathode then yes, I agree with you. In that case OP would have to use P-channel between VCC and resistors. \$\endgroup\$
    – mkeith
    Dec 24, 2020 at 0:09
  • \$\begingroup\$ Thanks this makes sense but the LEDs are unfortunately common cathode so it looks like the P-channel is the way to go. \$\endgroup\$
    – brenzo
    Dec 24, 2020 at 1:04
  • \$\begingroup\$ LEDs being common cathode is now confirmed by OP. \$\endgroup\$
    – Justme
    Dec 24, 2020 at 1:05
3
\$\begingroup\$

Here is a PMOS based solution since you have common cathode LED's. The logic is not really right. You will have to re-arrange which LED's are connected to which MOSFET. Basically, the MOSFET will be turned on when you drive its gate low. All the LED's connected to that MOSFET will be turned on when the MOSFET is turned on.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
\$\begingroup\$

if for some reason you need to short the LED current instead of switching it you could fix your circuit by using one MOSFET for each resistor and interconnecting the gates instead of interconnecting the resistors.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

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.