LED and LCD Modules

By James S.

Introduction


LED (Light Emitting Diode) and LCD (Liquid Crystal Display) modules are electronic building blocks that contain some sort of display (LED or LCD) and all the necessary circuitry to show text or graphics on the display (that is, the module contains some form of microcontroller). The display modules have an interface usually designed to be connected to some form of computer circuit which tells it what to display, although it is possible with some display modules to work them with simple switches, which is handy for testing.

Some display modules, in particular those that contain an LCD, are labelled as being 'intelligent' since they are able to accept commands in which to activate a cursor, scroll the display and other useful tasks. But whether the display module is regarded as intelligent or not, they can all be divided into the two main types which are text (or character) and graphic. Text (character) display modules can only show letters, numbers and special symbols; its graphical capabilities are very limited. Graphic display modules, however, are able to output text and pictures but generally are more complicated to use than text only display modules and don't follow a standard interface like most of the text only ones do. Graphic display modules actually are useful for circumstances where only text needs to be displayed, such as for word processors, as a graphic display module can show text in different forms more easily than a text only display.

LED Display Modules


LED displays seem to be as popular as ever even though LCDs have many advantages over them but perhaps it's the bright lights and different colours that make them still so much in demand. There are two main types of LED modules for displaying information and they are the segment type and the dot matrix type. Segment displays use a number of usually rectangular LEDs arranged in the figure of an eight and by lighting different combinations of the segments, numbers and some letters or other symbols can be shown. Dot matrix displays, however, use a number of round LEDs arranged horizontally and vertically to form a square or rectangle. Lighting up these LEDs forms patterns such as characters or pictures, much in the same way as images are formed on your TV screen or computer monitor. The big advantage of dot matrix displays over the segment type is that better looking numbers and letters can be displayed, as well as images.

LED displays come in all sorts of sizes and colours and especially with the dot matrix displays you can get bi-colour and tri-colour versions, which means that each LED can light up one of two or three colours. On the downside, these displays are much more expensive and require a more complicated controller chip that is part of the LED module.

DLR1414 4 Character 5x7 Alphanumeric LED Dot Matrix Display Module


This LED dot matrix display module can illuminate up to 4 characters, each of which can be one of a number of predefined letters, numbers, or special characters such as punctuation. Each LED dot is red and the whole module runs off a single 5V supply and is TTL compatible. Note that the display module starts up in a random state.

The display module is not truly intelligent as it can only receive raw data of what character to display; it cannot accept any commands. Two address signals, A0 and A1 select which digit to update and a single active low write signal latches the data for the chosen digit. The ASCII value of the character to display for the selected digit is written to the 7 bit data bus; the display module has 128 built in characters conforming to the ASCII standard (with some exceptions). 

A triangle on the side of the display points out the first pin and on the opposite side of the display is pin 12 (just like with DIP IC numbering). The pinout is as follows:

1 D5
2 D4
3 /WR
4 A1 digit select
5 A0 digit select
6 Vcc
7 GND
8 D0
9 D1
10 D2
11 D3
12 D6

Each digit is numbered from 1 to 4 with digit 4 being on the end where pin 1 and 12 are. Use A0 and A1 to select the digit as below:

A1

A0

Digit

0

0

1

0

1

2

1

0

3

1

1

4

When it comes to soldering LED displays I usually use a chip holder and fortunately if you want to fit multiple of these displays side-by-side onto chip holders you can fit two into a single 28 pin chip holder (there is approx. 20mm distance between the rows of pins). This works out because there is a gap of one pin's worth between both displays.

Sure 0832 DE-DP10XV110 LED Dot Matrix Display Module


This display is a real beauty but quite surprisingly can be bought fairly cheap which is just as well as the accompanying documentation is very poor and not because it was translated from another language. The documentation has only just the basic information for using the display and some parts are quite confusing. For example, the display module has a blink command that you might assume would flash all the LEDs on or off but it actually blinks only LEDs that were previously lit; there is no mention in the documentation what exactly the blink command does so it's only though trying that you find out.

The display module (below) has 256 red LEDs arranged in an 8 by 32 format (8 height and 32 wide, although you could have it the other way up and treat it as a tall display). The module is actually made up of 4 smaller LED dot matrix displays each of which has 64 LEDs in 8 by 8 format, however, the module chip maps the addresses to the correct LEDs for you.



Cascading the display modules is possible so that you can put together up to 4 display modules to create a longer or higher display system. Each display module has two 16 pin connectors for power and interface signals so that each display can be linked up to the next (a ribbon cable came packaged with the display module). There is also a set of switches on each display module in which to give each a unique selection value through the interface (so that if you do have more than one display connected together, you can select each in turn to 'talk to' by its ID value). If you do link up display modules, you can solder connectors to the display modules in which to supply more power.

Being a serial display module data has to be sent to the display as a number of bits one after each other along with a write or read signal that acts as a clock for timing. Although it is possible to read from the display module's memory, if you are interfacing using a computer you can probably do without the read connection (by keeping it at logic 1) since a computer should have enough memory to keep a copy of what is on the LED display if need be. But with the case of a microcontroller based system that has very little RAM is might be a good idea to make use of the read signal.

The display module runs of a 5V supply (although not mentioned in the documentation, it appears to be TTL compatible) but is able to retain its memory long after power is disconnected, perhaps due to an on-board capacitor. Interestingly, although the display module is one colour only, the LEDs look to be of the tri-colour type (if you look closely at each LED you can see three connections) and since the display module is available in different colours, perhaps Sure only connect the colour that is needed save having to use a different display for each colour type.

There are a number of commands that the display module recognises to turn the display on or off, to write data to the display memory to turn the LEDs on or off, to read from the display memory, and various others. Even though the commands have to be sent in serial form and to fill or clear the display requires a lot of data to be sent to the display module, it still updates instantly even through a parallel port interface (yes I used the parallel port even though the display module is serial but it is the best interface for me to use).

You can write 4 bits to each display memory address and each of those 4 bits controls a group of 4 LEDs in sequence. To light an LED, the bit needs to be at logic 1 and to turn off an LED the bit must be at logic 0. Since the display module is not able to generate characters itself, you have to create any characters (numbers, letters, etc) and other images yourself and then send them to the display module as the correct arrangement of bits.

** More to be added soon ***

Sure 2416 DE-DP016 LED Dot Matrix Display Module

This display module is similar to the Sure 0832 DE-DP10XV110 LED Dot Matrix Display Module but bigger in size. It has 384 red LEDs arranged in a 24 by 16 format (16 height and 24 wide). Although up to four of these display modules can be linked up in the same way as the 0832 display module, the 2416 modules can only be stacked closely together side-by-side as the main circuit is at the bottom of the display module.

Bundled with the display module was two ribbon cables, and two additional power connectors were already soldered to the display module. The pinout is almost the same as the 0832 display module with the difference in the order of the chip select connections (a much more logical order). So if you wanted to link one of these displays to a 0832 display module, all you need to do is remember that the chip select signals will be different for one of the displays. Oddly, in the documentation (which is only slightly worse than the documentation for the 0832 display module), the photo of the display module shows that it has eight switches yet the pinout lists only the (expected) four chip select signals.

There is one problem with this display module using the same control chip as the 0832 display module; when power is first connected, it is only possible to access half of the display. By way of a command (called common options) you have to tell the display module to switch to the mode where you can use the whole display. This also changes the layout of the display memory addresses so that they flow down the complete display. 

*** More to be added soon***

LCD Modules


Liquid Crystal Displays (LCDs) have many advantages over other forms of display, for one thing they use very little current and because of that they have found themselves in many portable devices. That said, LCDs often require back lights and can be more difficult to read than other display technology such as LEDs.

It's just as well that Intelligent LCDs were invented, which can use either a parallel or serial interface, and are designed to help out the programmer with displaying information on an LCD. The text only intelligent displays usually have a built-in character generator (that is, a ROM containing the graphical information of each character) and accept a limited amount of commands to display characters, scroll the display, move to a set position, and so on. This 'intelligence' is thanks to one or more controller chips that are part of the LCD module, handling both input from the 'outside world' and updating the LCD.

