# Tutorial – LM3915 Logarithmic Dot/Bar Display Driver IC

Introduction

This is the second of three articles that will examine the LM391x series of LED driver ICs. The first covered the LM3914, this will cover the LM3915 and the LM3916 will follow. The goal of these is to have you using the parts in a small amount of time and experiment with your driver ICs, from which point you can research further into their theory and application.

Although these parts have been around for many years, the LM3915 isn’t used that much however for the sake of completeness we’re writing the tutorial. The LM3915 offers a simple way to display a logarithmic voltage level using one or more groups of ten LEDs with a minimum of fuss. If you’re wanting to make a VU meter, you should use the LM3916 which we will cover in the final instalment of this trilogy.

Instead of having each LED represent a voltage level as with the LM3914, each LED connected to the LM3915 represents a 3 dB (decibel) change in the power level of the signal. For more on decibels, check out Wikipedia.

To display these power level changes we’ll run through a couple of examples that you can use in your own projects and hopefully give you some ideas for the future. Originally by National Semiconductor, the LM391X series is now handled by Texas Instruments.

Getting Started

You will need the LM3915 data sheet, so please download that and keep it as a reference. First – back to basics. The LM3915 controls ten LEDs. It controls the current through the LEDs with the use of only one resistor, and the LEDs can appear in a bar graph or single ‘dot’ when in use. The LM3915 contains a ten-stage voltage divider, each stage when reached will illuminate the matching LED (and those below it in level meter mode).

Let’s consider the most basic of examples (from page two of the data sheet) – a simple logarithmic display of voltage between 0 and 10V:

After building the circuit you can connect a signal to measure via pin 5, and the GND to pin 2. We’ve built the circuit exactly as above on some stripboard for demonstration purposes, with the only difference being the use of an 8.2kΩ resistor for R2:

To show this in action we use a signal of varying AC voltage – a sine wave at around 2 kHz. In the following video, you can see the comparison of the signal’s voltage against the LEDs being illuminated, and you will see the logarithmic voltage increase represented by the LEDs:

We used the bar display mode for the voltage increase, and the dot display mode for the voltage decrease. Did you notice that during the voltage decrease, the LEDs below the maximum level being displayed were dim?

As the signal’s voltage was varying very quickly, the change in the LED’s location is a blur due to the speed of change. In the video below, we’ve slowed the frequency right down but kept the same maximum voltage.

Well that was a lot of fun, and gives you an idea of what is possible with the LM3915.

Displaying weaker signals

In non-theoretical situations your input signal won’t conveniently be between 0 and 10 V. For example the line level on audio equipment can vary between 1 and 3V peak to peak. For example, here’s a random DSO image from measuring the headphone output on my computer whilst playing some typical music:

Although it’s an AC signal we’ll treat it as DC for simplicity. So to display this random low DC voltage signal we’ll reduce the range of the display to 0~3V DC. This is done using  the same method as with the LM3914 – with maths and different resistors.

Consider the following formulae:

As you can see the LED current (Iled) is simple, however we’ll need to solve for R1 and R2 with the first formula to get our required Vref of 3V. For our example circuit I use 2.2kΩ for R2 which gives a value of 1.8kΩ for R1. However putting those values in the ILED formula gives a pretty low current for the LEDs, about 8.3 mA.

Live and learn – so spend time experimenting with values so you can match the required Vref and ILED.

Nevertheless in this video below we have the Vref of 3V and some music in from the computer as a sample source of low-voltage DC. This is not a VU meter! Wait for the LM3916 article to do that.

Again due to the rapid rate of change of the voltage, there is the blue between the maximum level at the time and 0V.

Chaining multiple LM3915s

This is covered well in the data sheet, so read it for more on using two LM3915s. Plus there are some great example circuits in the data sheet, for example the 100W audio power meter on page 26 and the vibration meter (using a piezo) on page 18.

Conclusion

As always we hope you found this useful. Don’t forget to stay tuned for the final instalment about the LM3916.

This post is brought to you by pmdway.com – everything for makers and electronics enthusiasts, with free delivery worldwide.

To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on twitter @tronixstuff.

# Tutorial – LM3914 Dot/Bar Display Driver IC

This is the first of three tutorials that will examine the LM391x series of LED driver ICs. In this first tutorial we cover the LM3914, then the LM3915 and LM3916 will follow. The goal of these tutorials is to have you using the parts in a small amount of time and experiment with your driver ICs, from which point you can research further into their theory and application.

Although these parts have been around for many years, the LM3914 in particular is still quite popular. It offers a simple way to display a linear voltage level using one or more groups of ten LEDs with a minimum of fuss.

You can order LM3914s in various pack sizes from PMD Way with free delivery, worldwide

With a variety of external parts or circuitry these LEDs can then represent all sorts of data, or just blink for your amusement. We’ll run through a few example circuits that you can use in your own projects and hopefully give you some ideas for the future. Originally by National Semiconductor, the LM391X series is now handled by Texas Instruments.

Getting Started

You will need the LM3914 data sheet, so please download that and keep it as a reference. So – back to basics. The LM3914 controls ten LEDs. It controls the current through the LEDs with the use of only one resistor, and the LEDs can appear in a bar graph or single ‘dot’ when in use. The LM3914 contains a ten-stage voltage divider, each stage when reached will illuminate the matching LED (and those below it in level meter mode).

Let’s consider the most basic of examples (from page two of the data sheet) – a voltmeter with a range of 0~5V.

The Vled rail is also connected to the supply voltage in our example. Pin 9 controls the bar/dot display mode – with it connected to pin 3 the LEDs will operate in bar graph mode, leave it open for dot mode.

The 2.2uF capacitor is required only when “leads to the LED supply are 6″ or longer”. We’ve hooked up the circuit above, and created a 0~5V DC source via a 10kΩ potentiometer with a multimeter to show the voltage – in the following video you can see the results of this circuit in action, in both dot and bar graph mode:

Customising the upper range and LED current

Well that was exciting, however what if you want a different reference voltage? That is you want your display to have a range of 0~3 V DC? And how do you control the current flow through each LED? With maths and resistors. Consider the following formulae:

As you can see the LED current (Iled) is simple, our example is 12.5/1210 which returned 10.3 mA – and in real life 12.7 mA (resistor tolerance is going to affect the value of the calculations).

Now to calculate a new Ref Out voltage – for example  we’ll shoot for a 3 V meter, and keep the same current for the LEDs. This requires solving for R2 in the equation above, which results with R2 = -R1 + 0.8R1V. Substituting the values – R2 = -1210 + 0.8 x 1210 x 3 gives a value of 1694Ω for R2. Not everyone will have the E48 resistor range, so try and get something as close as possible. We found a 1.8 kΩ for R2 and show the results in the following video:

You can of course have larger display range values, but a supply voltage of no more than 25 V will need to be equal to or greater than that value. E.g. if you want a 0~10 V display, the supply voltage must be >= 10V DC.

Creating custom ranges

Now we’ll look at how to create  a lower range limit, so you can have displays that (for example) can range from a non-zero positive value. For example, you want to display levels between 3 and 5V DC. From the previous section, you know how to set the upper limit, and setting the lower limit is simple – just apply the lower voltage to pin 4 (Rlo).

You can derive this using a resistor divider or other form of supply with a common GND. When creating such circuits, remember that the tolerance of the resistors used in the voltage dividers will have an affect on the accuracy. Some may wish to fit trimpots, which after alignment can be set permanently with a blob of glue.

Chaining multiple LM3914s

Two or more LM3914s can be chained together to increase the number of LEDs used to display the levels over an expanded range. The circuitry is similar to using two independent units, except the REFout (pin 7) from the first LM3914 is fed to the REFlo (pin 4) of the second LM3914 – whose REFout is set as required for the upper range limit. Consider the following example schematic which gave a real-world range of 0~3.8V DC:

The 20~22kΩ resistor is required if you’re using dot mode (see “Dot mode carry” in page ten of the data sheet). Moving on, the circuit above results with the following:

Where to from here?

Now you can visually represent all sorts of low voltages for many purposes. There’s more example circuits and notes in the LM3914 data sheet, so have a read through and delve deeper into the operation of the LM3914.

Furthermore Dave Jones from eevblog.com has made a great video whcih describes a practical application of the LM3914:

Conclusion

As always we hope you found this useful. Don’t forget to stay tuned for the second and third instalments using the LM3915 and LM3916.

This post is brought to you by pmdway.com – everything for makers and electronics enthusiasts, with free delivery worldwide.

To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on twitter @tronixstuff.

# Project – Scrolling text clock

