Connecting the LED scale. LM3914N LED scale driver. Using Test Devices

New articles

● Project 4: LED scale 10 segments. Rotate the potentiometer to change the number of illuminated LEDs

In this experiment, we will look at the operation of Arduino analog inputs, the operation of a potentiometer as an analog sensor, and will demonstrate the readings of an analog sensor using an LED scale.

Required components:

In previous experiments, we looked at working with Arduino digital pins; they have only two possible states: on or off, HIGH or LOW, 1 or 0. But to obtain information about the world around us, it is necessary to work with analog data, which has an infinite number of possible values ​​in a given range. To receive analog data, Arduino has analog inputs equipped with a 10-bit A/D converter for analog conversions. The accuracy of the ADC is determined by the resolution. 10-bit means the ADC can divide the analog signal into 210 different values. Therefore, Arduino can assign 210 = 1024 analog values, from 0 to 1023. The reference voltage determines the maximum voltage, its value corresponds to the value of 1023 ADC. At 0V pin the ADC returns 0, the reference voltage returns 1023. Although the reference voltage can be changed, we will use a 5V reference voltage.

Let's look at how to use a potentiometer as an analog sensor. Figure 4.1 shows how to properly connect your

Rice. 4.1. Wiring diagram for a potentiometer as an analog sensor

Potentiometer for Arduino as an analog sensor. We connect one of the outer pins to ground, the other outer pin to +5 V. We connect the middle pin of the potentiometer to the analog input A0 of the Arduino board. To read data from an analog port, Arduino has the analogRead() function.
We load the sketch from Listing 4.1 onto the Arduino board to read values ​​from the analog port and output them to the Arduino serial port monitor.

Const int POT=0 ; int valpot = 0 ; void setup()( Serial.begin(9600 ); ) void loop()( valpot = analogRead(POT); Serial.println(valpot); // output values ​​to serial port delay(500); // delay 0.5 sec }
Connection order:


2. Load the sketch from Listing 4.1 onto the Arduino board.
3. Launch the serial port monitor in the Arduino IDE.
4. Turn the potentiometer knob and observe the output of the analog values ​​of the potentiometer to the serial port monitor (see Fig. 4.2).


Rice. 4.2. Outputting analog potentiometer values ​​to a serial monitor

Now let's visualize the analog potentiometer data using a 10-digit linear LED scale. The scale is an assembly of 10 independent LEDs with cathodes on the side of the inscription on the body. To connect the scale to Arduino we will use 10 digital pins D3-D12. The connection diagram is shown in Fig. 4.3. Each of the scale LEDs is connected with the anode pin to the Arduino digital pin, and the cathode to ground through a series-connected 220 Ohm limiting resistor. We scale the analog potentiometer data (0-1023) into scale data (0-10) using the map() function and light the corresponding number of LEDs. The sketch is shown in Listing 4.2.

const int POT=0 ; // Analogue input A0 for connecting a potentiometer int valpot = 0 ; // variable to store the potentiometer value // list of contacts for connecting the LED scale const int pinsled=(3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ); int counts = 0 ; // variable to store the scale value void setup()( for (int i=0 ;i<10 ;i++) { // Configure scale connection pins as outputs pinMode(pinsled[i],OUTPUT); digitalWrite(pinsled[i],LOW); ( ) void loop()( valpot = analogRead(POT); // read potentiometer data // scale the value to the range 0-10 counted=map(valpot,0,1023,0,10); // light up the number of bars on the scale equal to counted for (int i=0 ;i<10 ;i++) { if (i// light up the scale LED digitalWrite(pinsled[i],HIGH); else // turn off the scale LED digitalWrite(pinsled[i],LOW); ) )

Connection order:

1. Connect the potentiometer according to the diagram in Fig. 4.1.
2. We connect the leads of the LED scale with the anode contacts through limiting resistors with a nominal value of 220 Ohms to the Arduino D3-D12 pins, and the cathode contacts to the ground (see Fig. 4.3).
3. Load the sketch from Listing 4.2 onto the Arduino board.
4. Turn the potentiometer knob and observe on the LED scale the level of the potentiometer value from the maximum value.

Today, there are hundreds of varieties of LEDs, differing in appearance, glow color and electrical parameters. But they are all united by a common principle of operation, which means that the connection diagrams to the electrical circuit are also based on general principles. It is enough to understand how to connect one indicator LED and then learn how to create and calculate any circuits.

LED pinout

Before we consider how to properly connect an LED, you need to learn how to determine its polarity. Most often, indicator LEDs have two terminals: anode and cathode. Much less often, in a case with a diameter of 5 mm, there are specimens that have 3 or 4 terminals for connection. But it’s also not difficult to figure out their pinouts.

SMD LEDs can have 4 outputs (2 anodes and 2 cathodes), which is due to their production technology. The third and fourth pins can be electrically unused, but used as an additional heat sink. The pinout shown is not standard. To calculate the polarity, it is better to first look at the datasheet and then confirm what you see with a multimeter. You can visually determine the polarity of an SMD LED with two terminals by looking at the cut. The cut (key) in one of the corners of the housing is always located closer to the cathode (minus).

The simplest LED connection diagram

There is nothing easier than connecting an LED to a low-voltage DC source. This could be a battery, accumulator or low-power power supply. It is better if the voltage is at least 5 V and no more than 24 V. Such a connection will be safe, and to implement it you will only need 1 additional element - a low-power resistor. Its task is to limit the current flowing through the p-n junction at a level not higher than the nominal value. To do this, the resistor is always installed in series with the emitting diode.

Always maintain correct polarity when connecting an LED to a constant voltage (current) source.

If a resistor is excluded from the circuit, then the current in the circuit will be limited only by the internal resistance of the EMF source, which is very small. The result of such a connection will be instant failure of the emitting crystal.

Calculation of the limiting resistor

Looking at the current-voltage characteristic of the LED, it becomes clear how important it is not to make a mistake when calculating the limiting resistor. Even a slight increase in the rated current will lead to overheating of the crystal and, as a result, to a decrease in operating life. The choice of resistor is made according to two parameters: resistance and power. Resistance is calculated using the formula:

  • U – supply voltage, V;
  • U LED – forward voltage drop across the LED (nameplate value), V;
  • I – rated current (certificate value), A.

The result obtained should be rounded up to the nearest value from the E24 series, and then calculate the power that the resistor will have to dissipate:

R – resistance of the resistor accepted for installation, Ohm.

More detailed information about calculations with practical examples can be found in the article. And those who do not want to dive into the nuances can quickly calculate the resistor parameters using an online calculator.

Turning on the LEDs from the power supply

We will talk about power supplies (PSUs) operating from a 220 V AC network. But even they can differ greatly in output parameters. It can be:

  • AC voltage sources, inside of which there is only a step-down transformer;
  • unstabilized direct voltage sources (DCS);
  • stabilized PPI;
  • stabilized direct current sources (LED drivers).

You can connect an LED to any of them by adding the necessary radio elements to the circuit. Most often, stabilized power supply voltages of 5 V or 12 V are used as a power supply. This type of power supply means that in the event of possible fluctuations in the network voltage, as well as when the load current changes within a given range, the output voltage will not change. This advantage allows you to connect LEDs to the power supply using only resistors. And it is precisely this connection principle that is implemented in circuits with indicator LEDs.
Powerful LEDs must be connected through a current stabilizer (driver). Despite their higher cost, this is the only way to guarantee stable brightness and long-term operation, as well as to eliminate premature replacement of an expensive light-emitting element. This connection does not require an additional resistor, and the LED is connected directly to the driver output subject to the following conditions:

  • Driver I - driver current according to the passport, A;
  • I LED - rated current of the LED, A.

If the condition is not met, the connected LED will burn out due to overcurrent.

Serial connection

Assembling a working circuit using one LED is not difficult. It's another matter when there are several of them. How to correctly connect 2, 3... N LEDs? To do this, you need to learn how to calculate more complex switching circuits. The series connection circuit is a chain of several LEDs, in which the cathode of the first LED is connected to the anode of the second, the cathode of the second to the anode of the third, and so on. A current of the same magnitude flows through all elements of the circuit:

And the voltage drops are summed up:

Based on this, we can draw conclusions:

  • It is advisable to combine only LEDs with the same operating current into a series circuit;
  • if one LED fails, the circuit will open;
  • The number of LEDs is limited by the power supply voltage.

Parallel connection

If you need to light several LEDs from a power supply with a voltage of, for example, 5 V, then they will have to be connected in parallel. In this case, a resistor must be placed in series with each LED. Formulas for calculating currents and voltages will take the following form:

Thus, the sum of the currents in each branch should not exceed the maximum permissible current of the power supply unit. When connecting LEDs of the same type in parallel, it is enough to calculate the parameters of one resistor, and the rest will be of the same value.

All rules for serial and parallel connection, illustrative examples, as well as information on how not to turn on LEDs can be found in.

Mixed inclusion

Having understood the serial and parallel connection circuits, it's time to combine. One of the options for combined LED connection is shown in the figure.

By the way, this is exactly how every LED strip is designed.

Connection to AC mains

Connecting LEDs from a power supply is not always advisable. Especially when it comes to the need to backlight a switch or indicate the presence of voltage in the power strip. For such purposes, it will be enough to assemble one of the simple ones. For example, a circuit with a current-limiting resistor and a rectifying diode that protects the LED from reverse voltage. The resistance and power of the resistor are calculated using a simplified formula, neglecting the voltage drop across the LED and diode, since it is 2 orders of magnitude less than the mains voltage:

Due to the high power dissipation (2–5 W), the resistor is often replaced with a non-polar capacitor. Working on alternating current, it seems to “extinguish” excess voltage and hardly heats up.

Connecting flashing and multi-color LEDs

Externally, flashing LEDs are no different from conventional analogues and can flash in one, two or three colors according to the algorithm specified by the manufacturer. The internal difference is the presence of another substrate under the housing, on which the integrated pulse generator is located. The rated operating current, as a rule, does not exceed 20 mA, and the voltage drop can vary from 3 to 14 V. Therefore, before connecting a flashing LED, you need to familiarize yourself with its characteristics. If they are not there, then you can find out the parameters experimentally by connecting to an adjustable power supply at 5–15 V through a resistor with a resistance of 51–100 Ohms.

The multi-color case contains 3 independent crystals of green, red and blue. Therefore, when calculating resistor values, you need to remember that each glow color has its own voltage drop.

Once again about three important points

  1. Direct rated current is the main parameter of any LED. By lowering it, we lose brightness, and by overestimating it, we sharply reduce the service life. Therefore, the best power source is an LED driver; when connected to it, a constant current of the required value will always flow through the LED.
  2. The voltage given in the datasheet for the LED is not decisive and only indicates how many volts will drop at the p-n junction when the rated current flows. Its value must be known in order to correctly calculate the resistor resistance if the LED will be powered by a conventional power supply.
  3. To connect high-power LEDs, it is important not only to have a reliable power supply, but also to have a high-quality cooling system. Installing LEDs with a power consumption of more than 0.5 W on the radiator will guarantee their stable and long-term operation.

Read also

LED scale driver chip LM3914.

Based on this microcircuit, LED indicators with a linear scale can be designed. The LM3914 chip is based on 10 comparators.

The input signal through the operational amplifier is supplied to the inverse inputs of the LM3914 comparators, and their direct inputs are connected to a resistor voltage divider. LEDs are connected to ten outputs of the comparators.

The microcircuit has a choice of display mode, column or dot mode, that is, as the signal level changes, moving along the ruler, only one LED lights up.

LM3914N pins:

10…18 - outputs.

2 - minus power.

3 - plus power supply from 3...18 volts.

4 - voltage is applied to this pin, the value of which determines the lower indication level. Acceptable level from 0 to Upit.

5 - an input signal is supplied to this pin.

6 - voltage is applied to this pin, the value of which determines the upper level of indication. Acceptable level from 0 to Upit.

7, 8 - terminals for regulating the current flowing through the LEDs.

9 - pin is responsible for the display operating mode (“dot” or “column”)

The LED switching threshold is calculated automatically by the microcircuit using the formula Uv. – Un.)/10

Operation of the indicator on the LM3914N chip

While on the leg Uin. the signal is lower than the voltage at the Un pin, the LEDs do not light up. As soon as the input signal equals Un. – LED HL1 will light up. With a subsequent increase in the signal, in the “dot” mode, HL1 turns off and HL2 lights up at the same time. If the LM3914 operates in the “column” mode, then when HL2 is turned on, HL1 does not go out. To select one of the two operating modes, do the following:

  • “Point” mode - connect pin 9 to the power supply minus or leave it unconnected.
  • Column mode - connect pin 9 to the positive power supply of the microcircuit.

The problem is that this set has already been discontinued, so you will have to improvise and purchase spare parts separately. It is worth especially noting that the basis of the circuit is the UAA180 chip or the domestic analogue 1003PP1. Knowing now this will not be difficult for you assemble with your own hands devices with LED scale for your car.

Purpose of the microcircuit pins:
1 – earth;
18 – power supply up to +18 Volts;
17 – input for measured voltage;
16 – reference lower level of measured voltage;
3 – reference upper level;
2 – LED brightness control;
4..15 – outputs for controlling the inclusion of LEDs.

The microcircuit divides the voltage difference between the 3rd and 16th legs into 12 ranges, and if the voltage on the 17th leg falls into one of these ranges, the corresponding LED lights up. However, there are restrictions: the voltage at the measuring terminals cannot be more than 6 Volts.
To limit the measured voltage, we assemble a measuring chain of a zener diode and two resistors. Let V be the voltage in the on-board network. In a chain of zener diode VD1 and resistances R1, R2, the voltage on the zener diode will be constant 9 Volts (approximately), and on the bridge R1, R2 it will be equal to (V-9). With equal resistances R1=R2, the voltage across resistance R2 will be equal to half (V-9), i.e. if the network voltage V changes from 10 to 15 Volts, then the voltage at the point between R1 and R2 will change from (10-9)/2 =0.5 to (15-9)/2 =3 Volts.
The chain R3, R4, R5 and the zener diode VD2 set the reference minimum and maximum voltage. Minimum zero, because 16th foot on the ground. The maximum is set by a trimming resistor at about 3 Volts. With this setting, it is possible to measure the voltage of the on-board network in the range from 9 to 15 Volts in increments of 0.5 Volts per LED.
The R6, R7 chain simply sets the brightness of the diodes. At R6=50K the brightness is greater, at 100K it is less.

The variants of circuits with a “running dot” and “luminous pillar” scale differ only in the connection of LEDs to the microcircuit. The measuring circuits remain the same.

The scheme is configured as follows. The voltmeter needs to be connected to a 14.7V reference source, turn the trimmer so that the column of 11 LEDs lights up, then slowly turn the trimmer in the opposite direction until the 11th LED goes out and only 10 LEDs remain on in the column.
It is assumed that the scale has a scale of 2 LEDs per 1 Volt, and turning on the 11th LED corresponds to the measured voltage reaching a level of 14.7V as shown in the figure below.

Above the LEDs in the front panel of the voltmeter there are color markings of voltage ranges:
up to 11.6V - red, battery charge less than 50%;
11.6-12.6V - red dotted line, battery charge 50-100%;
12.6V - green dot, charge 100%;
13.7-14.7V - green, generator voltage is normal;
more than 14.7V - red, overcharge.

The circuit was soldered in the “luminous pillar” version. The picture below shows a general view of what happened. I made the lighting with one baseless 12V car light bulb.

Everything was assembled approximately as in the picture below.

Board drawing. Made in a mirror image to transfer the print onto the foil for etching. If you print at a density of 300 dpi, you get an image on a scale of 1:1.

Placement of parts. View from the side of installation of radio components. The tracks are actually on the other side of the board, but here they are drawn visible, as if the board were transparent.

While operating the device on the vehicle, a flaw was discovered.

Due to the discreteness of the scale, the last LED in the luminous column often operates in flickering mode. Not always, but often. At first, the blinking distracts attention, but then you get used to it, and the blinking is perceived as an attempt by the device to depict half a division of a discrete scale.

Fuel level indicator

The fuel gauge is actually an ohmmeter and measures the resistance of the rheostat sensor. If you connect a variable solenoid to the pointer, then its readings should correspond to the following:
0 Ohm – the arrow lies on the left edge of the scale;
15 Ohm – arrow on the border of the red and white zones;
45 Ohm – arrow on line 1/2;
90 Ohm – arrow on line 1;
when the arrow breaks, the pointer is on the right edge of the scale;

From the previous diagram, a fairly simple diagram of the fuel level indicator is obtained, because a voltmeter can be used as an ohmmeter, which measures the voltage across a resistance through which a stabilized current flows.

With this connection, the 78L03 stabilizer operates as a 30 mA current source. A 3V zener diode is needed to protect the measuring input of the microcircuit from overvoltage in the event of a “break” in the sensor wire. If the sensor short-circuits, the readings should be the same as for an empty tank.
Chain R3, C3 slows down the change in voltage at measuring input 17 of the UAA180 microcircuit. The chain time constant is about 2 seconds. Such a slowdown should prevent jumps in the readings of the device when the sensor float fluctuates along with the gasoline level while driving.
To configure the device, instead of a rheostat sensor, you need to connect a 90 Ohm resistance and, by rotating the trimming resistor, find the moment when the full luminous column turns on.
The picture below shows the front panel of the pointer.

After installing the devices on the car, a flaw in the operation of the fuel remaining indicator was noticed.
When the tank is full, everything is fine, but when the tank becomes more than half empty, then while driving (in turns, or when accelerating/braking), the readings can change by 3 divisions (and this is a quarter of the scale!), for example, from 1 to 4 LEDs. Obviously, this is due to the pouring of gasoline over a horizontally located tank under the influence of inertial forces. How to deal with this is not yet very clear.

Board drawing.

Placement of parts.

Thermometer

In the books they write that the dependence of the resistance of a working TM-100A sensor (standard sensor on UZAM) on temperature should be as follows:

Degrees – Ohms 40 – 400...530 80 – 130...160 100 – 80...95 120 – 50...65

The relationship is inverse, and not linear. But the sensor is ratiometric type. Such a sensor ensures a change in the current in the pointer winding in proportion to the measured value. An interesting thing turns out: if such a sensor is connected in series with a correctly selected additional resistance (equal to the resistance of the meter winding), a stabilized voltage is applied to this chain, then the voltage at this additional resistance will be proportional to the temperature. This additional resistance is approximately 150 ohms. Due to the fact that the temperature sensor must be installed on ground, the circuit did not turn out to be simple. What happened is shown in the figure.

Explanation for those who want to understand the circuit.
The diagram is made inside out. Imagine a watch in which the clock hand always points up and the dial rotates under the hand. The 17th leg, which should be connected to the measured voltage, is connected to a stabilized 3 Volts. Difference of measured min. and max. The voltage between the 16th and 3rd legs is also stabilized, about 3 Volts, but the voltages on the 16th and 3rd legs change synchronously, “floating” around the voltage on the 17th leg. In general, the circuit works in such a way that the LED scale readings correspond to the voltage across resistor R3. Bridges with zener diodes are needed to maintain the voltage boundaries of the measured range.

However, it turned out that in the thermometer circuit it is possible to do without stabilization at all. Below is a much simpler diagram. It is based on the fact that no matter how the supply voltage of the circuit changes at a constant temperature, the proportion of voltages at the inputs of the microcircuit U16:U17:U3 will remain constant. The absolute values ​​will change, but their relationship to each other will not.

Bridge R4-R5-R6 sets the boundaries of the measured range. Trimmer R1 allows you to shift the readings up or down. Resistance R3 is necessary to lower the supply voltage to a level at which the voltage at the DA1 inputs will not exceed the maximum permissible 6V.

This scheme can only be used in the luminous dot mode. The fact is that at a minimum temperature the voltage measured in this circuit is maximum. As the temperature increases, the voltage decreases to a minimum. In order for the luminous point to move along the scale from left to right with increasing temperature, and not vice versa, it is enough to arrange the LEDs on the indicator in the reverse order. But this is only possible for a luminous point. The luminous pillar does not light up in reverse order.

To “flip” the voltage relative to the middle of the measured range, you can add an operational amplifier inverter to the circuit.

The resistance values ​​that set the voltages at inputs 3 and 16 are selected in such a way that the full scale of 12 LEDs corresponds to a range of 80°C.

The circuit is configured as follows. You can lower the temperature sensor into boiling water, or instead of the sensor, connect a resistance of 91 Ohms to the circuit and use a trimming resistor to find the moment when the glowing column switches from 10 to 11 LEDs, which should correspond to the boiling point of water - 100 ° C.

In general, the resistance values ​​and settings should correspond to the front panel of the thermometer like this.

The thermometer had such a flaw.

Because The scale was calculated on a scale of 3 LEDs at 20°C, then one diode covers a range of approximately 7 degrees. If 10 diodes light up on the scale while driving, then the temperature can be from 93 to 100 ° C, but it is impossible to say exactly how much. At the same time, a car thermometer does not need an extended left part of the scale for low temperatures. Therefore, when repeating the design, it would be better to make a thermometer with a scale of 5°C per diode, for example, from 50 to 110°C, as in the figure below.

Board drawing.


LED scales are often used to monitor voltage.
Let's consider several ways to construct such schemes.
Passive scales are powered by a signal source and have the simplest circuit.


This could be a car voltmeter. Then VD8 should be selected for 12 volts, since it sets the illumination voltage of the first LED on the scale. The following LEDs VD2 - VD4 are connected via diode transitions VD5-VD7. The drop across each diode averages 0.7 volts. As the voltage increases, the LEDs will turn on one by one.
If you put two or three diodes in each arm, the voltage scale will stretch the corresponding number of times.


According to this scheme, a battery indicator from 3V to 24V is built

Another way to build a line of diodes.


In this circuit, the LEDs light up in pairs, the switching step is 2.5 volts (depending on the type of LED).
All of the above circuits have one drawback - very smooth illumination of the LEDs as the voltage increases. For sharper switching, transistors are added to such circuits in each arm.

Now let's look at the active scales.
There are specialized microcircuits for this purpose, but we will consider more affordable elements that most people have on hand. Below is a diagram of logical repeaters. Logic chips 74ls244, 74ls245 for 8 channels are suitable here. Don’t forget to supply +5 volt power to the microcircuit itself (not indicated on the diagram).


Response threshold of the first element DD1
equal to the logical level for a given series of chips.

If we use inverters of the type K155LN1, K155LN2, 7405, 7406 in such a circuit. The connection will be as follows:


The advantage is that in such a circuit the output works with an open collector, this allows the use of ULN2003 and the like in the assembly circuit.
Well, the last thing is the implementation of a running point on logical elements 4i-not.

The logic works in such a way that each element, when turned on, prohibits the operation of all elements of the lowest number. K155LA6 microcircuits are used in this circuit. The last two elements DD3 and DD4, as can be seen from the diagram, can have two inputs, for example: K155LA3, K155LA8.
For battery devices, it is advisable to use low-power analogues from the 176 and 561 series of microcircuits.

 
Articles By topic:
Anatomy of Google Search Deliver accurate and relevant results
Hello friends! As you know, search engines for many sites are the main source of visitors. One of the options for increasing traffic from search engines is to work on a project to optimize it in search results. Today I'll look at everything
Register on Facebook and log in to your page
06/29/13 47.9K Want to sign up for Facebook to meet new people and have new experiences, but don't know where to start? - We will be happy to help you - registration on Facebook takes only a few minutes. It is important to remember that the site does not charge
Review and technical specifications of the Samsung Galaxy E5 smartphone What to do next
Samsung Galaxy E5 is the standard of the middle class of the modern Samsung lineup. This model has gained popularity among users for several reasons: the first is its stylish design and monolithic construction, the second is quite productive
Additional memory for tablets and smartphones
Kingston's DataTraveler microDuo drives feature a compact form factor and provide additional storage for tablets and smartphones that support USB OTG (On-The-Go) functionality. The USB OTG standard allows you to directly connect mobile devices