HD44780 LCD modules


The 'HD44780' and compatible intelligent LCD modules are able to display characters only and are very commonly used in a wide range of electronic devices such as in printers, vending machines and much more. These parallel intelligent LCDs are easy to use to the point that for testing purposes you can get one to display characters by using just switches! They are usually used in either 4 or 8-bit mode with the 4-bit mode requiring that both halves of the 8-bit data be sent one after another but having the advantage that fewer connections are needed. This is especially useful when, for e.g., you are interfacing an LCD module to a microcontroller that has few I/O.

You can get HD44780 LCD modules that can display only a few characters, and others that can show as many as eighty, either on one or more lines; these display modules all use a standard 14 connection pinout with one or two additional connections if there is a backlight (usually an LED). There are HD44780 LCD modules that can display more than eighty characters, however, they actually use more than one controller chip and have a different 16 (or more) connection pinout.

There are two basic modes for using an HD44780 LCD module: instruction mode and data mode. Instruction mode is used when you want to send the LCD module commands such as to clear the display or to turn the display on or off. The data mode is used to display characters on the LCD by sending it ASCII values representing the characters. A single input connection to the LCD module called RS (Register Select) selects whether the value on the data bus is to be interpreted as character data or an instruction.

It should be noted that not all characters in the ASCII standard are available as some are replaced with special symbols such as an arrow or the Yen character. That at least makes it more appealing to use worldwide but it you really need the missing characters you can create them yourself and then send them to the LCD module. There is only room for 8 custom characters, a limitation which it seems is due to the fixed length instructions. The custom characters are stored in RAM as part of the LCD module so they will remain as long as power is connected to the LCD module (and the custom characters start up in a random state when the LCD module first gets power). A unique feature concerning the custom characters is that if you modify them while one or more of them is being displayed, they will be updated immediately, making possible simple animations.

There are a couple of things to watch out for that you should be aware of when using these LCD modules. Firstly, HD44780 LCD modules normally initialize themselves when powered up with the display turned off. However, under certain conditions the LCD modules's initialization may fail so it's always best to manually initialize the LCD module using its built-in instructions. It's a good idea to turn on the flashing cursor as a simple test to make sure the LCD module is working.

Another thing to watch out for is that the LCD module can be powered through a computer or microcontroller's I/O without power connected to the LCD module's power supply connections. Not only can this harm the LCD module but it also causes the LCD module to retain its current state (for e.g., what it is displaying). If you want to remove power from the LCD module while keeping the I/O connected then set the I/O to logic 0 before removing the power. The reason you may want to do this is to reset the LCD without turning off the computer or microcontroller.

You can learn more about the HD44780 LCD module by viewing this link HDD4780 datasheet and by reading the HD44780 projects on this page.

Raspberry Pi to HD44780 LCD module

The Raspberry Pi is a great little computer which can be connected to a HD44780 compatible LCD module using its GPIO as a way of outputting useful information, such as the date and time or the current temperature. In this example project I've used the LCD module in 4-bit mode so that only 6 GPIO signal connections are needed. The code initialises the LCD module and displays 'Hello world!' on the first line along with the flashing cursor and has been tested on a Raspberry Pi B+ (but should work on other models).

The set-up is as follows (note: for the Raspberry Pi, board numbering has been used):

LCD pin 1 (Vss) to Rasp GND
LCD pin 2 (VDD) to Rasp 5V
LCD pin 3 (Vo) to 10K variable resistor centre; remaining connections to GND and 5V respectively.
LCD pin 4 (RS) to Rasp pin 26 with 10K pull-up resistor to Rasp 5V
LCD pin 5 (R/W) to Rasp GND
LCD pin 6 (E) to Rasp pin 24 with 10K pull-up resistor to Rasp 5V
LCD pin 7 to 10 (D0 to D3) to Rasp GND
LCD pin 11 (D4) to Rasp pin 12 with 10K pull-up resistor to Rasp 5V
LCD pin 12 (D5) to Rasp pin 16 with 10K pull-up resistor to Rasp 5V
LCD pin 13 (D6) to Rasp pin 18 with 10K pull-up resistor to Rasp 5V
LCD pin 14 (D7) to Rasp pin 22 with 10K pull-up resistor to Rasp 5V

