Skip to content

Driving LEDs

Lena Schimmel edited this page Apr 1, 2024 · 4 revisions

LEDs can be driven / powered / controlled in different ways. They all have in common:

  • the (average) brightness is roughly proportional to the (average) current flowing through the LED
  • the (average) current must stay below a certain limit, or the LED will be destroyed

Here, "average" relates to pulses and fluctuations in the current which are typically in the range of milli- or microseconds.

ESP-driven PWM with resistors

The first iteration of besteLampe! (Main Module v1, LED Module A and A2) uses series resistors to limit the maximum current to a save value, so that you could directly apply 24V to the board and the LEDs would light up at 100% of the specified brightness. The Main Module uses one MOSFET per LED channel for PWM - Pulse Width Modulation, which is basically turning the LED on and off so fast that the human eye can't recognize it, and instead interprets it as reduced brightness. In each instant with the LEDs turned on, the current is still limited by the series resistors.

While this driving scheme works quite well, it has two major disadvantages:

  • mediocre efficiency: about 1/4 of the power is lost inside the resistors without generating any light
  • you need to have the right count of LEDs in series - usually 5 to 8, depending on the actual LED model and color - or the efficiency gets much worse

Also, this driving scheme cannot adapt to changing circumstances. For example, LEDs which change their forward voltage when their temperature changes, and when aging. If the power supply would change its voltage, it would not compensate for that as well.

Constant current driver

A "constant current driver" is a circuit that is tuned to provide a specific current. From here on, it will be shortened as CCD (not to be confused with a "Charge-Coupled Device"). You can then hook up one or more LEDs in series, and the circuit keeps the current constant, somewhat independent of the number and type of LEDS, their age and temperature, and the input voltage from the power supply. A CCD does not need a series resistor to limit the current (technically, there is a resistor in series that is involved in regulating the current, typically called R_sense. It has a very low resistance and wastes practically no power).

When it is operated within certain parameters, a CCD is also much more efficient than the first approach.

But how do you change the brightness when the CCD is designed to keep the current always constant?

There may be some CCDs which make that impossible. But most of them will offer one or more ways to influence the (average) current:

  • analog dimming
    • controlled by analog voltage
    • controlled by PWM input
    • controlled via a digital protocol, e.g. over I2C or SPI
  • pwm dimming
    • controlled via PWM input (pulsed signal)
    • controlled via a digital protocol, e.g. over I2C or SPI

Here, analog dimming means: adjusting the current, and PWM dimming means: switching the output on and off, while keeping the current constant as long as it is switched on.

While it is possible to create a CCD circuit from a lot of basic components (like transistors), it's usually centered around a CCD-IC that handles many of the complex tasks, and only needs some passive components to work. There are dozens or hundreds of different CCD-ICs.

To make things very confusing, all those ICs use PWM internally to control the current, with very high switching frequencies (usually several MHz). Those that offer externally controlled PWM have actually two nested PWM controls, and the externally controlled supports much lower frequencies (usually some kHz, but some ICs go as low as 200 Hz). PWM parameters are not only defined by the frequency - there are minimums and maximums for the on time, the off time, the duty cycle... and when a datasheet has a value for those, it never explicitly states if it applies to the internal or the external PWM.

In general, it's hard to find the right CCD...

  • some can generate a PWM signal on their own, controlled via a digital protocol
  • some have 12, 16 or even 48 channels
  • some can handle currents up to 1.5A per channel
  • some can dim smoothly until the LEDs emit almost no light
  • some can handle high (external) PWM frequencies
  • some can combine analog and PWM dimming (and many can do both, but not both at the same time!)

Single stage CCD with integrated PWM generation

So I've basically given up finding a CCD that can all it needs to do, because each one can either generate a PWM signal, but only drive about 30mA to 200mA, or it can drive higher currents but needs an externally generated PWM signal.

Two-stage CCD

I've also given up the two-stage approach:

  • a weak CCD to generate up to 16 PWM signals (e.g. Texas Instruments TLC59711)
  • several strong CCDs (at least one per channel) which amplify the PWM signal and drive LEDs with higher currents (e.g. Texas Instruments TPS92200)

It's less-than-trivial because the first stage has no digital logic output - instead there are two terminals that may oscillate between arbitrary voltages and need to be logic-converted first.

Also, the second stage is usually very picky about the timing of the PWM signal it accepts (especially for duty cycles below 10% or above 90%), and the first stage is very inflexible and does not output what is needed.

ESP-driven PWM with CCD

So now I'm back to generating the PWM signal with the ESP32, and using a high-power CCD with PWM input. Finding the right timings for every needed duty cycle is still hard: it depends on many circumstances and the datasheets are not really helping. But I'm working on a test rig that automatically applies various combinations of on- and off-times and measures the light output, to find the actual working range of the CCD, and also measure the efficiency for each configuration.

Color correction

The chosen brightness may not always be fully proportional / linear to the actual brightness, so the result of mixing of multiple color channels may have color shifts if this is not compensated for.

But even when a single color channel is driven, some LEDs tend to change their color slightly. This effect is stronger for analog dimming and weaker for PWM dimming. So the testing rig shall also measure the emitted color.

Addressable / digitally controllable LEDs

These are addressable chips that are connected in series and then controlled individually. They come in two flavors:

  • bare control ICs, so you attach 3 or 4 LEDs to each IC
  • integrated with the LEDs, so you have a single package that contains both the logic and 3 or 4 LEDs with different color

They all have in common that they offer only 256 levels of dimming. Most (but not all) also have very low PWM frequencies that cause noticeable flickering. It's also hard / impossible to get the integrated ones with specific color temperatures, hues or CRI values.

I did not (yet) find anything about their efficiency, and I'm unsure if they use series resistors or CCD to control the current at 100% dimming.

All in all, these LEDs do not solve my needs.

Why all this complexity?

Using CCD instead of series resistors is more efficient - but does that justify the added complexity?

There's another reason, which is not as directly related as the efficiency:

For some applications it's important to control the direction and scattering of the emitted light very precisely. The best available methods to do this use reflectors and/or lenses, which require that the light comes from a single point, or at least from a very small area or volume (up to about 15mm x 15mm).

If I want to emit several 1000 Lumen from such small areas, and control the color and spectrum by combining many different LED color channels, I cannot afford to use 5 to 8 LEDs per channel. With high-power LEDs, I can get the needed brightness with 1 to 3 LEDs per channel, but then the approach with series resistors becomes very inefficient, up to the point of not being viable.

So in the end it's either - or:

  • get the CCD approach working
  • no precise control of the light direction and scattering