wiki:HD44780_09

HD44780

This driver supports all display modules based on the Hitachi HD44780 chip. These displays are made by different manufactures, and come in various sizes. The HD44780 is probably the most common display driver.

The displays are connected to the parallel board (see "Wiring" below), and are quite timing-critical. There's no way to delay a usermode program under Linux for e.g. 40 usec, so we have to do busy-waiting. This has been done in a delay loop, which had to be calibrated. Since 0.9.8 there are two new delay loops, one based on the processor's TSC (Time Stamp Counter), one based on gettimeofday(). lcd4linux decides automatically which one to use (it prefers the TSC method, but falls back to gettimeofday() if neither the tsc flag nor the MHz value is set in /proc/cpuinfo). Calibration is no longer necessary!

The driver knows of two ways of controlling the parallel port: The (old, ugly and unportable) raw programming of ports, and the new, cool, great ppdev() style. You decide which one to use by specifying either a hexadecimal value or a device file with the 'Port' entry in the config file.

Note that the old port programming only works with standard ports (0x3f8, 2f8,...), but not with PCI parallel port cards.

ppdev requires kernel 2.4. The configure script detects if you have the required include files, and deactivates ppdev if they are not there. You should use ppdev whenever possible''' Raw port access may be dropped someday.

Note that you have to use parport devices (usually /dev/parports/* with major number 99), the printer devices (/dev/printers/* with major number 6) do NOT work!

The driver supports vertical, horizontal and split bars (two independent bars in one line), all bar types can be used simultanously. As the displays only have 8 user-defined characters, the needed characters to display all the bars must be reduced to 8. This is done by replacing characters with similar ones. To reduce flicker, a character which is displayed at the moment, will not be redefined, even if it's not used in this run. Only if the character compaction fails, this characters will be redefined, too.

Configuration:

The driver needs the following entries in lcd4linux.conf:

Display: "HD44780"
Port: either the hexadecimal address of the parallel port ("0x378") or a ppdev device ("/dev/parports/0")
Size: [columns]x[rows] e.g. "16x2"
Bits: set to 4 if you want to use the 4-bit wiring; default "8"
Controllers: set to 2 if you have a dual-controller display; default "1"
Wire.RW: default "GND" (see Wiring below)
Wire.RS: default "AUTOFD"
Wire.ENABLE: default "STROBE"
Wire.ENABLE2: default "GND"
Wire.GPO: default "GND"
GPOs: number of general purpose outputs, use 0 (zero, which is the default) to deactivate this feature

Wiring:

There are two basic wiring modes for HD44780-Displays: a 4 bit and a 8 bit mode. Since 0.9.11 lcd4linux supports both modes!

There are large (40x4) displays which internally constist of two HD44780 chips, with two seperate "Enable" lines. Since 0.9.11 lcd4linux supports these displays, too!

Normally a HD44780-based display has 14 or 16 pins, where pins 15 and 16 are used for backlight. Power (+5V) must be supplied via pins 1(GND) and 2(+5V), be careful not to change polarity, you will destroy your display! Pin 3 is used to control the contrast, you can either hardwire it to GND (pin 1) or place a potentiometer (10k-20k) between pins 1 and 2, and connect pin 3 to the slider.

There are a lot of different wirings out there (lcdproc, WinAmp, ...), so I decided to implement a "parallel port abstraction layer" which makes the wiring completely configurable! (this is what the Wire.xy entries in the configuration are for). This feature is available in V0.9.9, previous versions still use the default wiring. If you don't use the this default wiring scheme, you have to change these lines accordingly.

The wiring configuration uses abstract signal names (e.g. STROBE) instead of pin numbers on the parallel port. So here's a translation table:

PinNameI/O
1STROBEOut
2DB0I/O
3DB1I/O
4DB2I/O
5DB3I/O
6DB4I/O
7DB5I/O
8DB6I/O
9DB7I/O
10ACKIn
11BUSYIn
12PAPER ENDIn
13SELECTOut
14AUTOFDOut
15ERRORIn
16INITOut
17SLCTINIn
18-25GNDn/a

Now for the wiring details in 8-bit mode:

  • The data lines (DB0..DB7 on the display, DB1..DB8 on the parallel port) are connected directly.
  • The "RS" (Register Select, 0=data, 1=command) signal has to be connected to one of the control signals (STROBE, SELECT, AUTOFD or INIT). LCD4Linux's default is AUTOFD.
  • The "RW" (Read/Write?) signal from the display may be harwired to GND, we do not read anything from the display. If you connect it to a control signal, you have to specify it with the Wire.RW line. LCD4Linux's default is GND
  • The "Enable" (toggled when data is valid) signal has to be connected to one of the control signals. LCD4Linux's default is STROBE.
  • The second "Enable" (for displays with two controllers) signal has to be connected to one of the control signals. LCD4Linux's default is GND (i.e. not connected).

and with 4-bit mode:

  • The data lines (DB0..DB3 on the display, DB1..DB4 on the parallel port) are connected directly.
  • The "RS" (Register Select, 0=data, 1=command) signal has to be connected to one of the other data lines (DB1..4). LCD4Linux's default is DB4.
  • The "RW" (Read/Write?) signal from the display may be harwired to GND, we do not read anything from the display. If you connect it to a control signal, you have to specify it with the Wire.RW line. LCD4Linux's default is GND
  • The "Enable" (toggled when data is valid) signal has to be connected to one of the other data lines. LCD4Linux's default is DB6.
  • The second "Enable" (for displays with two controllers) signal has to be connected to one of the other data lines. LCD4Linux's default is GND (i.e. not connected).

Wiring Examples:

lcd4linux default 8-bit wiring:

 Wire.RW "GND"
 Wire.RS "AUTOFD"
 Wire.ENABLE "STROBE"
 Wire.ENABLE2 "SELECT"
 Wire.GPO "INIT"

lcd4linux default 4-bit wiring:

 Wire.RS "DB4"
 Wire.RW "DB5"
 Wire.ENABLE "DB6"
 Wire.ENABLE2 "DB7"
 Wire.GPO "GND"

WinAmp style wiring:

 Wire.RW "AUTOFD"
 Wire.RS "INIT"
 Wire.ENABLE "STROBE"
 Wire.GPO "GND"

GPO's:

You can connect up to 8 digital output lines to the parallel port with a simple additional circuit (e.g. to drive a LED). These lines can be controlled by lcd4linux, and need an additional control signal from the parallel port. You have to specify this signal with the Wire.GPO entry in the config file (the default is GND, i.e. not connected).

Schematic:

I'm using a 'general purpose' interface board to quickly test various displays. It consists of a stabilized voltage regulator, a connector to the parallel port, the circuit to drive 8 LED's, and two potentiometers to control backlight and contrast. Here's the schematic and board (designed with eagle):

HD44780 schematics HD44780 board


Last modified 13 years ago Last modified on 08/06/06 10:02:35