It's a good idea if possible to put the LCD module into breadboard along with the other components and then connect the Raspberry Pi GPIO pins to the breadboard using cables.

The Python code for this project can be found at the bottom of this page and is called gpio_hd44780_test.py. Since it uses GPIO it must be run from the terminal using the command sudo python gpio_hd44780_test.py. In about a second 'Hello world!' should appear on the LCD along with the flashing cursor, if not check your connections and try adjusting the LCD contrast using the variable resistor.

Normally when interfacing with an LCD module such as the HD44780 we have to wait some time (well, seconds perhaps) for the LCD to start up. But since we are using the Raspberry Pi by the time the computer boots the LCD module would have started up and be ready to use. In addition, as Python is quite slow (as it uses an interpreter) we can get away with having less delays. In fact, the only delays in the program are when toggling the LCD enable pin.

In case the LCD's built-in initialisation failed the Python code issues a function set command twice and then write further settings such as to put the LCD module to 4 bit mode. The function LCD_send_instr() is what writes a command to the LCD taking an 8-bit value as input before calling function LCD_send_data() which sends the byte as two lots of 4-bit data. Similar, function LCD_send_char() displays a single character on the LCD module but internally calls LCD_send_data(). The only difference is that LCD_send_instr() takes RS low to put the LCD into instruction mode whereas LCD_send_char() takes RS high to put the LCD into character mode. Lastly, function LCD_send_str() takes a string as input and outputs each character in turn by calling LCD_send_char().

At the very end of the program all GPIO are taken low so that it is safe to remove the LCD module from the 5V supply should you need to such as to reset the LCD. If one of the GPIO pins were high and you disconnected the 5V line from the LCD module it will still be powered by the GPIO which could harm the LCD and will prevent it from being reset.

PC Parallel Port to Parallel Intelligent LCD Module

(Updated: 29/8/10)

This is great for testing out a so-called intelligent LCD which is nothing more than an LCD and dedicated controller chip on board, but does a lot of the hard work of working an LCD, especially one which is capable of at least limited graphics. This means you can interface the LCD module to a PC's parallel port with not too much difficulty and once you have the software done, I'm sure you'll find many uses for it. There are other options, such as using an USB connection, however, only the parallel port will be covered here as for most people it's the easiest to program and use (if your computer has a parallel port).

Intelligent LCD modules can be divided into two main types and they are those which can display only characters with very limited graphics (by creating your own characters) and the ones that can display graphics as well as text which can be of different sizes and styles. I'll be discussing the character only type below as they are the simplest to start with yet have many uses.

The LCD module that I used for this project came from a chucked out fax machine, and was made by Sharp with the code F2631XH-44 written on the circuit board. It uses the SEC C748B chip, compatible with the industry standard HD44780 so I was able to use it without any trouble. It is made up of two lines that are each eight characters long but instead of one line below the other they are side by side. In other words, when the two line mode is enabled for this LCD module it is actually a single line with 16 characters.

Another suitable intelligent LCD, which came from a security alarm (that was not needed!), is a Winstar WH1602B and has 16 connections, the extra two (15 and 16) are for the LED backlight. This LCD module has two lines that are 16 characters wide, one below the other. Obviously the more characters that can be displayed at once the better but the software will have to be adjusted accordingly. It can be a little tricky to use both lines as you have to tell the cursor to move to the start of the next line at a certain position and before that you have to enable two line mode (as already explained may be just an extension of the single line).

Although these LCD modules have an 8-bit interface which is ideal for your average CPU, microprocessor and parallel port the LCD can be be forced into 4-bit mode. In 'nibble' mode you have to send one half of the byte after another which may seem a pain but the advantage is that you only need four connections (not including the other signals) instead of eight.



The circuit shown above illustrates the wiring needed for interfacing an LCD module to a typical PC parallel port. You can power the LCD module using a battery or batteries, or a wall adapter; the power supply's ground (0V) connection has to be connected to the parallel port's ground signal. The LCD can run off lower than 5V (a 4.5V battery is very handy) but you will need to use pull up resistors for D0-D7 and possibly the other connections to ensure that the LCD Module gets the right voltage levels for logic 1 and 0. Actually, the LCD and the controller chip that's part of the module can work down to a tiny voltage, I've noticed that amazingly it can get power from the parallel port's signals (though the characters will be very faint). This means that you need to remove the LCD module from the parallel port (just remove the ground connection) as well as the power supply to completely turn the LCD off.

When power is applied to the intelligent LCD it starts off with the display blanked (though commands can still be sent to it such as to put it into two-line mode) but you may still see a number of blocks. If you do, then you'll need to adjust the contrast (VR1) until the blocks vanish, but not too much. The variable resistor can be replaced with a fixed reistor, as soon as you have found the right setting you can measure the variable resistor's resistance with a multimeter (when the power is off) on the ohms range to determine the value to use for the fixed resistor. Or you can use a preset variable resistor which can be adjusted once; please be aware that two-line mode requires a different level of contrast compared to just one line.

It is a good idea when testing an LCD module for the first time to set up the hardware using breadboard. Some intelligent LCDs have a ribbon cable connected to them others have a row of 'legs' which can more easily be inserted into breadboard.

When the hardware has been set up, you'll need to write the software to control the LCD, an example program I wrote in C++ follows. I used a Borland compiler which had no parallel port access functions so I used direct access by incorporating a couple of lines of assembly language amongst the C++ coding. With modern operating systems this is not a good idea and will not work with Windows 2000 or higher. Therefore you may want to explore better alternatives for accessing your computer's parallel port, on your PC (for Windows 2000 and above you can download software to grant you access to the parallel port or you could use a special driver).

//PC parallel port to LCD module
//By James S.
//Uses LPT1

const dataPort=0x378; //LPT1 data port
const statusPort=0x379; //LPT1 status port
const controlPort=0x37A; //LPT1 control port
const dataPortDir=0x20; //LPT1 data port I/O mode
const ctrlINIT=0x04; //LPT1 control port INIT o/p
const ctrlSTROBE=0x01; //LPT1 control port STROBE o/p
const LCDclr=0x01; //Clear LCD command
const LCDonULBlinkCur=0x0f; //LCD on with cursor underline and blink command
const LCDoff=0x08; //LCD off command

bool LCDon; //Is the LCD on or off?

void writeCommand(byte data); //Write command byte to LCD
void writeChar(byte data); //Write character to LCD
void writeCtrlPort(byte data); //Write byte to LPT1 control port
void writeDataPort(byte data); //Write byte to LPT1 data port

__fastcall TMainForm::TMainForm(TComponent* Owner):TForm(Owner)
{
    LCDon=false; //Assumed LCD is off
}

void __fastcall TMainForm::LCDOnOffClick(TObject* Sender)
{
    LCDon=!LCDon; //Toggle LCD on/off

    if (LCDon) { //LCD to be turned on
        writeCommand(LCDonULBlinkCur); //Turn on LCD
        LCDOnOff->Caption="Turn LCD off";
    }
    else { //LCD to be turned off
        writeCommand(LCDoff); //Turn off LCD
        LCDOnOff->Caption="Turn LCD on";
    }
}

void writeCtrlPort(byte data) //Write byte to LPT1 control port
{
    _DX=controlPort;
    _AX=data;
    __emit__(0xee);
}

void writeDataPort(byte data) //Write byte to LPT1 data port
{
    _DX=dataPort;
    _AX=data;
    __emit__(0xee);
}

void writeCommand(byte data) //Send command to LCD
{
    writeCtrlPort(0); //Set data port to o/p and LCD to command mode
    writeDataPort(data); //Write command to data port
    writeCtrlPort(ctrlSTROBE); //Take LCD enable low
    writeCtrlPort(0); //Take LCD enable high
}

void writeChar(byte data) //Write character to LCD
{
    writeCtrlPort(ctrlINIT); //Set data port to o/p and LCD to character mode
    writeDataPort(data); //Write char to data port
    writeCtrlPort(ctrlINIT|ctrlSTROBE); //Take LCD enable low
    writeCtrlPort(ctrlINIT); //Take LCD enable high
}