The purpose of this project is to build a scrolling text clock that displays the time as it is spoken (for example, “it’s midnight”).

This is a quick project – we give you enough to get going with the hardware and sketch, and then you can take it further to suit your needs.

Hardware

You’ll need three major items –

You might want an external power supply, but we’ll get to that later on. The first stage is to fit your real-time clock. Click here for the tutorial if you need help with that. By now I hope you’re thinking “how do you set the time?”.

There’s two answers to that question. If you’re using the DS3231 just set it in the sketch (see below) as the accuracy is very good, you only need to upload the sketch with the new time twice a year to cover daylight savings.

Otherwise add a simple user-interface – a couple of buttons could do it. Finally you just need to put the hardware on the back of the DMD. There’s plenty of scope to meet your own needs, a simple solution might be to align the control board so you can access the USB socket with ease – and then stick it down with some Sugru.

With regards to powering the clock – you can run ONE LED display from the Arduino, and it runs at a good brightness for indoor use. If you want the DMD to run at full, retina-burning brightness you need to use a separate 5V 4A DC power supply. If you’re using two DMDs – that goes to 8A, and so on. Simply connect the external power to one DMD’s terminals (connect the second or more DMDs to these terminals):

If you don’t fancy chopping the end of your power supply cable, use a DC socket breakout.

The Arduino Sketch

You will need to install the following two Arduino libraries – TimerOne and DMD. Then upload the sketch:

```// for RTC
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 // the DS1307 RTC is 0x68

// for LED display
#include "SPI.h"
#include "DMD.h"
#include "TimerOne.h"
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

String finalString; // used to hold final sentence to display on DMD

void ScanDMD() // required for DMD
{
dmd.scanDisplayBySPI();
}

void setup()
{
// for DMD
Timer1.initialize( 5000 );
Timer1.attachInterrupt( ScanDMD );
dmd.clearScreen(true);

// for RTC
Wire.begin(); // fire up I2C bus
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
// change the variables and uncomment the setDateDs1307 to set the time
// then re-comment out the function and upload the sketch again
second = 0;
minute = 13;
hour = 23;
dayOfWeek = 4;
dayOfMonth = 19;
month = 5;
year = 13;
// setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}

// usual RTC functions
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.write(0);
Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(dayOfWeek));
Wire.write(decToBcd(dayOfMonth));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(00010000); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
Wire.endTransmission();
}

// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.write(0);
Wire.endTransmission();

// A few of these need masks because certain bits are control bits
*hour = bcdToDec(Wire.read() & 0x3f); // Need to change this if 12 hour am/pm
}

void drawText(String oldString)
{
dmd.clearScreen(true);
dmd.selectFont(Arial_Black_16);
char newString[256];
int sLength = oldString.length();
oldString.toCharArray(newString, sLength+1);
dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
long start=millis();
long timer=start;
long timer2=start;
boolean ret=false;
while(!ret){
if ((timer+20) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
}

void createTextTime(int hh, int mm)
// this mashes up all the time data into text as one sentence
{
finalString=" "; // wipe the sentence out for special cases (below)
finalString=finalString+"It's ";

if (hh==1 || hh==13) {
finalString=finalString+"one ";
}
if (hh==2 || hh==14) {
finalString=finalString+"two ";
}
if (hh==3 || hh==15) {
finalString=finalString+"three ";
}
if (hh==4 || hh==16) {
finalString=finalString+"four ";
}
if (hh==5 || hh==17) {
finalString=finalString+"five ";
}
if (hh==6 || hh==18) {
finalString=finalString+"six ";
}
if (hh==7 || hh==19) {
finalString=finalString+"seven ";
}
if (hh==8 || hh==20) {
finalString=finalString+"eight ";
}
if (hh==9 || hh==21) {
finalString=finalString+"nine ";
}
if (hh==10 || hh==22) {
finalString=finalString+"ten ";
}
if (hh==11 || hh==23) {
finalString=finalString+"eleven ";
}

switch(mm){
case 1:
finalString=finalString+"oh one ";
break;
case 2:
finalString=finalString+"oh two ";
break;
case 3:
finalString=finalString+"oh three ";
break;
case 4:
finalString=finalString+"oh four ";
break;
case 5:
finalString=finalString+"oh five ";
break;
case 6:
finalString=finalString+"oh six ";
break;
case 7:
finalString=finalString+"oh seven ";
break;
case 8:
finalString=finalString+"oh eight ";
break;
case 9:
finalString=finalString+"oh nine ";
break;
case 10:
finalString=finalString+"ten ";
break;
case 11:
finalString=finalString+"eleven ";
break;
case 12:
finalString=finalString+"twelve ";
break;
case 13:
finalString=finalString+"thirteen ";
break;
case 14:
finalString=finalString+"fourteen ";
break;
case 15:
finalString=finalString+"fifteen ";
break;
case 16:
finalString=finalString+"sixteen ";
break;
case 17:
finalString=finalString+"seventeen ";
break;
case 18:
finalString=finalString+"eighteen ";
break;
case 19:
finalString=finalString+"nineteen ";
break;
case 20:
finalString=finalString+"twenty ";
break;
case 21:
finalString=finalString+"twenty one ";
break;
case 22:
finalString=finalString+"twenty two ";
break;
case 23:
finalString=finalString+"twenty three ";
break;
case 24:
finalString=finalString+"twenty four ";
break;
case 25:
finalString=finalString+"twenty five";
break;
case 26:
finalString=finalString+"twenty six";
break;
case 27:
finalString=finalString+"twenty seven";
break;
case 28:
finalString=finalString+"twenty eight ";
break;
case 29:
finalString=finalString+"twenty nine ";
break;
case 30:
finalString=finalString+"thirty ";
break;
case 31:
finalString=finalString+"thirty one ";
break;
case 32:
finalString=finalString+"thirty two";
break;
case 33:
finalString=finalString+"thirty three ";
break;
case 34:
finalString=finalString+"thirty four";
break;
case 35:
finalString=finalString+"thirty five ";
break;
case 36:
finalString=finalString+"thirty six";
break;
case 37:
finalString=finalString+"thirty seven";
break;
case 38:
finalString=finalString+"thirty eight ";
break;
case 39:
finalString=finalString+"thirty nine ";
break;
case 40:
finalString=finalString+"forty ";
break;
case 41:
finalString=finalString+"forty one ";
break;
case 42:
finalString=finalString+"forty two ";
break;
case 43:
finalString=finalString+"forty three ";
break;
case 44:
finalString=finalString+"forty four ";
break;
case 45:
finalString=finalString+"forty five ";
break;
case 46:
finalString=finalString+"forty six ";
break;
case 47:
finalString=finalString+"forty seven ";
break;
case 48:
finalString=finalString+"forty eight ";
break;
case 49:
finalString=finalString+"forty nine ";
break;
case 50:
finalString=finalString+"fifty ";
break;
case 51:
finalString=finalString+"fifty one ";
break;
case 52:
finalString=finalString+"fifty two ";
break;
case 53:
finalString=finalString+"fifty three ";
break;
case 54:
finalString=finalString+"fifty four ";
break;
case 55:
finalString=finalString+"fifty five ";
break;
case 56:
finalString=finalString+"fifty six ";
break;
case 57:
finalString=finalString+"fifty seven ";
break;
case 58:
finalString=finalString+"fifty eight ";
break;
case 59: finalString=finalString+"fifty nine "; break;
}

// midday?
if (hh==12 && mm==0) {
finalString=finalString+"midday ";
}
// midnight?
if (hh==00 && mm==0) {
finalString=finalString+"midnight ";
}

}

void loop()
{
// get the time from the RTC
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

// convert the time into a sentence string
createTextTime(hour,minute);

// now send the text to the DMD
drawText(finalString);
}```

The sketch has the usual functions to set and retrieve the time from DS1307/3232 real-time clock ICs, and as usual with all our clocks you can enter the time information into the variables in void setup(), then uncomment setDateDs1307(), upload the sketch, re-comment setDateDs1307, then upload the sketch once more. Repeat that process to re-set the time if you didn’t add any hardware-based user interface.

Once the time is retrieved in void loop(), it is passed to the function createTextTime(). This function creates the text string to display by starting with “It’s “, and then determines which words to follow depending on the current time. Finally the function drawText() converts the string holding the text to display into a character variable which can be passed to the DMD.

And here it is in action:

Conclusion

This was a quick project, however we hope you found it either entertaining or useful – and another random type of clock that’s easy to reproduce or modify yourself.

This post brought to you by pmdway.com – offering everything for makers and electronics enthusiasts, with free delivery worldwide.

To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on twitter @tronixstuff.