11 April 2010

LCD4Linux-TUTORIAL

Linux-Options:

lcd4linux [-c key=val] [-F] [-f config-file] [-i[i]] [-o output] [-q] [-v] 
-c key=valoverwrite entries from the config-file (key and value have to be specified)
-Fdo not fork and detach (run in foreground)
-f config-fileuse configuration from 'config-file' instead of /etc/lcd4linux.conf
-ienter 'interactive mode' (after display initialisation)
-iienter 'interactive mode' (before display initialisation)
-o outputwrite picture to 'output' (raster driver only)
-qsuppress startup and exit splash screen
-vgenerate info messages
-vvgenerate debugging messages
-hprint version number and a small help text, then exit
-llist available drivers

Start automatically during boot:

You have to create the startscript "/etc/init.d/lcd4linux" and generate the necessary runlevel entries by hand, e.g. with the command "ln -s /etc/init.d/lcd4linux /etc/rc5.d/S99lcd4linux".

Example for a startscript:

#! /bin/sh # # lcd4linux # PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin DAEMON=/usr/local/bin/lcd4linux NAME=lcd4linux DESC=lcd4linux test -f $DAEMON || exit 0 set -e case "$1" in   start)  echo -n "Starting $DESC: "  start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON  echo "$NAME."  ;;   stop)  echo -n "Stopping $DESC: "  start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON  echo "$NAME."  ;;   reload)  start-stop-daemon --stop --signal 1 --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON    ;;   restart|force-reload)  echo -n "Restarting $DESC: "  start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON  sleep 1  start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --exec $DAEMON  echo "$NAME."  ;;   *)  N=/etc/init.d/$NAME  echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2  exit 1  ;; esac exit 0 

Alternatively you can invoke LCD4Linux within the file /etc/init.d/boot.local.


HD44780 Wiring

95% of all trouble with displays connected to the parallel port are due to wrong wiring! There is no "standard", whereupon the wiring should be carried out. Thus LCD4Linux supports the so-called "soft wiring", which means that you can use (nearly) any wiring you like. You just have declare it in lcd4linux.conf. A HD44780 display typically has 16 connections (if only 14 are available, then the connections for backlight are missing). The connections have the following meaning:

PinNameComment
1GNDground
2VCCsupply voltage +5V
3LCD_DRIVEcontrast voltage (0 .. +5V)
4RSRegister Select (low=instruction, high=data)
5R/WRead / not Write (high=read, low=write)
6ENABLEstarts data read/write
7DB0Data Bit 0
8DB1Data Bit 1
9DB2Data Bit 2
10DB3Data Bit 3
11DB4Data Bit 4
12DB5Data Bit 5
13DB6Data Bit 6
14DB7Data Bit 7
15BACKLIGHTbacklight supply voltage
16BL GNDbacklight ground

The parallel port has 25 connections:

PinNameI/O
1STROBEOut
2DB0I/O
3DB1I/O
4DB2I/O
5DB3I/O
6DB4I/O
7DB5I/O
8DB6I/O
9DB7I/O
10ACKIn
11BUSYIn
12PAPEROUTIn
13SELECTIn
14AUTOFDOut
15ERRORIn
16INITOut
17SLCTINOut
18-25GNDn/a

The data lines (DB0..DB7 on the display, DB0..DB7 on the parallel port) are always connected directly (unless you are using the 4-bit mode - but that is intended for experts rather, and these are not reading this tutorial anyway :-). The interesting part is, how the display's control signal is connected with the 4 possible output lines from the parallel port:

display:

Pin 4: RS (Register Select) Pin 5: R/W (Read/Write) Pin 6: Enable 

parallel port:

Pin 1:  Strobe Pin 14: AutoFD Pin 16: Init Pin 17: SelectIn 

For each control line you have to specify, which signal of the parallel port is used. This is done by the "Wire.xy"-entries.

E.g. if you are using the popular WinAmp wiring, it has to be defined like this:

Display Pin 4 (RS)     => Parallelport Pin 16 (Init) Display Pin 5 (R/W)    => Parallelport Pin 14 (AutoFD) Display Pin 6 (Enable) => Parallelport Pin 1  (Strobe) 

The adequate soft-wiring entries have to be:

Wire.RW        'AUTOFD' Wire.RS        'INIT' Wire.ENABLE    'STROBE' Wire.ENABLE2   'GND' Wire.BACKLIGHT 'GND' Wire.GPO       'GND' 

Wiring example:

If you want to connect a standard HD44780 display to the parallel port using the WinAmp-Wiring, do it like the following:

LCDParallel PortPower Supplycontrast pot (10k)
Pin 1Pin 18GNDPin 1
Pin 2-+5VPin 3
Pin 3-Pin 2 (slider)
Pin 4Pin 16
Pin 5Pin 14
Pin 6Pin 1
Pin 7Pin 2
Pin 8Pin 3
Pin 9Pin 4
Pin 10Pin 5
Pin 11Pin 6
Pin 12Pin 7
Pin 13Pin 8
Pin 14Pin 9
Pin 15-100 ohm resistor to +5V
Pin 16-GND

TROUBLESHOOTING

Problems when compiling:

  • problems with user rights? install as root user
  • error in configure.log? try different configure options

e.g. errormessage

#error "gd.h not found!" make: *** [Raster.o] Error 1 

workaround: configure --with-drivers=all,\!PNG

Problems starting LCD4Linux:

  • rights on /etc/lcd4linux.conf set correctly?
  • is the display initialised when starting LCD4Linux?
  • invoke LCD4Linux with the options "-Fvvq" and have a look at the debug-output
  • check syntax in lcd4linux.conf