⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hd44780.docbook

📁 linux下LCD驱动的例子代码
💻 DOCBOOK
📖 第 1 页 / 共 4 页
字号:
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 staywithout drawbacks. In this case the simplicity of the long feeding wiresis compensated by some intelligence in the decoding of the data. If youhave no experience with the soldering iron, I do not recommend to buildthis wiring.</para><para>OK, so here is the wiring. First of the 'simple' 3 wires version. IC1 isthe shift register, a 4094. Do not forget to connect the 5V to pin 16 andGND 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 morecomplex. 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 toread the <link linkend="hd44780-connections-keypad">keypad section</link> in this document.</para></note><para>serialLpt wiring supports a keypad. The 3 wires version supports8 keys, or if you use multiple return lines up to 8 x 5 = 40 lines. The2 wires version supports 7 keys, or with multiple return lines7 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 remainingbuffers 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 forthat. 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-lis2"><title>LIS2 USB device "lis2"</title><para>LIS2 from VLSystem (http://www.vlsys.co.kr) is a full featured usb vfd modulewith four channel fan controls. This device can be access as a serial device withhelp of the kernel modules ftdi_sio which map the USB port to a serial port (/dev/ttyUSBx).</para></sect3><sect3 id="hd44780-los-panel"><title>LCD on Serial panel device "cwlos-panel"</title><para>See <ulink url="http://www.xs4all.nl/~mlf/los/">http://www.xs4all.nl/~mlf/los/</ulink>for information on this device.</para></sect3><sect3 id="hd44780-vdr-lcd"><title>VDR LCD iserial device "vdr-lcd"</title><para> ... to b documented ...</para><para>Please address Matteo Pillon for further information.</para></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 portbut 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 theconfig 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-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=lcdserializerDevice=/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 sourceand 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 thisvalue 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, soif 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 portbut 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 settingthe display's contrast using the "Contrast" configuration parameter as well asspecifying 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  |

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -