HD44780 HOWTO ------------- There are several ways of wiring up the HD44780 devices. Your choice will probably be governed largely by your ability to wire up each one and/or a desire to use the device with other programs. The LCDproc HD44780 driver supports the following connections on a parallel port: - 4-bit - 8-bit (winamp style) - extended 8-bit (LCD + LED bargraph) - serial LPT And supports a PIC-an-LCD connected to a serial port. The driver also lets you use multiple displays as a single virtual display. For example, a 4, 2 and 1 line display can be used to form a 7 line display. The number of displays is limited by the individual HD44780 driver. 1. Connections -------------- 1.1 Common connections for all connectiontypes ----------------------------------------------- No matter what connectiontype you choose, you will always need some connections. They are explaned here. 1.1.1 Power ------------ All variants use the same method of obtaining power. i.e., for each LCD: LCD pin signal 1 GND (connect to any of pins 18 - 25 of you parallel port) 2 +5V 3 Vadj (contrast) WARNING: Always double check your power connection, your display probably wont survive a reversely connected supply ! There are several ways to get 5V: - Connect to a 5V line intented for disk drives (the red wire is 5V, black is GND). - Get it from a joystick port (pin 1 and 9 are 5V, 4, 5 and 12 are GND). It seems that some soundcards can use these lines for communication, so if you want to use this first check wether it really gives a 'clean' 5V. - If you don't have a backlight, you can sometimes get the needed mA's from the LPT port itself. Connect a few diodes from the data pins to a capacitor and you have the 5V. If it's strong enough is another question... - Get it from the keyboard connector. I do not recommend to use this with a backlight, as the keyboard connector is often protected with a fuse of 100mA or 200mA. Connecting the contrast adjusting pin (Vadj.): (variable resistor) .------. Vcc ---| 10k |--- GND `---^--' /|\ | Vadj. 1.1.2 Keypad ------------- You can connect a keypad with all connection types. The maximum supported number of keys differs per type. There are several ways to connect the keys to the input pins. 1.1.2.1 Direct keys -------------------- If you connect a key like sketched below, then you can only connect one key per input pin. It is a simple solution if you need only few keys. O 5V | | - | | 10k | | - | +-----------o input (X) | | o \ o | | === GND By default, the following keystrokes are generated by the different keys: X0 A X1 B X2 C X3 D X4 E You should modify and recompile the driver to get other keystrokes. 1.1.2.2 Matrix keys -------------------- Using a matrix, we can connect much more keys. To simplify the drawing here, we replace all switches with an @ symbol: X line | | Y line ---+--------- | | | o | = --@-- \ | | o | | | +---+ | | We connect the matrix of keys like this: Y0 o---|<---@--@--@ | | | Y1 o---|<---@--@--@ | | | Y2 o---|<---@--@--@ | | | Y3 o---|<---@--@--@ O 5V | | | | diodes | | | ___ | 1N4148 +----------|___|---+ | | | ___ | | +-------|___|---+ | | | ___ | | | +----|___|---+ resistors 22k | | | o o o X0 X1 X2 As you can see, you need 1 resistor per X line, and 1 diode per Y line. Lcdproc will presume that you have a keypad with a layout like a telephone connected, with X and Y lines connected as show. To be more precise, it assumes this: X0 X1 X2 X3 Y0 1 2 3 A Y1 4 5 6 B Y2 7 8 9 C Y3 * 0 # D If you only need 10 keys, leave the rest away. However, the lcdproc menu is controlled by the keystrokes A to D. You should modify and recompile the driver to get an other keypad layout. You can buy arrays of keys that are connected like this in the electronics shop. They usually call it a matrix keypad. To hook it to lcdproc, you would only need to add the resistors and diodes. If you want to use just one return line, for example with the serialLpt wiring, it looks (completely drawn) like this: O 5V | .-. | | 4k7 or 22k diodes | | 1N4148 '-' ___ | Y0 o---|<---o o---+ ___ | Y1 o---|<---o o---+ ___ | Y2 o---|<---o o---+ ___ | Y3 o---|<---o o---+----o return line If the driver generates keypresses without you actually pressing a key, it might be that the unconnected input lines are picking up electromagnetic waves from the air. In that case connect the unconnected input lines (pin 10, 11, 12, 13 and 15 of the LPT) to VCC = 5V. 1.1.3 Backlight --------------- A small extension allows you to switch the backlight of the display on and off. At the moment only the 4bit and winamp connection types support this. The extension uses one output pin, you cannot use that pin for other functions anymore. The wiring looks like this: O 5V ___ | +---|___|---+ LPT Sub-D connector | 4k7 | | |e ___ | b |/ BL pin o------------|___|---+---------| 1k |\ bc327 |c | LCD connector | +--------o 15 backlight +--------o 16 GND backlight | === GND Note: 4k7 means 4,7 kohm. The BC327 transistor has the following connections: _____ | | |bc327| |_____| | | | | | | | | | c b e Sometimes the backlight connections are not on the 'main' connector, but on the side. If that is the case, there is usually NO RESISTOR present to limit the current through the LEDs. Therefor you should then add a resistor after the transistor of about 10 ohm (see display documentation). If you want the backlight to light a bit while it's switched 'off', you can add a resistor bypassing the transistor from e to c, with a value of, say 47ohm or 22ohm. (My 4x20 has an internal resistor of 6ohm, so with 47 ohm extra it lights at only 1/9th. I like this. Joris.) 1.2 4-bit ---------- This is originally based on "lcdtext" (by Matthias Prinke). The pinouts are: printer port LCD D0 (2) D4 (11) D1 (3) D5 (12) D2 (4) D6 (13) D3 (5) D7 (14) D4 (6) RS (4) D5 (7) RW (5) (LCD3 - 6) (optional - pull all LCD RW low) D6 (8) EN (6) D7 (9) EN2 (LCD2 - 6) (optional) If you want to connect more than two displays to the parallel port then wire D5 (pin 7) to the enable line (pin 6) of the third LCD. Then for displays four to seven use: printer port LCD STR (1) EN4 LF (14) EN5 INIT (16) EN6 SEL (17) EN7 The optional keypad can be connected as follows: printer port keypad D0 (2) Y0 D1 (3) Y1 D2 (4) Y2 D3 (5) Y3 D4 (6) Y4 D5 (7) Y5 nSTRB (1) Y6 nLF (14) Y7 INIT (16) Y8 nSEL (17) Y9 nACK (10) X0 BUSY (11) X1 PAPEREND (12) X2 SELIN (13) X3 nFAULT (15) X4 The optional backlight wiring should be connected to D5, pin 7. 1.3 8-bit "Winamp" ------------------- This type of connection should work with winamp. printer port LCD D0 (2) D0 (7) D1 (3) D1 (8) D2 (4) D2 (9) D3 (5) D3 (10) D4 (6) D4 (11) D5 (7) D5 (12) D6 (8) D6 (13) D7 (9) D7 (14) nSTRB (1) EN (6) nLF (14) nRW (5) (EN3 6 - LCD 3) (optional) INIT (16) RS (4) nSEL (17) EN2 (6 - LCD 2) (optional) If you want the display to work with the Winamp plugin, wire nLF (pin 14) to nRW of your LCD. You can then use the plugin in bidirectional mode (wich is much faster). With 3 connected LCDs this is not possible. Note from Benjamin: I haven't tried using winamp while having the third LCD connected to this line. The optional keypad can be connected as follows: printer port keypad D0 (2) Y0 D1 (3) Y1 D2 (4) Y2 D3 (5) Y3 D4 (6) Y4 D5 (7) Y5 D6 (8) Y6 D7 (9) Y7 nLF (14) Y8 INIT (16) Y9 nACK (10) X0 BUSY (11) X1 PAPEREND (12) X2 SELIN (13) X3 nFAULT (15) X4 The optional backlight wiring should be connected to nSEL, pin 17. 1.4 Extended 8-bit "lcdtime" ----------------------------- This is originally based on "lcdtime" (by Benjamin Tse ) and allows you to combine the LCD with a LED bargraph. The LCD is driven by LCDproc and the LEDs by another program such as portato. Further details can be obtained from: http://metalab.unc.edu/pub/linux/system/status/lcdtime-0.2.tar.gz http://metalab.unc.edu/pub/linux/system/status/meter-0.2.tar.gz http://metalab.unc.edu/pub/linux/system/status/portato-1.2.tar.gz Theoretically this wiring sends the data over twice as slow as the winamp or ext8bit wirings, because it only sends 4 bits at a time. The LCD connections are: printer port LCD D0 (2) D0 (7) D1 (3) D1 (8) D2 (4) D2 (9) D3 (5) D3 (10) D4 (6) D4 (11) D5 (7) D5 (12) D6 (8) D6 (13) D7 (9) D7 (14) nSEL (17) - nSTRB (1) RS (4) nLF (14) RW (5) (LCD2 - 6) (optional - pull all LCD RW low) INIT (16) EN (6) See the lcdtime tar-ball (above) for full details of the bargraph connections. The optional keypad can be connected as follows: printer port keypad D0 (2) Y0 D1 (3) Y1 D2 (4) Y2 D3 (5) Y3 D4 (6) Y4 D5 (7) Y5 D6 (8) Y6 D7 (9) Y7 nSTRB (1) Y8 nSEL (17) Y9 nACK (10) X0 BUSY (11) X1 PAPEREND (12) X2 SELIN (13) X3 nFAULT (15) X4 The backlight wiring should be attached to nSEL, pin 17. Because the portato program (mentioned above) also uses this pin to control the bargraph, you cannot use the backlight control together with the bargraph. 1.5 Serial LPT --------------- This interface uses a handful of wires to interface to the HD44780. Suitable for high noise, long connections. Designed by Andrew McMeikan . The original wiring and driver can be found at: http://members.xoom.com/andrewmuck I (Joris) have extended this driver and the wiring a bit. It now supports keys again (it had earlier supported keys, but some time did not). Further I have extended the driver and the wiring to be able to run using 2 instead of 3 output pins. That's even one less pin ! :) Of course the use of fewer lines than the other wirings can not stay without drawbacks. In this case the simplicity of the long feeding wires is compensated by some intelligence in the decoding of the data. If you have no experience with the soldering iron, I do not recommend to build this wiring. OK, so here is the wiring. First of the 'simple' 3 wires version. IC1 is the shift register, a 4094. Do not forget to connect the 5V to pin 16 and GND to pin 8 of the IC. IC1 ----------- | 4094 | 5V | shift reg | display O | | /keys | 1| |3 +----|STR Q0|---------------------o 7 D0 | | |4 /Y0 Data | 2| Q1|---------------------o 8 D1 D3 5 o---------------------------|D |5 /Y1 | | Q2|---------------------o 9 D2 | 3|CK |6 /Y2 D4 6 o---------------------------| Q3|---------------------o 10 D3 | | |10 /Y3 | 15| Q4|---------------------o Y4 +----|OE |11 | Q5|---------------------o 4 RS | |12 /Y5 | Q6|---------------------o Y6 | |13 | Q7|---------------------o Y7 | |9 | QS|-- +--o 5 RW | __|10 | | QS|-- === | | ----------- D2 4 o-------------------------------------------------------------o 6 EN D7 9 o-------------------------------------------------------------o 6 EN2 (2nd LCD) 5V O-----+--------+----------------------------------+-----o 2 VCC | | | | | | |100n O 16 .-. --- IC1 | |<---o 3 Vlcd --- O 8 | |10k | | '-' GND | | | 18..25 o-----------+--------+--------------------------+-------+-----o 1 GND | === GND The second possible wiring is with 2 output lines. This one is a bit more complex. If you do not understand the schematic, do not build it. IC2 ----------- | 74HCT164 | | shift reg | display | | /keys Data 1| |3 D3 5 o-----------------------+---|D Q0|---------------------o 7 D0 | | |4 /Y0 | 2| Q1|---------------------o 8 D1 +---|D |5 /Y1 | Q2|---------------------o 9 D2 | |6 /Y2 | Q3|---------------------o 10 D3 | |10 /Y3 Clock 8| Q4|---------------------o Y4 D4 6 o---------------------------|CK |11 | Q5|---------------------o 4 RS ___ 9|\ 8 9|_ |12 /Y5 +--|___|--+----| >o----|R Q6|---------------------o Y6 | 22k | |/ | |13 | --- IC1 | Q7|---+ +--o 5 RW | --- | | | 5V | | |100p ----------- | O === | | | | | === | .-. | | | |22k +--------------------------------------+ | | | '-' | ___ 11|\ 10 | 5|\ 6 +--|___|--+----| >o-------------------||----+-----| >o---o 6 EN 22k | |/ 22p |/ --- IC1 IC1 --- |22p | IC1=74HCT14 (6x Schmitt trigger inverter) === 5V O--+-------+------+------+------------------------+-----o 2 VCC | | | | 13|\ 12 | | | | +---| >o- | |100n O 14 O 14 |/ .-. --- IC1 IC2 | |<---o 3 Vlcd --- O 7 O 7 1|\ 2 3|\ 4 | |10k | | | +--| >o- +--| >o- '-' GND | | | | |/ | |/ | 18..25 o--------+-------+------+-------+----------+-----+------+-----o 1 GND | === GND 1.6 PIC-an-LCD serial device "picanlcd" ---------------------------------------- The PIC-an-LCD module is also supported. It is not connected to the LPT port but to a serial port, which saves you from a lot of potential problems. To use it, specify the device to which you have connected the module in the config file with the Device= setting. The default is /dev/lcd. It does not support a keypad nor backlight switching. 1.7 LIS2 Usb device =================== LIS2 from VLSystem (http://www.vlsys.co.kr) is a full featured usb vfd module with four channel fan controls. This device can be access as a serial device with help of the kernel modules ftdi_sio wich map the usb port to a serial port (/dev/ttyUSBx). To use LIS2 with LCDproc, you will need a few settings in the config file : [server] Driver=hd44780 [hd44780] size=20x2 ConnectionType=lis2 #Device=/dev/ttyUSB0 extendedmode=false Size of the display (size=20x2), driver to use in ConnectionType: lis2, the serial Usb device as device settings (default is /dev/ttyUSB0), and extendedmode should be left to false, as this device don't seems to support hd44780 extended mode. The device support only a subset of the hd44780 specification. For now, I find this function: Function #1 : Clear Screen Send char(0) Send char(160) Send char(0) Send char(167) Function #2 : Cursors move: (x,y) Send char(0) Send char(160 + y) Send char(x) Send char(167) Function #3 : Write a char Send char(asciiCode) : asciiCode 0 to 7 can be redefine to user charset (see below). Function #4 : Redefine a char Send char(0) Send char(171) Send char(matriceNum) : Ascii code of char to refine, from 0 to 7 Send char(line) : the line to change Send char(pixel) : define wich pixel of the line is on or off. There's 5 pixels by line, adresse by power of 2, from right to left (16, 8, 4, 2, 1). Function #5 : Fan Control Send char(0) Send char(174) Send char(0) Send char(0) Send char(fan1) Send char(0) Send char(fan2) Send char(0) Send char(fan3) Send char(0) Send char(fan4) Send char(0) Send char(0) fanX is a value from 0 to 255, 0 is fan off, 255 is fan full speed. 1.5.1 Keypad ------------ To understand this part of the serialLpt documentation, you also need to read the keypad section in this document. serialLpt wiring supports a keypad. The 3 wires version supports 8 keys, or if you use multiple return lines up to 8 x 5 = 40 lines. The 2 wires version supports 7 keys, or with multiple return lines 7 x 5 = 35 keys. The return lines are the following: nACK (10) X0 BUSY (11) X1 PAPEREND (12) X2 SELIN (13) X3 nFAULT (15) X4 On lines longer than, say a meter, you should buffer the return line(s). If you only have 1 return line, you can buffer it with two remaining buffers from the 74HCT14: 1|\ 2 13|\ 12 ___ keypad o-----| >o------| >o---|___|---+---o input pin on LPT port return |/ |/ 220E | IC1 IC1 --- --- 1nF | === Also a backlight is suported. You will also need a port from the 74HCT14 for that. The BL output below should be connected to the BL input in paragraph 1.1.3. ___ 3|\ 4 Data o-----|___|--+----| >o----o BL output LPT-D3 470k | |/ --- IC1 --- |100nF | === 2. Compiling ------------ Make sure that the HD44780 files are built when you run configure. This can be done by specifying "--enable-drivers=all" or by "--enable-drivers=hd44780". 3. Running ---------- Modify the LCDd.conf file before you run LCDd. In this config file are detailed instructions on how to configure the HD44780 driver. Then as usual, start LCDd with the correct config file: LCDd -c ./LCDd.conf for example. If you want to override the driver selection in LCDd.conf then use: LCDd -c ./LCDd.conf -d HD44780 If you use this, the HD44780 driver will read the options from the config file. 4. Miscellania --------------- This text originally taken from a message by Bill Farrow . Updated February 2000, Benjamin Tse (blt@ComPorts.com) Updated October 2001, Joris Robijn (joris at robijn.net)