void __fastcall TMainForm::sendCharClick(TObject* Sender)
{
    //Send character to LCD
    int byte=StrToIntDef(charIn->Text,0); //Get character code
    writeChar(byte);
}

void __fastcall TMainForm::clearLCDClick(TObject* Sender)
{
    writeCommand(LCDclr); //Clear LCD
}



The LCD module, above, can display up to 40 characters on its single line (take note that what looks like an underscore at the end of the website address on the display is actually the built-in cursor that can be enabled or disabled as needed). I had to solder a ribbon cable to the dual-in-line connections on the LCD module so getting the right order of odd and even rows was very important.

The intelligent LCD will miss commands or characters if received too fast; you can check the module's busy flag to see if it's ready to accept more data but it's simpler just to wait a specific amount of time between sending data. Reading the busy flag requires use of the LCD's R/W line and that would need an extra output from the computer you are using. It's better to keep the R/W input connected to 0V so it's always in write mode and wait a short amount of time before sending the next byte to the LCD.

Using a for loop to create a delay isn't a good idea since the length of delay would be different on a faster or slower computer. Instead, use a timer component or better, a delay function (such as the Sleep() Windows function).

Fax machine LCD Module

In an old fax machine I was taking apart I found an LCD module that was connected to a circuit board with a flat cable. Since the LCD module has 10 connections I guessed that it was probably HD44780 compatible, assuming that there were only 4 data bits. The LCD module has these markings:

Using my PIC LCD Character Module Driver (which you can find on the Interfacing page) the LCD module worked fine. The big problem was the flat cable connected to the LCD module as I was unable to solder wires to a suitable connector. So, what I did was solder wires direct to the LCD module where the flat cable is connected.

The only difference to a standard HD44780 LCD modules is that only triangle characters can be displayed on the second line (they were used by the fax machine to point to different things).

VTECH Precomputer 2000 LCD Module

 
When I bought a VTECH Precomputer 2000 cheaply at a carboot sale for the parts I assumed it used a standard HD44780 LCD character module. Well, that turned out to be almost true but it took a bit of unscrewing to find out exactly how the display works.

The Precomputer 2000 uses a Z80 (8-bit) CPU which shows how popular the CPU has been considering the Z80 came out in 1976 and the Precomputer 2000 was released in 1993. The CPU is on the main board along with a chip marked LH532HEE which is possibly a ROM containing the program code for the Z80 and a chip with the code S2564RL-100 which could be RAM. There is also an unknown chip on its own board soldered upside down to the main board; it looks to be a 'blob' IC.

As for the LCD module, it is connected to the main board with two ribbon cables, one 8 way and the other 4 way. In addition, there is a red and black wire going from the power supply board (to which the battery supply and external power supply are connected) to the LCD module. Turns out the red and black wires are not the power supply but instead are shorted together by the contrast switch to select the two levels of contrast. This is done using two resistors on board the LCD module.

I had to unscrew the LCD module to separate the actual LCD from its controller board to get further answers and I found as well as there being a 'blob' chip there was also a SED1278F chip in a square package. The SED1278F is a dot matrix LCD controller driver very similar to the HD44780. As soon as I had a datasheet for the SED1278F I was able to identify the pin-out of the two buses. If you do take this LCD module apart and put it back together and when you test it you find that the characters aren't being displayed correctly then you have the LCD the wrong way round. So you will need to unscrew it, turn the LCD round and screw it back-all while the power is off, of course.

Starting with the 4 way bus, looking from the back, connection 1 is closest to the capacitor (there are no markings on the display board so I had to do my own numbering). The connections are as follows:


1

VDD

2

RS

3

GND

4

E


VDD is the supply voltage, 5V, and RS is the 'Register Select' input; logic 0 tells the LCD module you are sending an instruction and logic 1 is for sending data (characters). On the LCD module the R/W input to the SED1278F is connected to GND so the LCD module is always in write mode. Lastly, the E input is like a clock signal which forces the LCD module to execute an instruction or display a character when the E signal goes from a high to low state.

As for the 8 way data bus, I regard connection 1 as being closest to the group of unused connections on the back of the LCD module. This is the data bus which are the 8 inputs used to transfer instructions or character data to the LCD module.


1

DB7

2

DB6

3

DB5

4

DB4

5

DB3

6

DB2

7

DB1

8

DB0


I tested the LCD module by using breadboard and first sending the code to turn the display on and then to output a character. That worked and I found it is can display 20 characters on 2 lines so it will be a very useful display.

WGM-12232M Graphic LCD Module

 
This graphic module has a resolution of 122x32 black pixels and features a green backlight that can be enabled or disabled. Two NJU6450 bit map LCD drivers update the LCD, with the left hand of the display controlled by one NJU6450 and the other side handled by the other NJU6450. So, in other words, one NJU6450 controls a total of 61x32 pixels. Each of the two sections of the display are divided up into columns, which go across horizontally, and pages which are vertically rectangular divisions. So, to access a particular part of the display you need to specify both the column and page value and select one of the two chips. Writing data to the display RAM sets pixels vertically, and automatically increases the column value so you can quickly update the display (however, you will need to reset the value after it reaches its maximum value).
 
The module has 20 connections and its pinout is shown below:
 
1 VDD (Power supply +5V)
2 GND
3 VO (Contrast adjust 0 to -5V)
4 /RST (Active low reset)
5 CS1 Chip select 1
6 CS2 Chip select 2
7 R/W (0 to write, 1 to read)
8 NC (No connection)
9 A0 (0 command, 1 data)
10 to 17 DB0 to DB7 (8-bit data bus)
18 VBC Backlight enable switch (0 off, 1 on)
19 to 20 GND
 
For contrast you only need some kind of potential divider (which could be a variable resistor) between the power supply connections with the middle tapping wired to VO. If you only want to write to the display you can tie R/W to GND, which saves an I/O pin on your microcontroller (or whatever system you are using). Reading from the display is, nonetheless, useful for getting the contents of the display RAM and for checking the busy flag to see whether the module is ready to accept another command or display data. If you don't check the busy flag then you will need to make sure you don't update the module too quickly. I have tested the display with the Arduino Uno and by using a 1ms delay the display updated very quickly (almost instant).

Build Your Own Display


(Added: 17/02/2012)

While displays of all sorts are readily available at cheap prices, it's very rewarding to make your own and it may be that you can't get hold of a particular type of display or the one you want is expensive. This section will deal with making your own 7-segment LED display which can be connected to some form of decoder to show numbers on the display. So while the rest of this page has been concerned with display modules, which are displays that have a built-in decoder and interface, this section is about making just the display part.

A 7-segment display is made up of 7 segments arranged in a figure '8' which can display numbers and some letters by lighting combinations of the segments. I should point out that although these types of displays are called 7-segment, they often include one or more LED's that act as a decimal point. The decimal point may be at the left of the main 7 segments, to the right, at both sides, and may even include additional LED's either side near the top (such as for clock radios).

Internally, big 7 segment displays, like those typically used in arcade machines, their segments are actually made up of multiple LED's in a row, since a single LED would not light up the whole area of the segment. If you look carefully at the back of one of these large displays while the segments are on, you should be able to make out the individual LED's that make up each segment.

Before making the display you need to think about the size you want it to be, the colour of the segments and how many decimal points (if any) you want. A good idea is to pick the LED's you want to use (they could be round or rectangular) and then place them into a board with pre-drilled holes (such as strip board or matrix board). You can then space out the LED's as you please and see how they look as well as the overall size of the display.

Once you know the layout of the LED's and how many LED's each segment is made up of you can work out the wiring. This will depend on whether you want the display to be common anode or common cathode and how the LED's of each segment are to be connected. If you want to be able to use low voltage for the segments then the LED's in each segment can be connected in parallel (through suitable limiting resistor). However, if you intend to operate the display segments at a higher voltage then the segment LED's could be connected in series which could eliminate the need for segment limiting resistors (for e.g., 3 LED's with a forward voltage drop of 2V can be connected in series and run off 6V without a limiting resistor). If there are a lot of LED's in each segment then you may have to connect them in a combination of series and parallel as to get a good balance of voltage and current requirements.

