Files
lcdproc/docs/lcdproc-user/drivers/hd44780.docbook
T

1928 lines
52 KiB
Plaintext

<sect1 id="hd44780-howto">
<title>The HD44780 Driver</title>
<para>
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.
</para>
<para>
The LCDproc HD44780 driver supports the following connections on a
parallel port:
</para>
<itemizedlist>
<listitem><para>4-bit</para></listitem>
<listitem><para>8-bit (winamp style)</para></listitem>
<listitem><para>extended 8-bit (LCD + LED bargraph)</para></listitem>
<listitem><para>serial LPT</para></listitem>
</itemizedlist>
<para>
It also supports the following connections:
</para>
<itemizedlist>
<listitem><para>A PIC-an-LCD or LCD serializer connected to a serial port</para></listitem>
<listitem><para>A I<superscript>2</superscript>C port expander connected to an I<superscript>2</superscript>C port</para></listitem>
</itemizedlist>
<para>
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.
</para>
<sect2 id="hd44780-connections">
<title>Connections</title>
<sect3 id="hd44780-connections-common">
<title>Common connections for all connectiontypes</title>
<para>
No matter what connectiontype you choose, you will always need some
connections. They are explaned here.
</para>
<sect4 id="hd44780-connections-power">
<title>Power</title>
<para>
All variants use the same method of obtaining power. i.e., for each LCD:
</para>
<table>
<title>HD44780: Power Connections</title>
<tgroup cols="3">
<thead>
<row>
<entry>LCD</entry>
<entry>pin</entry>
<entry>signal</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>GND</entry>
<entry>(connect to any of pins 18 - 25 of you parallel port)</entry>
</row>
<row>
<entry>2</entry>
<entry>+5V</entry>
<entry></entry>
</row>
<row>
<entry>3</entry>
<entry>Vadj</entry>
<entry>(contrast)</entry>
</row>
</tbody>
</tgroup>
</table>
<warning>
<para>
Always double check your power connection, your display will probably
NOT survive a reversely connected supply !
</para>
</warning>
<para>
There are several ways to get 5V:
</para>
<itemizedlist>
<listitem><para>
Connect to a 5V line intented for disk drives (the red wire is 5V,
black is GND).
</para></listitem>
<listitem><para>
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.
</para></listitem>
<listitem><para>
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...
</para></listitem>
<listitem><para>
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.
</para></listitem>
</itemizedlist>
<figure>
<title>HD44780: Connecting the contrast adjusting pin (Vadj.)</title>
<screen>
<![CDATA[
(variable resistor)
.------.
Vcc ---| 10k |--- GND
`---^--'
/|\
|
Vadj.
]]>
</screen>
</figure>
</sect4>
<sect4 id="hd44780-connections-keypad">
<title>Keypad</title>
<para>
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.
</para>
<sect5 id="hd44780-connections-keypad-direct">
<title>Direct Keys</title>
<para>
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.
</para>
<figure>
<title>HD44780: Direct Keys</title>
<screen>
<![CDATA[
O 5V
|
|
-
| | 10k
| |
-
|
+-----------o input (X)
|
|
o
\
o
|
|
=== GND
]]>
</screen>
</figure>
<para>
By default, the following keystrokes are generated by the different keys:
</para>
<table>
<title>HD44780: Default Keystrokes</title>
<tgroup cols="2">
<tbody>
<row>
<entry>X0</entry>
<entry>A</entry>
</row>
<row>
<entry>X1</entry>
<entry>B</entry>
</row>
<row>
<entry>X2</entry>
<entry>C</entry>
</row>
<row>
<entry>X3</entry>
<entry>D</entry>
</row>
</tbody>
</tgroup>
</table>
</sect5>
<sect5 id="hd44780-connections-keypad-matrix">
<title>Matrix Keys</title>
<para>
Using a matrix, we can connect much more keys. To simplify the drawing here,
we replace all switches with an @ symbol:
</para>
<figure>
<title>HD44780: Single Matrix Key</title>
<screen>
<![CDATA[
X line
|
|
Y line ---+---------
| | |
o | = --@--
\ | |
o |
| |
+---+
|
|
]]>
</screen>
</figure>
<para>
We connect the matrix of keys like this:
</para>
<figure>
<title>HD44780: Complete Key Matrix</title>
<screen>
<![CDATA[
Y0 o---|<---@--@--@
| | |
Y1 o---|<---@--@--@
| | |
Y2 o---|<---@--@--@
| | |
Y3 o---|<---@--@--@ O 5V
| | | |
diodes | | | ___ |
1N4148 +----------|___|---+
| | | ___ |
| +-------|___|---+
| | | ___ |
| | +----|___|---+ resistors 22k
| | |
o o o
X0 X1 X2
]]>
</screen>
</figure>
<para>
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:
</para>
<table>
<title>HD44780: Keypad Layout</title>
<tgroup cols="5">
<tbody>
<row>
<entry></entry>
<entry><emphasis>X0</emphasis></entry>
<entry><emphasis>X1</emphasis></entry>
<entry><emphasis>X2</emphasis></entry>
<entry><emphasis>X3</emphasis></entry>
</row>
<row>
<entry><emphasis>Y0</emphasis></entry>
<entry>1</entry>
<entry>2</entry>
<entry>3</entry>
<entry>A</entry>
</row>
<row>
<entry><emphasis>Y1</emphasis></entry>
<entry>4</entry>
<entry>5</entry>
<entry>6</entry>
<entry>B</entry>
</row>
<row>
<entry><emphasis>Y2</emphasis></entry>
<entry>7</entry>
<entry>8</entry>
<entry>9</entry>
<entry>C</entry>
</row>
<row>
<entry><emphasis>Y3</emphasis></entry>
<entry>*</entry>
<entry>0</entry>
<entry>#</entry>
<entry>D</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
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.
</para>
<para>
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.
</para>
<para>
If you want to use just one return line, for example with the serialLpt
wiring, it looks (completely drawn) like this:
</para>
<figure>
<title>HD44780: One Return Line</title>
<screen>
<![CDATA[
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
]]>
</screen>
</figure>
<tip>
<para>
If the driver generates keypresses without that you actually press 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.
</para>
</tip>
</sect5>
</sect4>
<sect4 id="hd44780-connections-backlight">
<title>Backlight</title>
<para>
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:
</para>
<figure>
<title>HD44780: Backlight Wiring</title>
<screen>
<![CDATA[
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
]]>
</screen>
</figure>
<caution>
<para>
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).
</para>
</caution>
<tip>
<para>
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.)
</para>
</tip>
</sect4>
</sect3>
<sect3 id="hd44780-4-bit">
<title>4-bit</title>
<para>
This is originally based on "lcdtext" (by Matthias Prinke).
</para>
<table>
<title>HD44780: 4-bit Pinouts (1)</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>LCD</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>D4 (11)</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>D5 (12)</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>D6 (13)</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>D7 (14)</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>RS (4)</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>RW (5) (LCD3 - 6) (optional - pull all LCD RW low (*) )</entry>
</row>
<row>
<entry>D6 (8)</entry>
<entry>EN (6)</entry>
</row>
<row>
<entry>D7 (9)</entry>
<entry>EN2 (LCD2 - 6) (optional)</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
(*) on the RW line of the display: this line decides whether the display receives data from the
LPT port, or whether it sends data to the LPT port. If grounded, it receives. If High or connected
to nothing at all, it "sends" (i.e., will not work as intended). So, if you are not sure that
you need it otherwise, then connect it to GND. This certainly applies if you have only one display.
</para>
<para>
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:
</para>
<table>
<title>HD44780: 4-bit Pinouts (2)</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>LCD</entry>
</row>
</thead>
<tbody>
<row>
<entry>STR (1)</entry>
<entry>EN4</entry>
</row>
<row>
<entry>LF (14)</entry>
<entry>EN5</entry>
</row>
<row>
<entry>INIT (16)</entry>
<entry>EN6</entry>
</row>
<row>
<entry>SEL (17)</entry>
<entry>EN7</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The optional keypad can be connected as follows:
</para>
<table>
<title>HD44780: 4-bit Keypad Pinouts</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>LCD</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>Y0</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>Y1</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>Y2</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>Y3</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>Y4</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>Y5</entry>
</row>
<row>
<entry>nSTRB (1)</entry>
<entry>Y6</entry>
</row>
<row>
<entry>nLF (14)</entry>
<entry>Y7</entry>
</row>
<row>
<entry>INIT (16)</entry>
<entry>Y8</entry>
</row>
<row>
<entry>nSEL (17)</entry>
<entry>Y9</entry>
</row>
<row>
<entry>nACK (10)</entry>
<entry>X0</entry>
</row>
<row>
<entry>BUSY (11)</entry>
<entry>X1</entry>
</row>
<row>
<entry>PAPEREND (12)</entry>
<entry>X2</entry>
</row>
<row>
<entry>SELIN (13)</entry>
<entry>X3</entry>
</row>
<row>
<entry>nFAULT (15)</entry>
<entry>X4</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The optional backlight wiring should be connected to D5, pin 7.
</para>
</sect3>
<sect3 id="hd44780-8-bit-winamp">
<title>8-bit "Winamp"</title>
<para>
This type of connection should work with winamp.
</para>
<table>
<title>HD44780: "Winamp" wiring</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>LCD</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>D0 (7)</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>D1 (8)</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>D2 (9)</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>D3 (10)</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>D4 (11)</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>D5 (12)</entry>
</row>
<row>
<entry>D6 (8)</entry>
<entry>D6 (13)</entry>
</row>
<row>
<entry>D7 (9)</entry>
<entry>D7 (14)</entry>
</row>
<row>
<entry>nSTRB (1)</entry>
<entry>EN (6)</entry>
</row>
<row>
<entry>nLF (14)</entry>
<entry>nRW (5) (EN3 6 - LCD 3) (optional (*) )</entry>
</row>
<row>
<entry>INIT (16)</entry>
<entry>RS (4)</entry>
</row>
<row>
<entry>nSEL (17)</entry>
<entry>EN2 (6 - LCD 2) (optional)</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
(*) on the RW line of the display: this line decides whether the display receives data from the
LPT port, or whether it sends data to the LPT port. If grounded, it receives. If High or connected
to nothing at all, it "sends" (i.e., will not work as intended). So, if you are not sure that
you need it otherwise, then connect it to GND. This certainly applies if you have only one display.
</para>
<para>
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.
</para>
<para>
The optional keypad can be connected as follows:
</para>
<table>
<title>HD44780: "Winamp" wiring - Keypad</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>keypad</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>Y0</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>Y1</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>Y2</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>Y3</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>Y4</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>Y5</entry>
</row>
<row>
<entry>D6 (8)</entry>
<entry>Y6</entry>
</row>
<row>
<entry>D7 (9)</entry>
<entry>Y7</entry>
</row>
<row>
<entry>nLF (14)</entry>
<entry>Y8</entry>
</row>
<row>
<entry>INIT (16)</entry>
<entry>Y9</entry>
</row>
<row>
<entry>nACK (10)</entry>
<entry>X0</entry>
</row>
<row>
<entry>BUSY (11)</entry>
<entry>X1</entry>
</row>
<row>
<entry>PAPEREND (12)</entry>
<entry>X2</entry>
</row>
<row>
<entry>SELIN (13)</entry>
<entry>X3</entry>
</row>
<row>
<entry>nFAULT (15)</entry>
<entry>X4</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
The optional backlight wiring should be connected to nSEL, pin 17.
</para>
</sect3>
<sect3 id="hd44780-8-bit-lcdtime">
<title>8-bit "lcdtime"</title>
<para>
This is originally based on "lcdtime" (by Benjamin Tse
<email>blt@ComPorts.com</email>) 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:
</para>
<para>
<ulink url="http://metalab.unc.edu/pub/linux/system/status/lcdtime-0.2.tar.gz">http://metalab.unc.edu/pub/linux/system/status/lcdtime-0.2.tar.gz</ulink>
<ulink url="http://metalab.unc.edu/pub/linux/system/status/meter-0.2.tar.gz">http://metalab.unc.edu/pub/linux/system/status/meter-0.2.tar.gz</ulink>
<ulink url="http://metalab.unc.edu/pub/linux/system/status/portato-1.2.tar.gz">http://metalab.unc.edu/pub/linux/system/status/portato-1.2.tar.gz</ulink>
</para>
<note>
<para>
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.
</para>
</note>
<para>
The LCD connections are:
</para>
<table>
<title>HD44780: "lcdtime" wiring</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>LCD</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>D0 (7)</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>D1 (8)</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>D2 (9)</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>D3 (10)</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>D4 (11)</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>D5 (12)</entry>
</row>
<row>
<entry>D6 (8)</entry>
<entry>D6 (13)</entry>
</row>
<row>
<entry>D7 (9)</entry>
<entry>D7 (14)</entry>
</row>
<row>
<entry>nSEL (17)</entry>
<entry>-</entry>
</row>
<row>
<entry>nSTRB (1)</entry>
<entry>RS (4)</entry>
</row>
<row>
<entry>nLF (14)</entry>
<entry>RW (5) (LCD2 - 6) (optional - pull all LCD RW low (*))</entry>
</row>
<row>
<entry>INIT (16)</entry>
<entry>EN (6)</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
(*) on the RW line of the display: this line decides whether the display receives data from the
LPT port, or whether it sends data to the LPT port. If grounded, it receives. If High or connected
to nothing at all, it "sends" (i.e., will not work as intended). So, if you are not sure that
you need it otherwise, then connect it to GND. This certainly applies if you have only one display.
</para>
<para>
See the lcdtime tar-ball (above) for full details of the bargraph
connections.
</para>
<para>
The optional keypad can be connected as follows:
</para>
<table>
<title>HD44780: "lcdtime" wiring - keypad</title>
<tgroup cols="2">
<thead>
<row>
<entry>printer port</entry>
<entry>keypad</entry>
</row>
</thead>
<tbody>
<row>
<entry>D0 (2)</entry>
<entry>Y0</entry>
</row>
<row>
<entry>D1 (3)</entry>
<entry>Y1</entry>
</row>
<row>
<entry>D2 (4)</entry>
<entry>Y2</entry>
</row>
<row>
<entry>D3 (5)</entry>
<entry>Y3</entry>
</row>
<row>
<entry>D4 (6)</entry>
<entry>Y4</entry>
</row>
<row>
<entry>D5 (7)</entry>
<entry>Y5</entry>
</row>
<row>
<entry>D6 (8)</entry>
<entry>Y6</entry>
</row>
<row>
<entry>D7 (9)</entry>
<entry>Y7</entry>
</row>
<row>
<entry>nSTRB (1)</entry>
<entry>Y8</entry>
</row>
<row>
<entry>nSEL (17)</entry>
<entry>Y9</entry>
</row>
<row>
<entry>nACK (10)</entry>
<entry>X0</entry>
</row>
<row>
<entry>BUSY (11)</entry>
<entry>X1</entry>
</row>
<row>
<entry>PAPEREND (12)</entry>
<entry>X2</entry>
</row>
<row>
<entry>SELIN (13)</entry>
<entry>X3</entry>
</row>
<row>
<entry>nFAULT (15)</entry>
<entry>X4</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
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.
</para>
</sect3>
<sect3 id="hd44780-seriallpt">
<title>Serial LPT</title>
<para>
This interface uses a handful of wires to interface to the
HD44780. Suitable for high noise, long connections. Designed by
Andrew McMeikan <email>andrewm@engineer.com</email>. The original wiring and
driver can be found at:
</para>
<para>
<ulink url="http://members.xoom.com/andrewmuck">http://members.xoom.com/andrewmuck</ulink>
</para>
<para>
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).
</para>
<para>
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 ! :)
</para>
<para>
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.
</para>
<para>
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.
</para>
<figure>
<title>HD44780: Serial LPT wiring ('simple')</title>
<screen>
<![CDATA[
IC1
-----------
| 4094 |
5V | shift reg | display
O | | keys
| 1| |4
+----|STR Q0|--------------------o 11 D4 Y0
| | |5
Data | 2| Q1|--------------------o 12 D5 Y1
D3 5 o-------------------------|D |6
| | Q2|--------------------o 13 D6 Y2
| 3| |7
D4 6 o-------------------------|CK Q3|--------------------o 14 D7 Y3
| | |14
| 15| Q4|--------------------o Y4
+----|OE |13
| Q5|--------------------o 4 RS Y5
| |12
| Q6|--------------------o Y6
| |11
| 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
]]>
</screen>
</figure>
<para>
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.
</para>
<figure>
<title>HD44780: Serial LPT wiring ('complex')</title>
<screen>
<![CDATA[
IC2
-----------
| 74HCT164 |
| shift reg | display
| | keys
Data 1| |3
D3 5 o---------------------+---|D Q0|--------------------o 11 D4 Y0
| | |4
| 2| Q1|--------------------o 12 D5 Y1
+---|D |5
| Q2|--------------------o 13 D6 Y2
| |6
| Q3|--------------------o 14 D7 Y3
| |10
Clock 8| Q4|--------------------o Y4
D4 6 o-------------------------|CK |11
| Q5|--------------------o 4 RS Y5
___ 9|\ 8 9|_ |12
+--|___|--+----| >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
]]>
</screen>
</figure>
<sect4 id="hd44780-seriallpt-keypad">
<title>Serial LPT Keypad</title>
<note>
<para>
To understand this part of the serialLpt documentation, you also need to
read the <link linkend="hd44780-connections-keypad">keypad section</link> in this document.
</para>
</note>
<para>
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.
</para>
<table>
<title>HD44780: Serial LPT - Keypad return lines</title>
<tgroup cols="2">
<tbody>
<row>
<entry>nACK (10)</entry>
<entry>X0</entry>
</row>
<row>
<entry>BUSY (11)</entry>
<entry>X1</entry>
</row>
<row>
<entry>PAPEREND (12)</entry>
<entry>X2</entry>
</row>
<row>
<entry>SELIN (13)</entry>
<entry>X3</entry>
</row>
<row>
<entry>nFAULT (15)</entry>
<entry>X4</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
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:
</para>
<figure>
<title>HD44780: Serial LPT - Keypad return lines buffered</title>
<screen>
<![CDATA[
1|\ 2 13|\ 12 ___
keypad o-----| >o------| >o---|___|---+---o input pin on LPT port
return |/ |/ 220E |
IC1 IC1 ---
--- 1nF
|
===
]]>
</screen>
</figure>
</sect4>
<sect4 id="hd44780-seriallpt-backlight">
<title>Serial LPT Backlight</title>
<para>
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 the
<link linkend="hd44780-connections-backlight">backlight section</link>
</para>
<figure>
<title>HD44780: Serial LPT - Backlight extra circuit</title>
<screen>
<![CDATA[
___ 3|\ 4
Data o-----|___|--+----| >o----o BL output
LPT-D3 470k | |/
--- IC1
---
|100nF
|
===
]]>
</screen>
</figure>
</sect4>
</sect3>
<sect3 id="hd44780-picanlcd">
<title>PIC-an-LCD serial device "picanlcd"</title>
<para>
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.
</para>
<para>
For more information see the
<ulink url="http://dalewheat.com/pdf/PIC-an-LCD.pdf">PIC-an-LCD User Manual</ulink>
by Dale Wheat.
</para>
</sect3>
<sect3 id="hd44780-lis2">
<title>LIS2 USB device "lis2"</title>
<para>
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 which map the USB port to a serial port (/dev/ttyUSBx).
</para>
</sect3>
<sect3 id="hd44780-lcdserializer">
<title>LCD serializer device "lcdserializer"</title>
<para>
LCD serializer connection is technically the same of PIC-an-LCD with the same advantages,
it uses the serial port making things really simple.
<ulink url="http://www.mindspring.com/~tcoonan/lcd.html">LCD serializer</ulink>
is not a commercial product like PIC-an-LCD, it's just a project found digging on the net and freely available.
You have all the tools and the code to build it yourself and to customize the behaviour of the device.
</para>
<sect4 id="hd44780-lcdserializer-whatyouneed">
<title>What you need</title>
<para>
<itemizedlist>
<listitem><para>Some electronic knowledge and familiarity with the soldering iron</para></listitem>
<listitem><para>A PIC16F84 (I used PIC16F84A) or PIC16C54</para></listitem>
<listitem><para><ulink url="http://jdm.homepage.dk/newpic.htm">JDM PIC programmer</ulink></para></listitem>
<listitem><para><ulink url="http://gputils.sf.net">gputils</ulink> and <ulink url="http://www.iki.fi/hyvatti/pic/picprog.html">picprog</ulink> installed on your GNU/Linux box</para></listitem>
</itemizedlist>
</para>
</sect4>
<sect4 id="hd44780-lcdserializer-burning">
<title>Burning the PIC</title>
<para>
First, you need to download the asm source for your pic and then make the hex:
</para>
<para>
<command>
gpasm lcd16f84_custom.asm
</command>
</para>
<para>
Now the binary is ready to be flashed to the PIC.
Connect the programmer with the PIC installed and issue the following command to see it burning ;-):
</para>
<para>
<command>
picprog --erase --burn --input lcd16f84.hex --pic /dev/ttyS0
</command>
</para>
</sect4>
<sect4 id="hd44780-lcdserializer-runninglcdproc">
<title>Running lcdproc</title>
<para>
It's time to build the <ulink url="http://www.mindspring.com/~tcoonan/lcdpic.html">operating circuit</ulink>,
remember this driver uses a baud rate of 9600, so JP2 need to be closed.
</para>
<para>
Now power on the board. You should see OK. on the LCD screen, otherwise, double-check all the connections.
</para>
<para>
Change LCDd.conf to include the following statments in the hd44780 section:
</para>
<para>
<screen>
ConnectionType=lcdserializer
Device=/dev/ttyS0
</screen>
</para>
<para>
Finally, start the daemon and relax watching lcdproc running.
</para>
</sect4>
<sect4 id="hd44780-lcdserializer-customizemsg">
<title>Customizing startup message</title>
<para>
If want to change the default startup message (OK.), you can edit the asm source
and write anything you want.
Open the asm source with your preferred editor and look for this:
</para>
<para>
<programlisting>
<![CDATA[
;******* START Main Loop Here **************
; This is where we should insert any little startup LCD messages...
; Print "OK." on startup...
movlw 0x4F
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 0x4B
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 0x2E
movwf ARG1
call SendLCDData
call InitDelay200MS
]]>
</programlisting>
</para>
<para>
This piece of code sends three characters to the LCD.
The first line sets the value of w register (working register, aka accumulator) to 0x4F ('O' in ascii). The second line copies this
value to ARG1, then the value is sent to the LCD. The fourth line delays the execution.
</para>
<para>
You don't have to write the ascii values in your modification, gpasm does the translation for you, so
if you want to see Booting... at startup, change the code above to look like this:
</para>
<para>
<programlisting>
<![CDATA[
;******* START Main Loop Here **************
; This is where we should insert any little startup LCD messages...
; Print "Booting..." on startup...
movlw 'B'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 'o'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 'o'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 't'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 'i'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 'n'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw 'g'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw '.'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw '.'
movwf ARG1
call SendLCDData
call InitDelay200MS
movlw '.'
movwf ARG1
call SendLCDData
call InitDelay200MS
]]>
</programlisting>
</para>
<para>
Refer to <link linkend="hd44780-lcdserializer-burning">burning section</link> in order to compile and reflash the new firmware.
</para>
</sect4>
</sect3>
<sect3 id="hd44780-bwctusb">
<title>BWCT USB device "bwctusb"</title>
<para>
The BWCT USB LCD module is also supported. It is not connected to an LPT port
but to an USB port, which saves you from a lot of potential problems.
To use it, set the connection type in the config file with the ConnectionType=
setting to "bwctusb" (without the quotes).
It does neither support a keypad nor backlight switching but it supports setting
the display's contrast using the "Contrast" configuration parameter as well as
specifying which one (of multiple BWCT LCD devices) is wanted using the
"SerialNumber" configuration parameter.
</para>
</sect3>
<sect3 id="hd44780-i2c">
<title>I<superscript>2</superscript>C with Port-Expander</title>
<para>
If you have an I<superscript>2</superscript>C port available that is supported by your kernel
(through /dev/i2c*), you can add a I<superscript>2</superscript>C port expander there
(PCF8574P in this example).
</para>
<figure>
<title>HD44780: PCF8574P port expander on I2C bus</title>
<screen>
<![CDATA[
IC1
-----------
| PCF8574P |
| I2C-Port- | HD44780
| Expander | display
| |4
| P0|----------------------------o 11 D4
| |5
I2C-Bus 14| P1|----------------------------o 12 D5
SCL o-------------------------|SCL |6
| P2|----------------------------o 13 D6
15| |7
SDA o-------------------------|SDA P3|----------------------------o 14 D7
| |9
|1 P4|----------------------------o 4 RS
Set I2C-Address +-----|A0 |10
here: | |2 P5|----------------------------o 5 RW
GND: Bit:=0 +-----|A1 |11
VCC: Bit:=1 | |3 P6|----------------------------o 6 EN
+-----|A1 | ___
Here: 0x00 | | | +---|___|--o 15 backlight
=== | | |c 10R
| |12 ___ b|/
|13 P7|-----|___|-----|
-|INT | 1k |\
| | bc557 |e
----------- |
|
+5V o-----------+------------------+---------------------+--+----------o 2 VCC
| | |
| | |
|10uF O 16 .-.
--- IC1 | |<-----------o 3 Vlcd
--- O 8 | |10k
| | '-'
| | |
GND o-----------+-------+----------+---------------------+-------+-----o 1 GND
| |
=== GND +-----o 16 GND Backlight
]]>
</screen>
</figure>
<sect4 id="hd44780-i2c-config">
<title>Configuration</title>
<figure>
<title>HD44780: Configuration for I<superscript>2</superscript>C with port expander</title>
<screen>
<![CDATA[
[HD44780]
ConnectionType=i2c
Device=/dev/i2c-0
Port=0x20
Backlight=yes
Size=40x2
DelayBus=false
DelayMult=1
Keypad=no
]]>
</screen>
</figure>
<para>
Device is the device file for your I<superscript>2</superscript>C bus (here /dev/i2c-0).
You have to load the kernel standard module i2c-dev and
the bus driver, but NO i2c chip modules (e.g. pcf8574)!
</para>
<para>
Port contains the i2c address of the i2c port expander
(here 0x20, the PCF8574 from the example above, with all address bits set to 0).
Bit 8 of the address (normally 0 in I2C addresses) given in port is special:
It tells the driver to treat the device as PCA9554 or similar,
a device that needs a 2-byte command, and it will be stripped
off the address.
</para>
<figure>
<title>HD44780: Examples of I<superscript>2</superscript>C port expander adresses</title>
<screen>
<![CDATA[
port=0x20..0x27 PCF8574 with A[012]=0..7
port=0x38..0x3f PCF8574A with A[012]=0..7
port=0xa0..0xa7 PCA9554 with A[012]=0..7
port=0xa0..0xa7 PCA9554A with A[012]=0..7
]]>
</screen>
</figure>
</sect4>
</sect3>
</sect2>
<sect2 id="hd44780-compiling">
<title>Compiling</title>
<para>
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".
</para>
</sect2>
<!-- ## Hitachi HD44780 driver ## -->
<sect2 id="hd44780-config">
<title>Configuration in LCDd.conf</title>
<sect3>
<title>[hd44780]</title>
<variablelist>
<varlistentry>
<term>
<command>Port=</command>
<arg choice="plain"><replaceable>PORT</replaceable></arg>
</term>
<listitem><para>
Specify the address of the parallel port the LCD is connected to.
Common values for <replaceable>PORT</replaceable> are <literal>0x278</literal>,
<literal>0x378</literal> and <literal>0x3BC</literal>.
If not given, the default is <literal>0x378</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>ConnectionType=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal><emphasis>4bit</emphasis></literal></arg>
<arg choice="plain"><literal>8bit</literal></arg>
<arg choice="plain"><literal>serialLpt</literal></arg>
<arg choice="plain"><literal>winamp</literal></arg>
<arg choice="plain"><literal>picanlcd</literal></arg>
<arg choice="plain"><literal>bwctusb</literal></arg>
<arg choice="plain"><literal>lcdserializer</literal></arg>
<arg choice="plain"><literal>lis2</literal></arg>
<arg choice="plain"><literal>i2c</literal></arg>
</group>
</arg>
</term>
<listitem>
<para>
Select the type of the wiring / display connection.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>ConnectionType</entry>
<entry>Wiring / Display Type</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>4bit</literal></entry>
<entry>HD44780 4bit Wiring (default)</entry>
</row>
<row>
<entry><literal>8bit</literal></entry>
<entry>HD44780 8bit Wiring ("lcdtime")</entry>
</row>
<row>
<entry><literal>serialLpt</literal></entry>
<entry>HD44780 Serial LPT Wiring</entry>
</row>
<row>
<entry><literal>winamp</literal></entry>
<entry>HD44780 8bit Wiring "winamp" Style</entry>
</row>
<row>
<entry><literal>picanlcd</literal></entry>
<entry>PIC-an-LCD serial device "picanlcd"</entry>
</row>
<row>
<entry><literal>bwctusb</literal></entry>
<entry>BWCT USB device "bwctusb"</entry>
</row>
<row>
<entry><literal>lcdserializer</literal></entry>
<entry>LCD serializer "lcdserializer"</entry>
</row>
<row>
<entry><literal>lis2</literal></entry>
<entry>LIS2 from VLSystem (http://www.vlsys.co.kr)</entry>
</row>
<row>
<entry><literal>i2c</literal></entry>
<entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<tip>
<para>
The above table might be outdated, when you read this.
If you suspect the table above to be outdated, you might want to have a look at
<filename>server/drivers/hd44780-drivers.h</filename>
which contains the actual translation code.
</para>
</tip>
</listitem>
</varlistentry>
<varlistentry>
<term>
<command>Keypad=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal>yes</literal></arg>
<arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>
</group>
</arg>
</term>
<listitem><para>
Tell whether you have a keypad connected.
You may also need to configure the keypad layout further on in this file.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>Contrast=</command>
<arg choice="plain"><replaceable>CONTRAST</replaceable></arg>
</term>
<listitem><para>
Set the initial contrast for the <literal>bwctusb</literal> connection type.
Legal values for <replaceable>CONTRAST</replaceable> are <literal>0</literal> - <literal>1000</literal>.
If not given, it defaults to <literal>300</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>Backlight=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal>yes</literal></arg>
<arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>
</group>
</arg>
</term>
<listitem><para>
Specifiy if you have a switchable backlight.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>OutputPort=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal>yes</literal></arg>
<arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>
</group>
</arg>
</term>
<listitem><para>
Tell if you have the additional output port ("bargraph") and you want to
be able to control it with the lcdproc OUTPUT command
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>Lastline=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>
<arg choice="plain"><literal>no</literal></arg>
</group>
</arg>
</term>
<listitem><para>
Specifies if the last line is pixel addressable or it controls an
underline effect. [default: yes (= pixel addressable); legal: yes, no]
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>Size=</command>
<arg choice="plain">
<replaceable>WIDTH</replaceable>
<literal>x</literal>
<replaceable>HEIGHT</replaceable>
</arg>
</term>
<listitem><para>
Specifies the size of the LCD.
Default: <literal>20x4</literal>
In case of multiple combined displays, this should be the total size.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>vspan=</command>
<arg choice="plain">
<replaceable>HEIGHT</replaceable>
<literal>,</literal>&hellip;
</arg>
</term>
<listitem><para>
For multiple combined displays: how many lines does each display have.
E.g. <literal>Vrspan=2,2</literal> means you have two displays and
each has two lines.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>ExtendedMode=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal>yes</literal></arg>
<arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>
</group>
</arg>
</term>
<listitem><para>
If you have a KS0073 or an other 'almost HD44780-compatible', set this
flag to get into extended mode (4-line linear).
This flag is NOT the old obsolete Extended option.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>DelayMult=</command>
<arg choice="plain"><replaceable>DELAY</replaceable></arg>
</term>
<listitem><para>
If your display is slow and cannot keep up with the flow of data from
LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4
to increase the delays. Default: 1.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>DelayBus=</command>
<arg choice="plain">
<group choice="req">
<arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>
<arg choice="plain"><literal>no</literal></arg>
</group>
</arg>
</term>
<listitem><para>
You can reduce the inserted delays by setting this to <literal>no</literal>.
On fast PCs it is possible your LCD does not respond correctly.
Default: <literal>yes</literal>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<command>KeyMatrix_4_1=</command>
<arg choice="plain"><replaceable>KEY</replaceable></arg>
</term>
<term>
<command>KeyMatrix_4_2=</command>
<arg choice="plain"><replaceable>KEY</replaceable></arg>
</term>
<term>
<command>KeyMatrix_4_3=</command>
<arg choice="plain"><replaceable>KEY</replaceable></arg>
</term>
<term>
<command>KeyMatrix_4_4=</command>
<arg choice="plain"><replaceable>KEY</replaceable></arg>
</term>
<listitem><para>
If you have a keypad you can assign keystrings to the keys.
See documentation for used terms and how to wire it.
For example to give directly connected key 4 the string "Enter", use:
KeyDirect_4=Enter
For matrix keys use the X and Y coordinates of the key:
KeyMatrix_1_3=Enter
</para></listitem>
</varlistentry>
</variablelist>
</sect3>
</sect2>
<sect2 id="hd44780-configuration">
<title>Configuration</title>
</sect2>
<sect2 id="hd44780-running">
<title>Running</title>
<para>
Modify the LCDd.conf file before you run LCDd. In this config file are
detailed instructions on how to configure the HD44780 driver.
</para>
<para>
Then as usual, start LCDd with the correct config file:
</para>
<para>
E.g. <command>LCDd -c ./LCDd.conf</command>
</para>
<para>
If you want to override the driver selection in LCDd.conf then use:
</para>
<para>
<command>LCDd -c ./LCDd.conf -d HD44780</command>
</para>
<para>
If you use this, the HD44780 driver will read the options from the config
file anyway.
</para>
</sect2>
<sect2 id="hd44780-miscellania">
<title>Miscellania</title>
<para>
This text has originally been taken from a message by Bill Farrow
<email>bfarrow@arrow.bsee.swin.edu.au</email>.
</para>
<para>
Updated February 2000, Benjamin Tse <email>blt@ComPorts.com</email>
</para>
<para>
Updated October 2001, Joris Robijn <email>joris@robijn.net</email>
</para>
<para>
Converted to docbook March 2002, Rene Wagner <email>reenoo@gmx.de</email>
</para>
<para>
Updated April 2002, Rene Wagner <email>reenoo@gmx.de</email>
</para>
<para>
Updated and extended April 200r62, Peter Marschall <email>peter@adpm.de</email>
</para>
</sect2>
</sect1>