7
\$\begingroup\$

If I'm here today, it's because I need some help for something that is, I think, easy for you. I am quite a newbie in EE but I am trying to improve myself :).

Here is the thing, I'll try to be as clear as possible with what I am dealing with. I am trying to figure out how I could create some level of brightness for some LEDs connected to an Arduino knowing that I can't use PWM.

Here is what I did since then : First schematic

I have three LEDs and I would like to have 3 levels of brightness for them. The LED I have are 3.02V / 15mA. So if I am not wrong, with a 3.3V power supply, I need a 20 Ohm resistor to bright one of them fully. With a MOSFET properly chosen, I will be able to drive it, am I right ? If so, with the above schematic, will I be able to have my 3 levels of brightness ? Since for each MOSFET, I have a different resistor value.

Are there others ways to achieve what I am trying to do without PWM ?

Thank you in advance for your answers !

(sorry if my English is not perfect)

\$\endgroup\$
  • 3
    \$\begingroup\$ This will, depending on your code, give you more than 3 levels of brightness. Consider what will happen if you turn on more than 1 pin. (Pin 1+2, 1+3, 2+3, 1+2+3) \$\endgroup\$ – Christian V Aug 30 '16 at 9:47
  • \$\begingroup\$ Actually I'll turn on only one PIN at a time. \$\endgroup\$ – vionyst Aug 30 '16 at 9:54
  • 4
    \$\begingroup\$ Just out of curiosity, why can't you PWM? \$\endgroup\$ – Scott Seidman Aug 30 '16 at 11:35
  • \$\begingroup\$ Multiple additive currents are not all that useful with LEDs used for visual purposes because of the logarithmic human eye response. \$\endgroup\$ – Spehro Pefhany Aug 30 '16 at 12:00
  • 1
    \$\begingroup\$ @ScottSeidman Actually because I am using an I2C I/O expander and there isn't PWM on it. \$\endgroup\$ – vionyst Aug 30 '16 at 12:07
11
\$\begingroup\$

Source followers will not turn on completely so your circuit isn't great. If you want to ground the LEDs, you can use P-channel MOSFETs rated for 3V or lower drive, keeping in mind that the control signals will be inverted (low=on). Or you can connect the LEDs to +3.3 and use N-channel MOSFETs with the sources grounded.

Also, your paralleling of the LEDs is not the best. Assuming they are all very similar it can work okay, but it's better to give each LED its own ballast resistor otherwise slight differences in the forward voltages (they usually have a fairly wide range) will result in one LED hogging more current than its share.

The lowest value you have is 20 ohms so you could put ~60 ohms in series with each LED and then use 0 ohms/80 ohms/230 ohms for the other two resistors. For visual indicator or backlight LEDs the resistor values are not that critical and you can adjust them to convenient values by experimentation to get the visual effect you want, the key thing is that R1~R3 are equal, and they set the maximum brightness. The other two resistors add to R1||R2||R3, so you get the same effect as with 20R/100R/250R running the parallel set, or individual series resistors of 60/300/750 ohms on each LED.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 1
    \$\begingroup\$ You need 4 resistors less than what I was thinking of. +1 \$\endgroup\$ – Arsenal Aug 30 '16 at 9:48
  • \$\begingroup\$ @Arsenal You can submit your answer as an alternative to get more even brightness, but watch out for sneak paths. You might need more transistors too. \$\endgroup\$ – Spehro Pefhany Aug 30 '16 at 9:51
  • \$\begingroup\$ Wow thank you for your answer. That's an elegant way to achieve it ! But I am not sure to understand when you say "The other two resistors add to R1||R2||R3, so you get the same effect as with 20R/100R/250R running the parallel set, or individual series resistors of 60/600/750 ohms on each LED". Am I right If i say that when M3 is on, The resistor on each LED is 60+230 Ohm ? \$\endgroup\$ – vionyst Aug 30 '16 at 11:11
  • 1
    \$\begingroup\$ The effective total resistance is 20 ohms + 230 ohms = 250 ohms, for three, so the current through each is equivalent to 1/3 of that, or like each LED had an individual 750 ohm resistor in series. \$\endgroup\$ – Spehro Pefhany Aug 30 '16 at 11:47
  • \$\begingroup\$ This answer provides the correct "ratios" of the resistors. However, the values are wrong because the 15 ma required, is for EACH diode. So, the total current required is 45ma. You will need about 75 ohms, NOT 20, to limit the current. \$\endgroup\$ – Guill Sep 2 '16 at 22:31
3
\$\begingroup\$

If you can increase the voltage of your power source you could use a circuit like

schematic

simulate this circuit – Schematic created using CircuitLab

As others have said, by turning on more than one mosfet you can have up to 5 levels of brightness (8 if you add a suitable resistor before \$M_1\$).

\$\endgroup\$
  • \$\begingroup\$ No I can't increase it. At least not for now. \$\endgroup\$ – vionyst Aug 30 '16 at 11:27
  • \$\begingroup\$ Actually it would be something like 5 levels of brightness, due to M2 and M3 not making much of a difference when M1 is conducting, If R1 is placed in series with M1 then you will have 8 levels of brightness, but the value has to be adjusted so R1||R2||R3 = 10 ohms \$\endgroup\$ – LuisF Aug 30 '16 at 13:25
  • \$\begingroup\$ You're right, \$M_1\$ would have to have a resistor, too, to get the 8 levels of brightness. Thanks, I'll edit the post. \$\endgroup\$ – hcabral Aug 30 '16 at 13:47
0
\$\begingroup\$

https://en.wikipedia.org/wiki/Resistor_ladder

An "R–2R" ladder is a way to create a digital-to-analog converter (DAC). Connect an IO pin to each rung of the ladder and turn on different combinations of pins to produce different voltages.

EDIT: Had a play about in LTSpice just now (haven't got any microcontrollers on my bench at the moment so I've simulated the IO pins using pulse sources)...

QTLP690C

With some tweaking I think these V & A steps can be massaged into the right ranges.

Using a LED so close to the input voltage is a bit of a bummer though, especially if PWM is not allowed.

The QTLP690C is the closest LED I can find in the default LTSpice library so the actual ones you are using might vary a bit.

A ladder probably isn't the best way I admit but the OP asked for alternatives to PWM.

\$\endgroup\$
  • \$\begingroup\$ LEDs brightness is mostly current controlled, they have a relatively constant forward voltage drop. so IMHO varying the voltage is not quite what is needed, though it may be a means to current control. So, it might be helpful to create the whole circuit and see how the current varies. \$\endgroup\$ – gbulmer Aug 30 '16 at 14:47
  • \$\begingroup\$ @gbulmer, has physics changed recently? :) j/k This does work if you choose sensible resistor values. \$\endgroup\$ – Wossname Aug 30 '16 at 14:55
  • 1
    \$\begingroup\$ "Has physics changed recently?" not in my world. The LED spec is "3.02V / 15mA", you only have 3.3V to play with, and human vision is logarithmic. So I would very much like to see how changing the voltage with an R-2R resistor ladder is going to work. So, by all means, define the circuit using R-2R resistors and I/O ports, stating your assumptions, and show me how you get 3, or more, distinct brightness levels on 3 LEDs. \$\endgroup\$ – gbulmer Aug 30 '16 at 15:07

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.