More to be added soon!
 

An example of a Serial LCD Module

I took a bit of a risk when I bought online an LCD module that I knew nothing about but eventually I got it working. It's a sixteen 7-segment LCD module with what look like 16 commas, and has the numbers 35 209 16170 written on the board. The only clue to getting it working (and I do like a challenge!) was the two PCF2111T chips which so happen to be LCD drivers.

Having found a pdf data sheet about the LCD driver ICs I did a pinout of the LCD module connector which has no indication of the pin markings but the leads are all grey except for one red one.

(Red) Data input line enable DLEN (CBUS) 1

(Grey) Data input line enable DLEN (CBUS) 2

(Grey) Data input DATA (CBUS) 1 and 2

(Grey) Clock burst input CLB (CBUS) 1 and 2

(Grey) VDD (2.25V to 6.0V)

(Grey) VSS (0V)

Each LCD driver chip controls half of the display (i.e. eight 7 segments and eight commas) and just to complicate things a bit more you can only alter half of those segments at once. So, to update the entire display you would need to write to the LCD module four times. This is because one LCD driver has two latches and you can only select one or the other:

* The A latch is responsible for the segments a, b, c and g.

* The B latch is responsible for the segments d, e, f and comma.

This was assuming the usual labelling and that I had the display the right way up, but which way is the right way up depends whether you want the commas to be commas.

This LCD module isn't intelligent and requires a lot of hard work from the user; basically you send a pattern of bits using the DATA signal which, as well as turning on or off the segments, selects which latch you want to use that data. The DATA and CLB (clock) are common to both of the LCD driver chips, which of the two chips you want to receive the data is selected by taking either of the DLEN signals high.

I tested the LCD module using the parallel port of my PC which may seem a strange choice but it was the most easy for me to use. I powered the display using a 5V PSU and connected the power, display and parallel port to a common ground (0V) connection. Using C++ to 'talk' to the LCD module, the reason it took me so long to get the display working was the problem of sending the correct sequence of bits. The PCF2111T chips are 34-bit but, as suggested in the data sheet, you have to send a leading zero which is one of the conditions the LCD driver chips look out for to know when the start of a sequence has begun.

When I had finished the code I was impressed that the entire display updated very fast as I used no delays which I would have had to had it been an intelligent LCD. But it was just as well the LCD module responded as fast as it did as I had to do a lot of converting and such to send parallel data in serial form.

Since you can only display a limited number of characters using seven segments but I wanted to be able to use the String class, I tetsed each character in the string and if it was one that could be displayed on the LCD I converted the ASCII value to the correct index. This index was used to look up which segments are lit or not lit for each character stored in the array.

For the characters that couldn't be displayed on the LCD I instead sent a space character to be safe but you could use another character if you wanted to. And if there were less than 16 characters in the string, spaces were padded onto the end so that the whole display was always updated.

If you want to show numbers on the LCD it's a simple matter of converting the number variable into String form which even takes care of the minus sign for negative values (as soon as I had added the minus sign in 7-segment form). Originally, as another test, I wanted to display a sum on the LCD and the result but a plus symbol isn't possible using 7-segment so I did a minus problem instead.

It's a good idea to put the coding into a class so that any program that wants to use the LCD module can and won't have to worry about knowing how to use the LCD; you'll also save on code as well be reusing it. You will need only provide public functions to allow the program to display data on the LCD module, keeping everything else private.

All content of this and related pages is copyright (c) James S. 2010-2015

New: Raspberry Pi to HD44780 LCD module (24/11/2014)
Update: DLR1414 4 Character 5x7 Alphanumeric LED Dot Matrix Display Module (21/05/2014)
Fax machine LCD Module (Added: 10/06/2013)
VTECH Precomputer 2000 LCD Module (Added: 25/05/2012)
Build Your Own Display
WGM-12232M Graphic LCD Module


You can email me at james.boshikoopa@gmail.com

To return to the main electronics page please click here.
ċ
gpio_hd44780_test.py
(4k)
James Stuart,
Nov 24, 2014, 7:16 AM
Comments