Home Map Index Search News Archives Links About LF
[Top bar]
[Bottom bar]
This document is available in: English  Castellano  Deutsch  Francais  Italiano  Nederlands  Russian  Turkce  Korean  

convert to palmConvert to GutenPalm
or to PalmDoc

[Photo of the Author]
by Guido Socher

About the author:

Guido is a long time Linux fan. His Linux home page can be found at www.oche.de/~bearix/g/.


Using Serial Line LCD displays under Linux



This article shows how to use the BLC2021 PC-Bay Insert serial line display from Matrix Orbital under Linux. The BLC2021 is a small dot matrix LCD display which is very easy to use and does not require any additional controller chip or complicated driver.



With some hobby building skills you can use your old PC to build an MP3 player for your living room or to control the central heating in the house or just use it as an intranet server. The use cases are probably manifold. In all of these cases it would be nice to have the computer inside a small metal box without a big monitor and keyboard around. Instead you would like to have a small LCD display which shows the title of the current song on the MP3 player, the temperature for your heating control system or the status of your server.

The LCD displays form matrix-orbital are ideal for such applications.

LCDs and computer electronics in general are rather sensitive things. Connecting an LCD display backward to power supplies or too high voltage can easily destroy the display. We present in this article the BLC2021 serial line PC bay insert because it is very easy to install and comes with all the cables needed to plug it into your computer. All you need to install the BLC2021 is a small screw driver. With the ready made cables and connectors that come with the BLC2021 there is not much that can go wrong.



The BLC2021 comes with all the needed cables and fits into a 5.25 Inch PC-bay. You need to connect the power supply to the computers internal power supply and the flat-band cable to a RS232 serial port. One possibility to do this is to go out with the cable on an empty slot position at the back of your computer and connect it to the external RS232 connector.

Matrix-orbital provides driver software on a floppy disk. It contains lcdproc-0.3.3 for Linux. It is GPL software and available as source code on the floppy. However the lcdproc-0.3.3 is written for 4 line displays and the BLC2021 has only 2 lines. Therefore you will only see a flickering display.
More recent versions of lcdproc seem to be usable with two line displays but I have not tested it.

lcdproc was written to display periodically system information such as uptime, memory usage, etc..
In this article we will not use lcdproc. We present a more general way of writing information to the display. Using the display is very simple and you don't actually need complicated driver software for Linux. All you need to do is to initialize the serial line correctly and then you can even use a shell script to drive the LCD display. The rest of this article explains how to do that.


Using the LCD display

The BLC2021 can read normal ASCII characters from the serial line but before you can do that you need to initialize the serial line:

  1. Download the mtxorb program (mtxorb-0.2.tar.gz) unpack it with tar zxvf mtxorb-0.2.tar.gz (note some browsers do already "gunzip" .gz files during download but forget to rename the file to mtxorb-0.2.tar. In that case try tar xvf mtxorb-0.2.tar.gz).
  2. Compile it: cd mtxorb-0.2; make
  3. Create a softlink to the device where the LCD display is connected:
    cd /dev; ln -s ttyS0 lcd      (for first serial line, COM1)
    cd /dev; ln -s ttyS1 lcd      (for second serial line, COM2)
  4. The mtxorb program assumes that you have jumpered the LCD display to a serial line speed of 19200 baud. This is the default factory setting for the BLC2021.
  5. Use the command mtxorb to initialize the serial line:
    mtxorb /dev/lcd

Now the display is ready to use. Here is a little example of a perl script that displays a counter counting up every second:
#!/usr/bin/perl -w
open(LCD,">/dev/lcd")||die "ERROR: can not write to /dev/lcd\n";
my $i=0;
    print LCD chr(0xFE),"X"; # clear the display
    print LCD "Count $i\n";
close LCD;

The BLC2021 understands a small command set. To get into the command mode you need to send the character Hex FE to the display and then give the actual command character. The command character X clears the display. The commands are documented in the small manual that comes with the LCD display. There are commands to set the contrast, switch on/off back light and to create your own custom characters.  

Writing system information to the display

As already described one option to write system info such as swap memory usage, uptime and load to the display is to use lcdproc.

Another option is to use the mtxorb program from above and then write again a small perl script. You can read uptime from /proc/uptime swap usage from /proc/meminfo and cpu load from /proc/loadavg. This is exactly what this perl script called lcdwriter (click here to download) does. As it is just a script it is also very easy to customize and modify for display other things than just swap, uptime and load.


Where to buy the BLC2021?

Matrix Orbital seems to be a typical example of a company with good products but poor marketing. The LCD display that they wanted to send directly to me has never arrived. Matrix Orbital has a list of vendors on their web site. For Germany it is e.g the "elektronikladen.de" that sells these displays. I ordered it there via e-mail and it arrived within 24 hours in my letter box. Very fast service! The vendor list has of course also addresses of vendors in other countries. The prize of the BLC2021 is just under 100 Euro.


Talkback form for this article

Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers:
 talkback page 

Webpages maintained by the LinuxFocus Editor team
© Guido Socher, FDL

Click here to report a fault or send a comment to LinuxFocus

2001-01-27, generated by lfparser version 2.8