Česky English

LED lighting design

Why LED? Because there is no better available light source today (2022). Efficiency of classic incandescent bulbs ranges in single percents while that of LEDs in tens, so we get much more light from the same amount of electricity (and directly in the right colour, without additional losses in tinted glass). They are shockproof: no thin filament in a glass bubble, just a solid lump of silicon and plastic. If we don't torture them with excessive currents or temperatures, they last more or less forever. They're small, light and cheap. Know anything better?

And why bother with our own design when we can buy complete lights on every corner? Because the commercially available ones don't always match our requirements for light output and distribution, colours, power supply, waterproofing, durability and other parametres. Or because we may want to light up model railway, theatre props, off-grid garden shed or anything else where available standard lamps wouldn't work. Or simply because we like to make things ourselves :-).

If you know nothing about electrics, you may want to start from the basics, but most of the necessary theory is explained here. When using the provided equations, always substitute voltage in volts (V), current in ampéres (A) and resistance in ohms (Ω), no milliamps or kiloohms, or you get garbage. Regarding the necessary instrumentation, you will certainly need a soldering iron: preferably some with a fine enough point and a temperature regulation. Then a solder: the tin alloy wire we solder with (60 % tin and 40 % lead works best for me). And also a flux: stuff which cleans metal surfaces and improves adhesion; for copper and tin, rosin is the best. Soldering temperature is optimal when rosin begins to boil. When it sizzles and changes colour to dark brown, it's too hot, decomposes and loses its fluxy properties. Use copper for all conductors if possible, it has low resistance and solders very well. You can live without printed circuit boards (PCBs), but it's better with them. You can make them out of cuprextite (copper-plated composite board), on which you draw the future conductive paths with a protective varnish and then etch away the rest (or you can scrape the nonconductive areas away with a knife, which is more work, or buy a pre-drilled PCB with pre-made conductive strips, which may not fit your design as neatly as you'd like). Electronic components can be bought in special shops (some examples from the Czech Republic: GM Electronic, JD&VD, Netmart, Ecom, EZK, Conrad and others), common consumer electronic stores or hobby shops don't stock them.

LED types and parametres

LEDs are made as round clear "bullet" shells with leads, as SMD (Surface-Mounted Device - tiny cube with soldering tabs) or in various holders designed to be mounted on a heat sink or built into housings. The technology advances quickly, LED performance improves every year. They have already surpassed the best halogen bulbs by a large margin, so there's no point in waiting for something better.

The easiest work (and fewest things a beginner can mess up) is with clear round 5 mm diodes: they have a built-in reflector and lens, so no external optics are needed, and the beam is nicely uniform, without dark spots or sharp edges. Choose a clear shell (neither diffuse nor tinted, the clear allows most light through), and beam angle of cca 10..15° for headlights and 30..60° for taillights. Light output of round LEDs is usually rated in candelas and it tells us how bright the LED looks if we look directly into the beam. 1 cd is roughly the output of one ordinary candle. Tens or hundreds mcd are only enough for dashboard indicators, main bicycle lights need thousands (last time I used 3000 mcd LEDs at the rear and 10000 at the front, if I remember correctly). Negative lead is marked by a flat section at the LED's base. Don't rely on the looks of the internal components, their polarity varies. Also, one of the leads is usually shorter, but we are going to trim them anyway.

Light output of high-power or SMD LEDs is usually rated in lumens, which means a sum of all the emitted light in all directions. The candela-style luminosity then depends on how narrow a beam we squish that light output into - and we need some external optical component for that. The best choice are probably clear acrylic TIR (Total Internal Reflection) reflectors: small, light and efficient. Their only disadvantage is that they only come in circular shapes: they can't shape the beam so that it uniformly illuminates the road and doesn't glare. Parabolic reflectors have somewhat lower reflectivity and take more space, but we can place the LED slightly out of focus and shape the beam as we please, at least in theory.

LEDs are quite sensitive to high temperatures, so they must be soldered quickly (max. about 3 seconds), so that heat doesn't have enough time to get to the semiconductor core and fry it. It also helps to leave their leads somewhat longer and clamp them with aluminium hairgrips for heat sinks while soldering.

Measuring LED characteristics

Nominal parametres from datasheets (like 3.3 V / 20 mA) are not very useful - they are more like absolute maximum values than a recommended working point, and they may not be accurate. Better is to measure everything yourself:

We need a voltmeter, an ampermeter, and some means of power regulation: either an adjustable resistor as pictured, or a source of adjustable voltage (in which case we use a fixed resistor). Turn the knob until the ampmeter shows the current you want (I usually choose cca 1 mA under the nominal value for bike light applications and just a few mA for decorative modeling purposes), then read the actual threshold voltage on the voltmeter (usually significantly lower than the nominal one) and write both numbers down. They are what you will feed into the following equations.

Current-limiting resistor calculation

An LED is to electricity what a weir is to water. Until we exceed its threshold voltage (weir height), there's no current and no light. After we exceed it, the current flows almost freely and if we don't limit it by some external means (resistor), the diode burns out. A basic circuit with one LED and one resistor works like this:

R=(U-U[LED])/I[LED]

U is the source voltage, ULED is the diode's threshold voltage, and ILED is the current we want to run through it. Conversely, we get current from voltages and resistances by flipping the equation:

I[LED]=(U-U[LED])/R

LEDs can be stacked in series:

R=(U-(U[LED1]+U[LED2]))/I[LED]

Current ILED is the same in all of them. Each diode takes as much voltage as it needs, so we can combine LEDs of different types, the only things to watch is the current and the sum of their voltages.

LEDs can also be stacked in parallel:

R=(U-U[LED])/(I[LED1]+I[LED2])

Be careful here. The resistor limits the total current and sends the same voltage to each diode, but how the current distributes between them depends completely on their internal characteristics which may not be exactly equal. So, parallel setting is only suitable for LEDs of the same type, and it's better to use slightly lower total current so that it doesn't exceed safe values in "weakest" pieces.

And of course, we can combine the two variants (Σ means sum):

R=(U-sum(U[LED]))/sum(I[LED])

You will probably not find a resistor of exactly the calculated resistance, they only come in certain selected values. The reason is production tolerances: if we make a 100 Ω resistor with an accuracy of 5 %, the next lower value can't be more than 91 and the next higher must be at least 110, so that the nominally bigger one will always be actually bigger. The sequence of values was chosen to contain the roundest numbers (1, 10, 100, 1000 etc.), so the rest may look slightly odd (22, 47, 56 etc.).

The only takeaway for us is: round the calculated resistance up to the closest larger available value. Slightly lower current won't hurt anything, slightly higher might. Then feed the selected resistance back into the equations above and calculate how big the actual current will be. For example, if a nominally 20 mA LED gets around 18..19 mA, is't just about right: the difference in light output will be too small to notice and long term durability will be assured (the "long term" meaning decades).

Resistor combinations

If several resistors are connected in series, their resistances add up:

R=R1+R2

If several resistors are connected in parallel, their reciprocal values add up:

R=1/(1/R1+1/R2)

This is useful for obtaining values we don't have in our parts bin, or to get more wattage (just don't forget that if you connect two different resistors in parallel, more current will flow through the smaller one - always calculate it to make sure it's not too much).

Waste heat

We know how much current runs through the limiting resistor, now let's check how much it heats up. Emitted thermal power is equal to input electrical power: voltage times current. Voltage can be derived from current, resistance and Ohm's law, the result is:

P=RI2

The resistor must be rated for this or more watts. Too large power rating is no problem, too small will probably burn. Most applications don't need more than 0.6 or 1 W resistors, but once you start playing with high-power LEDs and currents reach hundreds of mA, it's better to use higher power ratings than necessary to prevent burning your fingers or melting hot glue insulation.

Resistor types and parametres

Resistors come in many types based on the manufacturing technology: carbon, metalized, metal oxide and several others. For our low power DC purposes, the type doesn't matter at all.

Precision of a resistor can vary, the most common values are 5 and 1 %. They cost more or less the same, so buying the 5 % doesn't make much sense.

Resistor shells come in two basic variants: with leads, or SMD. SMDs mount on the metal side of circuit boards and their advantage is they take up less space. Leaded resistors mount by holes in the board and have an advantage of being easier to remove and allowing other conductive paths to run between their leads.

Battery-powered circuit design

A battery is a direct current (DC) source. Its voltage doesn't depend much on the current being drawn from it. As a battery discharges, its voltage gradually drops, together with current and light output. Accumulators' voltage first decreases very slowly, then drops suddenly when they approach full discharge. Primary cells' voltage decreases faster. Circuit design procedure can be summarized into two points:

  1. Stack LEDs in series so that their total threshold voltage equals the voltage of discharged battery (3 V per cell for Li-ion, cca 1 V per cell for Ni-MH). Single-use batteries can be drained deeper, so using shorter series is OK.
  2. Calculate limiting resistors based on maximum voltage of fully charged battery.

From the efficiency point of view, the best is to use as much of the battery voltage as possible to overcome LED threshold voltage (and generate light), and lose as little as possible on limiting resistors. From the practical point of view, it's better to have some margin for voltage drop during discharge. The best is to use a switching regulator instead of resistors: the LEDs get constant voltage and current independent on the battery voltage. As an example, look at the USB charger paragraph here and imagine lights in place of the USB socket and a different voltage regulator:

An advantage is that the unusable energy stays in the battery instead of being wasted in resistors. And that the lights shine constantly regardless of the battery state. That's also a disadvantage: as soon as it discharges under some threshold, they go out without warning. It can be worked around by some discharge indication, automatic dimming, flashing or something similar, but that requires a more complex circuit, usually with a microprocessor.

Generator-powered circuit design

Unlike incandescent bulbs, LEDs need DC supply. Too high voltage in the nonconducting direction would destroy them. Bicycle "dynamos" are actually alternators, the produced alternating current must be first rectified and filtered to be useful:

With a bit of simplification, we can assume that the generated power is directly proportional to riding speed. And power is voltage times current, so the more current we draw, the less voltage we get. To know one nominal voltage is not enough, we need the whole volt-amper characteristics. Some can be found in the reviews section here and thanks to standardization, they are very likely to fit your generator as well. If not, you can measure it yourself. You need a voltmeter, ampmeter, speedometer, set of resistors cca from 10 to 70 Ω, capacitor, notepad, pencil and a stretch of safe, smooth and level road.

It is necessary to somehow limit the generated voltage. Without any load (i.e. zero current), it reaches many tens of volts. With lights to feed, it is usually smaller, but there is no clear maximum as with a battery. The simplest voltage limiter is a Zener diode: a component which becomes conductive when voltage across its leads exceeds its threshold, draining excess current from the generator and keeping the voltage constant.

Current limitation is usually built into the generator itself (with some exceptions): even with shorted-out terminals, it can't exceed 500..600 mA.

Circuit design is an iterative process which is easiest to do with a computer (Excel or the like): only write the formulas once and they will be recalculated automatically every time you change an input value. The process may look like this:

  1. Select LED threshold voltage so that it matches the zero-current generated voltage at the speed when you want the lights to turn on. My preferred value is 6 V which roughly corresponds to walking speed (5..6 km/h).
  2. Choose range of speeds where you usually ride and where you want the best possible efficiency without additional losses on a voltage limiter. I usually choose top speed of 30 km/h.
  3. Select a working point on a volt-amper curve for the chosen top speed. I usually select 8.2 V because Zener diodes are available for that voltage, and then read the current on the other axis - usually something around 450 mA.
  4. Find the chosen point on the other characteristics of the generator (U, I and P vs. speed and load) and check if it isn't located in some inefficient edge area - like the current being too high (high losses) or too low (less power at low speeds). Change your working point if needed.
  5. Try to throw in first few LEDs: some white at the front, some red at the rear and anything else that crosses your mind. Number of them in series is determined by the selected threshold voltage, limiting resistors are based on voltage in the chosen working point.
  6. Sum all currents in your LEDs. Add more of them or remove some until the total current roughly matches the chosen working point.
  7. Select the voltage-limiting Zener diode. Its threshold voltage is the same as the working point, current is the difference between maximum possible (short-circuit) generated current and total current drawn by the lights, power is U*I. Round this number up (better to choose too much than too little) and select a suitable diode from a catalog.
  8. If any of the designed numbers change unexpectedly during the process (e.g. the working current, because we can't add half a LED), go back, rewrite it and recalculate all results depending on it.

This is approximately what happens inside the lights while riding:

When accelerating from a standstill, voltage (the thick green line) grows quickly because there is no current being drawn. As soon as it crosses threshold voltage of our LEDs (bottom red line), lights come to life. Upon further acceleration, voltage, current and amount of light all keep growing. From the moment we reach our working point speed (upper red line), light output is at its maximum. Upon further acceleration, protective Zener diode opens and starts draining away excess current, so voltage doesn't grow any further.

Capacitor magic

A capacitor works a little bit like a small battery. Its capacity is tiny, but it can be charged and discharged very quickly. It's useless for battery-powered lights, but cooperates very well with a generator.

First capacitor trick is voltage filtering (smoothing). Generator produces alternating voltage, bridge rectifier turns all half-waves to the same side, but the momentary value still oscillates from zero to maximum and back. A capacitor works like a buffer tank: discrete splashes of current go in, averaged and mostly stable stream flows out. This eliminates flickering of lights at low speeds (most prominent with hub generators) and also improves efficiency: voltage peaks would otherwise get lost in a limiter and there would be nothing to fill the valleys. A capacity of 1000 µF should be enough for filtering (bigger is not a problem), voltage rating should be sufficiently higher than the working point (I usually choose 16 V which is about double).

Second trick is called standlight: a light that continues to shine after the bike stops. Capacitors can't feed main lights, but one or two weaker LEDs are no problem. Main lights can only drain the capacitor down to their threshold voltage (which is rather high because their LEDs are stacked in series), the rest is left for our single-LED standlight. Calculate its limiting resistor to give it cca 5 mA (or whatever you like) at the main lights' threshold voltage, and of course less than its allowed maximum at the working point. I usually choose something over 2 kΩ, that and a capacity of 10 mF per LED gives about 1 minute of light.

If you need larger capacity, connect more capacitors in parallel, their capacities will add up. If you need higher voltage rating, the only viable option is to go find a higher-voltage capacitor. Don't connect caps in series, you would lose capacity - it decreases according to the same formula as resistance of parallel resistors.

Combining generator and accumulators

This combo gives you the best of both worlds: unlimited power source and full light long after stopping. It also gives you more freedom when designing the circuit: power input of the lights doesn't have to exactly match the generator output because the battery absorbs excesses and covers shortages. All you need is a balanced long term energy budget.

Two Li-ion cells in series proved to work best for my purposes. Their working voltage ranges from 3 to 4.2 V per cell, which means 6..8.4 V total. What a luck, that exactly matches both the threshold voltage of my usual LED set and a working point of a standard bike generator. Maximum allowed charging currents are usually larger than what the generator can provide. One of the two things to watch closely is maximum voltage: overcharged Li-ions tend to explode. It can be done with a simple 8.2 V Zener diode, but first make sure what voltage it shows at maximum achievable current - its volt-amper curve isn't perfectly vertical, the voltage rises a bit with increasing current. Better is to build a voltage limiter out of TL431 reference chip and a power transistor, which can be tuned more precisely and allows getting closer to full charge. The other thing to watch is minimum voltage because deep discharge to less than 3 V per cell is harmful to Li-ions. But that's easy, just connect all LEDs in series with threshold voltage of 6 V or more.

A disadvantage of Li-ion is they don't like being charged in temperatures under 0 °C. In winter, we either have to disable the charging, or keep the battery warm. Maybe it could be heated by waste heat from limiting resistors of high power headlights - I don't know, will test it next time. Considering other battery types, I don't know anything better than lithium (Li-ion, Li-pol and maybe also LiFePO4 which I don't know in detail). Lead-acid batteries require long charging with low current and are rather heavy. With Ni-Cd and Ni-MH, it's harder to tell when they are fully charged, and I don't know how they tolerate frequently interrupted charging.

Other notes

Count with water. Lights are most needed during rain or similar horrors, so they must not mind getting wet. Heat-shrink tubes sometimes don't provide a perfectly watertight insulation, silicone or hot glue is better. All housings and boxes should have a drainage hole at the bottom.

Every contact is a potential source of trouble: it can disconnect, corrode or get dirty. The best is to securely solder everything we don't really need to disconnect.

Hot glue is a nice stuff, but don't rely on it being able to hold a light on a mudguard or frame tube. Always secure it with something else (screw, hole, wire etc.) which will hold it if the glue comes off.

Service life of correctly designed and insulated LED lights is practically unlimited. If they don't get damaged mechanically, they will outlast all other components of your bike and probably also the bike itself.

From the "be seen" perspective, the best colour for a front light is cold white. Warm white is everywhere (street lamps, windows, most car headlights), cold white is less common and stands out better.

How strong headlights do we need? Depends on what we need them for. A fellow going by the nickname Brahma started a poll at a cycling forum and then wrapped it up neatly:

The topic has been discussed enough and all contributors have said all they could, so let me wrap it up.

Bicycle headlight power depends on the night riding style and surface quality. The more difficult road/trail, the more light is necessary. For rough terrain, a bike-mounted light is not enough, headlamp (may be weaker than the main headlight) helps a lot by shining wherever we need to look. Headlamp is not appropriate for roads because its beam is unsteady and glares people.

For a smooth empty road without street lamps, most people are comfortable with about 200 lumens.

For city traffic where everyone is illuminated and we need to be seen among cars, 400 lumens is better.

For fast riding on a broken road where it's necessary to avoid potholes, about 600 lumens is needed.

For rough terrain 1000 lumens or more, plus a headlamp.

The data have been compiled from individual preferences of various cyclists. It is no dogma, everyone feels it differently. And everyone's riding style and environment are different.

Where to point the lights so that they illuminate, but don't glare? Taillights are easy: aim them horizontally, shining at people's eyes is their purpose. Glaring is prevented by not making them exceedingly strong. Headlights need to be tilted down a bit. Czech law specifically says that the beam's axis must not intersect the ground farther than 20 m before the front wheel, but that's too far to be useful, in my opinion: 10 m is better, sometimes even less. The best is to find a straight, dry, tree-lined road, ride there after nightfall and tilt the headlight back and forth until you find an angle which gives you the longest possible illuminated strip of asphalt in front of you. If the beam is too high, the asphalt gets darker because more light disappears uselessly in the sky (and in eyes of oncoming drivers). If it's too low, asphalt in the distance also gets darker because you can't see over the bright patch right in front of you. So find your sweet spot and secure the headlight in that position.

Ads: