The Classroom

The LM3914 IC

Driving LED Bargraph Displays

Daniel Koch

Issue 26, September 2019

Learn how the LM3914 IC can be used to create a useful visual display in your next project.

This handy integrated circuit (IC) takes a voltage at its input and drives a bar graph of LEDs to reflect the level of the input. Used for far more than audio level displays, this device can indicate the level of almost anything you need a visual for.

The LM3914 is, in fact, one of a pair of devices, the other being the LM3915. The difference is that the LM3914 gives a linear response, suitable for most applications, while the LM3915 gives a logarithmic response, which is suitable for audio signals. Audio signal level meters are well described and circuits for them abound, so we will concentrate on the linear version.

We will cover the geometry of the LM3914, then learn more about certain pin functions, how to set the LED current, how to scale the input for different signal ranges, and then explore a soil moisture meter circuit that you can build.

Downloading a copy of the datasheet for this IC will be helpful as you read. The datasheet can be downloaded from the TI website: http://www.ti.com/product/LM3914

Note: All voltages stated are DC, unless otherwise noted.

GETTING TO KNOW THE LM3914

SPECIFICATIONS:
Supply Voltage <3V to 25V
Internal Reference Voltage 1.2V to 12V
Inputs Rated to 35V without damage, operate down to ground
Input Range (Functional) 0 to 12V
Output Current Programmable from 2mA to 30mA
Output Type Current-limited open-collector NPN

The LM3914 is usually available from electronics retailers in an 18-pin Dual In-line Plastic (DIP) package. As with all DIP or DIL (Dual In-Line) ICs, pin 1 is marked with either a dot recessed into the case, or with a notch at the end.

PIN 1: The connection for LED No.1. It is the only LED connection on this side of the IC.

PIN 2: The ground connection, but within the Texas Instruments datasheet (one of several manufacturers for this device), this pin is labelled either ground or ‘V-’, depending on where it is in the document.

PIN 3: Marked ‘V+’ and is the power supply connection. More on this later, as there are quirks.

PIN 4: Labelled as ‘RLO’, which represents Reference Low. This is the lower limit that the internal voltage divider works to, and is usually connected to ground as the lowest reference. It can be altered with a voltage divider to change the range with which the device measures.

PIN 5: The input for the signal being measured. It is labelled as ‘SIG’ in most datasheets, but sometimes ‘In’ is used here and there.

PIN 6: Marked ‘RHI’, for Reference High, and is the upper limit of the internal voltage divider. This is usually tied to the reference out pin, described next, but again, can be controlled to change the behaviour of the device.

PIN 7: Marked ‘REF OUT’, which supplies a reference voltage out. This does two jobs, and as described later, the external resistors connected here set the LED current.

PIN 8: The reference adjustment pin, labelled ‘REF ADJ’. This enables, via a resistor, to alter the reference voltage, and so vary the input signal range.

PIN 9: The ‘MODE’ pin. If this pin is connected to the V+ pin 3, (the datasheet has the word ‘directly’ in italics), then the device operates in bar mode, where the LEDs light cumulatively from 1 to 10, so that for a given signal level, all the LEDs before it are lit as well. If Pin 9 is left unconnected, the device operates in dot mode, whereby only the LED representing the level in question is lit, while those behind it and in front are not lit.

That’s the first side of the IC. The other side, with the remaining nine pins, are all LED connections, from LED No.2 to LED No.10. As you may have noticed, this device has the LED anodes (+) connected from a supply rail, with the cathodes (-) connected to the device pins. This is because the LM3914 and LM3915 have active low outputs. That is, when the output is activated, it goes low, allowing current to flow through to ground. You can see why in the functional block diagram.

Functional block diagram.

This shows that the incoming signal is fed to a buffer, which then parallel feeds the inverting inputs of ten comparators. The non-inverting input of each comparator is connected to a different section of the voltage divider made up of 1kΩ resistors. The output of each comparator is connected to the base of an NPN transistor, which has its emitter connected via a resistor (not shown) to ground, and its collector open, connected to the LED pins of the IC. Hence, the connection of the LEDs with anode to supply, and cathode to the pin. Of course, there is a lot more going on inside the IC, but functional block diagrams are necessarily simplified.

SOME DISCREPANCIES

Throughout the datasheets from the main manufacturers, we found some variations worth mentioning. The first has been noted, that being the different labelling of the ground pin, which appears with the letters ‘GND’, ‘V-’, or the electrical symbol for ground, depending on where it is found. The reality is, datasheets are a collaborative work and this reflects the different standards that exist in the industry. All the different labels mean the same thing in this case.

Of more concern is the voltage to the LEDs. Most diagrams show the IC with ten LEDs connected, even in the functional block diagrams which generally don’t show external components, except when there is a specific need. The challenge, however, is in the way they are supplied. The LM3914/15 both feature internal current limiting for the LEDs, and the first page introduction in most manufacturers’ datasheets makes a point that no resistors are required.

However, in some places, the LEDs are shown supplied by a separate supply voltage, marked ‘V+LED’ among other denotations. The tables showing electrical characteristics and parameters also make reference to LED supply voltage, often, but not always, given as 5V.

In other places, the LED anodes are shown connected in parallel to the same supply voltage that the IC runs on, which has a range well above 5V. One of the first ‘typical application’ diagrams in the Texas Instruments datasheet, a 0-5V bar graph voltmeter, shows the use of ‘VLED’, while Figure 17, an expanded scale meter on page 13 of the same datasheet, shows a full-wave rectified 10V AC transformer supplying the LEDs, and a separate 8V DC supplying the IC.

There are more references to separate LED power supply throughout the datasheet, which implies that this is common practice. However, at no point is this described as recommended practice, or its necessity described.

Meanwhile, Figure 19 in the same datasheet shows the LEDs supplied via a 3V rail which also supplies the IC, while Figure 20 on page 15 of the datasheet shows the same arrangement with a 5V rail. Furthermore, while many LEDs will comfortably operate on 3V (remember, the LEDs are current-limited inside the IC), 5V is high for many, even when current-limited. The LM3915 (the logarithmic version) datasheet from National Semiconductor shows, on page 15, a vibration sensor circuit that states the common LED and IC supply as 3-20V. On top of that, Jaycar has been selling for years a kit in their Short Circuits range which has the LEDs supplied directly from the 9V battery.

All of this is rather unsettling. So, with no firm answers, we set about a bench test. A circuit was breadboarded to read a signal between 0 and 3V, powered from a 12V supply, with the LEDs connected to the 12V. The LEDs were garden-variety 2V, 20mA red diffused, while the IC was set to supply 22mA. This was left for nine hours with an input of 1.9V lighting LED 6. A 2.6V drop was measured across the LED, while it was demonstrated to draw 21.6mA. This situation remained across the day, with no change in LED voltage or current measurements (which would indicate a failure, overheating, or degradation), and no loss of brightness. For fire safety reasons in the building, we turn power off to the workbench at night, but we hazard a collective guess that it would run overnight and all week too.

This test, in conjunction with the other evidence, suggests that both options will work. The reality is that if your end-use features highly sensitive LEDs, such as some low-current ultra-brights, or will have supply fluctuations, the addition of a voltage regulator for a separate LED supply voltage may be useful, but for most purposes, supplying the LEDs from the general supply rail is fine.

It is also worth noting here that in several of the diagrams in the datasheets, a 2.2μF tantalum or 10μF electrolytic capacitor is specified between the LED rail and ground. This is used for situations where the LEDs are to be mounted away from the board on leads 150mm or longer.

This is because the IC has circuitry inside it to detect any current variations and regulate according, which in turn, allows the IC to function from relatively noisy supplies for the LEDs. The datasheets recommend this capacitor be connected near LED 1's anode, and routed straight to pin 2, not the general ground rail. This helps stabilise the overall IC circuitry in these conditions. It is not needed when well-filtered power supplies are used with LEDs connected close to the IC.

On top of that, it has always been considered good practice to have filter capacitors on power supply rails anyway. In recent years this has become less common, with the rise of tightly-regulated switchmode power supplies, including some that mount straight to breadboards. The widespread use of battery power for projects has also reduced this need. In testing, we powered our circuit from a lab power supply designed to be as smooth as possible.

REFERENCE VOLTAGE

The reference voltage can be programmed from between 1.2V and 12V. Unless the voltage divider is being externally manipulated, RLO is connected to ground and the voltage reference is fed to the RHI input. These are the two ends of the voltage divider, which divides the reference voltage into ten equal voltages, determining the threshold for each step of the display. For example, at 1.2V reference, each LED represents 120mV if input signal increases. If the reference voltage was set to 12V, each LED would represent a 1.2V increase in the input signal.

The REF OUT pin has a constant, nominal 1.25V between it and ground.

Calculating the voltage reference requires some maths set out below, that isn’t as scary as it looks to many. Just remember your order of operations: brackets and orders (powers) first, then division and multiplication, then addition and subtraction. Remember, when items are simply next to each other, this represents multiplication, and that any number has to be in its base unit, e.g., 75μA becomes 0.000075A.

VOUT = VREF + IADJR2

Where VOUT is the range that you want to measure across, VREF is the nominal 1.25V, R2 and R1 are the resistors shown. IADJ is given in the data sheet as 75μA typical, 120μA maximum.

For our test circuit, we wanted a 3V range, which is VOUT = 3V. We ended up using a 750Ω resistor for R1 which measured at 744Ω, a 1kΩ resistor for R2 which measured at 993Ω, and the typical value for IADJ, 75μA. Plug the numbers in and see what you get. We ended up with 2.992V (rounded), which is pretty close. We measured between pin 7 and ground, and found 2.973V with a multimeter.

These numbers are close enough to our target given the variables and inaccuracies like the quality of the contact between meter probe and pin, that kind of thing. Before you launch into this maths however, read on for a simple bypass that will work for those who need to get close to the mark before using the more complex formula above.

CURRENT SETTING

The current drawn across the two resistors described in the voltage reference section also determines the current through the LEDs. The current through the LEDs will be ten times whatever is drawn from pin 7, the Ref Out pin. This adds another layer of complexity to the design at first glance, but it actually makes the maths a bit simpler if you’re not up to large equations like those above, and specifically, good at transposing them.

For our LEDs, we wanted a current of 20mA. That means the current through the resistors at pin 7 has to be 2mA, as above. We also know that we want (in our test case) a voltage range of 0- 3V for our input, which is what VOUT represents in the equation above. This allows us to get pretty close to the mark using Ohm’s Law:

R = V/I

R = 3/0.002

R = 1500Ω

This 1500Ω is made up of both resistors R1 and R2. Because we know we want a drop of 1.25V across R1 for our reference voltage, we can calculate again, by using some more basic maths. The 1.25V is a proportion of the 3V, so the value R1 that causes it is a corresponding proportion of the total 1500Ω.

R1 = (R1+R2) x (VREF/VOUT)

R1 = 1500 x (1.25/3)

R1 = 1500 x 0.41666

R1 = 625Ω

That leaves R2, which can be found by subtracting 625Ω from 1500Ω, leaving 875 for R2. This maths gets you pretty close to the mark, and with some substituting of near values, it will get you where you need to be if you’re not there already.

MANIPULATING THE VOLTAGE DIVIDER

There is another way to make the LM3914 do what you want it to. Because the ends of the voltage divider terminate at pins which we usually tie to ground and the reference voltage, we can in fact connect them another way.

If you were to connect an external voltage divider to the RHI pin, you would be setting the upper limit of the divider independent of the reference voltage (which you still need to set for the current limit in the LEDs and other functions).

If you were to tie the RLO pin to an external voltage divider as well, you would be able to set the range of the input, and its upper and lower limits. This means that you could create a voltage range somewhere in the middle of a bigger range. For example, if you had a signal that varied between 0 and 12 volts but you were only interested in the 6V to 9V part of the signal. Or, perhaps your sensor has a minimum output, say 3V, at its lowest value in the application you have it in. Connecting external voltage dividers to the RHI and RLO pins allows you to factor this in.

Regular voltage divider maths features here. When connecting two resistors between supply and ground, the voltage at their junction will be proportional to their values. In other words, if the resistors are equal, then half the voltage drops across each and the voltage at their junction is half the supply. If the value of the first resistor is one quarter of the total value of the two, then only one quarter of the voltage drops across it, and the voltage at the junction will be three quarters of the supply.

The maximum voltage that can be fed to RHI is 1.5V less that the supply voltage. This must be considered in any external manipulation of the voltage divider if it is to work correctly. If this is fed incorrectly, you will not get an accurate display, if any.

CASCADING

The LM3914 has the ability to be cascaded in dot mode so that displays bigger than 10 units can be created. It is not possible to terminate the chain (i.e., make a 15-unit display) in any less than multiples of 10. This means that you can produce a display with twenty, thirty, or even one hundred units. Note, however, that the input range is still 0-12V across all stages, so if you did cascade ten LM3914s, each would need to be set up to display 1.2V of the total.

To make this work, the voltage reference adjust pins (Pin 8) are shown in the datasheet application circuits to not have a resistor between pin 8 and pin 7, instead being tied to ground for the first stage, and to the REF OUT (pin 7) of the previous stage for those that follow. Note also that the resistor value to set REF OUT also changes.

Because the REF ADJ is fed from the previous stage, the second resistor is not needed. The resistor values shown, taken from Texas Instruments’ datasheet, set an LED current of 10mA. See the diagram for more details, it is derived from the Texas Instruments datasheet again, but has some features altered.

It is also important to remember the arrangement of the LEDs for cascading stages, as it's different to previous arrangements. There is a 20kΩ resistor between supply and pin 11, in parallel with LED number 9 (pin 11), on all but the final stage. In the final stage, pin 11 is connected directly to pin 9. Pin 9 itself is connected to pin 1 of the next driver in parallel with LED number 1, as shown.

A NOTE ABOUT DISPLAY MODULES: One interesting point gleaned from the datasheet is that the Bar/Dot mode can be used to trigger a visual alarm. The circuit shows that if the output of LED No.10 is connected in parallel to a PNP transistor, the whole display will switch from dot to bar mode when LED 10 lights. This will provide a very obvious visual reference that the scale has been maxed. Component values may need altering depending on your supply voltage and transistor. These values worked on our test bench but for an input of 0-1.2V.

Hands On:

LED Bargraph Display

Parts Required:JaycarAltronicsCore Electronics
1 × Small BreadboardPB8820P1002CE05102
1 × Wire LinksPB8850P1014ACE05631
3 × Plug to Socket Jumper WiresWC6028P1017PRT-12794
1 × LM3914 Linear Display DriverZL3914Z2670COM-12694
1 × Blue 5mm LEDZD0180Z0869CE05103
2 × Orange 5mm LED-Z0804CE05103^
4 × Green 5mm LEDZD0172Z0864CE05103
2 × Yellow 5mm LEDZD0162Z0867CE05103
1 × Red 5mm LEDZD0150Z0863ACE05103
2 × 10kΩ TrimpotsRT4650R2382ACOM-09806
1 × 620Ω Resistor*RR0567R7553COM-05092
1 × 24Ω Resistor*RR0533R7519COM-05092
1 × DF Robot Capacitive Soil Sensor--SEN0193

Parts Required:

* Quantity shown, may be sold in packs.

^ Use the white LEDs in this pack instead of orange.

The features of our circuit have already largely been explained. It is a single stage, 10-LED display calibrated to display a range from 0V - 3V. This matches the signal from DF Robot’s capacitive soil moisture sensor. Capacitive sensors escape the corrosion issues that plague resistive sensors of the type traditionally used to sense soil moisture. The LEDs are coloured so that they show ‘Too wet’, ‘getting too wet’, ‘ok’, ‘drying out’, and ‘too dry’. We haven’t produced a PCB for this. If you do wish to make your project permanent, we suggest using one of the prototyping boards on the market that are the same layout as a breadboard. Jaycar’s HP9570 is an example.

The circuit is similar to that which we described in the ‘voltage reference’ section. It features the two trimpots to set the reference voltage and LED current, ten LEDs, the LM3914, and two voltage dividers.

During testing, it became obvious that the stated range of 0-3V for the sensor was never going to happen. When immersed in water, the sensor gives a voltage of 1.2V. When wiped dry and sat on the wooden bench, it gave a 2.5V output. This meant that external voltage dividers had to be used to feed RHI, which needs to be at 2.5V, and RLO, which needs to be at 1.2V. To get these values, 10kΩ trimpots were used.

If the device will be located in a garden, it can be powered by a solar set-up or a battery. The addition of a 5V regulator will be required. We suggest a switchmode module for this, as they are more efficient and versatile than the linear version you could build. If you’re going to provide your project with 5V, don’t worry about the regulator.

CONSTRUCTION

Building it is straightforward, mainly due to the low component count. Follow the schematic and Fritzing closely.

When installing the LEDs, note their colours, and the fact that the anodes insert into the supply rail.

The DF Robot sensor requires 3.3 - 5V, and as such, we’re powering the whole circuit with 5V. The sensor features a locking header socket for connection, and a cable is supplied with the locking header connection on one end, and the usual PCB headers at the other. The circuit board from the soil line up also needs to be waterproofed, as it is supplied as a regular board. You could cut a slot in a small project enclosure, or 3D print a case. You could also just drown the whole thing in synthetic sealant down to the soil line, but be careful to use a neutral, non-corrosive product.

The diagram shows resistors of 620Ω and 24Ω for the voltage reference/current setting. These were found using the simplified maths above, which yielded values of 625Ω and 25Ω. The more complex equation was used to verify the values.

This gave us the required current for our LEDs, but your application may be different, and if it is, the relevant sections of the article above will get you to where you need to be.

TESTING

You may find in use that you need to adjust the range of the input. Different plants have different soil moisture requirements. What is too wet for some is ideal for others, although all plants have a ‘too wet’ and a ‘too dry’ point. The trimpots should cover this. We can’t provide much guidance here as there are almost as many variables as there are people to use the circuit, but the principles have been described above. Ultimately, you might need a sample of soil that is too wet, and one that is too dry, to calibrate the circuit. Ideally, you want ‘too wet’ to light LED 2, next to the blue LED, so you can keep LED 1 as ‘drowning’, with the same idea for the other end of the scale.

IN SUMMARY

The LM3914 is far more versatile than we have space to describe in full. This application, though practical, is one of many possibilities. The Typical Applications in the datasheets describe tachometers, voltage displays, zero-centred meters (which you could use as a feedback display in zero-turn motor arrangements), and a different way of connecting RLO and RHI to shift the input range up the scale.

However, as presented, the IC is versatile enough for you to gain a working understanding with which to explore. Perhaps you can choose two LED pins, one dry, and one wet, to connect to a micro-controlled garden watering system? You could also use the DF Robot sensor directly here, but that would deprive you, unless otherwise arranged, of the immediate visual display.

Further to this, you can use the display as-is, with alterations to trimpot settings and resistor values, to monitor other types of sensor. Perhaps a strain or deflection gauge, or even a basic anemometer, using a motor to produce a voltage.

We hope that this introduction to the LM3914 fosters your creativity and inventiveness, and inspires you to come up with your own novel, but practical (or just because) uses for this versatile IC.