📄 hd44780.docbook
字号:
<sect1 id="hd44780-howto"><title>The HD44780 Driver</title><para>There are several ways of wiring up the HD44780 devices. Your choicewill probably be governed largely by your ability to wire up each oneand/or a desire to use the device with other programs.</para><para>The LCDproc HD44780 driver supports the following connections on aparallel 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 virtualdisplay. For example, a 4, 2 and 1 line display can be used to form a7 line display. The number of displays is limited by the individualHD44780 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 someconnections. 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 probablyNOT 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'sfrom the LPT port itself. Connect a few diodes from the data pins toa 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 witha backlight, as the keyboard connector is often protected with a fuseof 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 supportednumber of keys differs per type. There are several ways to connect the keysto 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 keyper 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 telephoneconnected, with X and Y lines connected as show. To be more precise, itassumes 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 iscontrolled by the keystrokes A to D. You should modify and recompile thedriver to get an other keypad layout.</para><para>You can buy arrays of keys that are connected like this in the electronicsshop. They usually call it a matrix keypad. To hook it to lcdproc, youwould only need to add the resistors and diodes.</para><para>If you want to use just one return line, for example with the serialLptwiring, 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 upelectromagnetic waves from the air. In that case connect the unconnectedinput 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 onand off. At the moment only the 4bit and winamp connection types supportthis. The extension uses one output pin, you cannot use that pin for otherfunctions 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 | === GNDNote: 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 onthe side. If that is the case, there is usually NO RESISTOR present to limitthe current through the LEDs. Therefor you should then add a resistor afterthe 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 canadd a resistor bypassing the transistor from e to c, with a value of, say47ohm or 22ohm. (My 4x20 has an internal resistor of 6ohm, so with 47 ohmextra 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -