<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <META NAME="GENERATOR" CONTENT="lfparser_2.52"> <META NAME="LFCATEGORY" CONTENT="Hardware"> <link rel="icon" href="../../common/images/lf-16.png" type="image/png"> <TITLE>lf286, Hardware: Linux USB LCD display with watchdog and buttons</TITLE> <style type="text/css"> <!-- td.top {font-family: Arial,Geneva,Verdana,Helvetica,sans-serif; font-size:12 } pre { font-family:monospace,Courier } pre.code { font-family:monospace,Courier;background-color:#aedbe8; } p.cl { color:#EE9500 } table.left { margin-right:0.3cm } a.nodec { text-decoration:none } p.trans { font-size:8pt; text-align:right } p.clbox { width:50%; alignment:center; background-color:#FFD700; border-style:none; border-width:medium; border-color:#FFD700; padding:0.5cm; text-align:center } p.code { width:80%; alignment:center; background-color:#aedbe8; border-style:none; border-width:medium; border-color:#aedbe8; padding:0.1cm; text-align:left } p.foot { background-color:#AAAAAA; color:#FFFFFF; border-style:none; border-width:medium; border-color:#AAAAAA; padding:0.5cm ; margin-top:0.1cm; margin-right:1cm; margin-left:1cm; text-align:center } div.tbbutton { background: #ddd; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa; margin: 2px 5px 2px 5px; text-align: center; width: 20em; line-height: 1.2em; padding: 2px; font-size: 12px; white-space: nowrap; color: #555; } div.bbutton { background: #ddd; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa; float: left; margin: 2px 5px 2px 5px; text-align: center; line-height: 1.2em; padding: 2px; font-size: 12px; white-space: nowrap; color: #555; } --> </style> </HEAD> <BODY bgcolor="#ffffff" text="#000000"> <!-- this is generated html code. NEVER use this file for your translation work. Instead get the file with the same article number and .meta.shtml in its name. Translate this meta file and then use lfparser program to generate the final article --> <!-- lfparser can be obtained from http://main.linuxfocus.org/~guido/dev/lfparser.html --> <!-- this is used by a number of tools: =LF=AUTHOR: Guido Socher =LF=CAT___: Hardware =LF=TITLE_: Linux USB LCD display with watchdog and buttons =LF=NUMBER: 286 =LF=ANAME_: article286.shtml =LF=PARSER: 2.52 --> <!-- 2pdaIgnoreStart --> <!-- start navegation bar, current, style=2 --> <!-- top navegation bar --> <TABLE summary="topbar_1" cellspacing="0" cellpadding="0" border="0" align="center" width="90%"> <TR bgcolor="#2e2292"> <TD class="top"><TABLE summary="topbar_1_logo" cellspacing="0" cellpadding="0" border="0" width= "100%"> <TR><TD width="319"><a href="../../index.shtml"><IMG src="../../common/images/logolftop_319x45.gif" alt="[LinuxFocus-icon]" width="319" height="45" align="left" border="0"></a></TD> <TD class="top"> <TABLE summary="topbar_1_links" width="100%"> <TR align="right"> <TD class="top"> <A class="nodec" href="../../index.shtml"><FONT color= "#DDDDDD" size="2"><--</FONT></A> | <A class="nodec" href="../index.shtml"><FONT color= "#DDDDDD" size="2">Home</FONT></A> | <A class="nodec" href="../map.html"><FONT color= "#DDDDDD" size="2">Map</FONT></A> | <A class="nodec" href="../indice.html"><FONT color= "#DDDDDD" size="2">Index</FONT></A> | <A class="nodec" href="../Search/index.html"><FONT color= "#DDDDDD" size="2">Search</FONT></A> </TD> </TR> <TR align="right"> <TD class="top"> <HR width="100%" noshade size="1"> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <!-- end top navegation bar --> <!-- blue bar --> <TABLE summary="topbar_2" cellspacing="0" cellpadding="0" border="0" align="center" width="90%"> <TR bgcolor="#00ffff"> <TD><IMG src="../../common/images/transpix.gif" width="1" height= "2" alt=""></TD> </TR> </TABLE> <!-- end blue bar --> <!-- bottom navegation bar --> <TABLE summary="topbar_3" cellspacing="0" cellpadding="0" border="0" align="center" width="94%"> <TR bgcolor="#000000"> <TD> <TABLE summary="topbar_3_links" cellspacing="0" cellpadding="1" border="0" width= "100%"> <TR align="center"> <TD WIDTH="20%"><A class="nodec" href="../News/index.html"><FONT color= "#FFFFFF">News</FONT></A> </TD> <TD WIDTH="5%"><FONT color="#FFFFFF">|</FONT> </TD> <TD WIDTH="20%"><A class="nodec" href="../Archives/index.html"><FONT color= "#FFFFFF">Archives</FONT></A> </TD> <TD WIDTH="5%"><FONT color="#FFFFFF">|</FONT> </TD> <TD WIDTH="20%"><A class="nodec" href="../Links/index.html"><FONT color= "#FFFFFF">Links</FONT></A> </TD> <TD WIDTH="5%"><FONT color="#FFFFFF">|</FONT> </TD> <TD WIDTH="20%"><A class="nodec" href="../aboutus.html"><FONT color= "#FFFFFF">About LF</FONT></A> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <!-- end bottom navegation bar --> <!-- stop navegation bar --> <!-- SSI_INFO --> <!-- tr_staticssi include virtual --> <!-- tr_staticssi exec cmd --> <!-- addedByLfdynahead ver 1.5 --><TABLE ALIGN="right" border=0><TR><TD ALIGN="right"><FONT SIZE="-1" FACE="Arial,Helvetica">This document is available in: <A href="../../English/March2003/article286.shtml">English</a> <A href="../../Castellano/March2003/article286.shtml">Castellano</a> <A href="../../ChineseGB/March2003/article286.shtml">ChineseGB</a> <A href="../../Deutsch/March2003/article286.shtml">Deutsch</a> <A href="../../Francais/March2003/article286.shtml">Francais</a> <A href="../../Russian/March2003/article286.shtml">Russian</a> <A href="../../Turkce/March2003/article286.shtml">Turkce</a> <A href="../../Polish/March2003/article286.shtml">Polish</a> </FONT></TD></TR></TABLE><br> <!-- SSI_INFO STOP --> <!-- 2pdaIgnoreStop --> <!-- SHORT_BIO_ABOUT_THE_AUTHOR_AND_INDEX_START --> <TABLE ALIGN="LEFT" BORDER="0" WIDTH="195" summary="about the author" class="left"> <TR> <TD> <img src="../../common/images/Guido-S.gif" alt= "[Photo of the Author]" height="164" width="173"> <BR>by Guido Socher <a href="http://linuxfocus.org/~guido/"><font size="1">(homepage)</font></a> <BR><BR> <I>About the author:</I><BR> <!-- aboutauthor_start --> <p>Guido likes Linux because it is a paradise for people who want to develop their own software and hardware.</p> <!-- aboutauthor_stop --> <!-- TRANSLATED_TO en --> <!-- TRANSLATED_TO_STOP --> <!-- INDEX_START --> <BR><i>Content</i>: <UL> <LI><A HREF="#286lfindex0">Introduction</A></LI> <LI><A HREF="#286lfindex1">The driver</A></LI> <LI><A HREF="#286lfindex2">The schematic</A></LI> <LI><A HREF="#286lfindex3">Working with SMD chips</A></LI> <LI><A HREF="#286lfindex4">The test</A></LI> <LI><A HREF="#286lfindex5">Alternatives</A></LI> <LI><A HREF="#286lfindex6">References</A></LI> <LI><A HREF="http://cgi.linuxfocus.org/cgi-bin/lftalkback?anum=286">Talkback form for this article</A></LI> </UL> </TD></TR></TABLE> <!-- INDEX_STOP --> <!-- SHORT_BIO_ABOUT_THE_AUTHOR_AND_INDEX_STOP --> <!-- HEAD_OF_THE_ARTICLE_START --> <br> <table border="0"><tr><td> <!-- tr_staticssi include virtual --> <!-- tr_staticssi exec cmd --> <!-- addedByLfPdf ver 0.1 --> <TABLE style="border-style:outset; border-width:1px" align="right" bgcolor="#ff9616" cellspacing="1"><TR><TD bgcolor="#ff9616"> <a href="../Archives/lf-2003_03-0286.pdf"><small>PDF</small></a> </TD></TR></TABLE> <H2>Linux USB LCD display with watchdog and buttons</H2> <img src="../../common/images/article286/linuxusblcd_title.jpg" alt="[Illustration]" hspace="10" width="250" height="353"> <!-- ABSTRACT OF THE ARTICLE --> <P><i>Abstract</i>: <P> <!-- articleabstract_start --> This article is the result of the very positive feedback on the hardware articles that I have written so far. You LinuxFocus readers are really a great audience! Some of you wanted to know how to interface the USB bus. So here is a nice solution. We use the LCD display from the <a href="../May2002/article236.shtml">May 2002 article</a> and make it work with the USB bus. The whole thing will be powered from the USB bus. Therefore you do not need any extra power supply. <br><br> For this article you need at least a partial installation of the Linux AVR development environment. How to set it up is described in this article: <a href= "../March2002/article231.shtml">Programming the AVR Microcontroller with GCC</a>. <!-- articleabstract_stop --> <br><!-- HR divider --><center><font color="#8282e0"><b>_________________ _________________ _________________</b></font></center><br> </td></tr></table> <!-- HEAD_OF_THE_ARTICLE_STOP --> <!-- BODY_OF_THE_ARTICLE_START --> <A NAME="286lfindex0"> </A> <H2>Introduction</H2> <table align="right" cellspacing="10" width="200"> <tr> <td bgcolor="#aedbe8"> <center> <a href="http://shop.tuxgraphics.org"><img src="../../common/images2/tuxgraphics_hd44780_linux_lcd.jpg" alt="lcd from tuxgraphics" width="120" height="80"></a> <br>You can buy excellent LCD displays at <a href="http://shop.tuxgraphics.org">shop.tuxgraphics.org</a>. </center> </td> </tr> </table> USB is cool because it is a modern interface and it offers the possibility to power the devices directly via the USB bus. The connectors are small and high volumes of data can be transported over a small cable. That's the positive things about USB. The down side is that hardware design is difficult due the high frequencies and the protocol is rather complex. Just take a look a the specifications (<a href= "http://www.usb.org/developers/">http://www.usb.org/developers/</a>, you want the 1.1 specification) and you will be shocked. It's 327 pages long and very difficult to understand. No wonder that there are soooo many faulty implementations of USB devices. A more user friendly introduction can be found at <a href= "http://www.beyondlogic.org/">http://www.beyondlogic.org/</a> but the specification is still complex. <br> <br> What to do? How can we interface our Microcontroller to the USB bus? FTDI, a Scottish company, has the solution (<a href= "http://www.ftdichip.com">http://www.ftdichip.com</a>). They offer a chip which implements a USB serial interface. One side of the FT232BM chip is rs232 and the other USB. In other words you just replace the MAX232 which you previously needed for the power conversion on the rs232 lines with this FT232BM chip and you are done. <A NAME="286lfindex1"> </A> <H2>The driver</H2> The FT232BM is a true cross platform solution. Drivers are available for multiple operating systems. The Linux kernel module is called ftdi_sio and is open source. It is part of the standard Linux kernel. The FT232BM offers more than just a USB to rs232 conversion and the Linux kernel module is still under development to implement all functions. The USB to rs232 is however ready and I was e.g able to use a standard Redhat 7.3 Kernel (2.4.18) without recompilation or any modification. Just plug it in.<br> <br> ftdi_sio is being developed at <a href= "http://ftdi-usb-sio.sourceforge.net/">http://ftdi-usb-sio.sourceforge.net/</a>. <br> <br> With my Redhat 7.3 all modules would load automatically when I plug in the USB connector. If it does not work for your Linux distribution then check that you have the following modules (for USB-UHCI): <p class="code">/sbin/lsmod usb-uhci<br> /sbin/lsmod usbcore<br> /sbin/lsmod usbserial<br> /sbin/lsmod ftdi_sio<br> </p> The device file to communicate with the hardware is /dev/ttyUSB0 <br> <br> The developers of ftdi_sio recommend at least Kernel 2.4.20 but as you can see 2.4.18 does also work (at least the for the functions we need here). <A NAME="286lfindex2"> </A> <H2>The schematic</H2> The circuit is straight forward. You just insert the FT232BM between the Rx/Tx lines of the Microcontroller and the USB connector. A 6 Mhz Crystal and some other parts are needed which are described in the design specification from FTDI. The ferrite bead (in the schematic on the right) is a little coil which filters high frequencies (the USB bus runs at 48Mhz). You can also wind 10 loops of a thin wire over a 1K resistor and use it as a coil. <br> <br> <a href="../../common/images/article286/schematic.gif"><img src="../../common/images/article286/schematic_th.gif" alt= "schematic" width="531" height="354"></a> <br> One thing to pay attention to is the power consumption. You must consume less than 100mA if you design a bus powered device. In addition your device must support USB suspend mode. When the pin named "sleep" on the FT232BM goes low then the device must consume less than 0.5mA. The latter is a very tough requirement to implement. The AVR supports an "idle mode" where it consumes less than 2mA and a "power down" mode where it consumes only 20uA. It seems however easier to wake up the Microcontroller from "idle mode". I have therefore decided to use "idle mode" even if this violates the USB specification a little bit. The optional background light of the display will be switched off and the whole circuit will then consume 3mA. 3mA is more than 0.5mA but the USB host controller chips can not measure the current so accurate that they will detect this. It should work. <br> <br> Having said all this I must admit that I don't have a computer which supports suspend. Therefore I could not test this part. If you have a computer, probably a modern Laptop, that supports suspend then please test this and let me know what the result is. <br> <br> The rest of the circuit is almost identical to the one presented in the <a href="../May2002/article236.shtml">May 2002 article</a>. I will therefore not explain any further details. <br> You can click on the schematic for a bigger picture. The eagle files are packed together with software. You can download it at the end of the article. <br> <a href="../../common/images/article286/board.gif"><img src= "../../common/images/article286/board_th.gif" alt="board" width="145" height="195"></a> <br> The board is single sided and only the blue layer should be etched. The red lines are wires. <br> <br> The USB Type-B connector which you need for this circuit has the following pinout: <br> <center> <img src= "../../common/images/article286/usb_typeB_receptacle.gif" alt="type B Receptacle" width="232" height="277"> </center> <br> <A NAME="286lfindex3"> </A> <H2>Working with SMD chips</H2> SMD chips have good mechanical and electrical properties but they are a nightmare for hobby electronic fans. You really need some soldering skills and at least the part of the board where the SMD chip is mounted must be etched very clean and with high quality. In other words this is nothing for beginners. Look at the alternatives below if you are not sure that you can etch the board and solder the chip. <br> <br> Solder the SMD chip to the board before you add any other parts.<br> To solder the chip on put a little bit of solder onto the pads where the SMD chip goes. Next put a thin film of SMD solder paste (some people call it solder honey because it looks like honey). There is also a German company called "Kontakt Chemie" which produces a varnish called "Lötlack" spray. You can use this "Lötlack" spray instead of the solder honey if you want. <br> <br> Clean your soldering iron. There must not be any solder left on the tip of the iron. Then position the FT232BM exactly. Gently press on every pin of the chip with the soldering iron. Do not add extra solder. <img src= "../../common/images/article286/ft232SMD.jpg" alt="ft232SMD" align="right" width="250" height="168"> <br> <br> This procedure works very well. It is not important that you have a small soldering iron. Just use an ordinary one and make sure that it is clean before you touch the pins of the chip. I don't recommend to use kitchen toasters or other crude methods. You are likely to damage the chip with any other method. <A NAME="286lfindex4"> </A> <H2>The test</H2> I suggest testing the circuit in two steps. First connect the circuit without the AVR Microcontroller in the socket. Linux should recognize in FTDI chip and you should see the following entry in /proc/bus/usb/devices: <p class="code">T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0<br> D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1<br> P: Vendor=0403 ProdID=6001 Rev= 2.00<br> S: Manufacturer=FTDI<br> S: Product=USB <-> Serial<br> C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 90mA<br> I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=serial<br> E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl= 0ms<br> E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl= 0ms<br> </p> After that insert the AVR Microcontroller and load a test program which will cause the LED to blink. Unpack the linuxusblcd software package (see download at the end of the article) and type: <p class="code">make testload0</p> The programmer cable and the USB connector must both be plugged in. <br> If this test works then you can be sure that the Microcontroller will work.<br> <br> After this you can load the complete software into the Microcontroller: <p class="code">make load</p> Now you can use "ttydevinit /dev/ttyUSB0" to initialize the usb serial connection and with "cat > /dev/ttyUSB0" you can "talk" to the circuit. <p class="code">ttydevinit /dev/ttyUSB0<br> cat > /dev/ttyUSB0<br> D=hello world<br> </p> This will write "hello world" on the display. See the May 2002 article for details. The code for the May 2002 article also contained a program called llp.pl which can be used to have an interactive dialog with your computer via the 2 buttons on the LCD display. You can re-use it here. <br> <br> ... and here is the working display (buttons were not connected when the picture was taken, the FT232BM is under the board):<br> <center> <img src="../../common/images/article286/linuxusblcd_th.jpg" alt="usb lcd" width="400" height="481"><br> </center> <A NAME="286lfindex5"> </A> <H2>Alternatives</H2> Although the circuit presented here is very simple it is still nothing for beginners because of the skills you need to solder on the SMD chip. Therefore consider a ready made commercial solution of you don't feel confident about the SMD chip. The disadvantage is that you normally don't get all the extras like watch dog, LEDs and buttons. You usually get only the LCD display. The prices for the ready made commercial USB displays are reasonable. The parts alone for this article cost about 30 EUR and ready made displays are in the same order. <br> <br> Unfortunately most of the commercial products use own vendor IDs even if they are based on the ftdi chip. This means that the kernel module will not recognize them because the USB driver depends on these numbers. You need to edit the kernel sources and re-compile. Future kernel versions may already work if somebody else has updated the code. <ul> <li>http://www.matrixorbital.com/ They use also the ftdi 232bm but with their own vendor IDs. The display is called LK202-24-USB.<br> <br> </li> <li>http://www.usblcd.de/ This solution has it's own kernel module. It is however part of the standard Linux kernel. It will work out of the box with any 2.4.x kernel. Probably a very good solution.<br> <br> </li> <li>http://crystalfontz.com/ Their usb displays (632 and 634) use the FT232AM with own product IDs.<br> <br> </li> <li>http://www.cwlinux.com/eng/products/products_lcd.php I discovered this site just recently. They see to have LCDs with keypads. It's however twice as expensive as the solution from this article. <br> <br> </li> </ul> <br clear="all"> <A NAME="286lfindex6"> </A> <H2>References</H2> <ul> <li>All software and documents <a href="../../common/src/article286/index.html">mentioned in this article</a> (any updates of the linuxusblcd software will show up on this page)<br> <br> </li> <li>How to program the AVR Microcontroller: <a href= "../March2002/article231.shtml">Programming the AVR Microcontroller with GCC, March 2002 article</a><br> <br> </li> <li>The May 2002 article with the linuxlcdpanel. The perl program (called llp.pl) from this article can be re-used: <a href="../May2002/article236.shtml">May 2002 article</a><br> <br> </li> <li>The FTDI website: <a href= "http://www.ftdichip.com">www.ftdichip.com</a><br> <br> </li> <li>The datasheet for the FT232BM (from http://www.ftdichip.com): <a href= "../../common/src/article286/ftdichip_ds232b11.pdf">ftdichip_ds232b11.pdf, 820Kb</a><br> <br> </li> <li>Eagle for Linux <a href= "http://www.cadsoftusa.com/">cadsoftusa.com</a><br> <br> </li> <li>Eagle library for the FTDI chips (from http://www.elektronik-projekt.de) <a href= "../../common/src/article286/ftdi.lbr.gz">ftdi.lbr.gz</a><br> <br> </li> </ul> <!-- vim: set sw=2 ts=2 et tw=80: --> <!-- BODY_OF_THE_ARTICLE_STOP --> <!-- 2pdaIgnoreStart --> <A NAME="talkback"> </a> <h2>Talkback form for this article</h2> Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers: <center> <table width="250" border=0><tr><td> <div class="tbbutton"><A class="nodec" href="http://cgi.linuxfocus.org/cgi-bin/lftalkback?anum=286"> talkback page </a></div> </td></tr></table> </center> <br clear="all"> <HR size="2" noshade> <table width="250" border=0><tr><td> <div class="bbutton"><a class="nodec" href="../../index.shtml"><--, LF Home</a></div> </td><td> <div class="bbutton"><a class="nodec" href="index.shtml">Go to the index of this issue</a></div> </td></tr></table> <br clear="all"> <HR size="2" noshade> <!-- ARTICLE FOOT --> <CENTER><TABLE WIDTH="98%" summary="footer"> <TR><TD ALIGN=CENTER BGCOLOR="#bdc6d5" WIDTH="50%"> <A HREF="../../common/lfteam.html">Webpages maintained by the LinuxFocus Editor team</A> <BR><FONT COLOR="#1111aa"><a href="../../common/copy.html">© Guido Socher</a><br>"some rights reserved" see <a href="../../license/index.shtml">linuxfocus.org/license/</a><br><a href="http://www.linuxfocus.org">http://www.LinuxFocus.org</a></FONT> </TD> <TD BGCOLOR="#bdc6d5"> <!-- TRANSLATION INFO --> <font size=2>Translation information:</font> <TABLE summary="translators"> <tr><td><font size="2">en --> -- : Guido Socher (<a href="http://linuxfocus.org/~guido/"><font size="1">homepage</font></a>)</font></td></tr> </TABLE> </TD> </TR></TABLE></CENTER> <p><font size=1>2005-02-11, generated by lfparser version 2.52</font></p> <!-- 2pdaIgnoreStop --> </BODY> </HTML>