Detailed calculation LED resistance, circuit scheme

"Without electronics, neither amateurs nor professionals would deal with leds. These are one of the basic components, although they only serve as lighting and signaling. In my opinion, building your own ""flash"" and other lighting effects is a satisfying activity and a good reason to use a soldering iron or programmer.

Anyway, every now and then someone asks how to calculate the resistance of an LED...

What is LED?

Light-emitting diode is a kind of semiconductor diode, the side effect of current flowing through PN junction is to emit a certain length of light. Each PN knot will emit light, but usually very little. In the case of leds, this effect can be increased many times by choosing the right elements and compounds.

The basic parameters of each LED are its forward voltage Vf and forward current If. Leds and individual controlled led strip are current control elements, not voltage control elements. The forward voltage is important for the correct selection of current limiting resistance. In the case of color leds, we also have the length of the light emitted? . White leds have a given color temperature CRI value, or color rendering index. We also find other typical parameters of various diodes, such as reverse current, breakdown voltage, or power consumption.

The second set of important LED parameters is information about the housing. The choice here is vast, ranging from traditional round diodes with diameters of 3 and 5 mm, to miniature SMD diodes in a variety of sizes, to highly specialized diodes. The latter includes, for example, an SMD LED emitting ""to the board"" - the idea being that the board should have a hole in this place. Why mix it up? Well, because you can cover the panel with a thin film keyboard with an LED light hole - I came across such a solution on the panel of the Philips New Onyi breast pump. On the right is a diagram of a typical small LED in a circular 3mm/5mm housing. Here are examples of the various leds in the through-hole housing.

Leds are also available in the form of integrated modules, and in this category we will find LED bars, seven, fourteen and sixteen segment displays or 5x7 or 8x8 LED matrices. Here is an example of a four-bit seven-segment monitor. A power LED can consist of many smaller diodes in a series-parallel configuration, similar to the diode strips that pretend to be traditional incandescent light bulbs. In addition, there can be multiple independent diodes of different colors in one housing, as well as integrated circuits, but more on that below. In any case, there are so many options that it's hard to cover them all in one article.

How do I choose a resistor for an LED?

The general formula is:

R = (Vcc - Vf) / If

Where Vcc is the power supply voltage, Vf is the positive voltage of LED, and If is the required positive current of LED. The latter parameter affects the brightness of the diode. And how do you know the forward voltage of the diode? As I mentioned, this information is in the diode data sheet. If we don't have an annotation, then we can measure this value. We supply a 5V voltage to the diode through a 220 resistor, right? And measure the voltage between the anode and the cathode. Diode testing in multimeters works in a similar way, although not every multimeter copes well with leds.

To make life easier for beginners, typical forward voltage values for various LED colors are listed below, along with calculated resistance tables for typical forward voltages of 12.5mA, 15mA and 20mA and typical supply voltages of 3.3V, 5V, 9V, 12V, 15V and 24V. If we want to get a lower current than the one in the table, we multiply the resistance by two, and for a current three times lower, we multiply by three. Resistance values should be rounded to the nearest value in the E24 series. For 20mA, it's best to round. After the resistance is selected, the loss power is calculated according to the formula: P = R *

If^2 infrared: 1.9V

Diodes are mainly used in radio remotes and as illuminators for cameras that see in supposed darkness.

Red: 1.6-2V

One of the first LED diodes invented. Often found in displays and used as a power indicator. The color does not strain the eyes at night and is less noticeable from great distances.

Amber/orange: 2-2.1V

I highly recommend the color of the power indicator - it's a bit like old school neon and as non-harsh as red.

Yellow: 2.1-2.2V

I like this color very much. It is well suited to a seven-segment monitor and is readable both day and night, although it can be a bit harsh in the dark.

Green: 1.9-4V

Colors that are best distinguished by the human eye (which is why true night vision goggles give green monochromatic images). The colors are clearly visible, so the power indicator at night can be a bit annoying. A seven-segment display in this color always reminds me of a cash register. The wide range of available voltages stems from the diversity of materials used.

Blue: 2.5-3.7V

I personally hate the color. Very popular in all power indicators and seven-segment displays. Over the years, it's always been bad for the eyes and annoying at night. Using it in amateur architecture is to me a sign of kitsch and tastelessness. It is also related to Chinese waste.

Violet: 2.8-4V

So far, I've only seen leds in this color once, but I'm not impressed. It's not as annoying as blue leds, but I don't think these leds serve any purpose other than as ""decorations"".

Ultraviolet light: 3.1-4.4V

These diodes mainly come from key chains that check the authenticity of bills. They can also be used as an alternative form of illuminator for cameras that see and perform disinfection functions in the dark. Building disinfection stations using these leds has become a popular project of late.

In the above statement, I did not include the important color, namely white. This is not an oversight on my part, but a deliberate one. First, you need to answer a very important question:

What color is the white LED?

No, it's not white. Also, white leds are not white in many ways. We'll start with the easier way, which is to use red, green and blue leds to get white. This is how white is formed on color TVS and CRT monitors. This works well, but the color rendering index may not be the best. This can be improved using a second, more popular approach, but at the cost of a slight performance loss.

What color is the white LED of the latter type?

It's not white, but yellow or orange. It is yellow or orange because it is blue or ultraviolet. Contrary to appearances, this makes sense. Simply, the blue or UV diode is covered with a mixture of phosphorescence known to be sensitive to these colors in fluorescent lamps in order to obtain white in the form of secondary luminescence. Therefore, white diodes should be treated like blue or UV diodes. As Texas Instruments states in their white LED power application instructions, the forward voltage can be 3-5V, but typical leds are in the 3.1-3.7V range. To take a shortcut, the tables for blue, purple, and UV diodes in the list above would be appropriate.

Method of resistance

This method is simple and inexpensive, but because of the distribution of dipd parameters, these leds may not glow at the same brightness. When calculating, use the lowest forward voltage, not the highest. The formula for calculating resistance is as follows:

R = (Vcc - ( Vf1 + Vf2 + Vf3 + ... + Vfn )) / If

This formula is especially useful when connecting leds of different colors. For the same type of diode, the formula is as follows:

R = (Vcc - ( Vf min * n )) / If

Where n is the number of series diodes. The actual current will be lower than assumed.

In this solution, we stabilize the current, so we (almost) don't care about the forward voltage at all. It is important that the emitter - collector voltage of the transistor used is higher than the supply voltage, and that the sum of the maximum forward voltage of the diode is about 1V lower than the supply voltage. Let's look at the chart on the left.

There are only three leds in the picture, but there could be more. Theoretically, the maximum supply voltage is 45V. In practice, it is limited by the loss power of the transistor Q1, and then by the maximum collector-emitter voltage Vce. The value of R2 is chosen according to the current required. This will be helped by the following table, which contains typical currents, resistance values for the E245% series, and the maximum Vce voltage at the maximum power that the BC547C transistor can provide.

If we want to control the diode with a microcontroller, connecting R1 to the output is sufficient, rather than connecting it to the Vcc. If we need a higher supply voltage, then we choose a transistor with a correspondingly higher Vceo voltage, and Q1 should also have a higher allowable dissipation power. We also increase the value of R1 in proportion to the increase in voltage.

LED display and matrix

If we want to control many leds at once or use displays or LED matrices to communicate information, we need to solve the control problem. It does not make sense to connect each diode to an output of the microcontroller to control it individually. For example, a four-bit seven-segment display requires 32 outputs (including points). This problem was solved in the era of vacuum tubes, more specifically, digital tubes and VFD tubes. These tubes have a common anode and a set of cathodes, each of which opens a number or character in the nixie tube, or a segment in a VFD tube (or a seven-segment nixie variant called a Panaplex). The cathode of each lamp is connected in parallel, and the anode is switched on in turn. A display constructed in this way requires as many anode lines as the tubes in it, and as many cathode lines as the cathode lines, of which the largest number of lights are. The advent of diode and LED displays makes things easier, as it can reduce the power supply voltage, thus simplifying the control system. It also provides an alternative way to control the display by connecting the cathode together instead of the anode

Co-cathode or co-anode?

There is not much difference between common anode and common cathode monitors. Only the transistor type used to select the displays from the group and the polarity of the control signal will change. Let's take a set of four seven-segment monitors.

I. Common anode:

Resistor R1-R4 and PNP transistor Q1-Q4 are used to select one of the four displays. Resistor R5-R12 selects each cathode of the diode to be lit. Their values are selected according to the current If and voltage Vf of the diodes in the display. The typical value of R1-R4 is 10 kω. The maximum allowable current of the transistor should be 8 * If. In this circuit, the signal polarization is reversed and the anode (up to R1-R4) and cathode (R5-R12) outputs default to high levels. The control sequence is as follows:

1. We set the low state to R1.

2. Set the low state on the selected cathode output.

3. We're waiting.

4. Set all cathode outputs to high state.

5. We set the high state to R1.

We repeated the sequence of each anode output so quickly that the sequence of the entire display was repeated 20-25 times per second. The change in output state is best achieved in an interrupt triggered by one of the microcontroller timers.

This time R1-R8 selects the anode of the display, while R9-R12 selects their common cathode through the NPN transistor Q1-Q4. This time, it is the high level state of the selected anode and cathode output that lights up the display segment, while the low level state turns them off. The control sequence of the microcontroller part is virtually the same, with only differences in polarization. For me, this is the preferred control mode, but it is possible to use a logic level and low Rdson type MOSFET-N transistor instead of an NPN transistor, especially when we are controlling not a display but a matrix of many leds, as it is discussed below.

RGB matrix with shift register and MOSFET-N transistor

It is a solution dedicated to easily controlling a large number of leds with a minimum number of microcontroller pins. Below I have shown a schematic snippet of the system I have been working on, more precisely the 64 RGB LED matrix control system. It is an 8x8 LED matrix with common anodes in rows and common cathodes in columns. Technically, it is a 24x8 matrix, as each LED has a common cathode for red, green, and blue.

Here we have four 74HC595 shift registers linked together. They are controlled by three signals: clock, data, and transmission. Each time the Clock pin changes from low to high, the current state of the Data pin is loaded to position Q0 of the 74HC595 internal register, and Q7S outputs the state from the Q7 register position. Since the output of this register is connected to the input of the next register, we can transfer 32 bits to the register in a sequence. Changing the state of the transmission pin from low to high loads the state of the registers to their output Q0-Q7. The first three registers control the red, green, and blue anodes. The fourth controls the cathode through a logic level MOSFET-N transistor. Why? Because they can each flow through a current of 24*If, which is as much as 480mA.

The state of the matrix is stored in memory in three tables (R, G, and B) of eight bytes each. Each byte represents a column of the matrix. Every five milliseconds (due to the timer interruption), the program assembles a byte, selects one of the eight cathode outputs, and selects three values from the R, G, and B arrays, and sends them together into the register as soon as possible. Finally, the transmission pin becomes higher for a while, loading the loaded data to the output, and the corresponding LED lights up. Interrupt every 5 milliseconds, ensuring that the entire matrix is refreshed 25 times per second. By the way, it's the only perfect program

The running part... Are transistors needed to operate the display or matrix?

No. We can connect the common cathode or anode directly to the output of the microcontroller. The solution works by ensuring that only one LED is lit at a time. Otherwise, we overload the common pins of the diodes and damage the microcontroller. Most microcontrollers allow a maximum current of -25mA per pin, which they brag about in their data sheets. Because only one LED is on at a time and the rest are off, the overall brightness of the entire display decreases.

Matrix and display specific system

There are specialized LED driver systems on the market that can be used either for individual diodes or for displays and LED matrices. The 7400 and 4000 chip series feature from binary or BCD codes up to seven segments"

Leave a Comment